コード例 #1
0
        public static void OnDragEnter(TreeViewItemEx tvItem, DragEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine($"DragEnter: {tvItem.Item}");

            if (dropInfo == null)
            {
                dropInfo = new DropInfo();
            }

            if (dropInfo.CouldHadleDrop(e))
            {
                dropInfo.TargetItem = tvItem;
                e.Handled           = true;
            }
            OnDragOver(tvItem, e);
        }
コード例 #2
0
        public static void OnDragOver(TreeViewItemEx tvItem, DragEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine($"DragOver: {tvItem.Item}");

            if (dropInfo == null)
            {
                dropInfo = new DropInfo();
            }

            if (dropInfo.CouldHadleDrop(e))
            {
                // set the target item, this also initializes the DropTargetAdorner
                dropInfo.TargetItem = tvItem;

                // update data related to the current mouse position and the target item
                dropInfo.UpdateInsertPosition(e);
                dropInfo.UpdateTargetContainerAndIndex();

                // set the drop mode Copy|Move|None
                if (dropInfo.CanAcceptData(DropInfo.ExtractDropData(dragInfo, e)))
                {
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                    {
                        e.Effects = DragDropEffects.Copy;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }

                // this controls the adorner
                dropInfo.Effects = e.Effects;

                e.Handled = true;
            }
        }