private void InsertItemsAfterItem(ToolStripItem anchorItem, CopyToClipboardToolStripMenuItem[] items) { var startIndex = DropDownItems.IndexOf(anchorItem) + 1; for (var i = 0; i < items.Length; ++i) { DropDownItems.Insert(startIndex + i, items[i]); } }
public ICustomSubMenu InsertSubMenu(int position, string itemText) { ICustomSubMenu menuItem = ControlFactory.Instance.GetCustomSubMenu(); menuItem.Text = itemText; DropDownItems.Insert(position, (ToolStripItem)menuItem); return(menuItem); }
private void EnableAppropriateHostsWlb(WlbRecommendations recommendations) { if (Stopped || DropDownItems.Count == 0) { return; } // set the first menu item to be the WLB optimal server menu item var firstItem = DropDownItems[0] as VMOperationToolStripMenuSubItem; if (firstItem == null) { return; } var selection = Command.GetSelection(); var firstItemCmd = new VMOperationWlbOptimalServerCommand(Command.MainWindowCommandInterface, selection, _operation, recommendations); firstItem.Command = firstItemCmd; firstItem.Enabled = firstItemCmd.CanExecute(); var hostMenuItems = new List <VMOperationToolStripMenuSubItem>(); foreach (var item in DropDownItems) { var hostMenuItem = item as VMOperationToolStripMenuSubItem; if (hostMenuItem == null) { continue; } var host = hostMenuItem.Tag as Host; if (host != null) { var cmd = new VMOperationWlbHostCommand(Command.MainWindowCommandInterface, selection, host, _operation, recommendations.GetStarRating(host)); hostMenuItem.Command = cmd; hostMenuItem.Enabled = cmd.CanExecute(); hostMenuItems.Add(hostMenuItem); } } // sort the hostMenuItems by star rating hostMenuItems.Sort(new WlbHostStarCompare()); // refresh the drop-down-items from the menuItems. foreach (VMOperationToolStripMenuSubItem menuItem in hostMenuItems) { DropDownItems.Insert(hostMenuItems.IndexOf(menuItem) + 1, menuItem); } }
public ICustomMenuItem InsertItem(int position, string itemText, EventHandler eventHandler, bool isChecked, bool isEnabled, object image, object tag) { ICustomMenuItem menuItem = ControlFactory.Instance.GetCustomMenuItem(); menuItem.Text = itemText; menuItem.Image = image; menuItem.Checked = isChecked; menuItem.Enabled = isEnabled; menuItem.Tag = tag; menuItem.Click += eventHandler; menuItem.MouseDown += MenuItem_MouseDown; DropDownItems.Insert(position, (ToolStripItem)menuItem); return(menuItem); }
/// <summary> /// Adds a file to this RecentFileMenu /// </summary> public void AddFile(string fileName) { // check if the file is already in the collection int alreadyIn = GetIndex(fileName); if (alreadyIn > 0) // remove it { Settings.Default.RecentFiles.RemoveAt(alreadyIn); if (DropDownItems.Count > alreadyIn) { DropDownItems.RemoveAt(alreadyIn); } } else if (alreadyIn == 0) // it´s the latest file so return { return; } if (!this.Enabled) { this.Enabled = true; } // insert the file on top of the list Settings.Default.RecentFiles.Insert(0, fileName); DropDownItems.Insert(0, new RecentFileMenuItem(fileName)); // remove the last one, if max size is reached if (Settings.Default.RecentFiles.Count > Maximum) { Settings.Default.RecentFiles.RemoveAt(Maximum); } if (Settings.Default.RecentFiles.Count > Settings.Default.RecentFilesMax && DropDownItems.Count > Settings.Default.RecentFilesMax) { DropDownItems.RemoveAt(Settings.Default.RecentFilesMax); } // save the changes Settings.Default.Save(); }
private void HostsArchiveList_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { switch (e.ListChangedType) { case System.ComponentModel.ListChangedType.Reset: Reset(); break; case System.ComponentModel.ListChangedType.ItemAdded: { DropDownItems.Insert(e.NewIndex, new HostsArchiveToolStripMenuItem(_model[e.NewIndex])); } break; case System.ComponentModel.ListChangedType.ItemDeleted: DropDownItems.RemoveAt(e.NewIndex); break; case System.ComponentModel.ListChangedType.ItemMoved: { var item = DropDownItems[e.OldIndex]; DropDownItems.RemoveAt(e.OldIndex); DropDownItems.Insert(e.NewIndex, item); } break; case System.ComponentModel.ListChangedType.ItemChanged: { if (DropDownItems[e.NewIndex] is HostsArchiveToolStripMenuItem item) { item.Model = _model[e.NewIndex]; } } break; default: break; } }
void OnDropDownOpening(object sender, EventArgs e) { DropDownItems.Clear(); if (list == null) { return; } var currentTags = list.Tags; var tags = DataStore.Database.GetTags(false); foreach (var tag in tags) { var item = new ToolStripMenuItem(tag.Key) { Tag = tag.Key, CheckOnClick = true, Checked = currentTags.Contains(tag.Key) }; item.CheckedChanged += ItemCheckedChanged; DropDownItems.Insert(DropDownItems.Count, item); } DropDownItems.Insert(DropDownItems.Count, customTag); }
private void InsertNewItem(MostRecentItem item) { _favourites.Insert(0, item); DropDownItems.Insert(_favouritesStartIndex, CreateFavouriteItem(item)); }
public void InsertSeparator(int position) { DropDownItems.Insert(position, new ToolStripSeparator()); }
private void PopulateChildItem(ToolStripMenuItem item) { Visible = true; DropDownItems.Insert(0, item); Enabled = DropDownItems.Count > 0; }