Exemplo n.º 1
0
 void CleanUpAdorners()
 {
     if (_InsertAdorner != null)
     {
         _InsertAdorner.Dispose();
         _InsertAdorner = null;
     }
 }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 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;
                    }
                }
            }
        }