Browse Source
Fixed OverflowException when AvalonEditTextEditorAdapter.JumpTo was called with column==int.MaxValue. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4892 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
9 changed files with 92 additions and 52 deletions
@ -0,0 +1,71 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <author name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Media; |
||||||
|
|
||||||
|
namespace ICSharpCode.Core.Presentation |
||||||
|
{ |
||||||
|
sealed class ToolBarCheckBox : CheckBox, IStatusUpdate |
||||||
|
{ |
||||||
|
readonly Codon codon; |
||||||
|
readonly object caller; |
||||||
|
BindingExpressionBase isCheckedBinding; |
||||||
|
|
||||||
|
public ToolBarCheckBox(Codon codon, object caller) |
||||||
|
{ |
||||||
|
ToolTipService.SetShowOnDisabled(this, true); |
||||||
|
|
||||||
|
this.codon = codon; |
||||||
|
this.caller = caller; |
||||||
|
this.Command = CommandWrapper.GetCommand(codon, caller, true); |
||||||
|
CommandWrapper wrapper = this.Command as CommandWrapper; |
||||||
|
if (wrapper != null) { |
||||||
|
ICheckableMenuCommand cmd = wrapper.GetAddInCommand() as ICheckableMenuCommand; |
||||||
|
if (cmd != null) { |
||||||
|
isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.OneWay }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (codon.Properties.Contains("icon")) { |
||||||
|
var image = PresentationResourceService.GetImage(StringParser.Parse(codon.Properties["icon"])); |
||||||
|
image.Height = 16; |
||||||
|
image.SetResourceReference(StyleProperty, ToolBarService.ImageStyleKey); |
||||||
|
this.Content = new PixelSnapper(image); |
||||||
|
} else { |
||||||
|
this.Content = codon.Id; |
||||||
|
} |
||||||
|
UpdateText(); |
||||||
|
|
||||||
|
SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); |
||||||
|
} |
||||||
|
|
||||||
|
public void UpdateText() |
||||||
|
{ |
||||||
|
if (codon.Properties.Contains("tooltip")) { |
||||||
|
this.ToolTip = StringParser.Parse(codon.Properties["tooltip"]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void UpdateStatus() |
||||||
|
{ |
||||||
|
if (codon.GetFailedAction(caller) == ConditionFailedAction.Exclude) |
||||||
|
this.Visibility = Visibility.Collapsed; |
||||||
|
else |
||||||
|
this.Visibility = Visibility.Visible; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnClick() |
||||||
|
{ |
||||||
|
base.OnClick(); |
||||||
|
isCheckedBinding.UpdateTarget(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue