Example #1
0
        protected virtual IVisualEdge NewVisual(Point p)
        {
            var result = SceneExtensions.CreateEdge(this.Scene);

            newCounter++;
            result.Root = Current;
            result.Leaf = Current;
            return(result);
        }
        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;
        }