public void Remove_ValidValue_Success() { var verb = new DesignerVerb("Text", null); var collection = new DesignerVerbCollection { verb }; collection.Remove(verb); Assert.Empty(collection); collection.Add(null); collection.Remove(null); Assert.Empty(collection); }
/// <summary> /// Removes the specified designer verb from the collection of global designer verbs. /// </summary> /// <param name="verb">The <see cref="T:System.ComponentModel.Design.DesignerVerb"/> to remove.</param> public void RemoveVerb(DesignerVerb verb) { if (verbs.Contains(verb)) { verbs.Remove(verb); } }
/// <summary> /// Removes the specified designer verb from the collection of global designer verbs. /// </summary> /// <param name="verb">The <see cref="T:System.ComponentModel.Design.DesignerVerb"/> to remove.</param> public void RemoveVerb(DesignerVerb verb) { if ((verbsCollection != null) && verbsCollection.Contains(verb)) { verbsCollection.Remove(verb); } }
/// called to remove global verb public void RemoveVerb(System.ComponentModel.Design.DesignerVerb verb) { if (verb == null) { throw new ArgumentException("verb"); } globalVerbs.Remove(verb); // find the menu item associated with the verb ToolStripMenuItem associatedMenuItem = null; foreach (KeyValuePair <ToolStripMenuItem, DesignerVerb> de in menuItemVerb) { if (de.Value == verb) { associatedMenuItem = de.Key as ToolStripMenuItem; break; } } // if we found the verb's menu item, remove it if (associatedMenuItem != null) { menuItemVerb.Remove(associatedMenuItem); } // remove the verb from the context menu too contextMenu.Items.Remove(associatedMenuItem); }
public virtual void RemoveVerb(DesignerVerb verb) { if (verb == null) { throw new ArgumentNullException("verb"); } if (_globalVerbs.Contains(verb)) { _globalVerbs.Remove(verb); } this.OnCommandsChanged(new MenuCommandsChangedEventArgs(MenuCommandsChangedType.CommandRemoved, verb)); }
// DesignerVerbCollection public void DesignerVerbCollectionExample() { //<Snippet1> //<Snippet2> // Creates an empty DesignerVerbCollection. DesignerVerbCollection collection = new DesignerVerbCollection(); //</Snippet2> //<Snippet3> // Adds a DesignerVerb to the collection. collection.Add(new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent))); //</Snippet3> //<Snippet4> // Adds an array of DesignerVerb objects to the collection. DesignerVerb[] verbs = { new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent)), new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent)) }; collection.AddRange(verbs); // Adds a collection of DesignerVerb objects to the collection. DesignerVerbCollection verbsCollection = new DesignerVerbCollection(); verbsCollection.Add(new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent))); verbsCollection.Add(new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent))); collection.AddRange(verbsCollection); //</Snippet4> //<Snippet5> // Tests for the presence of a DesignerVerb in the collection, // and retrieves its index if it is found. DesignerVerb testVerb = new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent)); int itemIndex = -1; if (collection.Contains(testVerb)) { itemIndex = collection.IndexOf(testVerb); } //</Snippet5> //<Snippet6> // Copies the contents of the collection, beginning at index 0, // to the specified DesignerVerb array. // 'verbs' is a DesignerVerb array. collection.CopyTo(verbs, 0); //</Snippet6> //<Snippet7> // Retrieves the count of the items in the collection. int collectionCount = collection.Count; //</Snippet7> //<Snippet8> // Inserts a DesignerVerb at index 0 of the collection. collection.Insert(0, new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent))); //</Snippet8> //<Snippet9> // Removes the specified DesignerVerb from the collection. DesignerVerb verb = new DesignerVerb("Example designer verb", new EventHandler(this.ExampleEvent)); collection.Remove(verb); //</Snippet9> //<Snippet10> // Removes the DesignerVerb at index 0. collection.RemoveAt(0); //</Snippet10> //</Snippet1> }