예제 #1
0
 private void CleanUpAdorners()
 {
     if (insertAdorner != null)
     {
         insertAdorner.Dispose();
         insertAdorner = null;
     }
 }
예제 #2
0
        private void DragEnd()
        {
            autoScroller.IsEnabled = false;

            // Remove the drag adorner from the adorner layer.
            CleanUpAdorners();

            if (insertAdorner != null)
            {
                insertAdorner.Dispose();
                insertAdorner = null;
            }

            if (itemMouseIsOver != null)
            {
                itemMouseIsOver.IsCurrentDropTarget = false;
                itemMouseIsOver = null;
            }
        }
예제 #3
0
        void OnDragOver(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.None;
            e.Handled = true;

            // drag over is the only event which returns the position
            Point point = e.GetPosition(TreeView);

            if (TryScroll(point))
            {
                return;
            }

            if (IsMouseOverAdorner(point))
            {
                return;
            }
            var itemsPresenter = TreeView.ScrollViewer.Content as ItemsPresenter;

            /*
             * if (itemsPresenter.InputHitTest(e.GetPosition(itemsPresenter)) == null)
             * {
             *  if (insertAdorner != null) insertAdorner.Dispose();
             *  return;
             * }
             */

            if (itemMouseIsOver != null)
            {
                itemMouseIsOver.IsCurrentDropTarget = false;
            }

            itemMouseIsOver = GetTreeViewItemUnderMouse(point);
            //if (itemMouseIsOver == null) return;
            CanInsertReturn canInsertReturn = CanInsert(itemMouseIsOver, e.GetPosition, e.Data);

            if (canInsertReturn != null)
            {
                e.Effects = DragDropEffects.Move;

                if (insertAdorner == null)
                {
                    insertAdorner = new InsertAdorner(itemMouseIsOver, new InsertContent {
                        Before = canInsertReturn.Before
                    });
                }
                else
                {
                    insertAdorner.Dispose();
                    insertAdorner = new InsertAdorner(itemMouseIsOver, new InsertContent {
                        Before = canInsertReturn.Before
                    });
                }

                itemMouseIsOver.IsCurrentDropTarget = false;
            }
            else
            {
                if (insertAdorner != null)
                {
                    insertAdorner.Dispose();
                    insertAdorner = null;
                }

                if (CanDrop(itemMouseIsOver, e.Data))
                {
                    e.Effects = DragDropEffects.Move;
                }
                if (itemMouseIsOver != null)
                {
                    itemMouseIsOver.IsCurrentDropTarget = true;
                }
            }
        }