/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.ToolItem"/> class with the specified <paramref name="command"/>. /// </summary> /// <param name="command">Command to initialize the tool item with.</param> protected ToolItem(Command command) { ID = command.ID; Text = command.ToolBarText; ToolTip = command.ToolTip; Image = command.Image; Click += (sender, e) => command.Execute(); Enabled = command.Enabled; command.EnabledChanged += (sender, e) => Enabled = command.Enabled; Order = -1; }
protected ToolItem(Command command, Generator generator, Type type, bool initialize = true) : base(generator, type, initialize) { ID = command.ID; Text = command.ToolBarText; ToolTip = command.ToolTip; Image = command.Image; Click += (sender, e) => command.Execute(); Enabled = command.Enabled; command.EnabledChanged += (sender, e) => Enabled = command.Enabled; Order = -1; }
protected MenuItem(Command command, Generator generator, Type type, bool initialize = true) : base(generator, type, initialize) { ID = command.ID; Text = command.MenuText; ToolTip = command.ToolTip; Shortcut = command.Shortcut; Click += (sender, e) => command.Execute(); Validate += (sender, e) => Enabled = command.Enabled; Enabled = command.Enabled; command.EnabledChanged += (sender, e) => Enabled = command.Enabled; if (initialize) Handler.CreateFromCommand(command); }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.MenuItem"/> class with the specified command. /// </summary> /// <remarks> /// This links the menu item with the specified command, and will trigger <see cref="Command.Execute"/> /// when the user clicks the item, and enable/disable the menu item based on <see cref="Command.Enabled"/>. /// /// This is not a weak link, so you should not re-use the Command instance for other menu items if you are disposing /// this menu item. /// </remarks> /// <param name="command">Command to initialize the menu item with.</param> protected MenuItem(Command command) { ID = command.ID; Text = command.MenuText; ToolTip = command.ToolTip; Shortcut = command.Shortcut; Click += (sender, e) => command.Execute(); Validate += (sender, e) => Enabled = command.Enabled; Enabled = command.Enabled; command.EnabledChanged += (sender, e) => Enabled = command.Enabled; }