public ItemDroppedEventArgs(object item, DragDropKind kind) { _item = item; _kind = kind; }
public DragDropKind CanAcceptDrop(FolderConfigurationNodeBase dropData, DragDropKind kind) { if (dropData == null || this == dropData || this == dropData.Parent || this.IsDescendentOf(dropData)) return DragDropKind.None; return DragDropKind.Move; }
public override DragDropKind CanAcceptDrop(object[] items, DragDropKind kind) { // return the requested kind if all items are of type TItem, otherwise None return(CollectionUtils.TrueForAll(items, delegate(object obj) { return obj is TItem; }) ? kind : DragDropKind.None); }
/// <summary> /// Informs the specified item that it should accept a drop of the specified data, completing a drag-drop operation. /// </summary> /// <param name="item">The item being drag-dropped.</param> /// <param name="dropData">Information about the item being drag-dropped.</param> /// <param name="kind">The drop kind being performed.</param> /// <param name="position">The position of the drop location relative to <paramref name="item"/>.</param> /// <returns>The drop kind that will be accepted.</returns> public virtual DragDropKind AcceptDrop(object item, object dropData, DragDropKind kind, DragDropPosition position) { return(this.AcceptDrop(item, dropData, kind)); }
/// <summary> /// Informs the folder that the specified items were dragged from it. It is up to the implementation /// of the folder to determine the appropriate response (e.g. whether the items should be removed or not). /// </summary> /// <param name="items"></param> /// <param name="result">The result of the drag drop operation</param> public virtual void DragComplete(object[] items, DragDropKind result) { }
/// <summary> /// Informs the specified item that it should accept a drop of the specified data, completing a drag-drop operation. /// </summary> /// <param name="item">The item being drag-dropped.</param> /// <param name="dropData">Information about the item being drag-dropped.</param> /// <param name="kind">The drop kind being performed.</param> /// <param name="position">The position of the drop location relative to <paramref name="item"/>.</param> /// <returns>The drop kind that will be accepted.</returns> public virtual DragDropKind AcceptDrop(object item, object dropData, DragDropKind kind, DragDropPosition position) { return this.AcceptDrop(item, dropData, kind); }
/// <summary> /// Converts a <see cref="DragDropKind"/> to the WinForms <see cref="DragDropEffects"/> /// </summary> /// <param name="kind"></param> /// <returns></returns> private DragDropEffects GetDragDropEffect(DragDropKind kind) { switch (kind) { case DragDropKind.Move: return DragDropEffects.Move; case DragDropKind.Copy: return DragDropEffects.Copy; default: return DragDropEffects.None; } }
/// <summary> /// Asks the item if it can accept the specifid drop /// </summary> /// <param name="dropData"></param> /// <param name="kind"></param> /// <param name="position"></param> /// <returns></returns> public DragDropKind CanAcceptDrop(object dropData, DragDropKind kind, DragDropPosition position) { return _parentTree.Binding.CanAcceptDrop(_item, dropData, kind, position); }
/// <summary> /// Instructs the folder to accept the specified items /// </summary> /// <param name="items"></param> /// <param name="kind"></param> public virtual DragDropKind AcceptDrop(object[] items, DragDropKind kind) { return(DragDropKind.None); }
public override DragDropKind AcceptDrop(object[] items, DragDropKind kind) { // can't drop items into a container folder, since it contains only other folders return(DragDropKind.None); }
/// <summary> /// Called repeatedly as the object is dragged within this control /// </summary> /// <param name="e"></param> protected override void OnDragOver(DragEventArgs e) { // determine the node under the cursor Point cursor = _treeCtrl.PointToClient(new Point(e.X, e.Y)); BindingTreeNode node = (BindingTreeNode)_treeCtrl.GetNodeAt(cursor); // determine what effect the user is trying to accomplish DragDropEffects desiredEffect = GetDragDropDesiredEffect(e); // determine if the user is trying to drag to the top, middle or bottom areas of the node DragDropPosition position = DragDropPosition.Default; if (this.AllowDropToIndex && node != null) { float result = 1f * (cursor.Y - node.Bounds.Y) / node.Bounds.Height; if (result <= 0.2f) { position = DragDropPosition.Before; } else if (result >= 0.8f) { position = DragDropPosition.After; } } // optimization: only care if different than the last known drop-target node, or different desired effect, or different drop position if (node != _dropTargetNode || desiredEffect != _dropEffect || position != _dropPosition) { _treeCtrl.BeginUpdate(); // suspend drawing // un-highlight the last known drop-target node HighlightNode(_dropTargetNode, false); SetInsertMark(_dropTargetNode, DragDropPosition.Default); // set the drop target node to this node _dropTargetNode = node; _dropEffect = desiredEffect; _dropPosition = position; // check if drop target node exists and what kind of operation it will accept DragDropKind acceptableKind = (_dropTargetNode == null) ? DragDropKind.None : _dropTargetNode.CanAcceptDrop(GetDragDropData(e), GetDragDropKind(desiredEffect), _dropPosition); // display the appropriate effect cue based on the result e.Effect = GetDragDropEffect(acceptableKind); // if the drop target is valid and willing to accept data, highlight it if (acceptableKind != DragDropKind.None) { HighlightNode(_dropTargetNode, _dropPosition == DragDropPosition.Default); SetInsertMark(_dropTargetNode, _dropPosition); } _treeCtrl.EndUpdate(); // resume drawing } // perform drag scrolling if (_treeCtrl.ClientRectangle.Contains(cursor)) { if (cursor.Y > _treeCtrl.Height - _treeCtrl.ItemHeight / 2) { SendMessage(_treeCtrl.Handle, (int)WindowsMessages.WM_VSCROLL, new IntPtr(1), IntPtr.Zero); } else if (cursor.Y < _treeCtrl.ItemHeight / 2) { SendMessage(_treeCtrl.Handle, (int)WindowsMessages.WM_VSCROLL, IntPtr.Zero, IntPtr.Zero); } } base.OnDragOver(e); }
///<summary> /// Informs the specified item that it should accept a drop of the specified data, completing a drag-drop operation. ///</summary> ///<param name="item">The item being drag-dropped.</param> ///<param name="dropData">Information about the item being drag-dropped.</param> ///<param name="kind">The drop kind being performed.</param> ///<returns> ///The drop kind that will be accepted. ///</returns> public override DragDropKind AcceptDrop(object item, object dropData, DragDropKind kind) { return(_acceptDropHandler == null?base.AcceptDrop(item, dropData, kind) : _acceptDropHandler((TItem)item, dropData, kind)); }
public DragDropKind AcceptDrop(FolderConfigurationNodeBase dropData, DragDropKind kind) { if (dropData.Parent != null) dropData.Parent.SubTree.Items.Remove(dropData); AddChildNode(dropData); PropagateCheckStateUp(this); this.Modified = true; return DragDropKind.Move; }
public virtual DragDropKind AcceptDrop(object dropData, DragDropKind dragDropKind, DragDropPosition dragDropPosition) { // drop target must have a parent, otherwise there is no concept of "sibling" if (dragDropPosition != DragDropPosition.Default && !ReferenceEquals(this.Parent, null)) { if (dropData is AbstractActionModelTreeNode) { AbstractActionModelTreeNode droppedNode = (AbstractActionModelTreeNode) dropData; if (dragDropKind == DragDropKind.Move) { AbstractActionModelTreeNode sibling = null; if (droppedNode.Parent != null) { int index = droppedNode.Parent.Children.IndexOf(droppedNode) + (dragDropPosition == DragDropPosition.After ? -1 : 1); if (index >= 0 && index < droppedNode.Parent.Children.Count) sibling = droppedNode.Parent.Children[index]; } // to drag-move, we can't be dragging immediately before/after ourself, or onto one of our descendants if (!ReferenceEquals(this, droppedNode) && !ReferenceEquals(this, sibling) && !this.IsDescendantOf(droppedNode as AbstractActionModelTreeBranch)) { if (droppedNode.Parent != null) droppedNode.Parent.Children.Remove(droppedNode); this.Parent.Children.Insert(this.Parent.Children.IndexOf(this) + (dragDropPosition == DragDropPosition.After ? 1 : 0), droppedNode); return dragDropKind; } } } } return DragDropKind.None; }
internal DragDropKind CanFolderAcceptDrop(FolderTreeNode treeNode, object dropData, DragDropKind kind) { if (treeNode.Folder != _selectedTreeNode && dropData is ISelection) { return(treeNode.Folder.CanAcceptDrop((dropData as ISelection).Items, kind)); } return(DragDropKind.None); }
/// <summary> /// Instructs the folder to accept the specified items /// </summary> /// <param name="items"></param> /// <param name="kind"></param> public virtual DragDropKind AcceptDrop(object[] items, DragDropKind kind) { return DragDropKind.None; }
internal DragDropKind FolderAcceptDrop(FolderTreeNode treeNode, object dropData, DragDropKind kind) { if (treeNode.Folder != _selectedTreeNode && dropData is ISelection) { // inform the target folder to accept the drop var result = treeNode.Folder.AcceptDrop((dropData as ISelection).Items, kind); // inform the source folder that a drag was completed _selectedTreeNode.Folder.DragComplete((dropData as ISelection).Items, result); } return(DragDropKind.None); }
/// <summary> /// Informs the specified item that it should accept a drop of the specified data, completing a drag-drop operation. /// </summary> /// <param name="item">The item being drag-dropped.</param> /// <param name="dropData">Information about the item being drag-dropped.</param> /// <param name="kind">The drop kind being performed.</param> /// <returns>The drop kind that will be accepted.</returns> public virtual DragDropKind AcceptDrop(object item, object dropData, DragDropKind kind) { return DragDropKind.None; }
/// <summary> /// Informs the specified item that it should accept a drop of the specified data, completing a drag-drop operation. /// </summary> /// <param name="item">The item being drag-dropped.</param> /// <param name="dropData">Information about the item being drag-dropped.</param> /// <param name="kind">The drop kind being performed.</param> /// <returns>The drop kind that will be accepted.</returns> public virtual DragDropKind AcceptDrop(object item, object dropData, DragDropKind kind) { return(DragDropKind.None); }
public override DragDropKind AcceptDrop(object[] items, DragDropKind kind) { // can't drop items into a container folder, since it contains only other folders return DragDropKind.None; }
/// <summary> /// Asks the item if it can accept the specifid drop /// </summary> /// <param name="dropData"></param> /// <param name="kind"></param> /// <param name="position"></param> /// <returns></returns> public DragDropKind CanAcceptDrop(object dropData, DragDropKind kind, DragDropPosition position) { return(_parentTree.Binding.CanAcceptDrop(_item, dropData, kind, position)); }