protected override void OnMouseMove(MouseWithKeysEventArgs e) { if (DragState != null) { if (!e.IsRightButtonPressed) { DragState = null; Redraw(); return; } DragState.Query.DropPoint.Set(e.X, e.Y); DragState.Query.ShouldCopyInsteadOfMove = e.IsCtrlPressed; if (!DragState.Query.DragStartpoint.PointWithinDragSize(e.X, e.Y) || DragState.DragStarted) { DragState.Result = FindDropTarget(); DragState.DragStarted = true; } Redraw(); } }
protected override void OnMouseUp(MouseWithKeysEventArgs e) { if (e.Handled == true) { return; } bool shouldShowPopupMenu = e.IsRightButtonPressed; using (Redrawer r = new Redrawer(Root)) { if (DragState != null) { if (DragState.Result != null) { DragState.Query.ShouldCopyInsteadOfMove = e.IsCtrlPressed; DragState.Result.DropTargetContainer.AcceptBlocks( DragState.Query, DragState.Result); shouldShowPopupMenu = false; e.Handled = true; } else { if (DragState.DragStarted) { shouldShowPopupMenu = false; e.Handled = true; } } DragState = null; } if (shouldShowPopupMenu && e.IsRightButtonPressed) { Block rightClicked = FindBlockAtPoint(e.X, e.Y); if (rightClicked != null && rightClicked.Menu != null && rightClicked.MyControl.HitTest(e.X, e.Y)) { if (rightClicked.CanGetFocus) { rightClicked.SetFocus(); } MyRootControl.ShowPopupMenu(rightClicked.Menu, e.Location); e.Handled = true; } } } }
protected override void OnMouseDown(MouseWithKeysEventArgs e) { if (e.Handled == true) { return; } Block block = FindDraggableBlock(e.X, e.Y); if (e.IsRightButtonPressed && block != null && block.Draggable) { DragState = new DragInfo(block, e.X, e.Y); block.SetFocus(); } else { DragState = null; } }