private void RecurseDesignerTree(IDesigner designer, Hashtable table) { ITreeDesigner designer2 = designer as ITreeDesigner; if (designer2 != null) { IDesigner parent = designer2.Parent; if (parent != null) { this.RecurseDesignerTree(parent, table); } } foreach (Attribute attribute in TypeDescriptor.GetAttributes(designer)) { table[attribute.TypeId] = attribute; } }
/// <summary> /// this method is called when dragging a TabStrip off the toolbox. /// </summary> /// <param name="host"></param> /// <returns></returns> protected override IComponent[] CreateComponentsCore(IDesignerHost host) { IComponent[] components = base.CreateComponentsCore(host); Control parentControl = null; ControlDesigner parentControlDesigner = null; TabStrip tabStrip = null; IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); // fish out the parent we're adding the TabStrip to. if (components.Length > 0 && components[0] is TabStrip) { tabStrip = components[0] as TabStrip; ITreeDesigner tabStripDesigner = host.GetDesigner(tabStrip) as ITreeDesigner; parentControlDesigner = tabStripDesigner.Parent as ControlDesigner; if (parentControlDesigner != null) { parentControl = parentControlDesigner.Control; } } // Create a ControlSwitcher on the same parent. if (host != null) { TabPageSwitcher controlSwitcher = null; DesignerTransaction t = null; try { try { t = host.CreateTransaction("add tabswitcher"); } catch (CheckoutException ex) { if (ex == CheckoutException.Canceled) { return(components); } throw ex; } // create a TabPageSwitcher and add it to the same parent as the TabStrip MemberDescriptor controlsMember = TypeDescriptor.GetProperties(parentControlDesigner)["Controls"]; controlSwitcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher; if (changeSvc != null) { changeSvc.OnComponentChanging(parentControl, controlsMember); changeSvc.OnComponentChanged(parentControl, controlsMember, null, null); } // specify default values for our TabStrip Dictionary <string, object> propertyValues = new Dictionary <string, object>(); propertyValues["Location"] = new Point(tabStrip.Left, tabStrip.Bottom + 3); propertyValues["TabStrip"] = tabStrip; // set the property values SetProperties(controlSwitcher, propertyValues, host); } finally { if (t != null) { t.Commit(); } } // add the TabPageSwitcher to the list of components that we've created if (controlSwitcher != null) { IComponent[] newComponents = new IComponent[components.Length + 1]; Array.Copy(components, newComponents, components.Length); newComponents[newComponents.Length - 1] = controlSwitcher; return(newComponents); } } return(components); }
private bool Update() { bool flag = false; IDesigner designer = null; IComponent primarySelection = this._selectionService.PrimarySelection as IComponent; if (primarySelection != null) { designer = this._host.GetDesigner(primarySelection); } if (designer == null) { primarySelection = this._host.RootComponent; if (primarySelection != null) { designer = this._host.GetDesigner(primarySelection); } } if (designer != this._filterDesigner) { ArrayList list; if (designer != null) { AttributeCollection designerAttributes = this.GetDesignerAttributes(designer); list = new ArrayList(designerAttributes.Count); foreach (Attribute attribute in designerAttributes) { if (attribute is ToolboxItemFilterAttribute) { list.Add(attribute); } } } else { list = new ArrayList(); } if (this._filter == null) { flag = true; } else if (this._filter.Count != list.Count) { flag = true; } else { IEnumerator enumerator = this._filter.GetEnumerator(); IEnumerator enumerator2 = list.GetEnumerator(); while (enumerator2.MoveNext()) { enumerator.MoveNext(); if (!enumerator2.Current.Equals(enumerator.Current)) { flag = true; break; } ToolboxItemFilterAttribute current = (ToolboxItemFilterAttribute)enumerator2.Current; if (current.FilterType == ToolboxItemFilterType.Custom) { flag = true; break; } } } this._filter = list; this._filterDesigner = designer; this._toolboxUser = this._filterDesigner as IToolboxUser; if (this._toolboxUser == null) { IDesigner parent; for (ITreeDesigner designer2 = this._filterDesigner as ITreeDesigner; (this._toolboxUser == null) && (designer2 != null); designer2 = parent as ITreeDesigner) { parent = designer2.Parent; this._toolboxUser = parent as IToolboxUser; } } if ((this._toolboxUser == null) && (this._host.RootComponent != null)) { this._toolboxUser = this._host.GetDesigner(this._host.RootComponent) as IToolboxUser; } } if (this._filter == null) { this._filter = new ArrayList(); } return(flag); }