Esempio n. 1
0
        public override void OnMouseMove(MouseActionEventArgs e)
        {
            base.OnMouseMove(e);
            Resolved = Resolved && Source != null;

            if (Resolved && (e.Button != MouseActionButtons.Left))
            {
                EndAction();
            }
            if (Resolved && !Dragging)
            {
                Dragging = true;
                InprocDragDrop.Dragging = true;
                InprocDragDrop.Data     = new GraphCursor <IVisual, IVisualEdge>(Scene.Graph, Source);

                try {
                    var startData =
                        new DragStartData(
                            DragDropViz.TransferDataOfVisual(Scene.Graph, Source),
                            DragDropAction.All,
                            GetDragImageBackend(Scene.Graph, Source),
                            e.Location.X, e.Location.Y);

                    DragDropHandler.DragStart(startData);
                } catch {} finally {
                    EndAction();
                }
            }
        }
Esempio n. 2
0
        public virtual void Paste()
        {
            var     scene = this.Scene;
            IVisual item  = null;

#if TRACE
            Trace.WriteLine($"{this.GetType ().Name}.{nameof(Paste)}:\t" + string.Join(" | ", Clipboard.GetTypesAvailable().Select(f => f.Id)));
#endif
            if (InprocDragDrop.ClipboardData != null)
            {
                // TODO: refactor to use same code as above
                var source = InprocDragDrop.ClipboardData as GraphCursor <IVisual, IVisualEdge>;
                if (source != null && source.Cursor != item)
                {
                    item = Mesh.LookUp(source.Graph, scene.Graph, source.Cursor);
                    if (item == null)
                    {
                        //TODO: error here
                        //return;
                    }
                }
            }

            if (item == null)
            {
                item = DragDropViz.VisualOfTransferData(scene.Graph, Clipboard.GetTransferData(Clipboard.GetTypesAvailable())); //DragDropViz.DataManager.DataTypes));
            }
            if (item != null)
            {
                SceneExtensions.PlaceVisual(scene, scene.Focused, item, Layout);
            }
        }
Esempio n. 3
0
        public virtual void Copy()
        {
            if (false)
            {
                // TODO: it has to be cleared, if the next stuff is copied into clipboard
                // a clipboard Pasted-Event is needed
                InprocDragDrop.ClipboardData = new GraphCursor <IVisual, IVisualEdge>(Scene.Graph, Scene.Focused);
            }

            if (Scene.Focused == null)
            {
                Registry.Pooled <IMessageBoxShow> ().Show("Warning", "Select something to copy", MessageBoxButtons.Ok);
                return;
            }

            Clipboard.SetTransferData(DragDropViz.TransferDataOfVisual(Scene.Graph, Scene.Focused));
        }
Esempio n. 4
0
        public override void Dropped(DragEventArgs e)
        {
            var pt     = Camera.ToSource(e.Position);
            var scene  = this.Scene;
            var target = scene.Hovered ?? HitTestFocused(e.Position);

            IVisual item = null;

            if (Dragging && Dropping)
            {
                // the current Drop has started in this instance
                // so we make a link
                if (target != null && Source != target)
                {
                    SceneExtensions.CreateEdge(scene, Source, target);
                }
                e.Success = true;
                return;
            }

            if (InprocDragDrop.Dragging)
            {
                var source = InprocDragDrop.Data as GraphCursor <IVisual, IVisualEdge>;
                if (source != null && source.Cursor != target)
                {
                    item = Mesh.LookUp(source.Graph, scene.Graph, source.Cursor);
                    if (item == null)
                    {
                        //TODO: error here
                        //return;
                    }
                }
            }

            if (item == null)
            {
                item = DragDropViz.VisualOfTransferData(scene.Graph, e.Data);
                if (item != null)
                {
                    item.Location = pt;
                }
            }

            if (item != null)
            {
                SceneExtensions.AddItem(scene, item, Layout, pt);
                if (target != null && !scene.Graph.Edges(target).Any(edge => edge.Leaf == item || edge.Root == item))
                {
                    SceneExtensions.CreateEdge(scene, target, item);
                }
            }
            else
            {
                // no known type found to import
                string dt = "not found:\t";
            }

            InprocDragDrop.Data     = null;
            InprocDragDrop.Dragging = false;
            Dragging = false;
        }
Esempio n. 5
0
 public override TransferDataSource GetTransferData()
 {
     return(DragDropViz.TransferDataOfVisual(this.Scene.Graph, this.Scene.Focused));
 }