Пример #1
0
 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;
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
 public GraphItem(DiagramHelper owner)
     : base(owner)
 {
     ChildItems = new List<GraphItem>();
     Size = new Size(DiagramConstant.Random.Next(20, 40), DiagramConstant.Random.Next(20, 40));
 }
Пример #6
0
 public ParseDot(DiagramHelper owner, string textProgram)
 {
     this.owner = owner;
     this.textProgram = textProgram;
     Parse();
 }
Пример #7
0
 public void clear(object sender, EventArgs e)
 {
     helper = new DiagramHelper();
 }
Пример #8
0
 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);
 }
Пример #9
0
 public DiagramItem(DiagramHelper owner)
 {
     this.Owner = owner;
     Size = new Size(20, 20);
 }
Пример #10
0
        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);
        }