public BehaviorDataObject(ICollection dragComponents, Control source, DropSourceBehavior sourceBehavior) { this.dragComponents = dragComponents; this.source = source; this.sourceBehavior = sourceBehavior; this.target = null; }
private void StartDragOperation(Point initialMouseLocation) { ISelectionService service = (ISelectionService)this.serviceProvider.GetService(typeof(ISelectionService)); IDesignerHost host = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost)); if ((service != null) && (host != null)) { Control parent = this.containerControl.Parent; ArrayList dragComponents = new ArrayList(); foreach (IComponent component in service.GetSelectedComponents()) { Control control2 = component as Control; if ((control2 != null) && control2.Parent.Equals(parent)) { ControlDesigner designer = host.GetDesigner(control2) as ControlDesigner; if ((designer != null) && ((designer.SelectionRules & SelectionRules.Moveable) != SelectionRules.None)) { dragComponents.Add(control2); } } } if (dragComponents.Count > 0) { Point point; if (this.setInitialDragPoint) { point = this.behaviorService.ControlToAdornerWindow(this.containerControl); point = this.behaviorService.AdornerWindowPointToScreen(point); } else { point = initialMouseLocation; } DropSourceBehavior dropSourceBehavior = new DropSourceBehavior(dragComponents, this.containerControl.Parent, point); try { this.behaviorService.DoDragDrop(dropSourceBehavior); } finally { this.OkToMove = false; this.InitialDragPoint = Point.Empty; } } } }
protected virtual void OnMouseDragMove(int x, int y) { if (!this.mouseDragMoved) { Size dragSize = SystemInformation.DragSize; Size doubleClickSize = SystemInformation.DoubleClickSize; dragSize.Width = Math.Max(dragSize.Width, doubleClickSize.Width); dragSize.Height = Math.Max(dragSize.Height, doubleClickSize.Height); if ((this.mouseDragLast == InvalidPoint) || ((Math.Abs((int) (this.mouseDragLast.X - x)) < dragSize.Width) && (Math.Abs((int) (this.mouseDragLast.Y - y)) < dragSize.Height))) { return; } this.mouseDragMoved = true; this.ctrlSelect = false; } ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService)); if ((service != null) && !base.Component.Equals(service.PrimarySelection)) { service.SetSelectedComponents(new object[] { base.Component }, SelectionTypes.Toggle | SelectionTypes.Click); } if ((this.BehaviorService != null) && (service != null)) { ArrayList dragComponents = new ArrayList(); ICollection selectedComponents = service.GetSelectedComponents(); System.Windows.Forms.Control parent = null; foreach (IComponent component in selectedComponents) { System.Windows.Forms.Control control2 = component as System.Windows.Forms.Control; if (control2 != null) { if (parent == null) { parent = control2.Parent; } else if (!parent.Equals(control2.Parent)) { continue; } ControlDesigner designer = this.host.GetDesigner(component) as ControlDesigner; if ((designer != null) && ((designer.SelectionRules & System.Windows.Forms.Design.SelectionRules.Moveable) != System.Windows.Forms.Design.SelectionRules.None)) { dragComponents.Add(component); } } } if (dragComponents.Count > 0) { using (this.BehaviorService.AdornerWindowGraphics) { DropSourceBehavior dropSourceBehavior = new DropSourceBehavior(dragComponents, this.Control.Parent, this.mouseDragLast); this.BehaviorService.DoDragDrop(dropSourceBehavior); } } } this.mouseDragLast = InvalidPoint; this.mouseDragMoved = false; }
internal DragDropEffects DoDragDrop(DropSourceBehavior dropSourceBehavior) { this.DropSource.QueryContinueDrag += new QueryContinueDragEventHandler(dropSourceBehavior.QueryContinueDrag); this.DropSource.GiveFeedback += new GiveFeedbackEventHandler(dropSourceBehavior.GiveFeedback); DragDropEffects none = DragDropEffects.None; BehaviorDragDropEventArgs e = new BehaviorDragDropEventArgs(((DropSourceBehavior.BehaviorDataObject) dropSourceBehavior.DataObject).DragComponents); try { try { this.OnBeginDrag(e); this.dragging = true; this.cancelDrag = false; this.dragEnterReplies.Clear(); none = this.DropSource.DoDragDrop(dropSourceBehavior.DataObject, dropSourceBehavior.AllowedEffects); } finally { this.DropSource.QueryContinueDrag -= new QueryContinueDragEventHandler(dropSourceBehavior.QueryContinueDrag); this.DropSource.GiveFeedback -= new GiveFeedbackEventHandler(dropSourceBehavior.GiveFeedback); this.EndDragNotification(); this.validDragArgs = null; this.dragging = false; this.cancelDrag = false; this.OnEndDrag(e); } return none; } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw; } return DragDropEffects.None; } finally { if (dropSourceBehavior != null) { dropSourceBehavior.CleanupDrag(); } } return none; }
private void StartDragOperation(Point initialMouseLocation) { ISelectionService service = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService)); IDesignerHost host = (IDesignerHost) this.serviceProvider.GetService(typeof(IDesignerHost)); if ((service != null) && (host != null)) { Control parent = this.containerControl.Parent; ArrayList dragComponents = new ArrayList(); foreach (IComponent component in service.GetSelectedComponents()) { Control control2 = component as Control; if ((control2 != null) && control2.Parent.Equals(parent)) { ControlDesigner designer = host.GetDesigner(control2) as ControlDesigner; if ((designer != null) && ((designer.SelectionRules & SelectionRules.Moveable) != SelectionRules.None)) { dragComponents.Add(control2); } } } if (dragComponents.Count > 0) { Point point; if (this.setInitialDragPoint) { point = this.behaviorService.ControlToAdornerWindow(this.containerControl); point = this.behaviorService.AdornerWindowPointToScreen(point); } else { point = initialMouseLocation; } DropSourceBehavior dropSourceBehavior = new DropSourceBehavior(dragComponents, this.containerControl.Parent, point); try { this.behaviorService.DoDragDrop(dropSourceBehavior); } finally { this.OkToMove = false; this.InitialDragPoint = Point.Empty; } } } }