Esempio n. 1
0
 private void CleanUpAdorners()
 {
     if (insertAdorner != null)
     {
         insertAdorner.Dispose();
         insertAdorner = null;
     }
 }
        private void CleanUpAdorners()
        {
            if (dragAdorner != null)
            {
                // on external drop no cleanup method is called.
                dragAdorner.Dispose();
                dragAdorner = null;
            }

            if (insertAdorner != null)
            {
                insertAdorner.Dispose();
                insertAdorner = null;
            }
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
        private void DragEnd()
        {
            DragDrop.RemoveGiveFeedbackHandler(TreeView, OnGiveFeedBack);
            TreeView.Cursor        = initialCursor;
            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;
            }
        }
        void OnDragOver(object sender, DragEventArgs e)
        {
            // drag over is the only event which returns the position
            // GiveFeedback returns nonsense even from Mouse.GetPosition
            Point point = e.GetPosition(TreeView);

            if (TryScroll(point))
            {
                return;
            }

            if (dragAdorner == null)//external drop
            {
                var content = new DragContent();
                content.Add(e.Data);
                dragAdorner = new DragAdorner(TreeView, content);
            }

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

            if (itemsPresenter.InputHitTest(e.GetPosition(itemsPresenter)) == null)
            {
                dragAdorner.Content.CanDrop   = false;
                dragAdorner.Content.CanInsert = false;
                //dragAdorner.Content.InsertIndex = -1;
                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)
            {
                dragAdorner.Content.CanDrop   = false;
                dragAdorner.Content.CanInsert = true;
                //dragAdorner.Content.InsertIndex = canInsertReturn.Index;

                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
            {
                dragAdorner.Content.CanInsert = false;
                //dragAdorner.Content.InsertIndex = -1;
                if (insertAdorner != null)
                {
                    insertAdorner.Dispose();
                    insertAdorner = null;
                }

                dragAdorner.Content.CanDrop = CanDrop(itemMouseIsOver, e.Data) != null;
                if (itemMouseIsOver != null)
                {
                    itemMouseIsOver.IsCurrentDropTarget = true;
                }
            }
        }
Esempio n. 6
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;
                }
            }
        }
        void OnDragOver(object sender, DragEventArgs e)
        {
            // drag over is the only event which returns the position
            // GiveFeedback returns nonsense even from Mouse.GetPosition
            Point point = e.GetPosition(TreeView);

            if (TryScroll(point)) return;

            if (dragAdorner == null)//external drop
            {
                var content = new DragContent();
                content.Add(e.Data);
                dragAdorner = new DragAdorner(TreeView, content);
            }

            dragAdorner.UpdatePosition(point);
            if (IsMouseOverAdorner(point)) return;
            var itemsPresenter = TreeView.ScrollViewer.Content as ItemsPresenter;
            if (itemsPresenter.InputHitTest(e.GetPosition(itemsPresenter)) == null)
            {
                dragAdorner.Content.CanDrop = false;
                dragAdorner.Content.CanInsert = false;
                dragAdorner.Content.InsertIndex = -1;
                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)
            {
                dragAdorner.Content.CanDrop = false;
                dragAdorner.Content.CanInsert = true;
                dragAdorner.Content.InsertIndex = canInsertReturn.Index;

                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
            {
                dragAdorner.Content.CanInsert = false;
                dragAdorner.Content.InsertIndex = -1;
                if (insertAdorner != null)
                {
                    insertAdorner.Dispose();
                    insertAdorner = null;
                }

                dragAdorner.Content.CanDrop = CanDrop(itemMouseIsOver, e.Data) != null;
                if (itemMouseIsOver != null)
                {
                    itemMouseIsOver.IsCurrentDropTarget = true;
                }
            }
        }
        private void DragEnd()
        {
            DragDrop.RemoveGiveFeedbackHandler(TreeView, OnGiveFeedBack);
            TreeView.Cursor = initialCursor;
            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;
            }
        }
        private void CleanUpAdorners()
        {
            if (dragAdorner != null)
            {
                // on external drop no cleanup method is called.
                dragAdorner.Dispose();
                dragAdorner = null;
            }

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