void DesignerPanel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { IUISelectionService selectionServ = this.DesignedControl.Site.GetService(typeof(IUISelectionService)) as IUISelectionService; if (selectionServ == null) { return; } selectionServ.SetCursor(e.X, e.Y); if (_mouseDown) { if (_firstMove) { selectionServ.MouseDragBegin(this.DesignerPanel, e.X, e.Y); _firstMove = false; } else { selectionServ.MouseDragMove(e.X, e.Y); } } else if (selectionServ.SelectionInProgress) { selectionServ.MouseDragMove(e.X, e.Y); } }
protected override void OnMouseDragBegin(int x, int y) { // do not call base here because the behaviour is specific for the ControlDesgner (does IUISelectionService.DragBegin) // IUISelectionService selectionServ = this.GetService(typeof(IUISelectionService)) as IUISelectionService; if (selectionServ != null) { // once ControlDesigner.MouseDragBegin is fired this will start getting dragover events. // Point location = new Point(x, y); IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (base.MouseButtonDown == MouseButtons.Middle && host != null && host.RootComponent != this.Control) { location = this.Control.Parent.PointToClient(this.Control.PointToScreen(new Point(x, y))); // I have to do this, because I get DragOver events fired for the control I am actually dragging // this.Control.AllowDrop = false; selectionServ.DragBegin(); } else { selectionServ.MouseDragBegin(this.Control, location.X, location.Y); } } }