static void ProcessLinks(Dictionary<DrawingObject, IViewerObjectX> vObjectsMapping, Graph g, Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphLink gl in g.Links) {
                var sourceId = gl.Source.Id.LiteralValue;
                var targetId = gl.Target.Id.LiteralValue;

                Subgraph sourceSubgraph;
                Node source = !subgraphTable.TryGetValue(sourceId, out sourceSubgraph) ? drawingGraph.FindNode(sourceId) : sourceSubgraph;

                Subgraph targetSubgraph;
                Node target = !subgraphTable.TryGetValue(targetId, out targetSubgraph) ? drawingGraph.FindNode(targetId) : targetSubgraph;

                foreach (GraphCategory gc in gl.Categories) {
                    string c = gc.ToString().Replace("CodeSchema_", "");
                    if (c == "Contains") {
                        if (targetSubgraph != null)
                            sourceSubgraph.AddSubgraph(targetSubgraph);
                        else
                            sourceSubgraph.AddNode(target);
                    } else {
                        Edge edge = new Edge(source, target, ConnectionToGraph.Connected);

                        edge.Label = new Label(c);
                        XEdge xEdge = new XEdge(edge, c);
                        vObjectsMapping[edge] = xEdge;
                    }
                }
            }
        }
 static Dictionary<string, Subgraph> GetSubgraphIds(DgmlGraph g) {
     Dictionary<string, Subgraph> ret = new Dictionary<string, Subgraph>();
     foreach (GraphLink gl in g.Links)
         foreach (GraphCategory gc in gl.Categories)
             if (gc.ToString().Replace("CodeSchema_", "") == "Contains")
                 ret[gl.Source.Id.LiteralValue] = null; //init it later
     return ret;
 }
 static Dictionary<string, Subgraph> GetSubgraphIds(DgmlGraph g) {
     Dictionary<string, Subgraph> ret = new Dictionary<string, Subgraph>();
     foreach (GraphLink gl in g.Links)
         foreach (GraphCategory gc in gl.Categories)
             if (gc.ToString().Replace("CodeSchema_", "") == "Contains")
                 ret[gl.Source.Id.LiteralValue] = null; //init it later
     return ret;
 }
        static void ProcessNodes(DgmlGraph g,
                                 Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph) {
            foreach (GraphNode gn in g.Nodes) {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue)) {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;
                    drawingNode = subgraph;
                }
                else
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);

                drawingNode.Label = new Label(gn.Label) {Owner = drawingNode};
            }
        }
        static void ProcessNodes(DgmlGraph g,
                                 Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph) {
            foreach (GraphNode gn in g.Nodes) {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue)) {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;
                    drawingNode = subgraph;
                }
                else
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);

                drawingNode.Label = new Label(gn.Label) {Owner = drawingNode};
            }
        }
Beispiel #6
0
        static void ProcessLinks(DgmlGraph g,
                                 Dictionary <string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphLink gl in g.Links)
            {
                var sourceId = gl.Source.Id.LiteralValue;
                var targetId = gl.Target.Id.LiteralValue;

                Subgraph sourceSubgraph;
                Node     source = !subgraphTable.TryGetValue(sourceId, out sourceSubgraph)
                                  ? drawingGraph.FindNode(sourceId)
                                  : sourceSubgraph;

                Subgraph targetSubgraph;
                Node     target = !subgraphTable.TryGetValue(targetId, out targetSubgraph)
                                  ? drawingGraph.FindNode(targetId)
                                  : targetSubgraph;

                bool containment = false;
                foreach (GraphCategory gc in gl.Categories)
                {
                    string c = gc.ToString().Replace("CodeSchema_", "");
                    if (c == "Contains")
                    {
                        if (targetSubgraph != null)
                        {
                            sourceSubgraph.AddSubgraph(targetSubgraph);
                        }
                        else
                        {
                            sourceSubgraph.AddNode(target);
                        }
                        containment = true;
                    }
                }
                if (!containment)
                {
                    Edge edge = new Edge(source, target, ConnectionToGraph.Connected);
                    // edge.Label = new Label(c);
                }
            }
        }
        static void ProcessNodes(Dictionary<DrawingObject, IViewerObjectX> vObjectsMapping, Graph g, Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphNode gn in g.Nodes) {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue)) {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;

                    drawingNode = subgraph;
                } else
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);

                drawingNode.Label=new Label(gn.Label);

                string category = null;
                if (gn.Categories.Any())
                    category = gn.Categories.ElementAt(0).ToString().Replace("CodeSchema_", "");

                XNode vNode = new XNode(drawingNode, gn);
                vObjectsMapping[drawingNode] = vNode;
            }
        }
        static void ProcessLinks(DgmlGraph g,
                                 Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph) {
            foreach (GraphLink gl in g.Links) {
                var sourceId = gl.Source.Id.LiteralValue;
                var targetId = gl.Target.Id.LiteralValue;

                Subgraph sourceSubgraph;
                Node source = !subgraphTable.TryGetValue(sourceId, out sourceSubgraph)
                                  ? drawingGraph.FindNode(sourceId)
                                  : sourceSubgraph;

                Subgraph targetSubgraph;
                Node target = !subgraphTable.TryGetValue(targetId, out targetSubgraph)
                                  ? drawingGraph.FindNode(targetId)
                                  : targetSubgraph;

                bool containment=false;
                foreach (GraphCategory gc in gl.Categories) {
                    string c = gc.ToString().Replace("CodeSchema_", "");
                    if (c == "Contains") {
                        
                        if (targetSubgraph != null)
                            sourceSubgraph.AddSubgraph(targetSubgraph);
                        else
                            sourceSubgraph.AddNode(target);
                        containment = true;
                    }

                }
                if (!containment) {
                    Edge edge = new Edge(source, target, ConnectionToGraph.Connected);
                   // edge.Label = new Label(c);
                   
                }
            }
        }
        static void ProcessLinks(Dictionary <DrawingObject, IViewerObjectX> vObjectsMapping, Graph g, Dictionary <string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphLink gl in g.Links)
            {
                var sourceId = gl.Source.Id.LiteralValue;
                var targetId = gl.Target.Id.LiteralValue;

                Subgraph sourceSubgraph;
                Node     source = !subgraphTable.TryGetValue(sourceId, out sourceSubgraph) ? drawingGraph.FindNode(sourceId) : sourceSubgraph;

                Subgraph targetSubgraph;
                Node     target = !subgraphTable.TryGetValue(targetId, out targetSubgraph) ? drawingGraph.FindNode(targetId) : targetSubgraph;

                foreach (GraphCategory gc in gl.Categories)
                {
                    string c = gc.ToString().Replace("CodeSchema_", "");
                    if (c == "Contains")
                    {
                        if (targetSubgraph != null)
                        {
                            sourceSubgraph.AddSubgraph(targetSubgraph);
                        }
                        else
                        {
                            sourceSubgraph.AddNode(target);
                        }
                    }
                    else
                    {
                        Edge edge = new Edge(source, target, ConnectionToGraph.Connected);

                        edge.Label = new Label(c);
                        XEdge xEdge = new XEdge(edge, c);
                        vObjectsMapping[edge] = xEdge;
                    }
                }
            }
        }
        static void ProcessNodes(Dictionary <DrawingObject, IViewerObjectX> vObjectsMapping, Graph g, Dictionary <string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphNode gn in g.Nodes)
            {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue))
                {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;

                    drawingNode = subgraph;
                }
                else
                {
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);
                }

                drawingNode.Label = new Label(gn.Label);

                string category = null;
                if (gn.Categories.Any())
                {
                    category = gn.Categories.ElementAt(0).ToString().Replace("CodeSchema_", "");
                }

                XNode vNode = new XNode(drawingNode, gn);
                vObjectsMapping[drawingNode] = vNode;
            }
        }