public void UpdateMenu() { foreach (BarItem item in _ribbonManager.Items) { if (item.Tag != null) { YutaiCommand command = item.Tag as YutaiCommand; if (command != null) { item.Enabled = command.Enabled; if (item is BarCheckItem) { ((BarCheckItem)item).Checked = command.Checked; } continue; } } YutaiCommand oneCommand = _commands.Find(c => c.Key == item.Name); if (oneCommand != null) { item.Enabled = oneCommand.Enabled; if (item is BarCheckItem) { ((BarCheckItem)item).Checked = oneCommand.Checked; } continue; } } }
private void AddCommand(YutaiCommand command) { if (command is YutaiMenuCommand) { AddMenuCommand(command); return; } string[] names = command.Name.Split('.'); if (names.Length == 1) { ToolStripMenuItem menu = new ToolStripMenuItem { Text = command.Caption, Name = command.Name, ToolTipText = command.Tooltip, Image = command.Image, }; menu.Click += command.OnClick; contextMenuLayer.Items.Add(menu); } else if (names.Length == 2) { ToolStripDropDownButton dropDown = contextMenuLayer.Items[names[0]] as ToolStripDropDownButton; ToolStripMenuItem menu = new ToolStripMenuItem { Text = command.Caption, Name = command.Name, ToolTipText = command.Tooltip, Image = command.Image, }; menu.Click += command.OnClick; dropDown.DropDownItems.Add(menu); } }
private void AddMenuCommand(YutaiCommand command) { ToolStripDropDownButton dropDown = new ToolStripDropDownButton(); dropDown.Name = command.Name; dropDown.Text = command.Caption; contextMenuLayer.Items.Add(dropDown); }
private void AddCommand(YutaiCommand command) { if (command is YutaiMenuCommand) { ToolStripDropDownButton toolStripDropDownButton = new ToolStripDropDownButton(); toolStripDropDownButton.DisplayStyle = ToolStripItemDisplayStyle.Text; toolStripDropDownButton.Name = command.Name; toolStripDropDownButton.Text = command.Caption; Items.Add(toolStripDropDownButton); } else if (command is YutaiSeparatorCommand) { if (string.IsNullOrWhiteSpace(command.Key)) { Items.Add(new ToolStripSeparator()); } else { ToolStripDropDownButton dropDown = Items[command.Key] as ToolStripDropDownButton; dropDown.DropDownItems.Add(new ToolStripSeparator()); } } else { string[] names = command.Name.Split('.'); if (names.Length == 1) { ToolStripMenuItem menu = new ToolStripMenuItem { Text = command.Caption, Name = command.Name, ToolTipText = command.Tooltip, Image = command.Image, }; menu.Click += command.OnClick; Items.Add(menu); } else if (names.Length == 2) { ToolStripDropDownButton dropDown = Items[names[0]] as ToolStripDropDownButton; ToolStripMenuItem menu = new ToolStripMenuItem { Text = command.Caption, Name = command.Name, ToolTipText = command.Tooltip, Image = command.Image, }; menu.Click += command.OnClick; dropDown.DropDownItems.Add(menu); } } }
public RibbonItem(YutaiCommand command) { IRibbonItem source = (IRibbonItem)command; this._name = source.Name; this._key = source.Key; this._caption = source.Caption; this._image = source.Image; this._tooltip = source.Tooltip; this._category = source.Category; this._checked = source.Checked; this._enabled = source.Enabled; this._itemType = source.ItemType; _pluginIdentity = source.PluginIdentity; }
private BarItem CreateCommand(YutaiCommand command) { BarItem item = null; try { if (command.ItemType == RibbonItemType.Button || command.ItemType == RibbonItemType.Tool) { item = CreateButton(command); } else if (command.ItemType == RibbonItemType.ComboBox) { item = CreateComboBox(command); } else if (command.ItemType == RibbonItemType.RibbonEditItem) { item = CreateRibbonEditItem(command); } else if (command.ItemType == RibbonItemType.CheckBox) { item = CreateCheckBox(command); } else if (command.ItemType == RibbonItemType.DropDown) { item = CreateDropDown(command); } else if (command.ItemType == RibbonItemType.Label) { item = CreateLabel(command); } // if (!string.IsNullOrEmpty(command.Message)) item.ItemClick += FireMessageSetting; if (command.NeedUpdateEvent) { item.ItemClick += UpdateMenuClick; } item.Enabled = command.Enabled; item.SuperTip = new SuperToolTip(); item.SuperTip.Items.AddTitle(item.Caption); item.SuperTip.Items.Add((string)command.Tooltip); return(item); } catch (Exception ex) { return(null); } }
public void RefreshContextMenu() { PopupMenu mPCurrentPopupMenu = this.m_pCurrentPopupMenu; if (mPCurrentPopupMenu == null) { return; } for (int i = 0; i < mPCurrentPopupMenu.ItemLinks.Count; i++) { YutaiCommand command = mPCurrentPopupMenu.ItemLinks[i].Item.Tag as YutaiCommand; if (command == null) { continue; } mPCurrentPopupMenu.ItemLinks[i].Item.Enabled = command.Enabled; } }
public void AddCommand(YutaiCommand command) { //_menuIndex.AddItem(command); }
public void AddCommands(YutaiCommand icommand) { //最后交给RibbonMenu处理 }