public RebarDesigner() { _verbs = new DesignerVerbCollection(); _verbs.Add(new DesignerVerb("Add Band", new EventHandler(mnuAddBand))); _verbs.Add(new DesignerVerb("Remove Band", new EventHandler(mnuRemoveBand))); _verbs[1].Enabled = false; }
/// <summary> /// Gets the collection of verbs displayed in the top right menu of the designer. /// </summary> /// <param name="panel"></param> /// <returns></returns> public static DesignerVerbCollection GetDesignerVerbs(IDesignerHost host, MultiPanel panel) { var verbs = new DesignerVerbCollection(); verbs.Add(new DesignerVerb("Add Page", (sender, args) => AddPage(host, panel))); verbs.Add(new DesignerVerb("Remove Page", (sender, args) => RemovePage(host, panel))); foreach (MultiPanelPage page in panel.Controls) { var pageCopy = page; verbs.Add(new DesignerVerb("Select \"" + page.Text + "\"", (sender, args) => SelectPage(host, panel, pageCopy))); } return verbs; }
public FABaseDesigner() { changeService = null; designerVerbs = new DesignerVerbCollection(); ShowAbout = new DesignerVerb("About Farsi Libraries", OnShowAbout); ShowAbout.Checked = false; designerVerbs.Add(ShowAbout); Designers.Add(this); }
protected void EnsureVerbs() { DesignerVerbCollection selectionVerbs = null; ISelectionService selectionSvc = this.GetService(typeof(ISelectionService)) as ISelectionService; IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost; if (selectionSvc != null && host != null && selectionSvc.SelectionCount == 1) { IComponent primarySelection = selectionSvc.PrimarySelection as IComponent; if (primarySelection != null) { IDesigner designer = host.GetDesigner(primarySelection); if (designer != null) { selectionVerbs = designer.Verbs; } } } // Designer provided verbs have the higher precedence than the global // Dictionary <string, DesignerVerb> allVerbs = new Dictionary <string, DesignerVerb> (); if (_globalVerbs != null) { foreach (DesignerVerb verb in _globalVerbs) { allVerbs[verb.Text] = verb; } } if (selectionVerbs != null) { foreach (DesignerVerb verb in selectionVerbs) { allVerbs[verb.Text] = verb; } } if (_verbs == null) { _verbs = new DesignerVerbCollection(); } else { _verbs.Clear(); } foreach (DesignerVerb verb in allVerbs.Values) { _verbs.Add(verb); } }
public static DesignerVerbCollection GetAttributedVerbs(this ComponentDesigner designer) { var verbs = new DesignerVerbCollection(); foreach (var m in designer.GetType().GetMethods(allInstBind)) { foreach (DesignerVerbAttribute attr in m.GetCustomAttributes(typeof(DesignerVerbAttribute), true)) { verbs.Add(attr.GetDesignerVerb(designer, m)); } } return(verbs); }
public virtual void AddVerb(DesignerVerb verb) { if (verb == null) { throw new ArgumentNullException("verb"); } this.EnsureVerbs(); if (!_verbs.Contains(verb)) { if (_globalVerbs == null) { _globalVerbs = new DesignerVerbCollection(); } _globalVerbs.Add(verb); } this.OnCommandsChanged(new MenuCommandsChangedEventArgs(MenuCommandsChangedType.CommandAdded, verb)); }
public RTBDesigner() { this.verbs = new DesignerVerbCollection(); verbs.Add(new DesignerVerb("Add Sample Scopes", new EventHandler(AddSampleScopes))); }
/// <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); } }
public virtual void GetOleVerbs(DesignerVerbCollection rval) { System.Design.NativeMethods.IEnumOLEVERB e = null; System.Design.NativeMethods.IOleObject ocx = this.axHost.GetOcx() as System.Design.NativeMethods.IOleObject; if ((ocx == null) || System.Design.NativeMethods.Failed(ocx.EnumVerbs(out e))) { return; } if (e == null) { return; } int[] pceltFetched = new int[1]; System.Design.NativeMethods.tagOLEVERB rgelt = new System.Design.NativeMethods.tagOLEVERB(); this.foundEdit = false; this.foundAbout = false; this.foundProperties = false; while (true) { pceltFetched[0] = 0; rgelt.lpszVerbName = null; int hr = e.Next(1, rgelt, pceltFetched); if ((hr == 1) || System.Design.NativeMethods.Failed(hr)) { return; } if ((rgelt.grfAttribs & 2) != 0) { this.foundEdit = this.foundEdit || (rgelt.lVerb == -4); this.foundAbout = this.foundAbout || (rgelt.lVerb == 2); this.foundProperties = this.foundProperties || (rgelt.lVerb == 1); rval.Add(new HostVerb(new OleVerbData(rgelt), this.handler)); } } }
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 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); } }