internal DesignerActionBehavior(IServiceProvider serviceProvider, IComponent relatedComponent, DesignerActionListCollection actionLists, DesignerActionUI parentUI)
 {
     this.actionLists = actionLists;
     this.serviceProvider = serviceProvider;
     this.relatedComponent = relatedComponent;
     this.parentUI = parentUI;
 }
Exemplo n.º 2
0
        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);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public virtual DesignerActionListCollection GetComponentActions(IComponent component, ComponentActionsType type)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }
            DesignerActionListCollection result = new DesignerActionListCollection();

            switch (type)
            {
            case ComponentActionsType.All:
                GetComponentDesignerActions(component, result);
                GetComponentServiceActions(component, result);
                break;

            case ComponentActionsType.Component:
                GetComponentDesignerActions(component, result);
                break;

            case ComponentActionsType.Service:
                GetComponentServiceActions(component, result);
                break;
            }
            return(result);
        }
 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));
             }
         }
     }
 }
 public DesignerActionListsChangedEventArgs(object relatedObject, DesignerActionListsChangedType changeType,
                                            DesignerActionListCollection actionLists)
 {
     this.related_object = relatedObject;
     this.change_type    = changeType;
     this.action_lists   = actionLists;
 }
		public DesignerActionListsChangedEventArgs (object relatedObject, DesignerActionListsChangedType changeType,
							    DesignerActionListCollection actionLists)
		{
			this.related_object = relatedObject;
			this.change_type = changeType;
			this.action_lists = actionLists;
		}
 private void BuildActionLists()
 {
     this.actionLists = new DesignerActionListCollection();
     this.actionLists.Add(new FilterControlChooseDataSourceActionList(this));
     this.actionLists.Add(new FilterColumnEditingActionList(this));
     this.actionLists[0].AutoShow = true;
 }
Exemplo n.º 8
0
 protected override void RegisterActionLists(System.ComponentModel.Design.DesignerActionListCollection list)
 {
     base.RegisterActionLists(list);
     list.Add(new XRDataContainerDesignerDataActionList(this));
     list.Add(new XRDataContainerDesignerSortActionList(this));
     list.Add(CreateColumnActionList());
 }
Exemplo n.º 9
0
        public virtual DesignerActionListCollection GetComponentActions(IComponent component, ComponentActionsType type)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            DesignerActionListCollection actionLists = new DesignerActionListCollection();

            switch (type)
            {
            case ComponentActionsType.All:
                this.GetComponentDesignerActions(component, actionLists);
                this.GetComponentServiceActions(component, actionLists);
                return(actionLists);

            case ComponentActionsType.Component:
                this.GetComponentDesignerActions(component, actionLists);
                return(actionLists);

            case ComponentActionsType.Service:
                this.GetComponentServiceActions(component, actionLists);
                return(actionLists);
            }
            return(actionLists);
        }
Exemplo n.º 10
0
 public bool ShouldAutoShow(IComponent component)
 {
     if (this.serviceProvider != null)
     {
         DesignerOptionService service = this.serviceProvider.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
         if (service != null)
         {
             PropertyDescriptor descriptor = service.Options.Properties["ObjectBoundSmartTagAutoShow"];
             if (((descriptor != null) && (descriptor.PropertyType == typeof(bool))) && !((bool)descriptor.GetValue(null)))
             {
                 return(false);
             }
         }
     }
     if (this.designerActionService != null)
     {
         DesignerActionListCollection componentActions = this.designerActionService.GetComponentActions(component);
         if ((componentActions != null) && (componentActions.Count > 0))
         {
             for (int i = 0; i < componentActions.Count; i++)
             {
                 if (componentActions[i].AutoShow)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 11
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);
                    }
                }
            }
        }
 private void BuildActionLists()
 {
     this.actionLists = new DesignerActionListCollection();
     this.actionLists.Add(new DataGridViewChooseDataSourceActionList(this));
     this.actionLists.Add(new DataGridViewColumnEditingActionList(this));
     this.actionLists.Add(new DataGridViewPropertiesActionList(this));
     this.actionLists[0].AutoShow = true;
 }
Exemplo n.º 13
0
		public void AddRange (DesignerActionListCollection value)
		{
			if (value == null)
				throw new ArgumentNullException ("value");
			
			foreach (DesignerActionList actionList in value)
				Add (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;
 }
 public void AddRange(DesignerActionListCollection value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     int count = value.Count;
     for (int i = 0; i < count; i++)
     {
         this.Add(value[i]);
     }
 }
        public void AddRange(DesignerActionListCollection value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            foreach (DesignerActionList actionList in value)
            {
                Add(actionList);
            }
        }
        public void AddRange(DesignerActionListCollection value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            int count = value.Count;

            for (int i = 0; i < count; i++)
            {
                this.Add(value[i]);
            }
        }
Exemplo n.º 18
0
        /// <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)));
            }
        }
 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)));
 }
Exemplo n.º 20
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)));
        }
Exemplo n.º 21
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)));
             }
         }
     }
 }
Exemplo n.º 22
0
        /// <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)));
        }
Exemplo n.º 23
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 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);
             }
         }
     }
 }
Exemplo n.º 25
0
        protected void EnsureVerbs()
        {
            bool flag = false;

            if ((this._currentVerbs == null) && (this._serviceProvider != null))
            {
                Hashtable hashtable = null;
                if (this._selectionService == null)
                {
                    this._selectionService = this.GetService(typeof(ISelectionService)) as ISelectionService;
                    if (this._selectionService != null)
                    {
                        this._selectionService.SelectionChanging += new EventHandler(this.OnSelectionChanging);
                    }
                }
                int capacity = 0;
                DesignerVerbCollection verbs  = null;
                DesignerVerbCollection verbs2 = new DesignerVerbCollection();
                IDesignerHost          host   = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (((this._selectionService != null) && (host != null)) && (this._selectionService.SelectionCount == 1))
                {
                    object primarySelection = this._selectionService.PrimarySelection;
                    if ((primarySelection is IComponent) && !TypeDescriptor.GetAttributes(primarySelection).Contains(InheritanceAttribute.InheritedReadOnly))
                    {
                        flag = primarySelection == host.RootComponent;
                        IDesigner designer = host.GetDesigner((IComponent)primarySelection);
                        if (designer != null)
                        {
                            verbs = designer.Verbs;
                            if (verbs != null)
                            {
                                capacity            += verbs.Count;
                                this._verbSourceType = primarySelection.GetType();
                            }
                            else
                            {
                                this._verbSourceType = null;
                            }
                        }
                        DesignerActionService service = this.GetService(typeof(DesignerActionService)) as DesignerActionService;
                        if (service != null)
                        {
                            DesignerActionListCollection componentActions = service.GetComponentActions(primarySelection as IComponent);
                            if (componentActions != null)
                            {
                                foreach (DesignerActionList list2 in componentActions)
                                {
                                    DesignerActionItemCollection sortedActionItems = list2.GetSortedActionItems();
                                    if (sortedActionItems != null)
                                    {
                                        for (int j = 0; j < sortedActionItems.Count; j++)
                                        {
                                            DesignerActionMethodItem item = sortedActionItems[j] as DesignerActionMethodItem;
                                            if ((item != null) && item.IncludeAsDesignerVerb)
                                            {
                                                EventHandler handler = new EventHandler(item.Invoke);
                                                DesignerVerb verb    = new DesignerVerb(item.DisplayName, handler);
                                                verbs2.Add(verb);
                                                capacity++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (flag && (this._globalVerbs == null))
                {
                    flag = false;
                }
                if (flag)
                {
                    capacity += this._globalVerbs.Count;
                }
                hashtable = new Hashtable(capacity, StringComparer.OrdinalIgnoreCase);
                ArrayList list = new ArrayList(capacity);
                if (flag)
                {
                    for (int k = 0; k < this._globalVerbs.Count; k++)
                    {
                        string text = ((DesignerVerb)this._globalVerbs[k]).Text;
                        hashtable[text] = list.Add(this._globalVerbs[k]);
                    }
                }
                if (verbs2.Count > 0)
                {
                    for (int m = 0; m < verbs2.Count; m++)
                    {
                        string str2 = verbs2[m].Text;
                        hashtable[str2] = list.Add(verbs2[m]);
                    }
                }
                if ((verbs != null) && (verbs.Count > 0))
                {
                    for (int n = 0; n < verbs.Count; n++)
                    {
                        string str3 = verbs[n].Text;
                        hashtable[str3] = list.Add(verbs[n]);
                    }
                }
                DesignerVerb[] verbArray = new DesignerVerb[hashtable.Count];
                int            index     = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    DesignerVerb verb2 = (DesignerVerb)list[i];
                    string       str4  = verb2.Text;
                    if (((int)hashtable[str4]) == i)
                    {
                        verbArray[index] = verb2;
                        index++;
                    }
                }
                this._currentVerbs = new DesignerVerbCollection(verbArray);
            }
        }
		protected override void GetComponentDesignerActions (IComponent component, DesignerActionListCollection actionLists)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 27
0
 public void AddRange(DesignerActionListCollection value)
 {
     throw null;
 }
Exemplo n.º 28
0
		public void Add (IComponent comp, DesignerActionListCollection designerActionListCollection)
		{
			throw new NotImplementedException ();
		}
 private void BuildActionLists()
 {
     this.actionLists = new DesignerActionListCollection();
     this.actionLists.Add(new TableLayouPanelRowColumnActionList(this));
     this.actionLists[0].AutoShow = true;
 }
 internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerActionListCollection dalColl)
 {
     InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(comp)[typeof(InheritanceAttribute)];
     if (attribute != InheritanceAttribute.InheritedReadOnly)
     {
         if (dalColl == null)
         {
             dalColl = this.designerActionService.GetComponentActions(comp);
         }
         if ((dalColl != null) && (dalColl.Count > 0))
         {
             DesignerActionGlyph glyph = null;
             if (this.componentToGlyph[comp] == null)
             {
                 DesignerActionBehavior behavior = new DesignerActionBehavior(this.serviceProvider, comp, dalColl, this);
                 if (!(comp is Control) || (comp is ToolStripDropDown))
                 {
                     ComponentTray service = this.serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray;
                     if (service != null)
                     {
                         ComponentTray.TrayControl trayControlFromComponent = service.GetTrayControlFromComponent(comp);
                         if (trayControlFromComponent != null)
                         {
                             Rectangle bounds = trayControlFromComponent.Bounds;
                             glyph = new DesignerActionGlyph(behavior, bounds, service);
                         }
                     }
                 }
                 if (glyph == null)
                 {
                     glyph = new DesignerActionGlyph(behavior, this.designerActionAdorner);
                 }
                 if (glyph != null)
                 {
                     this.componentToGlyph.Add(comp, glyph);
                 }
                 return glyph;
             }
             glyph = this.componentToGlyph[comp] as DesignerActionGlyph;
             if (glyph != null)
             {
                 DesignerActionBehavior behavior2 = glyph.Behavior as DesignerActionBehavior;
                 if (behavior2 != null)
                 {
                     behavior2.ActionLists = dalColl;
                 }
                 glyph.Invalidate();
             }
             return glyph;
         }
         this.RemoveActionGlyph(comp);
     }
     return null;
 }
Exemplo n.º 31
0
		protected virtual void GetComponentServiceActions (IComponent component, DesignerActionListCollection actionLists)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 32
0
 void BuildActionLists()
 {
     m_actionLists = new DesignerActionListCollection();
     m_actionLists.Add(new DataGridViewChooseDataSourceActionList(this));
     m_actionLists.Add(new DataGridViewColumnEditingActionList(this));
     m_actionLists.Add(new DataGridViewPropertiesActionList(this));
 }
Exemplo n.º 33
0
        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);
                            }
                        }
                    }
                }
            }
        }
 public void UpdateTasks(DesignerActionListCollection actionLists, DesignerActionListCollection serviceActionLists, string title, string subtitle)
 {
     this._updatingTasks = true;
     base.SuspendLayout();
     try
     {
         base.AccessibleName = title;
         base.AccessibleDescription = subtitle;
         string focusId = string.Empty;
         Line focusedLine = this.FocusedLine;
         if (focusedLine != null)
         {
             focusId = focusedLine.FocusId;
         }
         ListDictionary categories = new ListDictionary();
         this.ProcessLists(actionLists, categories);
         this.ProcessLists(serviceActionLists, categories);
         List<LineInfo> list = new List<LineInfo> {
             new LineInfo(null, new DesignerActionPanelHeaderItem(title, subtitle), new PanelHeaderLine(this._serviceProvider, this))
         };
         int num = 0;
         foreach (ListDictionary dictionary2 in categories.Values)
         {
             int num2 = 0;
             foreach (List<LineInfo> list2 in dictionary2.Values)
             {
                 for (int k = 0; k < list2.Count; k++)
                 {
                     list.Add(list2[k]);
                 }
                 num2++;
                 if (num2 < dictionary2.Count)
                 {
                     list.Add(new LineInfo(null, null, new SeparatorLine(this._serviceProvider, this, true)));
                 }
             }
             num++;
             if (num < categories.Count)
             {
                 list.Add(new LineInfo(null, null, new SeparatorLine(this._serviceProvider, this)));
             }
         }
         int currentTabIndex = 0;
         for (int i = 0; i < list.Count; i++)
         {
             LineInfo info = list[i];
             Line line = info.Line;
             bool flag = false;
             if (i < this._lines.Count)
             {
                 Line line3 = this._lines[i];
                 if (line3.GetType() == line.GetType())
                 {
                     line3.UpdateActionItem(info.List, info.Item, this._toolTip, ref currentTabIndex);
                     flag = true;
                 }
                 else
                 {
                     line3.RemoveControls(base.Controls);
                     this._lines.RemoveAt(i);
                 }
             }
             if (!flag)
             {
                 List<Control> controls = line.GetControls();
                 Control[] array = new Control[controls.Count];
                 controls.CopyTo(array);
                 base.Controls.AddRange(array);
                 line.UpdateActionItem(info.List, info.Item, this._toolTip, ref currentTabIndex);
                 this._lines.Insert(i, line);
             }
         }
         for (int j = this._lines.Count - 1; j >= list.Count; j--)
         {
             this._lines[j].RemoveControls(base.Controls);
             this._lines.RemoveAt(j);
         }
         if (!string.IsNullOrEmpty(focusId))
         {
             foreach (Line line5 in this._lines)
             {
                 if (string.Equals(line5.FocusId, focusId, StringComparison.Ordinal))
                 {
                     line5.Focus();
                 }
             }
         }
     }
     finally
     {
         this.UpdateEditXPos();
         this._updatingTasks = false;
         base.ResumeLayout(true);
     }
     base.Invalidate();
 }
Exemplo n.º 35
0
        /// <summary>
        ///  Ensures that the verb list has been created.
        /// </summary>
        protected void EnsureVerbs()
        {
            // We apply global verbs only if the base component is the
            // currently selected object.
            //
            bool useGlobalVerbs = false;

            if (_currentVerbs is null && _serviceProvider != null)
            {
                Hashtable buildVerbs = null;
                ArrayList verbsOrder;

                if (_selectionService is null)
                {
                    _selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

                    if (_selectionService != null)
                    {
                        _selectionService.SelectionChanging += new EventHandler(OnSelectionChanging);
                    }
                }

                int verbCount = 0;
                DesignerVerbCollection localVerbs          = null;
                DesignerVerbCollection designerActionVerbs = new DesignerVerbCollection(); // we instanciate this one here...
                IDesignerHost          designerHost        = GetService(typeof(IDesignerHost)) as IDesignerHost;

                if (_selectionService != null && designerHost != null && _selectionService.SelectionCount == 1)
                {
                    object selectedComponent = _selectionService.PrimarySelection;
                    if (selectedComponent is IComponent &&
                        !TypeDescriptor.GetAttributes(selectedComponent).Contains(InheritanceAttribute.InheritedReadOnly))
                    {
                        useGlobalVerbs = (selectedComponent == designerHost.RootComponent);

                        // LOCAL VERBS
                        IDesigner designer = designerHost.GetDesigner((IComponent)selectedComponent);
                        if (designer != null)
                        {
                            localVerbs = designer.Verbs;
                            if (localVerbs != null)
                            {
                                verbCount      += localVerbs.Count;
                                _verbSourceType = selectedComponent.GetType();
                            }
                            else
                            {
                                _verbSourceType = null;
                            }
                        }

                        // DesignerAction Verbs
                        DesignerActionService daSvc = GetService(typeof(DesignerActionService)) as DesignerActionService;
                        if (daSvc != null)
                        {
                            DesignerActionListCollection actionLists = daSvc.GetComponentActions(selectedComponent as IComponent);
                            if (actionLists != null)
                            {
                                foreach (DesignerActionList list in actionLists)
                                {
                                    DesignerActionItemCollection dai = list.GetSortedActionItems();
                                    if (dai != null)
                                    {
                                        for (int i = 0; i < dai.Count; i++)
                                        {
                                            DesignerActionMethodItem dami = dai[i] as DesignerActionMethodItem;
                                            if (dami != null && dami.IncludeAsDesignerVerb)
                                            {
                                                EventHandler handler = new EventHandler(dami.Invoke);
                                                DesignerVerb verb    = new DesignerVerb(dami.DisplayName, handler);
                                                designerActionVerbs.Add(verb);
                                                verbCount++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // GLOBAL VERBS
                if (useGlobalVerbs && _globalVerbs is null)
                {
                    useGlobalVerbs = false;
                }

                if (useGlobalVerbs)
                {
                    verbCount += _globalVerbs.Count;
                }

                // merge all
                buildVerbs = new Hashtable(verbCount, StringComparer.OrdinalIgnoreCase);
                verbsOrder = new ArrayList(verbCount);

                // PRIORITY ORDER FROM HIGH TO LOW: LOCAL VERBS - DESIGNERACTION VERBS - GLOBAL VERBS
                if (useGlobalVerbs)
                {
                    for (int i = 0; i < _globalVerbs.Count; i++)
                    {
                        string key = ((DesignerVerb)_globalVerbs[i]).Text;
                        buildVerbs[key] = verbsOrder.Add(_globalVerbs[i]);
                    }
                }

                if (designerActionVerbs.Count > 0)
                {
                    for (int i = 0; i < designerActionVerbs.Count; i++)
                    {
                        string key = designerActionVerbs[i].Text;
                        buildVerbs[key] = verbsOrder.Add(designerActionVerbs[i]);
                    }
                }

                if (localVerbs != null && localVerbs.Count > 0)
                {
                    for (int i = 0; i < localVerbs.Count; i++)
                    {
                        string key = localVerbs[i].Text;
                        buildVerbs[key] = verbsOrder.Add(localVerbs[i]);
                    }
                }

                // look for duplicate, prepare the result table
                DesignerVerb[] result = new DesignerVerb[buildVerbs.Count];
                int            j      = 0;
                for (int i = 0; i < verbsOrder.Count; i++)
                {
                    DesignerVerb value = (DesignerVerb)verbsOrder[i];
                    string       key   = value.Text;
                    if ((int)buildVerbs[key] == i)
                    { // there's not been a duplicate for this entry
                        result[j] = value;
                        j++;
                    }
                }

                _currentVerbs = new DesignerVerbCollection(result);
            }
        }
 private void ProcessLists(DesignerActionListCollection lists, ListDictionary categories)
 {
     if (lists != null)
     {
         foreach (DesignerActionList list in lists)
         {
             if (list != null)
             {
                 IEnumerable sortedActionItems = list.GetSortedActionItems();
                 if (sortedActionItems != null)
                 {
                     foreach (DesignerActionItem item in sortedActionItems)
                     {
                         if (item != null)
                         {
                             LineInfo lineInfo = this.ProcessTaskItem(list, item);
                             if (lineInfo != null)
                             {
                                 this.AddToCategories(lineInfo, categories);
                                 IComponent relatedComponent = null;
                                 DesignerActionPropertyItem item2 = item as DesignerActionPropertyItem;
                                 if (item2 != null)
                                 {
                                     relatedComponent = item2.RelatedComponent;
                                 }
                                 else
                                 {
                                     DesignerActionMethodItem item3 = item as DesignerActionMethodItem;
                                     if (item3 != null)
                                     {
                                         relatedComponent = item3.RelatedComponent;
                                     }
                                 }
                                 if (relatedComponent != null)
                                 {
                                     IEnumerable<LineInfo> enumerable2 = this.ProcessRelatedTaskItems(relatedComponent);
                                     if (enumerable2 != null)
                                     {
                                         foreach (LineInfo info2 in enumerable2)
                                         {
                                             this.AddToCategories(info2, categories);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 37
0
 protected override void RegisterActionLists(System.ComponentModel.Design.DesignerActionListCollection list)
 {
     base.RegisterActionLists(list);
     list.Add(new MyCustomLabelActionList(this));
 }
        public virtual DesignerActionListCollection GetComponentActions(IComponent component, ComponentActionsType type)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            DesignerActionListCollection actionLists = new DesignerActionListCollection();
            switch (type)
            {
                case ComponentActionsType.All:
                    this.GetComponentDesignerActions(component, actionLists);
                    this.GetComponentServiceActions(component, actionLists);
                    return actionLists;

                case ComponentActionsType.Component:
                    this.GetComponentDesignerActions(component, actionLists);
                    return actionLists;

                case ComponentActionsType.Service:
                    this.GetComponentServiceActions(component, actionLists);
                    return actionLists;
            }
            return actionLists;
        }
 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);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 40
0
 public void Add(IComponent comp, DesignerActionListCollection designerActionListCollection)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 41
0
 protected virtual void GetComponentServiceActions(IComponent component, DesignerActionListCollection actionLists)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 42
0
 protected override void RegisterActionLists(System.ComponentModel.Design.DesignerActionListCollection list)
 {
     base.RegisterActionLists(list);
     list.Add(new XRTreeListDesignerDataActionList(this, this.Component as XRTreeList));
 }