Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            panel2.Size = panel2.BackgroundImage.Size;


            //   panel2.Focus();

            //    panel2.AutoScroll = true;
            panel3.MouseWheel += OnMouseWheelZoom;
            drawingNodes       = new List <DrawingNode>();
            shortestPath       = new List <INode>();


            nodeBrush     = new SolidBrush(Color.Black);
            busBrush      = new SolidBrush(Color.BlueViolet);
            restBrush     = new SolidBrush(Color.DarkOrange);
            edgeBrush     = new SolidBrush(Color.SlateGray);
            disabledBrush = new SolidBrush(Color.Red);
            shortestBrush = new SolidBrush(Color.DarkBlue);

            NodeTypeCombo.SelectedIndex = 0;
            created              = null;
            g                    = new Graph.Graph();
            begining             = true;
            beginingPath         = true;
            dijkstra             = new DijkstraAlgorithm(g);
            zoomstep             = 1;
            toolStripLabel1.Text = zoomstep * 100 + " %";
            bf                   = new BinaryFormatter();
            selecting            = false;
            graphNodes           = new List <GraphNode>();
        }
Exemplo n.º 2
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            using (FileStream fs = new FileStream("graph.bin", FileMode.Open))
            {
                g = (Graph.Graph)bf.Deserialize(fs);
                dijkstra.SetGraph(g);
            }
            drawingNodes.Clear();
            foreach (string key in g.Nodes.Keys)
            {
                drawingNodes.Add(new DrawingNode(g.Nodes[key].GetLocation(), g.Nodes[key].GetId(), 1.0));
            }
            foreach (string key in g.Nodes.Keys)
            {
                graphNodes.Add(new GraphNode(key, g.Nodes[key].GetLocation()));
            }

            panel2.Invalidate();
        }