Exemplo n.º 1
0
        public MenuCheckBox(UIElement inputBindingOwner, Codon codon, object caller, IReadOnlyCollection <ICondition> conditions)
            : base(codon, caller, conditions)
        {
            this.Command          = CommandWrapper.CreateCommand(codon, conditions);
            this.CommandParameter = caller;

            cmd = CommandWrapper.Unwrap(this.Command) as ICheckableMenuCommand;
            if (cmd != null)
            {
                isCheckedChangedHandler = cmd_IsCheckedChanged;
                cmd.IsCheckedChanged   += isCheckedChangedHandler;
                this.IsChecked          = cmd.IsChecked(caller);
            }

            if (!string.IsNullOrEmpty(codon.Properties["shortcut"]))
            {
                KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
                MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, null);
                this.InputGestureText = MenuService.GetDisplayStringForShortcut(kg);
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        public ToolBarSplitButton(Codon codon, object caller, IList submenu)
        {
            ToolTipService.SetShowOnDisabled(this, true);

            this.codon  = codon;
            this.caller = caller;

            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);
            }

            menuCommand       = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
            menuCommand.Owner = this;

            this.Command      = new CommandWrapper(codon, caller, menuCommand);
            this.DropDownMenu = MenuService.CreateContextMenu(submenu);

            UpdateText();
        }
Exemplo n.º 4
0
        public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand)
        {
            ToolTipService.SetShowOnDisabled(this, true);

            this.codon   = codon;
            this.caller  = caller;
            this.Command = CommandWrapper.GetCommand(codon, caller, createCommand);
            this.Content = ToolBarService.CreateToolBarItemContent(codon);

            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);
        }
Exemplo n.º 5
0
 public static void UpdateStatus(IEnumerable toolBarItems)
 {
     MenuService.UpdateStatus(toolBarItems);
 }