/// <summary>
        /// This will remove the all instances of the DesignerAction from  the 'comp' object.  If an alarm was set, it will be unhooked. This will also fire the DesignerActionChanged event.
        /// </summary>
        public void Remove(IComponent comp, DesignerActionList actionList)
        {
            if (comp == null)
            {
                throw new ArgumentNullException(nameof(comp));
            }
            if (actionList == null)
            {
                throw new ArgumentNullException(nameof(actionList));
            }
            if (!_designerActionLists.Contains(comp))
            {
                return;
            }

            DesignerActionListCollection actionLists = (DesignerActionListCollection)_designerActionLists[comp];

            if (!actionLists.Contains(actionList))
            {
                return;
            }

            if (actionLists.Count == 1)
            {
                //this is the last action for this object, remove the entire thing
                Remove(comp);
            }
            else
            {
                //remove each instance of this action
                ArrayList actionListsToRemove = new ArrayList(1);
                foreach (DesignerActionList t in actionLists)
                {
                    if (actionList.Equals(t))
                    {
                        //found one to remove
                        actionListsToRemove.Add(t);
                    }
                }

                foreach (DesignerActionList t in actionListsToRemove)
                {
                    actionLists.Remove(t);
                }

                OnDesignerActionListsChanged(new DesignerActionListsChangedEventArgs(comp, DesignerActionListsChangedType.ActionListsRemoved, GetComponentActions(comp)));
            }
        }
示例#2
0
 public void Remove(IComponent comp, DesignerActionList actionList)
 {
     if (comp == null)
     {
         throw new ArgumentNullException("comp");
     }
     if (actionList == null)
     {
         throw new ArgumentNullException("actionList");
     }
     if (this.designerActionLists.Contains(comp))
     {
         DesignerActionListCollection lists = (DesignerActionListCollection)this.designerActionLists[comp];
         if (lists.Contains(actionList))
         {
             if (lists.Count == 1)
             {
                 this.Remove(comp);
             }
             else
             {
                 ArrayList list = new ArrayList(1);
                 foreach (DesignerActionList list2 in lists)
                 {
                     if (actionList.Equals(list2))
                     {
                         list.Add(list2);
                     }
                 }
                 foreach (DesignerActionList list3 in list)
                 {
                     lists.Remove(list3);
                 }
                 this.OnDesignerActionListsChanged(new DesignerActionListsChangedEventArgs(comp, DesignerActionListsChangedType.ActionListsRemoved, this.GetComponentActions(comp)));
             }
         }
     }
 }
 public void Remove(IComponent comp, DesignerActionList actionList)
 {
     if (comp == null)
     {
         throw new ArgumentNullException("comp");
     }
     if (actionList == null)
     {
         throw new ArgumentNullException("actionList");
     }
     if (this.designerActionLists.Contains(comp))
     {
         DesignerActionListCollection lists = (DesignerActionListCollection) this.designerActionLists[comp];
         if (lists.Contains(actionList))
         {
             if (lists.Count == 1)
             {
                 this.Remove(comp);
             }
             else
             {
                 ArrayList list = new ArrayList(1);
                 foreach (DesignerActionList list2 in lists)
                 {
                     if (actionList.Equals(list2))
                     {
                         list.Add(list2);
                     }
                 }
                 foreach (DesignerActionList list3 in list)
                 {
                     lists.Remove(list3);
                 }
                 this.OnDesignerActionListsChanged(new DesignerActionListsChangedEventArgs(comp, DesignerActionListsChangedType.ActionListsRemoved, this.GetComponentActions(comp)));
             }
         }
     }
 }