Esempio n. 1
0
        protected virtual void GetComponentServiceActions(IComponent component, DesignerActionListCollection actionLists)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            if (actionLists == null)
            {
                throw new ArgumentNullException("actionLists");
            }
            DesignerActionListCollection lists = (DesignerActionListCollection)this.designerActionLists[component];

            if (lists != null)
            {
                actionLists.AddRange(lists);
                foreach (DesignerActionList list in lists)
                {
                    DesignerActionItemCollection sortedActionItems = list.GetSortedActionItems();
                    if ((sortedActionItems == null) || (sortedActionItems.Count == 0))
                    {
                        actionLists.Remove(list);
                    }
                }
            }
        }
        protected virtual void GetComponentServiceActions(IComponent component, DesignerActionListCollection actionLists)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (actionLists == null)
            {
                throw new ArgumentNullException(nameof(actionLists));
            }

            DesignerActionListCollection pushCollection = (DesignerActionListCollection)_designerActionLists[component];

            if (pushCollection != null)
            {
                actionLists.AddRange(pushCollection);
                // remove all the ones that are empty... ie GetSortedActionList returns nothing we might waste some time doing this twice but don't have much of a choice here... the panel is not yet displayed and we want to know if a non empty panel is present...
                foreach (DesignerActionList actionList in pushCollection)
                {
                    DesignerActionItemCollection collection = actionList.GetSortedActionItems();
                    if (collection == null || collection.Count == 0)
                    {
                        actionLists.Remove(actionList);
                    }
                }
            }
        }
        /// <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)));
            }
        }
Esempio n. 4
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)));
             }
         }
     }
 }
 protected virtual void GetComponentServiceActions(IComponent component, DesignerActionListCollection actionLists)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     if (actionLists == null)
     {
         throw new ArgumentNullException("actionLists");
     }
     DesignerActionListCollection lists = (DesignerActionListCollection) this.designerActionLists[component];
     if (lists != null)
     {
         actionLists.AddRange(lists);
         foreach (DesignerActionList list in lists)
         {
             DesignerActionItemCollection sortedActionItems = list.GetSortedActionItems();
             if ((sortedActionItems == null) || (sortedActionItems.Count == 0))
             {
                 actionLists.Remove(list);
             }
         }
     }
 }
 protected virtual void GetComponentDesignerActions(IComponent component, DesignerActionListCollection actionLists)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     if (actionLists == null)
     {
         throw new ArgumentNullException("actionLists");
     }
     IServiceContainer site = component.Site as IServiceContainer;
     if (site != null)
     {
         DesignerCommandSet service = (DesignerCommandSet) site.GetService(typeof(DesignerCommandSet));
         if (service != null)
         {
             DesignerActionListCollection lists = service.ActionLists;
             if (lists != null)
             {
                 actionLists.AddRange(lists);
             }
             if (actionLists.Count == 0)
             {
                 DesignerVerbCollection verbs = service.Verbs;
                 if ((verbs != null) && (verbs.Count != 0))
                 {
                     ArrayList list = new ArrayList();
                     bool flag = this.componentToVerbsEventHookedUp[component] == null;
                     if (flag)
                     {
                         this.componentToVerbsEventHookedUp[component] = true;
                     }
                     foreach (DesignerVerb verb in verbs)
                     {
                         if (flag)
                         {
                             verb.CommandChanged += new EventHandler(this.OnVerbStatusChanged);
                         }
                         if (verb.Enabled && verb.Visible)
                         {
                             list.Add(verb);
                         }
                     }
                     if (list.Count != 0)
                     {
                         DesignerActionVerbList list2 = new DesignerActionVerbList((DesignerVerb[]) list.ToArray(typeof(DesignerVerb)));
                         actionLists.Add(list2);
                     }
                 }
             }
             if (lists != null)
             {
                 foreach (DesignerActionList list3 in lists)
                 {
                     DesignerActionItemCollection sortedActionItems = list3.GetSortedActionItems();
                     if ((sortedActionItems == null) || (sortedActionItems.Count == 0))
                     {
                         actionLists.Remove(list3);
                     }
                 }
             }
         }
     }
 }
Esempio n. 7
0
        protected virtual void GetComponentDesignerActions(IComponent component, DesignerActionListCollection actionLists)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            if (actionLists == null)
            {
                throw new ArgumentNullException("actionLists");
            }
            IServiceContainer site = component.Site as IServiceContainer;

            if (site != null)
            {
                DesignerCommandSet service = (DesignerCommandSet)site.GetService(typeof(DesignerCommandSet));
                if (service != null)
                {
                    DesignerActionListCollection lists = service.ActionLists;
                    if (lists != null)
                    {
                        actionLists.AddRange(lists);
                    }
                    if (actionLists.Count == 0)
                    {
                        DesignerVerbCollection verbs = service.Verbs;
                        if ((verbs != null) && (verbs.Count != 0))
                        {
                            ArrayList list = new ArrayList();
                            bool      flag = this.componentToVerbsEventHookedUp[component] == null;
                            if (flag)
                            {
                                this.componentToVerbsEventHookedUp[component] = true;
                            }
                            foreach (DesignerVerb verb in verbs)
                            {
                                if (flag)
                                {
                                    verb.CommandChanged += new EventHandler(this.OnVerbStatusChanged);
                                }
                                if (verb.Enabled && verb.Visible)
                                {
                                    list.Add(verb);
                                }
                            }
                            if (list.Count != 0)
                            {
                                DesignerActionVerbList list2 = new DesignerActionVerbList((DesignerVerb[])list.ToArray(typeof(DesignerVerb)));
                                actionLists.Add(list2);
                            }
                        }
                    }
                    if (lists != null)
                    {
                        foreach (DesignerActionList list3 in lists)
                        {
                            DesignerActionItemCollection sortedActionItems = list3.GetSortedActionItems();
                            if ((sortedActionItems == null) || (sortedActionItems.Count == 0))
                            {
                                actionLists.Remove(list3);
                            }
                        }
                    }
                }
            }
        }
        protected virtual void GetComponentDesignerActions(IComponent component, DesignerActionListCollection actionLists)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (actionLists == null)
            {
                throw new ArgumentNullException(nameof(actionLists));
            }

            if (component.Site is IServiceContainer sc)
            {
                DesignerCommandSet dcs = (DesignerCommandSet)sc.GetService(typeof(DesignerCommandSet));
                if (dcs != null)
                {
                    DesignerActionListCollection pullCollection = dcs.ActionLists;
                    if (pullCollection != null)
                    {
                        actionLists.AddRange(pullCollection);
                    }

                    // if we don't find any, add the verbs for this component there...
                    if (actionLists.Count == 0)
                    {
                        DesignerVerbCollection verbs = dcs.Verbs;
                        if (verbs != null && verbs.Count != 0)
                        {
                            ArrayList verbsArray   = new ArrayList();
                            bool      hookupEvents = _componentToVerbsEventHookedUp[component] == null;
                            if (hookupEvents)
                            {
                                _componentToVerbsEventHookedUp[component] = true;
                            }
                            foreach (DesignerVerb verb in verbs)
                            {
                                if (hookupEvents)
                                {
                                    //Debug.WriteLine("hooking up change event for verb " + verb.Text);
                                    verb.CommandChanged += new EventHandler(OnVerbStatusChanged);
                                }
                                if (verb.Enabled && verb.Visible)
                                {
                                    //Debug.WriteLine("adding verb to collection for panel... " + verb.Text);
                                    verbsArray.Add(verb);
                                }
                            }
                            if (verbsArray.Count != 0)
                            {
                                DesignerActionVerbList davl = new DesignerActionVerbList((DesignerVerb[])verbsArray.ToArray(typeof(DesignerVerb)));
                                actionLists.Add(davl);
                            }
                        }
                    }

                    // remove all the ones that are empty... ie GetSortedActionList returns nothing we might waste some time doing this twice but don't have much of a choice here... the panel is not yet displayed and we want to know if a non empty panel is present...
                    // NOTE: We do this AFTER the verb check that way to disable auto verb upgrading you can just return an empty actionlist collection
                    if (pullCollection != null)
                    {
                        foreach (DesignerActionList actionList in pullCollection)
                        {
                            DesignerActionItemCollection collection = actionList.GetSortedActionItems();
                            if (collection == null || collection.Count == 0)
                            {
                                actionLists.Remove(actionList);
                            }
                        }
                    }
                }
            }
        }