Ejemplo n.º 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));

            var i = sender as RenderingItem;

            if (i != null)
            {
                e.Handled = true;
            }

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

            if (!UpdateSelection(e))
            {
                return;
            }

            var dragData = new DataObject(LayoutDesigner.DragIdentifier, this);

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

            e.Handled = true;
        }
Ejemplo n.º 3
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 _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;
        }
Ejemplo n.º 4
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            Debug.ArgumentNotNull(e, nameof(e));

            base.OnMouseMove(e);

            if (isDragging)
            {
                return;
            }

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

            var layoutDesigner = this.GetAncestorOrSelf <LayoutDesigner>();

            if (layoutDesigner == null)
            {
                return;
            }

            ContextMenu = null;

            var pos = PointFromScreen(AppHost.Shell.GetMousePosition());

            var overlayCanvas = layoutDesigner.GetCanvas();

            overlayCanvas.StartDragging();
            connector = new OverlayConnector(overlayCanvas, TranslatePoint(pos, overlayCanvas));

            isDragging = true;

            var dragData = new DataObject(BindingAnchorDragIdentifier, this);

            DragManager.DoDragDrop(this, dragData, DragDropEffects.Link);

            isDragging = false;

            connector.Remove();
            connector = null;
            overlayCanvas.EndDragging();

            e.Handled = true;

            if (ContextMenu != null)
            {
                ContextMenu.IsOpen = true;
            }
        }
Ejemplo n.º 5
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;
        }
        public void HandleMouseMove([NotNull] object sender, [NotNull] MouseEventArgs e)
        {
            Assert.ArgumentNotNull(sender, nameof(sender));
            Assert.ArgumentNotNull(e, nameof(e));

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

            var sectionControl = sender as UI.TemplateDesigner.TemplateSection;

            if (sectionControl != null && sectionControl.IsLastSection())
            {
                return;
            }

            var fieldControl = sender as UI.TemplateDesigner.TemplateField;

            if (fieldControl != null && fieldControl.IsLastField())
            {
                return;
            }

            var descriptor = new DragDataDescriptor
            {
                Type             = sender is UI.TemplateDesigner.TemplateSection ? @"section" : @"field",
                Data             = sender,
                TemplateDesigner = this
            };

            var dragData = new DataObject(@"SitecoreTemplateDesigner", descriptor);

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

            SetAdorner(-1);

            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;
        }