/** -------------------------------------------------------------------- **/ private void _ReconfigureFileMenuRecentUrlsItems() { List <string> CrawlHistory = MacroscopePreferencesManager.GetCrawlHistory(); ToolStripItemCollection RecentUrlItems = this.recentURLsToolStripMenuItem.DropDownItems; RecentUrlItems.Clear(); CrawlHistory.Reverse(); foreach (string Url in CrawlHistory) { string UrlTruncated = Url; ToolStripItem UrlItem = RecentUrlItems.Add(text: "..."); if (Url.Length > 64) { UrlTruncated = Url.Substring(0, 64) + "..."; } UrlTruncated = UrlTruncated.Replace("&", "&&"); UrlItem.Tag = Url; UrlItem.Text = UrlTruncated; UrlItem.Click += ClickCallbackFileMenuRecentUrlsItem; } { ToolStripSeparator separator = new ToolStripSeparator(); RecentUrlItems.Add(separator); } { ToolStripItem UrlItem = RecentUrlItems.Add(text: "Clear Recent URLs"); UrlItem.Click += ClickCallbackFileMenuRecentUrlsClear; } }
// Create components to select private void createComponentStrips() { List <string> componentNames = modelRenderer_.getComponentNames(); ToolStripItemCollection items = stripComponentVisualisation.DropDownItems; items.Clear(); // Show all the components ToolStripMenuItem item = (ToolStripMenuItem)items.Add("Show all"); item.Name = "All"; item.Click += new EventHandler(showComponents); // Show nothing item = (ToolStripMenuItem)items.Add("Show none"); item.Name = "Nothing"; item.Click += new EventHandler(showComponents); items.Add(new ToolStripSeparator()); // Component names foreach (string component in componentNames) { item = (ToolStripMenuItem)items.Add(component); item.Checked = true; item.CheckOnClick = true; item.CheckedChanged += showComponents; } }
/// <summary> /// Add the array of menu items to the system tray /// </summary> /// <param name="cms">The menu</param> /// <param name="parent">The root of the systray menu</param> public override void getSessionMenuItems(ContextMenuStrip cms, ToolStripItemCollection parent) { // Suspend the layout before modification cms.SuspendLayout(); parent.Clear(); // Setup the System tray array of menu items ToolStripMenuItem[] tsmiArray = new ToolStripMenuItem[getSessionController().getSessionList().Count]; int i = 0; foreach (Session s in getSessionController().getSessionList()) { tsmiArray[i] = new ToolStripMenuItem(s.SessionDisplayText, null, listBox1_DoubleClick); // Make sure the menu item is tagged with the session tsmiArray[i].Tag = s; i++; } if (tsmiArray != null) { parent.AddRange(tsmiArray); } // Now resume the layout cms.ResumeLayout(); }
private void menuSortLoop(ToolStripItemCollection mc) { if (mc == null) { return; } for (var i = 0; i < mc.Count; i++) { if (mc[i] is ToolStripDropDownItem) { menuSortLoop(((ToolStripDropDownItem)mc[i]).DropDownItems); } } var mis = new ArrayList(); foreach (ToolStripItem mi in mc) { mis.Add(mi); } mis.Sort(new Sorter(_menuorder)); mc.Clear(); for (var i = 0; i < mis.Count; i++) { mc.Add((ToolStripItem)mis[i]); } }
private void refresh_style_list() { styleListBox.Items.Clear(); styleListBox.Items.Add(Style.Empty()); foreach (Style s in Styles) { styleListBox.Items.Add(s); } ToolStripItemCollection ddi = styleToolStripMenuItem.DropDownItems; ToolStripItem ddi_header = ddi[0]; ddi.Clear(); ddi.Add(ddi_header); ToolStripMenuItem mi = null; ddi.Add(new ToolStripSeparator()); for (int i = 0; i < Math.Min(Styles.Count, 11); i++) { mi = new ToolStripMenuItem(Styles[i].Name); mi.Name = Styles[i].Name; mi.Tag = Styles[i]; mi.ShortcutKeys = Keys.Alt | (Keys.D1 + i); mi.Click += new EventHandler(styleMenuItem_Click); ddi.Add(mi); } }
public void BuildContextMenu(ToolStripItemCollection items) { if (items == null) { throw new ArgumentNullException("items"); } items.Clear(); if (m_Class == null) { return; } try { foreach (MethodData md in m_Class.Methods) { var method = new MethodDataExt(md); if (!method.HasQualifier("Implemented")) { continue; } var menuItem = new ToolStripMenuItem(); menuItem.Text = method.ToString(); menuItem.Tag = md; menuItem.Click += MethodOnClick; items.Add(menuItem); } } catch (ManagementException ex) { Debug.Print(ex.Message); } }
/// <summary> /// Creates a list of menu items. /// </summary> static private void SetItems(ToolStripItemCollection menuItems, OnlineProviders providers, EventHandler action, Action reconstruct) { if (providers is null || providers.Items.Count == 0) { return; } menuItems.Clear(); string nameItems = StackMethods.NameOfFromStack(3).Replace("Globals.", string.Empty); foreach (var item in providers.Items) { menuItems.Add(item.CreateMenuItem(action)); } if (providers.Configurable) { menuItems.Add(new ToolStripSeparator()); menuItems.Add(CreateConfigureMenuItem((sender, e) => { if (DataFileEditorForm.Run(nameItems, providers)) { reconstruct(); } })); } }
private void menuKeyConfigK_Click(object sender, EventArgs e) { for (int i = KeyConfigManager.minPlayer; i <= KeyConfigManager.maxPlayer; i++) { ToolStripItemCollection dropdown = ((ToolStripMenuItem)menuKeyConfigK.DropDownItems["menuPlayer" + i]).DropDownItems; ToolStripItemCollection open = ((ToolStripMenuItem)dropdown["menuOpenP" + i]).DropDownItems; ToolStripItemCollection edit = ((ToolStripMenuItem)dropdown["menuEditP" + i]).DropDownItems; ToolStripItemCollection delete = ((ToolStripMenuItem)dropdown["menuDeleteP" + i]).DropDownItems; open.Clear(); edit.Clear(); delete.Clear(); string[] namesOfKeyConfigs = keyConfigManager.getNames(i); foreach (string nameOfKeyConfig in namesOfKeyConfigs) { ToolStripMenuItem openItem = new ToolStripMenuItem(); ToolStripMenuItem editItem = new ToolStripMenuItem(); ToolStripMenuItem deleteItem = new ToolStripMenuItem(); openItem.Text = editItem.Text = deleteItem.Text = nameOfKeyConfig; openItem.Name = editItem.Name = deleteItem.Name = "menu" + nameOfKeyConfig + "P" + i; openItem.Click += menuOpen_Click; editItem.Click += menuEdit_Click; deleteItem.Click += menuDelete_Click; open.Add(openItem); edit.Add(editItem); delete.Add(deleteItem); } } }
private void selectWindowsToolStripMenuItem_DropDownOpening(object sender, EventArgs e) { ToolStripItemCollection items = addWindowsToolStripMenuItem.DropDownItems; items.Clear(); foreach (ApplicationWindow window in ApplicationWindow.GetApplicationWindows()) { if (window.Handle == this.Handle) { continue; } Process process = Process.GetProcessById(window.ProcessId); IntPtr handle = window.Handle; string title = window.Text; Icon icon = window.Icon; ToolStripMenuItem windowItem = new ToolStripMenuItem(title); windowItem.Click += (eventSender, eventArgs) => CaptureWindow(handle); if (icon != null) { windowItem.Image = icon.ToBitmap(); } items.Add(windowItem); } if (items.Count == 0) { items.Add(NoSelectionItem); } }
private void PopulateChannelsFolderInDropDownMenu(ToolStripItemCollection toolStripItemCollection, ChannelFolder channelFolder) { toolStripItemCollection.Clear(); ToolStripMenuItem channelToolStripMenuItem0 = new ToolStripMenuItem(Properties.Resources.ChooseFolder); channelToolStripMenuItem0.Tag = channelFolder; channelToolStripMenuItem0.Click += new EventHandler(channelFolderToolStripMenuItem_Click); toolStripItemCollection.Add(channelToolStripMenuItem0); foreach (Channel channel in channelFolder.ChannelList) { if (channel is ChannelFolder) { ToolStripMenuItem channelToolStripMenuItem = new ToolStripMenuItem(channel.Name); channelToolStripMenuItem.Tag = channel; channelToolStripMenuItem.DropDownItems.Clear(); channelToolStripMenuItem.DropDownOpening += new EventHandler(channelFolderToolStripMenuItem_DropDownOpening); ToolStripMenuItem channelToolStripMenuItem1 = new ToolStripMenuItem("Dummy"); channelToolStripMenuItem.DropDownItems.Add(channelToolStripMenuItem1); toolStripItemCollection.Add(channelToolStripMenuItem); } } }
private void PopulateChannelsInDropDownMenu(ToolStripItemCollection toolStripItemCollection, ChannelFolder channelFolder) { toolStripItemCollection.Clear(); foreach (Channel channel in channelFolder.ChannelList) { ToolStripMenuItem channelToolStripMenuItem = new ToolStripMenuItem(channel.Name); channelToolStripMenuItem.Tag = channel; if (channel is ChannelFolder) { channelToolStripMenuItem.DropDownItems.Add("dummy"); channelToolStripMenuItem.DropDownOpening += new EventHandler(channelToolStripMenuItem_DropDownOpening); } else { if (channel is ChannelTV) { channelToolStripMenuItem.Image = MainForm.imageListLogoTV.Images[(channel as ChannelTV).Logo]; if (channelToolStripMenuItem.Image == null) { channelToolStripMenuItem.Image = MainForm.imageListLogoTV.Images["LogoTVDefault"]; } } channelToolStripMenuItem.Click += new EventHandler(channelToolStripMenuItem_Click); } toolStripItemCollection.Add(channelToolStripMenuItem); } }
private static void CloneTo(this ToolStripItemCollection s, ToolStripItemCollection t) { t.Clear(); foreach (ToolStripItem i in s) { t.Add(i.Clone()); } }
public static void InitMenuActions( CObjetDonneeAIdNumerique objet, ToolStripItemCollection listMenusARemplir, MenuActionEventHandler onClickMenuActionEventHandler) { listMenusARemplir.Clear(); IDeclencheurAction[] declencheurs = CRecuperateurDeclencheursActions.GetActionsManuelles(objet, true); if (declencheurs.Length != 0) { foreach (IDeclencheurAction declencheur in declencheurs) { string strMenu = ""; if (declencheur is IDeclencheurActionManuelle) { strMenu = ((IDeclencheurActionManuelle)declencheur).MenuManuel; } string[] strMenus = strMenu.Split('/'); ToolStripItemCollection listeSousMenus = listMenusARemplir; if (strMenus.Length > 0) { foreach (string strSousMenu in strMenus) { if (strSousMenu.Trim().Length > 0) { ToolStripMenuItem sousMenu = null; foreach (ToolStripMenuItem item in listeSousMenus) { if (item.Text == strSousMenu) { sousMenu = item; break; } } if (sousMenu == null) { sousMenu = new ToolStripMenuItem(strSousMenu); listeSousMenus.Add(sousMenu); } listeSousMenus = sousMenu.DropDownItems; } } } CMenuItemActionManuelle itemAction = new CMenuItemActionManuelle(declencheur, objet); if (onClickMenuActionEventHandler != null) { itemAction.OnMenuAction += new MenuActionEventHandler(onClickMenuActionEventHandler); } listeSousMenus.Add(itemAction); } } if (listMenusARemplir.Count == 0) { ToolStripMenuItem itemActionVide = new ToolStripMenuItem(I.T("(None)|10074")); itemActionVide.Enabled = false; listMenusARemplir.Add(itemActionVide); } }
//--------------------------------------------------------------------- public void DestroyItemsInCollection(ToolStripItemCollection itemCollection) { if (itemCollection == null) { throw new ArgumentNullException(nameof(itemCollection)); } itemCollection.Clear(); }
public static void CreateScriptMenuItems(ToolStripItemCollection items, Action <ScriptDocument> clickHandler) { items.Clear(); foreach (ScriptDocument doc in CANAPEProject.CurrentProject.GetDocumentsByType(typeof(ScriptDocument))) { ToolStripItem item = items.Add(doc.Name); item.Click += (o, e) => clickHandler(doc); } }
/// <summary> /// Updates toolStripMenuItemSerialPort DropDownItems to include all available serial port. /// </summary> private void RefreshSerialPortList() { ToolStripItemCollection toolStripItemCollection = toolStripMenuItemSerialPort.DropDownItems; toolStripItemCollection.Clear(); toolStripItemCollection.Add("Refresh List"); foreach (string portName in System.IO.Ports.SerialPort.GetPortNames()) { toolStripItemCollection.Add("COM" + Regex.Replace(portName.Substring("COM".Length, portName.Length - "COM".Length), "[^.0-9]", "\0")); } }
/// <summary> /// Updates the webcam list in the sub-context menu for webcam selection. /// </summary> /// <param name="selectWebcamMenu">The webcam sub-context menu to update.</param> private void UpdateWebcamList(ToolStripMenuItem selectWebcamMenu) { ToolStripItemCollection dropDownItems = selectWebcamMenu.DropDownItems; dropDownItems.Clear( ); foreach (KeyValuePair <string, string> webcam in WebcamManager.GetWebcamList( )) { dropDownItems.Add(webcam.Value, null, (object sender, EventArgs handler) => WebcamManager.SelectWebcam(webcam.Key)); } }
private static void CloneTo(this ToolStripItemCollection source, ToolStripItemCollection target, ToolStripCloneOptions options) { if ((options & ToolStripCloneOptions.ClearTarget) != 0) { target.Clear(); } foreach (ToolStripItem item in source) { target.Add(item.CloneItem(options)); } }
public static void SortToolStripItemCollection(ToolStripItemCollection coll) { System.Collections.ArrayList oAList = new System.Collections.ArrayList(coll); oAList.Sort(new ToolStripItemComparer()); coll.Clear(); foreach (ToolStripItem oItem in oAList) { coll.Add(oItem); } }
public static void AddItem(this ToolStripItemCollection menu, DataTable subModules, EventHandler onClick) { menu.Clear(); foreach (DataRow subModule in subModules.Rows) { var title = subModule.ItemArray[10].ToString(); var routerLink = subModule.ItemArray[11].ToString(); var newItem = menu.Add(title, null, onClick); newItem.Tag = routerLink; //newItem.Name= menuId; } }
private void ResortToolStripItemCollection(ToolStripItemCollection coll) { var oAList = new ArrayList(coll); oAList.Sort(new ToolStripItemComparer()); coll.Clear(); foreach (ToolStripItem oItem in oAList) { coll.Add(oItem); } }
/// <summary> /// Create the menu with the recently used files. /// </summary> void PopulateRecentMenu() { ToolStripItemCollection menuItems = recentToolStripMenuItem.DropDownItems; menuItems.Clear(); _settings.RecentFiles.ForEach(f => { ToolStripMenuItem menuItem = new ToolStripMenuItem(f, null, new EventHandler(Recent_Click)); menuItems.Add(menuItem); }); }
public static void SortToolStripItemCollection(this ToolStripItemCollection items) { ArrayList aList = new ArrayList(items); aList.Sort(new ToolStripItemCollectionSorter()); items.Clear(); foreach (ToolStripItem item in aList) { items.Add(item); } }
public static void Sort(ToolStripItemCollection collection, IComparer comparer) { ArrayList items = new ArrayList(collection); items.Sort(comparer); collection.Clear(); foreach (object itm in items) { collection.Add(itm as ToolStripItem); } }
public static void SortContextMenuStrip(ToolStripItemCollection itemCollection) { List <ToolStripItem> itemList = new List <ToolStripItem>(); foreach (ToolStripItem item in itemCollection) { itemList.Add(item); } itemList = itemList.OrderBy(x => x.Text).ToList(); itemCollection.Clear(); itemCollection.AddRange(itemList.ToArray()); }
/// <summary> /// The <c>Terminate</c> function is called by KeePass when /// you should free all resources, close open files/streams, /// etc. It is also recommended that you remove all your /// plugin menu items from the KeePass menu. /// </summary> public override void Terminate() { // Remove all of our menu items m_tsMenu.Clear(); // Important! Remove event handlers! m_host.MainWindow.FileSaved -= OnFileSaved; // Delete Sub plugins KPELInlineEditing = null; KPELAddEntry = null; KPELOpenDirecotory = null; }
private void buildServerSubmenu() { ToolStripItemCollection subItems = ((ToolStripMenuItem)this.contextMenuStrip1.Items[0]).DropDownItems; subItems.Clear(); foreach (LaServer srv in this.serverList.ServerList) { ToolStripMenuItem itm = new ToolStripMenuItem(srv.ToString()); itm.Click += new EventHandler(serverSubmenu_Click); itm.Tag = srv; subItems.Add(itm); } }
public static void Populate(ToolStripItemCollection strips, List <OptionBase> options, Action <OptionBase> onOptionChanged = null, bool skipChildOptions = true) { using (new log.GroupDEBUG(g.IssueFinder, "Populate popup menu", false)) { strips.Clear(); var menus = Convert(options, onOptionChanged, skipChildOptions); foreach (var menu in menus) { if (menu != null) { strips.Add(menu); } } } }
private void RefreshSerialPortList(ToolStripMenuItem item) { Int32 last_baud = Convert.ToInt32(iniFile.Read("SerialPort", "Baudrate")); ToolStripItemCollection DropDownCollection = item.DropDownItems; DropDownCollection.Clear(); DropDownCollection.Add("刷新串口"); foreach (string portName in System.IO.Ports.SerialPort.GetPortNames()) { DropDownCollection.Add("COM" + Regex.Replace(portName.Substring("COM".Length, portName.Length - "COM".Length), "[^.0-9]", "\0") + ", " + 230400.ToString()); } DropDownCollection.Add(toolStripMenuItemOpenSerialConnectionDialog); }
private static void Clear() { int n = g_lTopLevelItems.Count; if (n == 0) { return; } BlockLayout(true); ToolStripItemCollection tsic = g_tsiHost.DropDownItems; // The following is very slow // int iKnown = n - 1; // for(int iMenu = tsic.Count - 1; iMenu >= 0; --iMenu) // { // if(tsic[iMenu] == g_lTopLevelItems[iKnown]) // { // tsic.RemoveAt(iMenu); // if(--iKnown < 0) break; // } // } // Debug.Assert(iKnown == -1); List <ToolStripItem> lOthers = new List <ToolStripItem>(); int iKnown = 0; for (int iMenu = 0; iMenu < tsic.Count; ++iMenu) { ToolStripItem tsi = tsic[iMenu]; if ((iKnown < n) && (tsi == g_lTopLevelItems[iKnown])) { ++iKnown; } else { lOthers.Add(tsi); } } Debug.Assert((iKnown == n) && ((lOthers.Count + n) == tsic.Count)); tsic.Clear(); tsic.AddRange(lOthers.ToArray()); // Restore others g_lTopLevelItems.Clear(); BlockLayout(false); }