Ejemplo n.º 1
0
		public void Constructor ()
		{
			DesignerActionMethodItem item = new DesignerActionMethodItem (new DesignerActionList (new Component ()),
				"myMember", "myDisplay");
			Assert.AreEqual ("myMember", item.MemberName, "#1");
			Assert.AreEqual ("myDisplay", item.DisplayName, "#2");
			Assert.IsNull (item.Category, "#3");
			Assert.IsNull (item.Description, "#4");
			Assert.IsFalse (item.IncludeAsDesignerVerb, "#5");
		}
 public override DesignerActionItemCollection GetSortedActionItems()
 {
     DesignerActionItemCollection items = new DesignerActionItemCollection();
     ContentDesignerState showDefaultContent = ContentDesignerState.ShowDefaultContent;
     if ((this._parent.ContentResolutionService != null) && (this._parent.GetContentDefinition() != null))
     {
         showDefaultContent = this._parent.ContentResolutionService.GetContentDesignerState(this._parent.GetContentDefinition().ContentPlaceHolderID);
     }
     if (showDefaultContent == ContentDesignerState.ShowDefaultContent)
     {
         DesignerActionMethodItem item = new DesignerActionMethodItem(this, "CreateBlankContent", System.Design.SR.GetString("Content_CreateBlankContent"), string.Empty, string.Empty, true) {
             ShowInSourceView = false
         };
         items.Add(item);
         return items;
     }
     if (ContentDesignerState.ShowUserContent == showDefaultContent)
     {
         items.Add(new DesignerActionMethodItem(this, "ClearRegion", System.Design.SR.GetString("Content_ClearRegion"), string.Empty, string.Empty, true));
     }
     return items;
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            this.AddHeaderItem(new DesignerActionHeaderItem("Actions", "600"));

            DesignerActionMethodItem add = new DesignerActionMethodItem(this, "AddPanel", "Add Panel", "600");
            DesignerActionMethodItem remove = new DesignerActionMethodItem(this, "RemovePanel", "Remove panel", "600", "Remove active panel");
            AccordionLayout layout = (AccordionLayout)this.Control;
            this.AddMethodItem(add);

            if (layout.ExpandedPanelIndex > -1)
            {
                this.AddMethodItem(remove);
            }
            else
            {
                this.RemoveMethodItem(remove);
            }

            return base.GetSortedActionItems();
        }
            public override DesignerActionItemCollection GetSortedActionItems()
            {
                DesignerActionItemCollection items = new DesignerActionItemCollection();

                DesignerActionMethodItem addItem = new DesignerActionMethodItem(this, "OnAddTabPanel", "Add Tab Panel", true);
                DesignerActionMethodItem removeItem = new DesignerActionMethodItem(this, "OnRemoveTabPanel", "Remove Tab Panel", true);
                items.Add(addItem);
                items.Add(removeItem);

                return items;
            }
 internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, System.Windows.Forms.ToolTip toolTip, ref int currentTabIndex)
 {
     this._actionList = actionList;
     this._methodItem = (DesignerActionMethodItem) actionItem;
     toolTip.SetToolTip(this._linkLabel, this._methodItem.Description);
     this._linkLabel.Text = DesignerActionPanel.StripAmpersands(this._methodItem.DisplayName);
     this._linkLabel.AccessibleDescription = actionItem.Description;
     this._linkLabel.TabIndex = currentTabIndex++;
 }
Ejemplo n.º 7
0
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            this.AddHeaderItem(new DesignerActionHeaderItem("Actions", "600"));

            DesignerActionMethodItem addPanel = new DesignerActionMethodItem(this, "AddPanel", "Add Panel", "600");
            DesignerActionMethodItem addTabPanel = new DesignerActionMethodItem(this, "AddTabPanel", "Add TabPanel", "600");
            
            //DesignerActionMethodItem clear = new DesignerActionMethodItem(this, "Clear", "Clear layout", "600", "Remove control from layout");

            if (((FitLayout)this.Control).Items.Count > 0)
            {
                //this.AddMethodItem(clear);
                this.RemoveMethodItem(addPanel);
                this.RemoveMethodItem(addTabPanel);
            }
            else
            {
                this.AddMethodItem(addPanel);
                this.AddMethodItem(addTabPanel);
                //this.RemoveMethodItem(clear);
            }

            return base.GetSortedActionItems();
        }
 public override DesignerActionItemCollection GetSortedActionItems()
 {
     DesignerActionItemCollection items = new DesignerActionItemCollection();
     if (this._parent.CanConfigure)
     {
         DesignerActionMethodItem item = new DesignerActionMethodItem(this, "Configure", System.Design.SR.GetString("DataSourceDesigner_ConfigureDataSourceVerb"), System.Design.SR.GetString("DataSourceDesigner_DataActionGroup"), System.Design.SR.GetString("DataSourceDesigner_ConfigureDataSourceVerbDesc"), true) {
             AllowAssociate = true
         };
         items.Add(item);
     }
     if (this._parent.CanRefreshSchema)
     {
         DesignerActionMethodItem item2 = new DesignerActionMethodItem(this, "RefreshSchema", System.Design.SR.GetString("DataSourceDesigner_RefreshSchemaVerb"), System.Design.SR.GetString("DataSourceDesigner_DataActionGroup"), System.Design.SR.GetString("DataSourceDesigner_RefreshSchemaVerbDesc"), false) {
             AllowAssociate = true
         };
         items.Add(item2);
     }
     return items;
 }
        /* Implementation of this abstract method creates smart tag
               items, associates their targets, and collects into list. */
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            DesignerActionItemCollection items = new DesignerActionItemCollection();
            try
            {
                // Creating the action list static headers.
                items.Add(new DesignerActionHeaderItem("Commands"));
                items.Add(new DesignerActionHeaderItem("Appearance"));

                if (!_linkedControl.HeaderVisibility)
                {
                    // Creates other action list headers.
                    items.Add(new DesignerActionHeaderItem("Tab Item Appearance"));

                    items.Add(new DesignerActionPropertyItem("TabStyles", "Tab Styles", "Appearance",
                         "Tab Style"));

                    items.Add(new DesignerActionPropertyItem("Alignments", "Tab Alignments", "Appearance",
                        "Tab Alignment"));

                    items.Add(new DesignerActionPropertyItem("FirstColor", "First Color", "Tab Item Appearance",
                        "First TabItem Color"));

                    items.Add(new DesignerActionPropertyItem("SecondColor", "Second Color", "Tab Item Appearance",
                        "Second TabItem Color"));

                    items.Add(new DesignerActionPropertyItem("GradientMode", "Gradient Mode", "Tab Item Appearance",
                        "Gradient Style"));

                    items.Add(new DesignerActionPropertyItem("IsSupportedAlphaColor", "Support Alpha Color", "Tab Item Appearance",
                        "Supports alpha component for tab item background colors"));

                    items.Add(new DesignerActionMethodItem(this,
                        "RandomizeColors", "Randomize Colors", "Tab Item Appearance",
                        "Randomize TabItem Colors", false));
                }

                items.Add(new DesignerActionMethodItem(this,
                    "HeaderVisibility", "StretchToParent " + (_linkedControl.HeaderVisibility ? "ON" : "OFF"), "Appearance",
                    "Determines whether the active tab is stretched to its parent container or not", false));

                items.Add(new DesignerActionMethodItem(this,
                    "AddTab", "Add Tab", "Commands",
                    "Add a new tab page to the container", false));

                if (_linkedControl.TabCount > 0)
                {
                    DesignerActionMethodItem methodRemove = new DesignerActionMethodItem(this, "RemoveTab", "Remove Tab", "Commands",
                        "Removes the selected tab page from the container", false);

                    items.Add(methodRemove);
                }

                // Add a new static header and its items.
                items.Add(new DesignerActionHeaderItem("Information"));
                items.Add(new DesignerActionTextItem("X: " + _linkedControl.Location.X + ", " + "Y: " + _linkedControl.Location.Y, "Information"));
                items.Add(new DesignerActionTextItem("Width: " + _linkedControl.Size.Width + ", " + "Height: " + _linkedControl.Size.Height, "Information"));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception while generating the action list panel for this KRBTabControl, " + ex.Message);
            }

            return items;
        }
Ejemplo n.º 10
0
            public override DesignerActionItemCollection GetSortedActionItems()
            {
                DesignerActionItemCollection actions = new DesignerActionItemCollection();
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this._designer.Component);
                PropertyDescriptor actionableProperty;

                actionableProperty = properties["LeftItems"];
                if (actionableProperty != null && actionableProperty.IsBrowsable)
                {
                    DesignerActionMethodItem editLeftItemsAction = new DesignerActionMethodItem(this, "EditLeftItems", "Edit Left Items...", "LeftData", "Edit the items visible in the left list");
                    actions.Add(editLeftItemsAction);
                }

                actionableProperty = properties["RightItems"];
                if (actionableProperty != null && actionableProperty.IsBrowsable)
                {
                    actions.Add(new DesignerActionMethodItem(this, "EditRightItems", "Edit Right Items...", "RightData", "Edit the items visible in the right list"));
                }

                DesignerActionHeaderItem behaviorHeader = new DesignerActionHeaderItem("Behavior", "Behavior");
                actions.Add(behaviorHeader);

                actionableProperty = properties["EnableMoveAll"];
                if ((actionableProperty != null) && actionableProperty.IsBrowsable)
                {
                    actions.Add(new DesignerActionPropertyItem("EnableMoveAll", "Toggle EnableMoveAll", "Behavior", "Toggles the visibility of the buttons which move all items"));
                }

                actionableProperty = properties["EnableMoveUpDown"];
                if ((actionableProperty != null) && actionableProperty.IsBrowsable)
                {
                    actions.Add(new DesignerActionPropertyItem("EnableMoveUpDown", "Toggle EnableMoveUpDown", "Behavior", "Toggles the visibility of the buttons which move chosen items up and down"));
                }

                return actions;
            }
 public override DesignerActionItemCollection GetSortedActionItems()
 {
     DesignerActionItemCollection items = new DesignerActionItemCollection();
     if (this._parent._userControlFound)
     {
         items.Add(new DesignerActionMethodItem(this, "EditUserControl", System.Design.SR.GetString("UserControlDesigner_EditUserControl"), string.Empty, string.Empty, true));
     }
     DesignerActionMethodItem item = new DesignerActionMethodItem(this, "Refresh", System.Design.SR.GetString("UserControlDesigner_Refresh"), string.Empty, string.Empty, true) {
         ShowInSourceView = false
     };
     items.Add(item);
     return items;
 }
            public override DesignerActionItemCollection GetSortedActionItems() {
                var items = new DesignerActionItemCollection();

                var addItem = new DesignerActionMethodItem(this, "OnAddTabPanel", "Add Tab Panel", true);
                var removeItem = new DesignerActionMethodItem(this, "OnRemoveTabPanel", "Remove Tab Panel", true);
                var hideContentOverflowItem = new DesignerActionPropertyItem("HideOverflowContent", "Hide overflow content at design-time");
                items.Add(addItem);
                items.Add(removeItem);
                items.Add(hideContentOverflowItem);

                return items;
            }
Ejemplo n.º 13
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);
            }
        }