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); }
public DesignerViewFrame (Control designedControl, ComponentTray tray) { if (designedControl == null) { throw new ArgumentNullException ("designedControl"); } if (tray == null) { throw new ArgumentNullException ("tray"); } // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); _designedControl = designedControl; this.SuspendLayout (); this.DesignerPanel.Controls.Add (designedControl); this.ResumeLayout (); this.ComponentTray = tray; }
protected override void Dispose (bool disposing) { if (_designedControl != null) { this.DesignerPanel.Controls.Remove (_designedControl); _designedControl = null; } if (_componentTray != null) { this.ComponentTrayPanel.Controls.Remove (_componentTray); _componentTray.Dispose (); _componentTray = null; } base.Dispose (disposing); }
private void EndDragDrop(bool allowSetChildIndexOnDrop) { Control target = this.data.Target as Control; if (target != null) { if (this.serviceProviderTarget == null) { this.serviceProviderTarget = target.Site; if (this.serviceProviderTarget == null) { return; } } if (this.destHost == null) { this.destHost = (IDesignerHost)this.serviceProviderTarget.GetService(typeof(IDesignerHost)); if (this.destHost == null) { return; } } if (this.behaviorServiceTarget == null) { this.behaviorServiceTarget = (BehaviorService)this.serviceProviderTarget.GetService(typeof(BehaviorService)); if (this.behaviorServiceTarget == null) { return; } } ArrayList list = null; bool flag = this.lastEffect == DragDropEffects.Copy; Control source = this.data.Source; bool localDrag = source.Equals(target); PropertyDescriptor member = TypeDescriptor.GetProperties(target)["Controls"]; PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(source)["Controls"]; IComponentChangeService service = (IComponentChangeService)this.serviceProviderSource.GetService(typeof(IComponentChangeService)); IComponentChangeService service2 = (IComponentChangeService)this.serviceProviderTarget.GetService(typeof(IComponentChangeService)); if (this.dragAssistanceManager != null) { this.dragAssistanceManager.OnMouseUp(); } ISelectionService service3 = null; if (flag || ((this.srcHost != this.destHost) && (this.destHost != null))) { service3 = (ISelectionService)this.serviceProviderTarget.GetService(typeof(ISelectionService)); } try { if ((this.dragComponents != null) && (this.dragComponents.Length > 0)) { string str; DesignerTransaction transaction = null; DesignerTransaction transaction2 = null; if (this.dragComponents.Length == 1) { string componentName = TypeDescriptor.GetComponentName(this.dragComponents[0].dragComponent); if ((componentName == null) || (componentName.Length == 0)) { componentName = this.dragComponents[0].dragComponent.GetType().Name; } str = System.Design.SR.GetString(flag ? "BehaviorServiceCopyControl" : "BehaviorServiceMoveControl", new object[] { componentName }); } else { str = System.Design.SR.GetString(flag ? "BehaviorServiceCopyControls" : "BehaviorServiceMoveControls", new object[] { this.dragComponents.Length }); } if ((this.srcHost != null) && (((this.srcHost == this.destHost) || (this.destHost == null)) || !flag)) { transaction = this.srcHost.CreateTransaction(str); } if ((this.srcHost != this.destHost) && (this.destHost != null)) { transaction2 = this.destHost.CreateTransaction(str); } try { ComponentTray tray = null; int num = 0; if (flag) { tray = this.serviceProviderTarget.GetService(typeof(ComponentTray)) as ComponentTray; num = (tray != null) ? tray.Controls.Count : 0; ArrayList objects = new ArrayList(); for (int j = 0; j < this.dragComponents.Length; j++) { objects.Add(this.dragComponents[j].dragComponent); } objects = DesignerUtils.CopyDragObjects(objects, this.serviceProviderTarget) as ArrayList; if (objects == null) { return; } list = new ArrayList(); for (int k = 0; k < objects.Count; k++) { list.Add(this.dragComponents[k].dragComponent); this.dragComponents[k].dragComponent = objects[k]; } } if ((!localDrag || flag) && ((service != null) && (service2 != null))) { service2.OnComponentChanging(target, member); if (!flag) { service.OnComponentChanging(source, descriptor2); } } int num4 = ParentControlDesigner.DetermineTopChildIndex(target); this.DropControl(this.primaryComponentIndex, target, source, localDrag); Point p = this.behaviorServiceSource.AdornerWindowPointToScreen(this.dragComponents[this.primaryComponentIndex].draggedLocation); p = ((Control)this.dragComponents[this.primaryComponentIndex].dragComponent).Parent.PointToClient(p); if (((Control)this.dragComponents[this.primaryComponentIndex].dragComponent).Parent.IsMirrored) { p.Offset(-((Control)this.dragComponents[this.primaryComponentIndex].dragComponent).Width, 0); } Control dragComponent = this.dragComponents[this.primaryComponentIndex].dragComponent as Control; PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(dragComponent)["Location"]; if ((dragComponent != null) && (descriptor3 != null)) { try { service2.OnComponentChanging(dragComponent, descriptor3); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw; } return; } } this.SetLocationPropertyAndChildIndex(this.primaryComponentIndex, target, p, this.shareParent ? (num4 + this.dragComponents[this.primaryComponentIndex].zorderIndex) : num4, allowSetChildIndexOnDrop); if (service3 != null) { service3.SetSelectedComponents(new object[] { this.dragComponents[this.primaryComponentIndex].dragComponent }, SelectionTypes.Click | SelectionTypes.Replace); } for (int i = 0; i < this.dragComponents.Length; i++) { if (i != this.primaryComponentIndex) { this.DropControl(i, target, source, localDrag); Point dropPoint = new Point(p.X + this.dragComponents[i].positionOffset.X, p.Y + this.dragComponents[i].positionOffset.Y); this.SetLocationPropertyAndChildIndex(i, target, dropPoint, this.shareParent ? (num4 + this.dragComponents[i].zorderIndex) : num4, allowSetChildIndexOnDrop); if (service3 != null) { service3.SetSelectedComponents(new object[] { this.dragComponents[i].dragComponent }, SelectionTypes.Add); } } } if ((!localDrag || flag) && ((service != null) && (service2 != null))) { service2.OnComponentChanged(target, member, target.Controls, target.Controls); if (!flag) { service.OnComponentChanged(source, descriptor2, source.Controls, source.Controls); } } if (list != null) { for (int m = 0; m < list.Count; m++) { this.dragComponents[m].dragComponent = list[m]; } list = null; } if (flag) { if (tray == null) { tray = this.serviceProviderTarget.GetService(typeof(ComponentTray)) as ComponentTray; } if (tray != null) { int num7 = tray.Controls.Count - num; if (num7 > 0) { ArrayList components = new ArrayList(); for (int n = 0; n < num7; n++) { components.Add(tray.Controls[num + n]); } tray.UpdatePastePositions(components); } } } this.CleanupDrag(false); if (transaction != null) { transaction.Commit(); transaction = null; } if (transaction2 != null) { transaction2.Commit(); transaction2 = null; } } finally { if (transaction != null) { transaction.Cancel(); } if (transaction2 != null) { transaction2.Cancel(); } } } } finally { if (list != null) { for (int num9 = 0; num9 < list.Count; num9++) { this.dragComponents[num9].dragComponent = list[num9]; } } this.CleanupDrag(false); if (this.statusCommandUITarget != null) { this.statusCommandUITarget.SetStatusInformation((service3 == null) ? (this.dragComponents[this.primaryComponentIndex].dragComponent as Component) : (service3.PrimarySelection as Component)); } } this.lastFeedbackLocation = new Point(-1, -1); } }