private void updateEnablement(ToolStripItemCollection items) { foreach (ToolStripItem item in items) { if (item != null) { StripCommand cmd = item.Tag as StripCommand; if (cmd != null) { item.Enabled = cmd.CanExecute(); ToolStripButton button = item as ToolStripButton; if (button != null) { button.Checked = cmd.HasExecuted(); } ToolStripMenuItem menu = item as ToolStripMenuItem; if (menu != null) { menu.Checked = cmd.HasExecuted(); } } } } }
private void setupMenu(ToolStripMenuItem tsMenu, string caption, string tip, Image image, StripCommand command) { tsMenu.Text = caption; tsMenu.Image = image; tsMenu.Tag = command; tsMenu.ToolTipText = tip; tsMenu.Click += toolItemClick; }
private void setupItem(ToolStripItem tsItem, string caption, string tip, Image image, StripCommand command) { tsItem.Text = caption; tsItem.Image = image; tsItem.Tag = command; tsItem.ToolTipText = tip; tsItem.Click += toolItemClick; }
private void setupButtonAndMenu(ToolStripButton tsButton, ToolStripMenuItem tsMenu, string caption, string tip, Image image, StripCommand command) { setupItem(tsButton, caption, tip, image, command); setupMenu(tsMenu, caption, tip, image, command); }
public CommandButton(StripCommand command) { _command = command; }