/// <summary> /// Called by TypeDescriptor when a type changes. If this type is currently holding /// our verb, invalidate the list. /// </summary> private void OnTypeRefreshed(RefreshEventArgs e) { if (_verbSourceType != null && _verbSourceType.IsAssignableFrom(e.TypeChanged)) { _currentVerbs = null; } }
public void CreateVerbs() { verbs = new DesignerVerbCollection(new DesignerVerb[] { new DesignerVerb("About", new EventHandler(OnSelectThisItem)), }); }
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; }
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 virtual void Dispose(bool disposing) { if (disposing) { if (_globalVerbs != null) { _globalVerbs.Clear(); _globalVerbs = null; } if (_verbs != null) { _verbs.Clear(); _verbs = null; } if (_commands != null) { _commands.Clear(); _commands = null; } if (_serviceProvider != null) { ISelectionService selectionSvc = _serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (selectionSvc != null) { selectionSvc.SelectionChanged -= OnSelectionChanged; } _serviceProvider = null; } } }
/// <summary> /// This is called by the selection service when the selection has changed. Here /// we invalidate our verb list. /// </summary> private void OnSelectionChanging(object sender, EventArgs e) { if (_currentVerbs != null) { _currentVerbs = null; OnCommandsChanged(new MenuCommandsChangedEventArgs(MenuCommandsChangedType.CommandChanged, null)); } }
public MenuCommandServiceImpl(IDesignerHost host) { this.host = host; commands = new Hashtable(); globalVerbs = new DesignerVerbCollection(); menuItemVerb = new Hashtable(); contextMenu = new ContextMenu(); lastSelectedComponent = null; }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void AddRange(DesignerVerbCollection value) { if (value == null) { throw new ArgumentNullException("value"); } int currentCount = value.Count; for (int i = 0; i < currentCount; i = ((i) + (1))) { this.Add(value[i]); } }
private static ToolStripMenuItem[] GetMenuItems(DesignerVerbCollection verbs) { var menuItems = new ToolStripMenuItem[verbs.Count]; for (int i = 0; i < menuItems.Length; i++) { menuItems[i] = new DesignerToolStripMenuItem(verbs[i].Text, verbs[i]); } return menuItems; }
public void AddRange(DesignerVerbCollection value) { if(value == null) { throw new ArgumentNullException("value"); } foreach(DesignerVerb verb in value) { Add(verb); } }
public FABaseDesigner() { changeService = null; designerVerbs = new DesignerVerbCollection(); ShowAbout = new DesignerVerb("About Farsi Libraries", OnShowAbout); ShowAbout.Checked = false; designerVerbs.Add(ShowAbout); Designers.Add(this); }
public void AddRange(DesignerVerbCollection value) { if (value == null) { throw new ArgumentNullException("value"); } foreach (DesignerVerb verb in value) { Add(verb); } }
public WizardFormDesigner() { m_verbs = new DesignerVerbCollection( new DesignerVerb[] { new DesignerVerb("Add Welcome Page", new EventHandler( OnAddWelcomeClick ) ), new DesignerVerb("Add Page", new EventHandler( OnAddPageClick ) ), new DesignerVerb("Add Final Page", new EventHandler( OnAddFinalClick ) ), new DesignerVerb("Remove Page", new EventHandler( OnRemoveClick ) ) } ); }
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 MenuCommandService(IDesignerHost host) { this.host = host; commands = new Hashtable(); globalVerbs = new DesignerVerbCollection(); menuItemVerb = new Dictionary<ToolStripMenuItem,DesignerVerb>(); contextMenu = new ContextMenuStrip(); lastSelectedComponent = null; //roman// this.AddCommand(new MenuCommand(ShowProperties, StandardCommands.PropertiesWindow)); this.AddCommand(new MenuCommand(ViewCode, StandardCommands.ViewCode)); }
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); }
/// <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 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)); }
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 override void Initialize(IComponent theComponent) { base.Initialize(theComponent); // IMPORTANT! This must be the very first line // ISelectionService events ISelectionService aSrv_Sel = (ISelectionService)GetService(typeof(ISelectionService)); if (aSrv_Sel != null) aSrv_Sel.SelectionChanged += new EventHandler(Handler_SelectionChanged); // IComponentChangeService events IComponentChangeService aSrv_CH = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (aSrv_CH != null) { aSrv_CH.ComponentRemoving += new ComponentEventHandler(Handler_ComponentRemoving); aSrv_CH.ComponentChanged += new ComponentChangedEventHandler(Handler_ComponentChanged); } // MultiPaneControl events DesignedControl.SelectedPageChanged += new EventHandler(Handler_SelectedPageChanged); // Prepare the verbs myAddVerb = new DesignerVerb("Add page", new EventHandler(Handler_AddPage)); myRemoveVerb = new DesignerVerb("Remove page", new EventHandler(Handler_RemovePage)); mySwitchVerb = new DesignerVerb("Switch pages...", new EventHandler(Handler_SwitchPage)); myVerbs = new DesignerVerbCollection(); myVerbs.AddRange(new DesignerVerb[] { myAddVerb, myRemoveVerb, mySwitchVerb }); }
public void Initialize(IComponent component) { if (component == null) throw new ArgumentNullException("component"); Component = (EditorSettingsApplier)component; Verbs = new DesignerVerbCollection { new DesignerVerb("Apply to all editors", delegate { DoDefaultAction(); }) }; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _dvAntialias = null; if (_iss != null) _iss.SelectionChanged -= new EventHandler(OnComponentSelectionChanged); _iss = null; _verbs = null; _bs.Adorners.Remove(_adorner); _bs = null; _adorner = null; } }
public void AddRange (DesignerVerbCollection value) { InnerList.AddRange (value); }
private void UpdateVerbStatus() { // Create verbs first time around if (_verbs == null) { _verbs = new DesignerVerbCollection(); _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers)); _moveFirstVerb = new DesignerVerb("Move Group First", new EventHandler(OnMoveFirst)); _movePrevVerb = new DesignerVerb("Move Group Previous", new EventHandler(OnMovePrevious)); _moveNextVerb = new DesignerVerb("Move Group Next", new EventHandler(OnMoveNext)); _moveLastVerb = new DesignerVerb("Move Group Last", new EventHandler(OnMoveLast)); _addTripleVerb = new DesignerVerb("Add Triple", new EventHandler(OnAddTriple)); _addLinesVerb = new DesignerVerb("Add Lines", new EventHandler(OnAddLines)); _addSepVerb = new DesignerVerb("Add Separator", new EventHandler(OnAddSep)); _addGalleryVerb = new DesignerVerb("Add Gallery", new EventHandler(OnAddGallery)); _clearItemsVerb = new DesignerVerb("Clear Items", new EventHandler(OnClearItems)); _deleteGroupVerb = new DesignerVerb("Delete Group", new EventHandler(OnDeleteGroup)); _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb, _addTripleVerb, _addLinesVerb, _addSepVerb, _addGalleryVerb, _clearItemsVerb, _deleteGroupVerb }); } bool moveFirst = false; bool movePrev = false; bool moveNext = false; bool moveLast = false; bool clearItems = false; if ((_ribbonGroup != null) && (_ribbonGroup.Ribbon != null) && _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup)) { moveFirst = (_ribbonGroup.RibbonTab.Groups.IndexOf(_ribbonGroup) > 0); movePrev = (_ribbonGroup.RibbonTab.Groups.IndexOf(_ribbonGroup) > 0); moveNext = (_ribbonGroup.RibbonTab.Groups.IndexOf(_ribbonGroup) < (_ribbonGroup.RibbonTab.Groups.Count - 1)); moveLast = (_ribbonGroup.RibbonTab.Groups.IndexOf(_ribbonGroup) < (_ribbonGroup.RibbonTab.Groups.Count - 1)); clearItems = (_ribbonGroup.Items.Count > 0); } _moveFirstVerb.Enabled = moveFirst; _movePrevVerb.Enabled = movePrev; _moveNextVerb.Enabled = moveNext; _moveLastVerb.Enabled = moveLast; _clearItemsVerb.Enabled = clearItems; }
private void UpdateVerbStatus() { // Create verbs first time around if (_verbs == null) { _verbs = new DesignerVerbCollection(); _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers)); _moveFirstVerb = new DesignerVerb("Move Cluster First", new EventHandler(OnMoveFirst)); _movePrevVerb = new DesignerVerb("Move Cluster Previous", new EventHandler(OnMovePrevious)); _moveNextVerb = new DesignerVerb("Move Cluster Next", new EventHandler(OnMoveNext)); _moveLastVerb = new DesignerVerb("Move Cluster Last", new EventHandler(OnMoveLast)); _addButtonVerb = new DesignerVerb("Add Button", new EventHandler(OnAddButton)); _addColorButtonVerb = new DesignerVerb("Add Color Button", new EventHandler(OnAddColorButton)); _clearItemsVerb = new DesignerVerb("Clear Items", new EventHandler(OnClearItems)); _deleteClusterVerb = new DesignerVerb("Delete Cluster", new EventHandler(OnDeleteCluster)); _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb, _addButtonVerb, _addColorButtonVerb, _clearItemsVerb, _deleteClusterVerb }); } bool moveFirst = false; bool movePrev = false; bool moveNext = false; bool moveLast = false; bool clearItems = false; if ((_ribbonCluster != null) && (_ribbonCluster.Ribbon != null)) { // Cast container to the correct type KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer; moveFirst = (lines.Items.IndexOf(_ribbonCluster) > 0); movePrev = (lines.Items.IndexOf(_ribbonCluster) > 0); moveNext = (lines.Items.IndexOf(_ribbonCluster) < (lines.Items.Count - 1)); moveLast = (lines.Items.IndexOf(_ribbonCluster) < (lines.Items.Count - 1)); clearItems = (_ribbonCluster.Items.Count > 0); } _moveFirstVerb.Enabled = moveFirst; _movePrevVerb.Enabled = movePrev; _moveNextVerb.Enabled = moveNext; _moveLastVerb.Enabled = moveLast; _clearItemsVerb.Enabled = clearItems; }
private void UpdateVerbStatus() { // Create verbs first time around if (_verbs == null) { _verbs = new DesignerVerbCollection(); _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers)); _moveFirstVerb = new DesignerVerb("Move Gallery First", new EventHandler(OnMoveFirst)); _movePrevVerb = new DesignerVerb("Move Gallery Previous", new EventHandler(OnMovePrevious)); _moveNextVerb = new DesignerVerb("Move Gallery Next", new EventHandler(OnMoveNext)); _moveLastVerb = new DesignerVerb("Move Gallery Last", new EventHandler(OnMoveLast)); _deleteGalleryVerb = new DesignerVerb("Delete Gallery", new EventHandler(OnDeleteGallery)); _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb, _deleteGalleryVerb }); } bool moveFirst = false; bool movePrev = false; bool moveNext = false; bool moveLast = false; if ((_ribbonGallery != null) && (_ribbonGallery.Ribbon != null) && _ribbonGallery.RibbonGroup.Items.Contains(_ribbonGallery)) { moveFirst = (_ribbonGallery.RibbonGroup.Items.IndexOf(_ribbonGallery) > 0); movePrev = (_ribbonGallery.RibbonGroup.Items.IndexOf(_ribbonGallery) > 0); moveNext = (_ribbonGallery.RibbonGroup.Items.IndexOf(_ribbonGallery) < (_ribbonGallery.RibbonGroup.Items.Count - 1)); moveLast = (_ribbonGallery.RibbonGroup.Items.IndexOf(_ribbonGallery) < (_ribbonGallery.RibbonGroup.Items.Count - 1)); } _moveFirstVerb.Enabled = moveFirst; _movePrevVerb.Enabled = movePrev; _moveNextVerb.Enabled = moveNext; _moveLastVerb.Enabled = moveLast; }
private void UpdateVerbStatus() { // Create verbs first time around if (_verbs == null) { _verbs = new DesignerVerbCollection(); _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers)); _moveFirstVerb = new DesignerVerb("Move Cluster Button First", new EventHandler(OnMoveFirst)); _movePrevVerb = new DesignerVerb("Move Cluster Button Previous", new EventHandler(OnMovePrevious)); _moveNextVerb = new DesignerVerb("Move Cluster Button Next", new EventHandler(OnMoveNext)); _moveLastVerb = new DesignerVerb("Move Cluster Button Last", new EventHandler(OnMoveLast)); _deleteButtonVerb = new DesignerVerb("Delete Cluster Button", new EventHandler(OnDeleteButton)); _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb, _deleteButtonVerb }); } bool moveFirst = false; bool movePrev = false; bool moveNext = false; bool moveLast = false; if ((_ribbonButton != null) && (_ribbonButton.Ribbon != null)) { // Cast container to the correct type KryptonRibbonGroupCluster cluster = (KryptonRibbonGroupCluster)_ribbonButton.RibbonContainer; moveFirst = (cluster.Items.IndexOf(_ribbonButton) > 0); movePrev = (cluster.Items.IndexOf(_ribbonButton) > 0); moveNext = (cluster.Items.IndexOf(_ribbonButton) < (cluster.Items.Count - 1)); moveLast = (cluster.Items.IndexOf(_ribbonButton) < (cluster.Items.Count - 1)); } _moveFirstVerb.Enabled = moveFirst; _movePrevVerb.Enabled = movePrev; _moveNextVerb.Enabled = moveNext; _moveLastVerb.Enabled = moveLast; }
// private void Verbs_Build() // private void Verbs_Set() // private void Verbs_Build() // 1.0.020 { // 1.0.020 // Build a new list of context menu items // 1.0.020 if (_Verbs == null) // 1.0.020 { // 1.0.020 _Verbs = new System.ComponentModel.Design.DesignerVerbCollection(); // 1.0.020 } // 1.0.020 else // 1.0.021 { // 1.0.021 _Verbs.Clear(); // 1.0.021 } // 1.0.021 //if (_Verbs.Count <= 0) // 1.0.020 { // 1.0.020 #region Create the .Verbs [ _Verbs.AddRange(...) ] //_Verbs.AddRange( // 1.0.020 // new System.ComponentModel.Design.DesignerVerb[] // 1.0.020 // { // 1.0.020 // new System.ComponentModel.Design.DesignerVerb( // 1.0.020 // "Add TdhTabPage", // 1.0.020 // new System.EventHandler(OnAdd_TdhTabPage) // 1.0.020 // ), // 1.0.020 // new System.ComponentModel.Design.DesignerVerb( // 1.0.020 // "Add TabPage", // 1.0.020 // new System.EventHandler(OnAdd_TabPage) // 1.0.020 // ), // 1.0.020 // new System.ComponentModel.Design.DesignerVerb( // 1.0.020 // "Remove Tab", // 1.0.020 // new System.EventHandler(OnRemove_TabPage) // 1.0.020 // ) // 1.0.020 // } // 1.0.020 // ); // 1.0.020 _Verb_Add_TdhTabPage = new System.ComponentModel.Design.DesignerVerb( // 1.0.021 "Add TdhTabPage", // 1.0.021 new System.EventHandler(OnAdd_TdhTabPage) // 1.0.021 ); // 1.0.021 _Verb_Add_TabPage = new System.ComponentModel.Design.DesignerVerb( // 1.0.021 "Add TabPage", // 1.0.021 new System.EventHandler(OnAdd_TabPage) // 1.0.021 ); // 1.0.021 _Verb_Remove_TabPage = new System.ComponentModel.Design.DesignerVerb( // 1.0.021 "Remove Tab", // 1.0.021 new System.EventHandler(OnRemove_TabPage) // 1.0.021 ); // 1.0.021 _Verbs.AddRange( // 1.0.021 new System.ComponentModel.Design.DesignerVerb[] // 1.0.021 { // 1.0.021 _Verb_Add_TdhTabPage, // 1.0.021 _Verb_Add_TabPage, // 1.0.021 _Verb_Remove_TabPage // 1.0.021 } // 1.0.021 ); // 1.0.021 #endregion } // 1.0.020 } // 1.0.020
/// <summary>Adds the specified collection of designer verbs to the collection.</summary> /// <param name="value">A <see cref="T:System.ComponentModel.Design.DesignerVerbCollection" /> to add to the collection. </param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="value" /> is null.</exception> public void AddRange(DesignerVerbCollection value) { base.InnerList.AddRange(value); }
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); } }
public void AddRange(DesignerVerbCollection !value) { Contract.Requires(value != null); }
public override void Initialize(IComponent component) { base.Initialize(component); ISelectionService Service = (ISelectionService)GetService(typeof(ISelectionService)); ((CardPanel)Control).PageChanged += new EventHandler(CardPanelDesigner_PageChanged); if (Service != null) { Service.SelectionChanged += new EventHandler(CardPanelDesigner_ComponentSelectionChanged); } IComponentChangeService ServiceChange = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (ServiceChange != null) { ServiceChange.ComponentRemoving += new ComponentEventHandler(CardPanelDesigner_ComponentRemoving); ServiceChange.ComponentChanged += new ComponentChangedEventHandler(CardPanelDesigner_ComponentChanged); } ListOfVerbs = new DesignerVerbCollection(new DesignerVerb[] { new DesignerVerb("Add Page", new EventHandler(CardPanelDesigner_AddPage)), new DesignerVerb("Remove Page", new EventHandler(CardPanelDesigner_RemovePage)) }); }
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 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); } }
/// <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 OnSelectionChanging(object sender, EventArgs e) { if (this._currentVerbs != null) { this._currentVerbs = null; this.OnCommandsChanged(new MenuCommandsChangedEventArgs(MenuCommandsChangedType.CommandChanged, null)); } }
public RTBDesigner() { this.verbs = new DesignerVerbCollection(); verbs.Add(new DesignerVerb("Add Sample Scopes", new EventHandler(AddSampleScopes))); }
private void OnTypeRefreshed(RefreshEventArgs e) { if ((this._verbSourceType != null) && this._verbSourceType.IsAssignableFrom(e.TypeChanged)) { this._currentVerbs = null; } }
public void AddRange(DesignerVerbCollection value) { throw new NotImplementedException(); }
protected virtual void Dispose (bool disposing) { if (disposing) { if (_globalVerbs != null) { _globalVerbs.Clear (); _globalVerbs = null; } if (_verbs != null) { _verbs.Clear (); _verbs = null; } if (_commands != null) { _commands.Clear (); _commands = null; } if (_serviceProvider != null) { ISelectionService selectionSvc = _serviceProvider.GetService (typeof (ISelectionService)) as ISelectionService; if (selectionSvc != null) selectionSvc.SelectionChanged -= OnSelectionChanged; _serviceProvider = null; } } }
private void UpdateVerbStatus() { // Create verbs first time around if (_verbs == null) { _verbs = new DesignerVerbCollection(); _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", new EventHandler(OnToggleHelpers)); _moveFirstVerb = new DesignerVerb("Move TrackBar First", new EventHandler(OnMoveFirst)); _movePrevVerb = new DesignerVerb("Move TrackBar Previous", new EventHandler(OnMovePrevious)); _moveNextVerb = new DesignerVerb("Move TrackBar Next", new EventHandler(OnMoveNext)); _moveLastVerb = new DesignerVerb("Move TrackBar Last", new EventHandler(OnMoveLast)); _deleteTrackBarVerb = new DesignerVerb("Delete TrackBar", new EventHandler(OnDeleteTrackBar)); _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb, _deleteTrackBarVerb }); } bool moveFirst = false; bool movePrev = false; bool moveNext = false; bool moveLast = false; if ((_ribbonTrackBar != null) && (_ribbonTrackBar.Ribbon != null)) { TypedRestrictCollection<KryptonRibbonGroupItem> items = ParentItems; moveFirst = (items.IndexOf(_ribbonTrackBar) > 0); movePrev = (items.IndexOf(_ribbonTrackBar) > 0); moveNext = (items.IndexOf(_ribbonTrackBar) < (items.Count - 1)); moveLast = (items.IndexOf(_ribbonTrackBar) < (items.Count - 1)); } _moveFirstVerb.Enabled = moveFirst; _movePrevVerb.Enabled = movePrev; _moveNextVerb.Enabled = moveNext; _moveLastVerb.Enabled = moveLast; }
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 override void Initialize(IComponent theComponent) { base.Initialize(theComponent); ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService)); if (service != null) { service.SelectionChanged += new EventHandler(this.Handler_SelectionChanged); } IComponentChangeService service2 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service2 != null) { service2.ComponentRemoving += new ComponentEventHandler(this.Handler_ComponentRemoving); service2.ComponentChanged += new ComponentChangedEventHandler(this.Handler_ComponentChanged); } this.DesignedControl.SelectedPageChanged += new EventHandler(this.Handler_SelectedPageChanged); this.myAddVerb = new DesignerVerb("Add page", new EventHandler(this.Handler_AddPage)); this.myRemoveVerb = new DesignerVerb("Remove page", new EventHandler(this.Handler_RemovePage)); this.mySwitchVerb = new DesignerVerb("Switch pages...", new EventHandler(this.Handler_SwitchPage)); this.myVerbs = new DesignerVerbCollection(); this.myVerbs.AddRange(new DesignerVerb[] { this.myAddVerb, this.myRemoveVerb, this.mySwitchVerb }); }
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)); }