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();
        }
Esempio n. 2
0
        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 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();
        }
Esempio n. 4
0
        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);
        }