Ejemplo n.º 1
0
        protected void AddGraph(PocGraphInfo graphInfo)
        {
            LayoutStates.Clear();

            if (graphInfo == null)
            {
                return;
            }

            HighlightAlgorithm?.ResetHighlight();

            RemoveAllGraphElement();

            Children.Clear();


            Dictionary <int, PocVertex> vertexControlsById = new Dictionary <int, PocVertex>();

            foreach (VertexInfo <PocVertex> info in graphInfo.Verteces.OfType <VertexInfo <PocVertex> >())
            {
                AddVertexControl(info);
                vertexControlsById.Add(info.ID, info.Vertex);
            }

            int i = 0;

            foreach (EdgeInfo <PocEdge> info in graphInfo.Edges.OfType <EdgeInfo <PocEdge> >())
            {
                PocVertex source = vertexControlsById[info.SourceID];
                PocVertex target = vertexControlsById[info.TargetID];

                CreateEdgeControl(new PocEdge(i.ToString(), source, target));
                i++;
            }
        }
Ejemplo n.º 2
0
        private void SaveGraphs()
        {
            var fd = new SaveFileDialog();

            if (fd.ShowDialog() == DialogResult.OK)
            {
                Commands = GraphLayoutCommand.Save;
                PocGraphInfo graphInfo = GraphInfo;
                graphInfo.Save(fd.FileName);
            }
        }