public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; Command = CommandWrapper.CreateLazyCommand(codon, conditions); CommandParameter = caller; Content = ToolBarService.CreateToolBarItemContent(codon); this.conditions = conditions; if (codon.Properties.Contains("name")) { Name = codon.Properties["name"]; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, Command, GetFeatureName()); inputGestureText = MenuService.GetDisplayStringForShortcut(kg); } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey); }
public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, string activationMethod, IReadOnlyCollection <ICondition> conditions) : base(codon, caller, conditions) { ActivationMethod = activationMethod; Command = CommandWrapper.CreateLazyCommand(codon, conditions); //this.CommandParameter = caller; if ("true" == codon.Properties["usedatacontext"]?.ToLowerInvariant()) { _useDataContext = true; var myBinding = new System.Windows.Data.Binding(nameof(DataContext)) { Source = this }; SetBinding(System.Windows.Controls.MenuItem.CommandParameterProperty, myBinding); // this.DataContextChanged += (s,e) => UpdateStatus(); // we can abstain from using this as long as the workbench calls UpdateStatus for all menus (especially the workbench's context menu) } else { CommandParameter = caller; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); AddGestureToInputBindingOwner(inputBindingOwner, kg, Command, GetFeatureName()); InputGestureText = MenuService.GetDisplayStringForShortcut(kg); } }
public MenuCheckBox(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) : base(codon, caller, conditions) { Command = CommandWrapper.CreateCommand(codon, conditions); CommandParameter = caller; cmd = CommandWrapper.Unwrap(Command) as ICheckableMenuCommand; if (cmd != null) { isCheckedChangedHandler = cmd_IsCheckedChanged; cmd.IsCheckedChanged += isCheckedChangedHandler; IsChecked = cmd.IsChecked(caller); } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, Command, null); InputGestureText = MenuService.GetDisplayStringForShortcut(kg); } }