Beispiel #1
0
        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();
        }
Beispiel #2
0
        public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, string activationMethod, IReadOnlyCollection <ICondition> conditions) : base(codon, caller, conditions)
        {
            this.ActivationMethod = activationMethod;
            if (createCommand)
            {
                this.Command = CommandWrapper.CreateCommand(codon, conditions);
            }
            else
            {
                this.Command = CommandWrapper.CreateLazyCommand(codon, conditions);
            }
            this.CommandParameter = caller;

            if (!string.IsNullOrEmpty(codon.Properties["shortcut"]))
            {
                KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
                AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName());
                this.InputGestureText = MenuService.GetDisplayStringForShortcut(kg);
            }
        }
        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);
            }
        }
        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);
        }
Beispiel #5
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);
        }