protected override 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) || ((actionLists.Count == 1) && (actionLists[0] is ControlDesigner.ControlDesignerActionList)))
         {
             DesignerVerbCollection verbs = service.Verbs;
             if ((verbs != null) && (verbs.Count != 0))
             {
                 DesignerVerb[] array = new DesignerVerb[verbs.Count];
                 verbs.CopyTo(array, 0);
                 actionLists.Add(new DesignerActionVerbList(array));
             }
         }
     }
 }
Esempio n. 2
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);
                    }
                }
            }
        }
 internal DesignerActionPanel CreateDesignerActionPanel(IComponent relatedComponent)
 {
     DesignerActionListCollection actionLists = new DesignerActionListCollection();
     actionLists.AddRange(this.ActionLists);
     DesignerActionPanel panel = new DesignerActionPanel(this.serviceProvider);
     panel.UpdateTasks(actionLists, new DesignerActionListCollection(), System.Design.SR.GetString("DesignerActionPanel_DefaultPanelTitle", new object[] { relatedComponent.GetType().Name }), null);
     return panel;
 }
Esempio n. 5
0
        public void Add(IComponent comp, DesignerActionListCollection designerActionListCollection)
        {
            if (comp == null)
            {
                throw new ArgumentNullException("comp");
            }
            if (designerActionListCollection == null)
            {
                throw new ArgumentNullException("designerActionListCollection");
            }
            DesignerActionListCollection lists = (DesignerActionListCollection)this.designerActionLists[comp];

            if (lists != null)
            {
                lists.AddRange(designerActionListCollection);
            }
            else
            {
                this.designerActionLists.Add(comp, designerActionListCollection);
            }
            this.OnDesignerActionListsChanged(new DesignerActionListsChangedEventArgs(comp, DesignerActionListsChangedType.ActionListsAdded, this.GetComponentActions(comp)));
        }
        /// <summary>
        /// Adds a new collection of DesignerActions to be monitored with the related comp object.
        /// </summary>
        public void Add(IComponent comp, DesignerActionListCollection designerActionListCollection)
        {
            if (comp == null)
            {
                throw new ArgumentNullException(nameof(comp));
            }
            if (designerActionListCollection == null)
            {
                throw new ArgumentNullException(nameof(designerActionListCollection));
            }

            DesignerActionListCollection dhlc = (DesignerActionListCollection)_designerActionLists[comp];

            if (dhlc != null)
            {
                dhlc.AddRange(designerActionListCollection);
            }
            else
            {
                _designerActionLists.Add(comp, designerActionListCollection);
            }
            OnDesignerActionListsChanged(new DesignerActionListsChangedEventArgs(comp, DesignerActionListsChangedType.ActionListsAdded, 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. 9
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);
                            }
                        }
                    }
                }
            }
        }