Beispiel #1
0
        public static void addLineEdge(GraphViewer gv, string src, string tar)
        {
            var graph = gv.Graph;
            var edge  = graph.AddEdge(src, null, tar);

            edge.SourceNode.AddOutEdge(edge);
            edge.TargetNode.AddInEdge(edge);

            var ledge = GeometryGraphCreator.CreateGeometryEdgeFromDrawingEdge(edge);

            //ledge.Source = edge.SourceNode.GeometryNode;
            //ledge.Target = edge.TargetNode.GeometryNode;
            ledge.Source.AddOutEdge(ledge);
            ledge.Target.AddInEdge(ledge);
            edge.GeometryEdge = ledge;
            ledge.Curve       = new Microsoft.Msagl.Core.Geometry.Curves.LineSegment(ledge.Source.Center, ledge.Target.Center);
            //gv.AddEdge(gv.CreateEdgeWithGivenGeometry(edge), true);
            Microsoft.Msagl.Layout.LargeGraphLayout.LgLayoutSettings lgsets = null;

            Microsoft.Msagl.Routing.StraightLineEdges.RouteEdge(ledge, 0);
            var oute = gv.CreateEdgeWithGivenGeometry(edge);

            gv.LayoutEditor.AttachLayoutChangeEvent(oute);
            gv.Invalidate();
            var sss = oute.Target;
            //gv.RouteEdge(edge);
        }
Beispiel #2
0
        public IViewerEdge RouteEdge(DrawingEdge drawingEdge)
        {
            var geomEdge  = GeometryGraphCreator.CreateGeometryEdgeFromDrawingEdge(drawingEdge);
            var geomGraph = drawingGraph.GeometryGraph;

            LayoutHelpers.RouteAndLabelEdges(geomGraph, drawingGraph.LayoutAlgorithmSettings, new[] { geomEdge });
            return(CreateEdge(drawingEdge, drawingGraph.LayoutAlgorithmSettings as LgLayoutSettings));
        }
Beispiel #3
0
        internal void CreateEdge()
        {
            if (Model == null)
            {
                return;
            }

            if (this.Source.Label == null || this.Target.Label == null)
            {
                return;
            }

            Dictionary <string, Entity> entitiesLookup = Model.DisplayedSubmodel.Entities.ToDictionary(x => x.Label, y => y);

            if ((entitiesLookup.ContainsKey(Source.Label) || entitiesLookup.ContainsKey(Target.Label)) == false)
            {
                return;
            }

            if (drawingEdge != null)
            {
                DeleteDrawingEdge(false);
            }

            if (Model.Graph != null)
            {
                drawingEdge       = Model.Graph.AddEdge(Source.Label, Target.Label);
                drawingEdge.Attr  = CreateEdgeAttr();
                drawingEdge.Label = CreateLabel(drawingEdge, Model.ShowRelationshipLabels ? Type : "");

                LayoutEdge coreEdge = GeometryGraphCreator.CreateGeometryEdgeFromDrawingEdge(drawingEdge);
                CreateEdgeCurve(drawingEdge, coreEdge);

                Model.GeometryGraph.Edges.Add(coreEdge);
                drawingEdge.GeometryEdge = coreEdge;
                drawingEdge.UserData     = this;
            }
            else
            {
                if (IsAddedOnViewGraph)
                {
                    IsAddedOnViewGraph = false;
                    return;
                }

                DrawingNode source = Model.GraphEditor.Graph.FindNode(Source.Label);
                DrawingNode target = Model.GraphEditor.Graph.FindNode(Target.Label);

                if (target != null)
                {
                    drawingEdge = Model.GraphEditor.Viewer.AddEdge(source, target, false);

                    drawingEdge.Attr     = CreateEdgeAttr();
                    drawingEdge.UserData = this;
                }
                RenameEdge();
            }
        }
Beispiel #4
0
        public static IViewerEdge addLineEdge2(GraphViewer gv, string src, string tar)
        {
            var graph = gv.Graph;
            var edge  = graph.AddEdge(src, null, tar);

            edge.SourceNode.AddOutEdge(edge);
            edge.TargetNode.AddInEdge(edge);

            var ledge = GeometryGraphCreator.CreateGeometryEdgeFromDrawingEdge(edge);

            ledge.Source.AddOutEdge(ledge);
            ledge.Target.AddInEdge(ledge);
            ledge.GeometryParent = graph.GeometryGraph;
            graph.GeometryGraph.Edges.Add(ledge);
            edge.GeometryEdge = ledge;
            //ledge.Curve = new LineSegment(ledge.Source.Center, ledge.Target.Center);
            //gv.AddEdge(gv.CreateEdgeWithGivenGeometry(edge), true);
            Microsoft.Msagl.Routing.StraightLineEdges.RouteEdge(ledge, 0);
            var oute = gv.CreateEdgeWithGivenGeometry(edge);

            gv.LayoutEditor.AttachLayoutChangeEvent(oute);
            return(oute);
        }