コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, string activationMethod) : base(codon, caller)
        {
            this.ActivationMethod = activationMethod;
            this.Command          = CommandWrapper.GetCommand(codon, caller, createCommand);

            if (!string.IsNullOrEmpty(codon.Properties["shortcut"]))
            {
                KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
                AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName());
                this.InputGestureText = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
            }
        }