Example #1
0
        internal override void OnMouseMove(MouseEventArgs e)
        {
            if (CheckOverScrollBar(e.GetPosition(TreeView)))
            {
                CleanUpAdorners();
                return;
            }

            if (dragPosition.HasValue)
            {
                var dragDiff = dragPosition.Value - e.GetPosition(TreeView);
                if (TreeView.DragCommand != null && (Math.Abs(dragDiff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(dragDiff.Y) > SystemParameters.MinimumVerticalDragDistance))
                {
                    // begin Drag
                    var draggableItems    = GetDraggableItems(dragPosition.Value);
                    var canDragParameters = new CanDragParameters(draggableItems, dragPosition.Value, dragButton);
                    dragPosition = null;

                    var canDrag = TreeView.DragCommand.CanExecute(canDragParameters);

                    if (canDrag && draggableItems.Count > 0)
                    {
                        var dragParameters = new DragParameters(draggableItems, canDragParameters.Position, canDragParameters.Button);
                        TreeView.DragCommand.Execute(dragParameters);

                        DragStart();
                        DragDrop.DoDragDrop(TreeView, dragParameters.Data, dragParameters.AllowedEffects);
                        DragEnd();
                        e.Handled = true;
                    }
                }
            }
        }
Example #2
0
        internal override void OnMouseMove(MouseEventArgs e)
        {
            IsDragging = false;

            if (!IsLeftButtonDown || CheckOverScrollBar(e.GetPosition(TreeView)))
            {
                CleanUpAdorners();
                return;
            }

            if (!CanDrag)
            {
                return;
            }

            //drag actually starting?
            Point  mousePos = e.GetPosition(null);
            Vector diff     = dragStartPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                IsDragging = true;

                DragContent dragData = new DragContent();
                foreach (var item in draggableItems)
                {
                    DragParameters dragParameters = new DragParameters(item);
                    TreeView.DragCommand.Execute(dragParameters);
                    dragData.Add(dragParameters.DraggedObject);
                }

                DragStart(dragData);
                DragDo(dragData);
                DragEnd();
                e.Handled = true;
            }
        }