private Graph BuildGraph(IBSharpContext context) {
            
            var result = new Graph {
                RankDir = RankDirType.RL,
                Label = "Графическая структура проекта",
                DefaultNode = new Node {
                    FontName = "Consolas", 
                    Shape = NodeShapeType.Box3d,
                    FontSize = 8,
                    Style = NodeStyleType.Filled
                },
                DefaultEdge = new Node {
                    FontName = "Consolas",
                    FontSize = 8
                },
            };
            var visited= new List<IBSharpClass>();
            if (null != ((BSharpContext) context).Dictionaries) {
                foreach (var e in ((BSharpContext) context).Dictionaries) {
                    var node = new Node {Code = "d" + e.Key, Label = e.Key,SubgraphCode = "dicts",Shape = NodeShapeType.Mcircle};
                    result.AddNode(node);
                    foreach (var i in e.Value) {
                        result.AddEdge(new Edge {From = i.cls.FullName, To = "d" + e.Key, ArrowHead = ArrowType.Curve});
                    }
                }
            }
            foreach (var c in context.Get(BSharpContextDataType.Working)) {
                BuildClass(result,context, (BSharpClass)c, visited);
            }

            result.AutoTune();
            return result;
        }
Esempio n. 2
0
 /// <summary>
 /// Добавляет или мержит нод
 /// </summary>
 /// <param name="newNode"></param>
 /// <returns></returns>
 public Node AddNode(Node newNode) {
     var existed = ResolveNode(newNode.Code);
     if (null != existed) {
         existed.Merge(newNode);
         return existed;
     }
     Nodes.Add(newNode);
     newNode.Parent = this;
     return newNode;
 }
        private void BuildClass(Graph g, IBSharpContext ctx, BSharpClass cls, IList<IBSharpClass> visited) {
            if (visited.Contains(cls)) return;
            visited.Add(cls);
            var label = cls.Name;
            if (!string.IsNullOrWhiteSpace(cls.Prototype)) {
                label = "[" + cls.Prototype + "]\r\n" + cls.Name;
            }
            var n = new Node {Code = cls.FullName, Label = label};
            if (!string.IsNullOrWhiteSpace(cls.Namespace)) {
                n.SubgraphCode  = (cls.Namespace.Replace(".", "__")) + "__";
            }
            CheckoutNamespace(g,cls.Namespace);
            if (cls.Is(BSharpClassAttributes.Abstract)) {
                n.Shape = NodeShapeType.Box;
                n.FillColor = Color.Yellow;
            }
            g.AddNode(n);
            if (null != cls.DefaultImport) {
                g.AddEdge(new Edge {From = cls.FullName, To = cls.DefaultImport.FullName,Label = "0"});
                BuildClass(g,ctx,(BSharpClass)cls.DefaultImport,visited);
            }
            int idx = 1;
            foreach (var i in cls.SelfImports) {
                g.AddEdge(new Edge {From = cls.FullName, To = i.Target.FullName,Label = (idx++).ToString()});
                BuildClass(g, ctx, (BSharpClass)i.Target, visited);
            }
            foreach (var i in cls.IncludedClasses) {
                g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead =ArrowType.Diamond});
                BuildClass(g, ctx, (BSharpClass)i, visited);
            }
            foreach (var i in cls.ReferencedClasses)
            {
                g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead = ArrowType.Vee,Color = Color.Blue});
                BuildClass(g, ctx, (BSharpClass)i, visited);
            }
            foreach (var i in cls.LateIncludedClasses)
            {
                g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead = ArrowType.ODiamond, Color = Color.Blue });
                BuildClass(g, ctx, (BSharpClass)i, visited);
            }

            foreach (var i in cls.ReferencedDictionaries) {
                g.AddEdge(new Edge { From = cls.FullName, To = "d"+i, ArrowHead = ArrowType.Inv, Color = Color.Blue });
            }
            
        }
Esempio n. 4
0
 /// <summary>
 /// Создает типовой узел
 /// </summary>
 /// <returns></returns>
 public static Node Create(string code,Action<Node> setup)
 {
     var result = new Node{Code=code};
     if (null != setup) {
         setup(result);
     }
     return result;
 }
Esempio n. 5
0
 /// <summary>
 ///     Возвращает все ноды, в которые входит данный нод
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 private IEnumerable<Node> GetOutNodes(Node node) {
     return EnumerateEdges().Where(_ => _.From == node.Code).Select(_ => ResolveNode(_.To));
 }