public MenuCheckBox(UIElement inputBindingOwner, Codon codon, object caller, IEnumerable <ICondition> conditions)
            : base(codon, caller, 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
                    });
                }
            }

            if (!string.IsNullOrEmpty(codon.Properties["shortcut"]))
            {
                KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
                MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, null);
                this.InputGestureText = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
            }
        }
Example #2
0
        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);
        }