/// <summary> /// Ends dragging any selected items managed by the adapter. May be called /// by another adapter when it ends dragging. May be called from within a transaction.</summary> void IItemDragAdapter.EndDrag() { // An item may be moved after a drag, need to update its DefaultPart bound by raising SelectedItemHit if (m_hitRecord != null && m_hitRecord.DefaultPart != null) { Point clientPoint = AdaptedControl.PointToClient(Cursor.Position); var hitRecord = Pick(clientPoint); if (hitRecord.Item == m_hitRecord.Item) { SelectedItemHit.Raise(this, new DiagramHitEventArgs(hitRecord)); } } }
private void control_DragDrop(object sender, DragEventArgs e) { if (m_selectionContext != null || !m_selectionContext.Selection.Any()) { // items may be selected programmatically after the drag & drop, // raise SelectedItemHit to enable label editor start editing with F2 without mouse click over the selected item first // items may be placed using mouse position as upper-left corner; // offset slightly of the mouse position to get better chance to pick the newly dropped item. const int offset = 20; var point = AdaptedControl.PointToClient(new Point(e.X + offset, e.Y + offset)); m_hitRecord = Pick(point); if (m_hitRecord != null) { SelectedItemHit.Raise(this, new DiagramHitEventArgs(m_hitRecord)); } } }
/// <summary> /// Updates mouse position</summary> /// <param name="e">Drag event arguments</param> protected void SetMousePosition(DragEventArgs e) { m_mousePosition = AdaptedControl.PointToClient(new Point(e.X, e.Y)); }