当前位置: 首页>>代码示例>>C#>>正文


C# ToolStripItemCollection.Clear方法代码示例

本文整理汇总了C#中System.Windows.Forms.ToolStripItemCollection.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemCollection.Clear方法的具体用法?C# ToolStripItemCollection.Clear怎么用?C# ToolStripItemCollection.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ToolStripItemCollection的用法示例。


在下文中一共展示了ToolStripItemCollection.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Sort

        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);
        }
开发者ID:isakkarlsson,项目名称:iphonebackupbrowser-enhanced,代码行数:9,代码来源:Util.cs

示例2: getSessionMenuItems

        /// <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();
        }
开发者ID:verbitan,项目名称:PuTTY-Session-Manager,代码行数:29,代码来源:SessionListControl.cs

示例3: SortItems

        /// <summary>
        /// Sorts the ToolStripItemCollection collection.
        /// </summary>
        /// <param name="items"></param>
        private void SortItems( ToolStripItemCollection items )
        {
            List<ToolStripItem> specs;

            if (items == null || items.Count == 0) {
                return;
            }

            specs = new List<ToolStripItem>();

            foreach (ToolStripItem item in items) {
                specs.Add(item);
            }

            specs.Sort(delegate( ToolStripItem a, ToolStripItem b )
            {
                string sortA;
                string sortB;

                if (a.GetType().Equals(typeof(SortableToolStripMenuItem))) {
                    sortA = ((SortableToolStripMenuItem)a).SortName;
                } else if (a.GetType().Equals(typeof(SortableToolStripSeparator))) {
                    sortA = ((SortableToolStripSeparator)a).SortName;
                } else {
                    sortA = string.Empty;
                }

                if (b.GetType().Equals(typeof(SortableToolStripMenuItem))) {
                    sortB = ((SortableToolStripMenuItem)b).SortName;
                } else if (b.GetType().Equals(typeof(SortableToolStripSeparator))) {
                    sortB = ((SortableToolStripSeparator)b).SortName;
                } else {
                    sortB = string.Empty;
                }

                return string.Compare(sortA, sortB, StringComparison.InvariantCultureIgnoreCase);
            });

            items.Clear();

            foreach (ToolStripItem item in specs) {
                items.Add(item);
            }
        }
开发者ID:kodybrown,项目名称:menustack,代码行数:48,代码来源:PopupForm.cs

示例4: FillRemotesToolStrip

        private void FillRemotesToolStrip(ToolStripItemCollection strip, bool includeLocalhost)
        {
            ToolStripItem[] items = new ToolStripItem[m_Core.Config.RemoteHosts.Count];

            int idx = 0;

            for (int i = 0; i < m_Core.Config.RemoteHosts.Count; i++)
            {
                RemoteHost host = m_Core.Config.RemoteHosts[i];

                // add localhost at the end
                if (host.Hostname == "localhost")
                    continue;

                ToolStripItem item = new ToolStripMenuItem();

                item.Image = host.ServerRunning && !host.VersionMismatch
                    ? global::renderdocui.Properties.Resources.tick
                    : global::renderdocui.Properties.Resources.cross;
                if (host.Connected)
                    item.Text = String.Format("{0} (Connected)", host.Hostname);
                else if (host.ServerRunning && host.VersionMismatch)
                    item.Text = String.Format("{0} (Bad Version)", host.Hostname);
                else if (host.ServerRunning && host.Busy)
                    item.Text = String.Format("{0} (Busy)", host.Hostname);
                else if (host.ServerRunning)
                    item.Text = String.Format("{0} (Online)", host.Hostname);
                else
                    item.Text = String.Format("{0} (Offline)", host.Hostname);
                item.Click += new EventHandler(switchContext);
                item.Tag = host;

                // don't allow switching to the connected host
                if (host.Connected)
                    item.Enabled = false;

                items[idx++] = item;
            }

            if(includeLocalhost && idx < items.Length)
                items[idx] = localContext;

            strip.Clear();
            foreach(ToolStripItem item in items)
                if(item != null)
                    strip.Add(item);
        }
开发者ID:kvark,项目名称:renderdoc,代码行数:47,代码来源:MainWindow.cs

示例5: ClearItems

 /// <summary>
 /// According to some information I found, the clear doesn't work correctly when the shortcutkeys are set?
 /// This helper method takes care of this.
 /// </summary>
 /// <param name="items"></param>
 private void ClearItems(ToolStripItemCollection items)
 {
     foreach(var item in items) {
         ToolStripMenuItem menuItem = item as ToolStripMenuItem;
         if (menuItem != null && menuItem.ShortcutKeys != Keys.None) {
             menuItem.ShortcutKeys = Keys.None;
         }
     }
     items.Clear();
 }
开发者ID:oneminot,项目名称:greenshot,代码行数:15,代码来源:ImageEditorForm.cs

示例6: InitializeToolStripItems

 private void InitializeToolStripItems(ToolStripItemCollection itemCollection, IntPtr menu)
 {
     itemCollection.Clear();
     int menuItemCount = Windows.GetMenuItemCount(menu);
     MENUITEMINFO lpmii = new MENUITEMINFO {
         cbSize = MENUITEMINFO.SizeOf
     };
     for (uint i = 0; i < menuItemCount; i++)
     {
         ToolStripItem item;
         lpmii.fMask = MIIM.MIIM_DATA | MIIM.MIIM_STRING | MIIM.MIIM_FTYPE | MIIM.MIIM_BITMAP | MIIM.MIIM_CHECKMARKS | MIIM.MIIM_STATE | MIIM.MIIM_SUBMENU | MIIM.MIIM_ID;
         lpmii.dwTypeData = null;
         Windows.GetMenuItemInfo(menu, i, true, ref lpmii);
         if ((lpmii.fType & MFT.MFT_SEPARATOR) > MFT.MFT_STRING)
         {
             item = new ToolStripSeparator();
         }
         else
         {
             item = new ToolStripMenuItem();
             if (lpmii.cch > 0)
             {
                 lpmii.cch++;
                 lpmii.dwTypeData = new string(' ', (int) lpmii.cch);
                 Windows.GetMenuItemInfo(menu, i, true, ref lpmii);
                 item.Text = lpmii.dwTypeData;
             }
             Image image = null;
             if (((lpmii.fMask & MIIM.MIIM_BITMAP) > ((MIIM) 0)) && (lpmii.hbmpItem != IntPtr.Zero))
             {
                 if (lpmii.hbmpItem == Windows.HBMMENU_CALLBACK)
                 {
                     lpmii.fType |= MFT.MFT_OWNERDRAW;
                 }
                 else
                 {
                     image = ImageHelper.FromHbitmapWithAlpha(lpmii.hbmpItem);
                     image.RotateFlip(RotateFlipType.Rotate180FlipX);
                 }
             }
             else if (((lpmii.fMask & MIIM.MIIM_CHECKMARKS) > ((MIIM) 0)) && (lpmii.hbmpUnchecked != IntPtr.Zero))
             {
                 image = ImageHelper.FromHbitmapWithAlpha(lpmii.hbmpUnchecked);
                 item.ImageTransparentColor = SystemColors.Window;
             }
             if (image != null)
             {
                 item.ImageScaling = ToolStripItemImageScaling.None;
                 item.Image = image;
             }
             if (((lpmii.fType & MFT.MFT_OWNERDRAW) > MFT.MFT_STRING) && ((this.ContextMenu3 != null) || (this.ContextMenu2 != null)))
             {
                 item.Paint += new PaintEventHandler(this.ToolStripMenuItem_Paint);
             }
             if (lpmii.hSubMenu != IntPtr.Zero)
             {
                 ToolStripMenuItem item2 = (ToolStripMenuItem) item;
                 item2.DropDownItemClicked += new ToolStripItemClickedEventHandler(this.ToolStrip_ItemClick);
                 if ((this.ContextMenu3 != null) || (this.ContextMenu2 != null))
                 {
                     item2.DropDownItems.Add(string.Empty);
                     item2.DropDownOpening += new EventHandler(this.ToolStripMenuItem_DropDownOpening);
                 }
                 else
                 {
                     this.InitializeToolStripItems(item2.DropDownItems, lpmii.hSubMenu);
                 }
             }
         }
         item.Tag = new MenuItemInfo { Info = lpmii, Menu = menu, Index = i };
         itemCollection.Add(item);
         this.ItemContainer.Add(item);
     }
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:74,代码来源:ShellContextMenuHelper.cs

示例7: ResortToolStripItemCollection

        private void ResortToolStripItemCollection(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);
            }
        }
开发者ID:Theo47,项目名称:depressurizer,代码行数:11,代码来源:MainForm.cs

示例8: PopulateChannelsInDropDownMenu

        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);
            }
        }
开发者ID:dgis,项目名称:CodeTV,代码行数:26,代码来源:WizardForm.cs

示例9: PopulateToolStrip

 //////////////////////////////////////////////////////////////////////////
 private void PopulateToolStrip(ActionStripItem Root, ToolStripItemCollection Items, bool AsMenu)
 {
     Items.Clear();
     AddStripItems(ActContext.ActiveObjects, Root, Items, AsMenu);
 }
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:6,代码来源:ActionStripBuilder.cs

示例10: getSessionMenuItems

 public override void getSessionMenuItems(ContextMenuStrip cms, ToolStripItemCollection parent)
 {
     parent.Clear();
     addSessionMenuItemsFolder(cms,parent,treeView.Nodes[0].Nodes);
 }
开发者ID:verbitan,项目名称:PuTTY-Session-Manager,代码行数:5,代码来源:SessionTreeControl.cs

示例11: PopulateToolStrip

 //////////////////////////////////////////////////////////////////////////
 public void PopulateToolStrip(ActionStripItem Root, ToolStripItemCollection Items, bool AsMenu)
 {
     Items.Clear();
     AddStripItems(Root, Items, AsMenu);
 }
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:6,代码来源:ActionStripBuilder.cs

示例12: FillGoToItems

 private void FillGoToItems(ToolStripItemCollection items)
 {
     items.Clear();
     foreach (var bookmark in Editor.Bookmarks) {
         ToolStripItem item = items.Add(bookmark.Name, imageList1.Images[9]);
         item.Tag = bookmark;
         item.Click += (o, a) => {
             var b = (Bookmark)(o as ToolStripItem).Tag;
             b.DoVisible();
         };
     }
     // --------------------------------------------------------
     foreach (HMSItem item in Functions) {
         ToolStripItem tipItem = items.Add(item.MenuText, imageList1.Images[item.ImageIndex]);
         tipItem.Tag = item.PositionStart;
         tipItem.Click += (o, a) => {
             try {
                 Editor.SelectionStart = (int)(o as ToolStripItem).Tag;
                 Editor.DoRangeVisible(Editor.Selection, true);
                 Editor.Invalidate();
             } catch { }
         };
     }
 }
开发者ID:WendyH,项目名称:HMSEditor,代码行数:24,代码来源:HMSEditor.cs

示例13: SortItems

        public void SortItems(ToolStripItemCollection items)
        {
            if(items == null)
                throw new ArgumentNullException("items");

            ArrayList list = new ArrayList();
            foreach(object o in items)
                list.Add(o);

            list.Sort(new ToolStripCustomIComparer());

            items.Clear();
            items.AddRange((ToolStripItem[])list.ToArray(typeof(ToolStripItem)));
        }
开发者ID:cyotek,项目名称:translateclient,代码行数:14,代码来源:BaseGUIForm.cs

示例14: CreateNewDocMenuItems

        private void CreateNewDocMenuItems(ToolStripItemCollection col)
        {
            col.Clear();

            ToolStripMenuItem newFolderItem = new ToolStripMenuItem("Folder", kwm.KwmAppControls.Properties.Resources.newfolder_16x16, HandleListviewCreateDirectoryMenu, "CreateDir");
            newFolderItem.ImageTransparentColor = Color.Magenta;

            col.Add(newFolderItem);

            col.Add(new ToolStripSeparator());

            List<NewDocument> newDocs = Misc.GetNewDocs(false);

            foreach (NewDocument doc in newDocs)
            {
                ToolStripMenuItem newItm = new ToolStripMenuItem(doc.DisplayName, doc.TypeIcon.ToBitmap(), HandleNewDocClicked, null);
                newItm.Tag = doc;
                col.Add(newItm);
            }
        }
开发者ID:tmbx,项目名称:kwm-release,代码行数:20,代码来源:AppKfsControl.cs

示例15: FillGoToItems

 private void FillGoToItems(ToolStripItemCollection items)
 {
     items.Clear();
     foreach (var bookmark in TB.Bookmarks) {
         ToolStripItem item = items.Add(bookmark.Name, imageList1.Images[9]);
         item.Tag = bookmark;
         item.Click += (o, a) => {
             var toolStripItem = o as ToolStripItem;
             if (toolStripItem == null) return;
             var b = (Bookmark)toolStripItem.Tag;
             b.DoVisible();
         };
     }
     // --------------------------------------------------------
     foreach (HMSItem item in Functions) {
         ToolStripItem tipItem = items.Add(item.MenuText, imageList1.Images[item.ImageIndex]);
         tipItem.Tag = item.PositionStart;
         tipItem.Click += (o, a) => {
             try {
                 var toolStripItem = o as ToolStripItem;
                 if (toolStripItem != null) TB.SelectionStart = (int)toolStripItem.Tag;
                 TB.DoRangeVisible(TB.Selection, true);
                 TB.Invalidate();
             }
             catch {
                 // ignored
             }
         };
     }
 }
开发者ID:WendyH,项目名称:HMSEditor_addon,代码行数:30,代码来源:HMSEditor.cs


注:本文中的System.Windows.Forms.ToolStripItemCollection.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。