public virtual void RearrangeModels(ModelDropEventArgs args) { DropTargetLocation dropTargetLocation = args.DropTargetLocation; if (dropTargetLocation == DropTargetLocation.Background) { this.ListView.AddObjects(args.SourceModels); } else if (dropTargetLocation != DropTargetLocation.AboveItem) { if (dropTargetLocation != DropTargetLocation.BelowItem) { return; } this.ListView.MoveObjects(args.DropTargetIndex + 1, args.SourceModels); } else { this.ListView.MoveObjects(args.DropTargetIndex, args.SourceModels); } if (args.SourceListView != this.ListView) { args.SourceListView.RemoveObjects(args.SourceModels); } }
public DragDropEffects CanModelDrop(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation) { var dragDropEffect = DragDropEffects.None; if (!NodeIsDraggable(dropSource)) { _infoMessage = Language.strNodeNotDraggable; _enableFeedback = false; } else { switch (dropTargetLocation) { case DropTargetLocation.Item: dragDropEffect = HandleCanDropOnItem(dropSource, dropTarget); break; case DropTargetLocation.AboveItem: case DropTargetLocation.BelowItem: dragDropEffect = HandleCanDropBetweenItems(dropSource, dropTarget); break; } } return(dragDropEffect); }
public void DropModel(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation) { if (dropTargetLocation == DropTargetLocation.Item) DropModelOntoTarget(dropSource, dropTarget); else if (dropTargetLocation == DropTargetLocation.AboveItem) DropModelAboveTarget(dropSource, dropTarget); else if (dropTargetLocation == DropTargetLocation.BelowItem) DropModelBelowTarget(dropSource, dropTarget); }
public DragDropEffects CanModelDrop(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation) { var dragDropEffect = DragDropEffects.None; if (!NodeIsDraggable(dropSource)) { _infoMessage = Language.strNodeNotDraggable; _enableFeedback = false; } else if (dropTargetLocation == DropTargetLocation.Item) dragDropEffect = HandleCanDropOnItem(dropSource, dropTarget); else if (dropTargetLocation == DropTargetLocation.AboveItem || dropTargetLocation == DropTargetLocation.BelowItem) dragDropEffect = HandleCanDropBetweenItems(dropSource, dropTarget); return dragDropEffect; }
public void DropModel(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation) { if (dropTargetLocation == DropTargetLocation.Item) { DropModelOntoTarget(dropSource, dropTarget); } else if (dropTargetLocation == DropTargetLocation.AboveItem) { DropModelAboveTarget(dropSource, dropTarget); } else if (dropTargetLocation == DropTargetLocation.BelowItem) { DropModelBelowTarget(dropSource, dropTarget); } }
public void DropModel(ConnectionInfo dropSource, ConnectionInfo dropTarget, DropTargetLocation dropTargetLocation) { switch (dropTargetLocation) { case DropTargetLocation.Item: DropModelOntoTarget(dropSource, dropTarget); break; case DropTargetLocation.AboveItem: DropModelAboveTarget(dropSource, dropTarget); break; case DropTargetLocation.BelowItem: DropModelBelowTarget(dropSource, dropTarget); break; } }
private void HandleReorder(ExtractableColumn sourceColumn, IOrderable targetOrderable, DropTargetLocation location) { if (targetOrderable == null) { targetOrderable = olvSelected.Objects.Cast <IOrderable>().OrderByDescending(o => o.Order).FirstOrDefault(); } if (targetOrderable == null) { return; } int destinationOrder = targetOrderable.Order; switch (location) { case DropTargetLocation.AboveItem: //bump down the other columns foreach (ConcreteColumn c in olvSelected.Objects.OfType <ConcreteColumn>().ToArray()) { if (c.Order >= destinationOrder && !Equals(c, sourceColumn)) { c.Order++; c.SaveToDatabase(); } } //should now be space at the destination order position sourceColumn.Order = destinationOrder; break; case DropTargetLocation.None: case DropTargetLocation.BelowItem: //bump up other columns foreach (ConcreteColumn c in olvSelected.Objects.OfType <ConcreteColumn>().ToArray()) { if (c.Order <= destinationOrder && !Equals(c, sourceColumn)) { c.Order--; c.SaveToDatabase(); } } sourceColumn.Order = destinationOrder; break; default: throw new ArgumentOutOfRangeException(); } sourceColumn.SaveToDatabase(); olvSelected.RefreshObjects(olvSelected.Objects.OfType <object>().ToArray()); SortSelectedByOrder(); }
/// <summary> /// When the mouse is at the given point, what should the target of the drop be? /// </summary> /// <remarks>This method should update the DropTarget* members of the given arg block</remarks> /// <param name="pt">The mouse point, in client co-ordinates</param> protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt) { const int SMALL_VALUE = 3; DropTargetLocation location = DropTargetLocation.None; int targetIndex = -1; int targetSubIndex = 0; if (this.CanDropOnBackground) { location = DropTargetLocation.Background; } // Which item is the mouse over? // If it is not over any item, it's over the background. ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y); if (info.Item != null && this.CanDropOnItem) { location = DropTargetLocation.Item; targetIndex = info.Item.Index; if (info.SubItem != null && this.CanDropOnSubItem) { targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem); } } // Check to see if the mouse is "between" rows. // ("between" is somewhat loosely defined) if (this.CanDropBetween && this.ListView.GetItemCount() > 0) { // If the mouse is over an item, check to see if it is near the top or bottom if (location == DropTargetLocation.Item) { if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top) { location = DropTargetLocation.AboveItem; } if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom) { location = DropTargetLocation.BelowItem; } } else { // Is there an item a little below the mouse? // If so, we say the drop point is above that row info = this.ListView.HitTest(pt.X, pt.Y + SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.AboveItem; } else { // Is there an item a little above the mouse? info = this.ListView.HitTest(pt.X, pt.Y - SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.BelowItem; } } } } args.DropTargetLocation = location; args.DropTargetIndex = targetIndex; args.DropTargetSubItemIndex = targetSubIndex; }