Пример #1
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);
            }
        }
Пример #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);
        }
Пример #3
0
        public ToolBarCheckBox(Codon codon, object caller, IEnumerable <ICondition> conditions)
        {
            this.RightToLeft = RightToLeft.Inherit;
            this.caller      = caller;
            this.codon       = codon;
            this.conditions  = conditions;
            try {
                menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
            } catch (Exception) {
            }
            if (menuCommand == null)
            {
                MessageService.ShowError("Can't create toolbar checkbox : " + codon.Id);
            }
            menuCommand.Owner = this;

            if (codon.Properties.Contains("label"))
            {
                Text = StringParser.Parse(codon.Properties["label"]);
            }
            if (Image == null && codon.Properties.Contains("icon"))
            {
                Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
            }
            UpdateText();
            UpdateStatus();
        }
Пример #4
0
 public ToolBarCheckBox(Codon codon, object caller)
     : base(new CheckBox())
 {
     this.description = string.Empty;
     this.menuCommand = null;
     this.RightToLeft = RightToLeft.Inherit;
     this.caller = caller;
     this.codon = codon;
     try
     {
         this.menuCommand = (ICheckableMenuCommand) codon.AddIn.CreateObject(codon.Properties["class"]);
         this.menuCommand.ID = codon.Id;
         this.menuCommand.Owner = this;
         this.menuCommand.Codon = codon;
     }
     catch (Exception exception)
     {
         LoggingService.Error(exception);
     }
     if (this.menuCommand == null)
     {
         MessageService.ShowError("Can't create toolbar checkbox : " + codon.Id);
     }
     this.UpdateText();
     this.UpdateStatus();
 }
Пример #5
0
 public MenuCheckBox(string text)
 {
     this.description = string.Empty;
     this.menuCommand = null;
     this.RightToLeft = RightToLeft.Inherit;
     this.Text = text;
 }
Пример #6
0
 public ToolBarCheckBox(string text)
     : base(new CheckBox())
 {
     this.description = string.Empty;
     this.menuCommand = null;
     this.RightToLeft = RightToLeft.Inherit;
     this.Text = text;
 }
Пример #7
0
 public MenuCheckBox(Codon codon, object caller)
 {
     this.description = string.Empty;
     this.menuCommand = null;
     this.RightToLeft = RightToLeft.Inherit;
     this.caller = caller;
     this.codon = codon;
     this.UpdateText();
 }
Пример #8
0
		void CreateMenuCommand()
		{
			if (menuCommand == null) {
				try {
					menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
				} catch (Exception e) {
					MessageService.ShowException(e, "Can't create menu command : " + codon.Id);
				}
			}
		}
Пример #9
0
 void CreateMenuCommand()
 {
     if (menuCommand == null)
     {
         try {
             menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
         } catch (Exception e) {
             MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
         }
     }
 }
Пример #10
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);
            }
        }
Пример #11
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);
            }
        }
Пример #12
0
        public ToolBarCheckBox(Codon codon, object caller)
        {
            this.RightToLeft = RightToLeft.Inherit;
            this.caller = caller;
            this.codon  = codon;
            try {
                menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
            } catch (Exception) {
            }
            if (menuCommand == null) {
                MessageService.ShowError("Can't create toolbar checkbox : " + codon.Id);
            }
            menuCommand.Owner = this;

            if (codon.Properties.Contains("label")){
                Text = StringParser.Parse(codon.Properties["label"]);
            }
            if (Image == null && codon.Properties.Contains("icon")) {
                Image = ResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
            }
            UpdateText();
            UpdateStatus();
        }
Пример #13
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);
        }