private void BeginDrag(MouseEventArgs e) { this.initialMousePosition = new Point(e.X, e.Y); RadElement elementAtPoint = sourceComponentElementTree.GetElementAtPoint(this.initialMousePosition); if (elementAtPoint == null) { return; } else { if ((elementAtPoint.Visibility != ElementVisibility.Visible)) { return; } } if (elementAtPoint is RadListElement) { return; } if (elementAtPoint is RadListVisualItem) { sourceListBox.SelectedItem = (elementAtPoint as RadListVisualItem).Data; } this.draggedItem = (elementAtPoint as RadListVisualItem).Data; DragCancelEventArgs args = new DragCancelEventArgs(this.draggedItem, null); if (args.Cancel) { this.draggedItem = null; return; } RadDragEventArgs dragArgs = new RadDragEventArgs(this.draggedItem, null); this.isRealDrag = false; this.dragging = true; if (this.feedBackForm == null) { feedBackForm = new FeedBackForm(); } this.colorToSet = this.FeedbackFormLineColor(); this.feedBackForm.LineColor = this.colorToSet; if (this.draggedItem != null) { PrepareDragging(e); } }
private void EndDrag(MouseEventArgs e) { this.dragging = false; if (this.draggedItem != null) { if (targetListBox != null) { if (targetListBox == sourceListBox && sourceListBox.Items.Count == 1) { return; } Point p2 = new Point(); p2 = sourceListBox.PointToScreen(new Point(e.X, e.Y)); p2 = targetListBox.PointToClient(p2); RadElement elementAtPoint = targetComponentElementTree.GetElementAtPoint(p2); if (elementAtPoint != null) { if ((elementAtPoint.Visibility != ElementVisibility.Visible)) { return; } //RadListVisualItem visualItem = elementAtPoint as RadListVisualItem; //if (visualItem != null) { //replacedItem = visualItem.Data; if (draggedItem == replacedItem) { return; } RefreshItemsAfterDragDrop(e); } } if (this.outlineForm != null) { this.outlineForm.Dispose(); this.outlineForm = null; } if (this.feedBackForm != null) { this.feedBackForm.Dispose(); this.feedBackForm = null; } this.isRealDrag = false; } } }
private void Control_MouseUp(object sender, MouseEventArgs e) { if (!this.dragging) { return; } if (targetListBox != null) { targetComponentElementTree = targetListBox.ElementTree; if (targetComponentElementTree.RootElement.ElementTree != null && this.AllowDragDrop) { targetComponentElementTree.RootElement.ElementTree.Control.Capture = false; if (e.Button == MouseButtons.Left) { if (this.outlineForm != null) { this.outlineForm.Hide(); } if (this.feedBackForm != null) { this.feedBackForm.Hide(); } EndDrag(e); } } } if (this.outlineForm != null) { this.outlineForm.Hide(); this.outlineForm.Dispose(); this.outlineForm = null; this.draggedItem = null; this.replacedItem = null; this.dragging = false; this.isRealDrag = false; } if (this.feedBackForm != null) { this.feedBackForm.Hide(); this.feedBackForm.Dispose(); this.feedBackForm = null; this.dragging = false; this.isRealDrag = false; } sourceListBox.FindForm().Cursor = Cursors.Arrow; }