예제 #1
0
        private void HandleMouseMove([NotNull] object sender, [NotNull] MouseEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            if (!DragManager.IsDragStart(this, e, ref dragOrigin))
            {
                return;
            }

            var selectedItem = TreeView.SelectedItem as TreeViewItem;

            if (selectedItem == null)
            {
                return;
            }

            var itemHeader = selectedItem.Tag as ItemHeader;

            if (itemHeader == null)
            {
                return;
            }

            var list = new List <ItemHeader>
            {
                itemHeader
            };

            var dragData = DragManager.SetData(list);

            DragManager.DoDragDrop(this, dragData, DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link);

            e.Handled = true;
        }
        private void HandleMouseMove([NotNull] object sender, [NotNull] MouseEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            if (!DragManager.IsDragStart(this, e, ref _origin))
            {
                return;
            }

            if (!AllowDrag)
            {
                return;
            }

            var items = SelectedItems;

            if (items.Count == 0)
            {
                return;
            }

            string dragIdentifier = null;

            foreach (var item in items)
            {
                var draggable = item as ICanDrag;
                if (draggable == null)
                {
                    return;
                }

                if (dragIdentifier == null)
                {
                    dragIdentifier = draggable.GetDragIdentifier();
                }
                else if (dragIdentifier != draggable.GetDragIdentifier())
                {
                    return;
                }
            }

            if (string.IsNullOrEmpty(dragIdentifier))
            {
                return;
            }

            var dragData = new DataObject(dragIdentifier, items);

            DragManager.SetData(dragData, items);
            DragManager.DoDragDrop(this, dragData, DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link);

            _origin.X = double.MinValue;
            _origin.Y = double.MinValue;

            e.Handled = true;
        }
예제 #3
0
        private void MouseMove([NotNull] object sender, [NotNull] MouseEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            if (!DragManager.IsDragStart(ListBox, e, ref _origin))
            {
                return;
            }

            var items = new List <object>();

            foreach (var selectedItem in ListBox.SelectedItems)
            {
                items.Add(selectedItem);
            }

            _adorners.Clear();

            /*
             * foreach (var item in this.ListBox.Items)
             * {
             * if (this.ListBox.SelectedItems.Contains(item))
             * {
             * continue;
             * }
             *
             * var control = item as Control;
             * if (control == null)
             * {
             * continue;
             * }
             *
             * var adorner = new ControlDragAdorner(control, ControlDragAdornerPosition.Bottom | ControlDragAdornerPosition.Top);
             *
             * this.adorners.Add(adorner);
             * }
             */
            var dragData = DragManager.SetData(items);

            DragManager.DoDragDrop(ListBox, dragData, DragDropEffects.Move);

            e.Handled = true;
        }
        private void HandleMouseMove([NotNull] object sender, [NotNull] MouseEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            if (!DragManager.IsDragStart(this, e, ref dragOrigin))
            {
                return;
            }

            var selectedItems = GetSelectedItems();

            if (!selectedItems.Any())
            {
                return;
            }

            var dragData = DragManager.SetData(selectedItems);

            DragManager.DoDragDrop(this, dragData, DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link);

            e.Handled = true;
        }