public DiagramItem Create(DiagramHelper owner, string id) { if(ht.ContainsKey(id)) return (DiagramItem)ht[id]; else { var result = new DiagramItem(owner) { Name = id }; ht.Add(id, result); return result; } }
public void ParserText_GetDiagramRelation() { string textProgram = "graph { a -- b; }"; DiagramHelper graph = new DiagramHelper(); ParseDot parserDot = new ParseDot(graph, textProgram); List<DiagramRelation> DiagramRelation = parserDot.GetDiagramRelations(); Assert.IsNotNull(DiagramRelation); Assert.AreEqual(1, DiagramRelation.Count); Assert.AreEqual("a", DiagramRelation[0].Item1.Name); Assert.AreEqual("b", DiagramRelation[0].Item2.Name); }
public void ParserText_GetNodes() { string textProgram = "graph { a -- b; }"; DiagramHelper graph = new DiagramHelper(); ParseDot parserDot = new ParseDot(graph, textProgram); List<DiagramItem> nodes = parserDot.GetDiagramItems(); Assert.IsNotNull(nodes); Assert.AreEqual(2, nodes.Count); Assert.AreEqual("a", nodes[0].Name); Assert.AreEqual("b", nodes[1].Name); }
public void AverageParse() { DiagramHelper graph = new DiagramHelper(); string textProgram = "graph { a -- b; b -- c; }"; graph.Load(textProgram); Assert.IsNotNull(graph.DiagramItems); Assert.AreEqual(3, graph.DiagramItems.Count); Assert.AreEqual("a", graph.DiagramItems[0].Name); Assert.AreEqual("b", graph.DiagramItems[1].Name); Assert.AreEqual("c", graph.DiagramItems[2].Name); Assert.IsNotNull(graph.DiagramRelations); Assert.AreEqual(2, graph.DiagramRelations.Count); Assert.AreEqual("a", graph.DiagramRelations[0].Item1.Name); Assert.AreEqual("b", graph.DiagramRelations[0].Item2.Name); Assert.AreEqual("b", graph.DiagramRelations[1].Item1.Name); Assert.AreEqual("c", graph.DiagramRelations[1].Item2.Name); }
public GraphItem(DiagramHelper owner) : base(owner) { ChildItems = new List<GraphItem>(); Size = new Size(DiagramConstant.Random.Next(20, 40), DiagramConstant.Random.Next(20, 40)); }
public ParseDot(DiagramHelper owner, string textProgram) { this.owner = owner; this.textProgram = textProgram; Parse(); }
public void clear(object sender, EventArgs e) { helper = new DiagramHelper(); }
private void load(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); DirectoryInfo di = new DirectoryInfo(Directory.GetCurrentDirectory() + @"\..\..\Test\XMLStore"); dialog.InitialDirectory = di.FullName; dialog.DefaultExt = "*.xml"; if (dialog.ShowDialog(this) != DialogResult.OK) return; helper = new DiagramHelper(); helper.DeserializeFromXMLFile(dialog.FileName); }
public DiagramItem(DiagramHelper owner) { this.Owner = owner; Size = new Size(20, 20); }
public void LargeTest() { DiagramHelper graph = new DiagramHelper(); string textProgram = GetTextProgram(); graph.Load(textProgram); Assert.IsNotNull(graph.DiagramItems); Assert.AreEqual(21, graph.DiagramItems.Count); Assert.IsNotNull(graph.DiagramRelations); Assert.AreEqual(41, graph.DiagramRelations.Count); }