internal void Invalidate() { IComponent relatedComponent = ((DesignerActionBehavior)this.Behavior).RelatedComponent; Point empty = Point.Empty; Control c = relatedComponent as Control; if (((c != null) && !(relatedComponent is ToolStripDropDown)) && (this.adorner != null)) { empty = this.adorner.BehaviorService.ControlToAdornerWindow(c); empty.X += c.Width; } else { ComponentTray alternativeParent = this.alternativeParent as ComponentTray; if (alternativeParent != null) { ComponentTray.TrayControl trayControlFromComponent = alternativeParent.GetTrayControlFromComponent(relatedComponent); if (trayControlFromComponent != null) { this.alternativeBounds = trayControlFromComponent.Bounds; } } Rectangle boundsForNoResizeSelectionType = DesignerUtils.GetBoundsForNoResizeSelectionType(this.alternativeBounds, SelectionBorderGlyphType.Top); empty.X = boundsForNoResizeSelectionType.Right; empty.Y = boundsForNoResizeSelectionType.Top; } empty.X -= this.GlyphImageOpened.Width + 5; empty.Y -= this.GlyphImageOpened.Height - 2; this.bounds = new Rectangle(empty.X, empty.Y, this.GlyphImageOpened.Width, this.GlyphImageOpened.Height); }
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); }
private void RotateTabSelection(bool backwards) { ComponentTray.TrayControl control2 = null; ISelectionService selectionService = base.SelectionService; if (selectionService != null) { IComponent component; Control control; IComponent primarySelection = selectionService.PrimarySelection as IComponent; if (primarySelection != null) { component = primarySelection; } else { component = null; foreach (object obj2 in selectionService.GetSelectedComponents()) { IComponent component3 = obj2 as IComponent; if (component3 != null) { component = component3; break; } } } if (component != null) { control = ComponentTray.TrayControl.FromComponent(component); } else { control = null; } if (control != null) { for (int i = 1; i < this.compositionUI.Controls.Count; i++) { if (this.compositionUI.Controls[i] == control) { int num2 = i + 1; if (num2 >= this.compositionUI.Controls.Count) { num2 = 1; } ComponentTray.TrayControl control3 = this.compositionUI.Controls[num2] as ComponentTray.TrayControl; if (control3 != null) { control2 = control3; break; } } } } else if (this.compositionUI.Controls.Count > 1) { ComponentTray.TrayControl control4 = this.compositionUI.Controls[1] as ComponentTray.TrayControl; if (control4 != null) { control2 = control4; } } if (control2 != null) { selectionService.SetSelectedComponents(new object[] { control2.Component }, SelectionTypes.Replace); } } }
protected override IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) { IDesignerSerializationService ds = (IDesignerSerializationService)host.GetService(typeof(IDesignerSerializationService)); if (ds == null) { return(null); } // Deserialize to components collection // ICollection objects = ds.Deserialize(_serializationData); ArrayList components = new ArrayList(); foreach (object obj in objects) { if (obj != null && obj is IComponent) { components.Add(obj); } } IComponent[] componentsArray = new IComponent[components.Count]; components.CopyTo(componentsArray, 0); ArrayList trayComponents = null; // Parent and locate each Control // if (defaultValues == null) { defaultValues = new Hashtable(); } Control parentControl = defaultValues["Parent"] as Control; if (parentControl != null) { ParentControlDesigner parentControlDesigner = host.GetDesigner(parentControl) as ParentControlDesigner; if (parentControlDesigner != null) { // Determine bounds of all controls // Rectangle bounds = Rectangle.Empty; foreach (IComponent component in componentsArray) { Control childControl = component as Control; if (childControl != null && childControl != parentControl && childControl.Parent == null) { if (bounds.IsEmpty) { bounds = childControl.Bounds; } else { bounds = Rectangle.Union(bounds, childControl.Bounds); } } } defaultValues.Remove("Size"); // don't care about the drag size foreach (IComponent component in componentsArray) { Control childControl = component as Control; Form form = childControl as Form; if (childControl != null && !(form != null && form.TopLevel) && // Don't add top-level forms childControl.Parent == null) { defaultValues["Offset"] = new Size(childControl.Bounds.X - bounds.X, childControl.Bounds.Y - bounds.Y); parentControlDesigner.AddControl(childControl, defaultValues); } } } } // VSWhidbey 516338 - When creating an item for the tray, template items will have // an old location stored in them, so they may show up on top of other items. // So we need to call UpdatePastePositions for each one to get the tray to // arrange them properly. // ComponentTray tray = (ComponentTray)host.GetService(typeof(ComponentTray)); if (tray != null) { foreach (IComponent component in componentsArray) { ComponentTray.TrayControl c = tray.GetTrayControlFromComponent(component); if (c != null) { if (trayComponents == null) { trayComponents = new ArrayList(); } trayComponents.Add(c); } } if (trayComponents != null) { tray.UpdatePastePositions(trayComponents); } } return(componentsArray); }
/// <include file='doc\CompositionCommandSet.uex' path='docs/doc[@for="CompositionCommandSet.RotateTabSelection"]/*' /> /// <devdoc> /// Rotates the selection to the element next in the tab index. If backwards /// is set, this will rotate to the previous tab index. /// </devdoc> private void RotateTabSelection(bool backwards) { ISelectionService selSvc; IComponent currentComponent; Control currentControl; ComponentTray.TrayControl nextControl = null; // First, get the currently selected component // selSvc = SelectionService; if (selSvc == null) { return; } object primarySelection = selSvc.PrimarySelection; if (primarySelection is IComponent) { currentComponent = (IComponent)primarySelection; } else { currentComponent = null; ICollection selection = selSvc.GetSelectedComponents(); foreach (object obj in selection) { if (obj is IComponent) { currentComponent = (IComponent)obj; break; } } } // Now, if we have a selected component, get the composition UI for it and // find the next control on the UI. Otherwise, we just select the first // control on the UI. // if (currentComponent != null) { currentControl = ComponentTray.TrayControl.FromComponent(currentComponent); } else { currentControl = null; } if (currentControl != null) { Debug.Assert(compositionUI.Controls[0] is LinkLabel, "First item in the Composition designer is not a linklabel"); for (int i = 1; i < compositionUI.Controls.Count; i++) { if (compositionUI.Controls[i] == currentControl) { int next = i + 1; if (next >= compositionUI.Controls.Count) { next = 1; } if (compositionUI.Controls[next] is ComponentTray.TrayControl) { nextControl = (ComponentTray.TrayControl)compositionUI.Controls[next]; } else { continue; } break; } } } else { if (compositionUI.Controls.Count > 1) { Debug.Assert(compositionUI.Controls[0] is LinkLabel, "First item in the Composition designer is not a linklabel"); if (compositionUI.Controls[1] is ComponentTray.TrayControl) { nextControl = (ComponentTray.TrayControl)compositionUI.Controls[1]; } } } // If we got a "nextControl", then select the component inside of it. // if (nextControl != null) { selSvc.SetSelectedComponents(new object[] { nextControl.Component }, SelectionTypes.Replace); } }