コード例 #1
0
        //-----------------------------------------------------------------------
        protected override void OnDragOver(DragEventArgs e)
        {
            if (e.Data.GetDataPresent("GraphNodeData") && (Data.Parent is GraphCollectionItem || Data.Parent.Parent is GraphCollectionItem))
            {
                if (adorner != null)
                {
                    adorner.Detach();
                    adorner = null;
                }

                adorner = new InsertionAdorner(true, false, this, draggedImage, e.GetPosition(this));

                e.Effects = DragDropEffects.Move;
                e.Handled = true;
            }
        }
コード例 #2
0
        //-----------------------------------------------------------------------
        public void DragStart(object sender, DragStartedEventArgs e)
        {
            if (DataItem is CollectionChildItem)
            {
                CollectionChildItem itemBase   = (CollectionChildItem)DataItem;
                DataItem            collection = itemBase.ParentCollection;

                if (collection != null)
                {
                    draggedImage = InsertionAdorner.ConvertElementToImage(this);

                    DataObject dragData = new DataObject("CollectionChildItem", DataItem);
                    dragData.SetData("Element", this);
                    DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);
                }
            }
            else if (DataItem is TreeItem)
            {
                TreeItem itemBase   = (TreeItem)DataItem;
                TreeItem collection = (TreeItem)itemBase.Parent;

                if (collection != null)
                {
                    draggedImage = InsertionAdorner.ConvertElementToImage(this);

                    DataObject dragData = new DataObject("TreeItem", DataItem);
                    dragData.SetData("Element", this);
                    DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);
                }
            }
            else if (DataItem is CommentItem)
            {
                CommentItem itemBase   = (CommentItem)DataItem;
                DataItem    collection = itemBase.Parent;

                if (collection != null && itemBase.CanReorder)
                {
                    draggedImage = InsertionAdorner.ConvertElementToImage(this);

                    DataObject dragData = new DataObject("CommentItem", DataItem);
                    dragData.SetData("Element", this);
                    DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);
                }
            }
        }
コード例 #3
0
        //#############################################################################################
        #region Mouse Events

        //-----------------------------------------------------------------------
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (Data.Parent is CollectionChildItem && Data.Parent.Parent is GraphCollectionItem)
            {
                draggedImage = InsertionAdorner.ConvertElementToImage(this);

                DataObject dragData = new DataObject("GraphNodeData", Data.Parent);
                dragData.SetData("Element", this);
                DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);

                e.Handled = true;
            }
            else if (Data is CommentItem && Data.Parent is GraphCollectionItem)
            {
                draggedImage = InsertionAdorner.ConvertElementToImage(this);

                DataObject dragData = new DataObject("GraphNodeData", Data);
                dragData.SetData("Element", this);
                DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);

                e.Handled = true;
            }
        }
コード例 #4
0
        //-----------------------------------------------------------------------
        protected override void OnDragOver(DragEventArgs e)
        {
            if (e.Data.GetDataPresent("CommentItem"))
            {
                if (adorner != null)
                {
                    adorner.Detach();
                    adorner = null;
                }

                adorner = new InsertionAdorner(true, false, this, draggedImage, e.GetPosition(this));

                e.Effects = DragDropEffects.Move;
                e.Handled = true;
            }
            else if (DataItem is CollectionChildItem)
            {
                CollectionChildItem item = e.Data.GetData("CollectionChildItem") as CollectionChildItem;
                var wrappedItem          = item.GetNonWrappedItem(item) ?? item.WrappedItem;

                DataItem collection = ((CollectionChildItem)DataItem).ParentCollection;

                if (collection is CollectionItem)
                {
                    var allowedDefs = (collection as CollectionItem).CDef.ChildDefinitions.Select(o => o.WrappedDefinition);

                    if (allowedDefs.Contains(item.WrappedItem.Definition) || allowedDefs.Contains(wrappedItem.Definition) ||
                        allowedDefs.Where(o => o is ReferenceDefinition).Any(o => (o as ReferenceDefinition).Definitions.Values.Contains(wrappedItem.Definition)))
                    {
                        if (adorner != null)
                        {
                            adorner.Detach();
                            adorner = null;
                        }

                        var dataItem = DataItem as DataItem;

                        adorner = new InsertionAdorner(true, false, this, draggedImage, e.GetPosition(this));
                    }
                }
                else if (collection is GraphCollectionItem)
                {
                    if ((collection as GraphCollectionItem).CDef.ChildDefinitions.Select(o => o.WrappedDefinition).Contains((item.Definition as CollectionChildDefinition).WrappedDefinition))
                    {
                        if (adorner != null)
                        {
                            adorner.Detach();
                            adorner = null;
                        }

                        var dataItem = DataItem as DataItem;

                        adorner = new InsertionAdorner(true, false, this, draggedImage, e.GetPosition(this));
                    }
                }

                e.Effects = DragDropEffects.Move;
                e.Handled = true;
            }
            else if (DataItem is TreeItem)
            {
                TreeItem item       = e.Data.GetData("TreeItem") as TreeItem;
                TreeItem collection = (TreeItem)DataItem;

                if (!item.Descendants.Contains(collection))
                {
                    if (adorner != null)
                    {
                        adorner.Detach();
                        adorner = null;
                    }

                    adorner = new InsertionAdorner(true, false, this, draggedImage, e.GetPosition(this));
                }

                e.Effects = DragDropEffects.Move;
                e.Handled = true;
            }
            else
            {
                e.Effects = DragDropEffects.None;
            }
        }