public ToolBarDropDownButton(Codon codon, object caller, IList subMenu, IEnumerable <ICondition> conditions) : base() { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; this.Orientation = Orientation.Vertical; //MenuItem rootMenu = new MenuItem(); if (codon.Properties.Contains("template") || codon.Properties.Contains("style") || codon.Properties.Contains("packIconKey")) { ToolBarService.CreateTemplatedToolBarItem(this, codon); } else { this.Content = ToolBarService.CreateToolBarItemContent(codon); } this.ItemsSource = MenuService.ExpandMenuBuilders(subMenu, false); // ContextMenu contextMenu = MenuService.CreateContextMenu(subMenu); // foreach (MenuItem item in contextMenu.Items) { // rootMenu.Items.Add(item); // } if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } //this.Items.Add(rootMenu); UpdateText(); }
public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.CommandParameter = caller; if (codon.Properties.Contains("template") || codon.Properties.Contains("style") || codon.Properties.Contains("packIconKey")) { ToolBarService.CreateTemplatedToolBarItem(this, codon); } else { this.Content = ToolBarService.CreateToolBarItemContent(codon); } this.conditions = conditions; if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName()); this.inputGestureText = MenuService.GetDisplayStringForShortcut(kg); } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey); }
public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, IEnumerable <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Command = CommandWrapper.GetCommand(codon, caller, createCommand, conditions); this.Content = ToolBarService.CreateToolBarItemContent(codon); this.conditions = conditions; if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName()); this.inputGestureText = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture); } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey); }
public ToolBarCheckBox(Codon codon, object caller, IEnumerable <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; this.Command = CommandWrapper.GetCommand(codon, caller, true, conditions); 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 }); } } this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); }
public ToolBarSplitButton(Codon codon, object caller, IList submenu, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; if (codon.Properties.Contains("template") || codon.Properties.Contains("style") || codon.Properties.Contains("packIconKey")) { ToolBarService.CreateTemplatedToolBarItem(this, codon); } else { this.Icon = ToolBarService.CreateToolBarItemContent(codon); } if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.CommandParameter = caller; this.ItemsSource = MenuService.ExpandMenuBuilders(submenu, false); UpdateText(); }
public void UpdateText() { if (codon.Properties.Contains("tooltip")) { this.ToolTip = StringParser.Parse(codon.Properties["tooltip"]); } if (codon.Properties.Contains("label")) { this.Content = ToolBarService.CreateToolBarItemContent(codon); } }
public ToolBarDropDownButton(Codon codon, object caller, IList subMenu) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } this.DropDownMenu = MenuService.CreateContextMenu(subMenu); UpdateText(); }
public ToolBarSplitButton(Codon codon, object caller, IList submenu, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.CommandParameter = caller; this.DropDownMenu = MenuService.CreateContextMenu(submenu); UpdateText(); }
public ToolBarSplitButton(Codon codon, object caller, IList submenu) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]); menuCommand.Owner = this; this.Command = new CommandWrapper(codon, caller, menuCommand); this.DropDownMenu = MenuService.CreateContextMenu(submenu); UpdateText(); }
public ToolBarCheckBox(Codon codon, object caller, IReadOnlyCollection <ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; this.Command = CommandWrapper.CreateCommand(codon, conditions); this.CommandParameter = caller; ICheckableMenuCommand cmd = CommandWrapper.Unwrap(this.Command) as ICheckableMenuCommand; if (cmd != null) { isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.OneWay }); } if (codon.Properties.Contains("template") || codon.Properties.Contains("style") || codon.Properties.Contains("packIconKey")) { ToolBarService.CreateTemplatedToolBarItem(this, codon); } else { this.Content = ToolBarService.CreateToolBarItemContent(codon); } if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); }