Clear() public method

public Clear ( ) : void
return void
        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);
        }
示例#2
0
        /// <summary>
        /// Sorts a ToolStripItemCollection by the Text property of each ToolStripItem.
        /// Sorting is alphanumeric and case insensitive.
        /// </summary>
        /// <param name="items">The System.Windows.Forms.ToolStripItemCollection to sort.</param>
        public static void Sort(ToolStripItemCollection items)
        {
            List <ToolStripMenuItem> itemList = new List <ToolStripMenuItem>(items.Count);

            ToolStripItem[] itemArray = new ToolStripItem[items.Count];
            items.CopyTo(itemArray, 0);

            Array.Sort <ToolStripItem>(itemArray, new ToolStripItemSorter());
            items.Clear();
            items.AddRange(itemArray);
        }
 public static void Update(System.Windows.Forms.ToolStripItemCollection toolStripItemCollection,
                           ToolStripItemCodonCollection codonCollection)
 {
     if (codonCollection == null || toolStripItemCollection == null)
     {
         Debug.Assert(false, "ToolStripItemCollection 或 CodonCollection为null");
         return;
     }
     toolStripItemCollection.Clear();
     foreach (IToolStripItemCodon codon in codonCollection)
     {
         toolStripItemCollection.Add((ToolStripItem)codon.View);
     }
 }
        /// <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();
        }
示例#5
0
        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);
        }
示例#6
0
 /// <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();
 }
 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);
     }
 }
示例#8
0
文件: WizardForm.cs 项目: dgis/CodeTV
        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);
            }
        }
示例#9
0
        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);
            }
        }
 public override void getSessionMenuItems(ContextMenuStrip cms, ToolStripItemCollection parent)
 {
     parent.Clear();
     addSessionMenuItemsFolder(cms,parent,treeView.Nodes[0].Nodes);
 }
 //////////////////////////////////////////////////////////////////////////
 private void PopulateToolStrip(ActionStripItem Root, ToolStripItemCollection Items, bool AsMenu)
 {
     Items.Clear();
     AddStripItems(ActContext.ActiveObjects, Root, Items, AsMenu);
 }
 //////////////////////////////////////////////////////////////////////////
 public void PopulateToolStrip(ActionStripItem Root, ToolStripItemCollection Items, bool AsMenu)
 {
     Items.Clear();
     AddStripItems(Root, Items, AsMenu);
 }
示例#13
0
 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 { }
         };
     }
 }
示例#14
0
        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)));
        }
示例#15
0
        /// <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);
            }
        }
示例#16
0
        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);
            }
        }
示例#17
0
        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);
            }
        }
示例#18
0
 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
             }
         };
     }
 }
示例#19
0
文件: WizardForm.cs 项目: dgis/CodeTV
        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);
                }
            }
        }