示例#1
0
        // Menu open
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Filter = "TXT File|*.txt";

            if (od.ShowDialog() == DialogResult.OK)
            {
                this.Cursor   = Cursors.WaitCursor;
                graphFileName = od.FileName;
                _MyDocument.Dispose();

                _MyDocument       = new GraphDocument(this.drawingSpace);
                _MyDocument.Graph = DGraph.CreateGraphFromFile(od.FileName);

                // Tao vi tri ngau nhien cho nut
                Random rand = new Random();
                for (int i = 0; i < _MyDocument.Graph.Nodes.Count; i++)
                {
                    _MyDocument.Graph.Nodes[i].Location = new Point(rand.Next(Format.Setting.NodeSize, drawingSpace.Width - Format.Setting.NodeSize), rand.Next(Format.Setting.NodeSize, drawingSpace.Height - Format.Setting.NodeSize));
                }

                // ve lai
                ReDraw();
                this.Cursor = Cursors.Default;

                lblGraphInfo.Text    = "Number of Nodes: " + _MyDocument.Graph.Nodes.Count.ToString() + " nodes\n\r";
                lblGraphInfo.Text   += "Number of Edges: " + _MyDocument.Graph.Edges.Count.ToString() + " edges\n\r";
                txtAlgorithmLog.Text = string.Empty;
            }
        }
示例#2
0
        public frmMain()
        {
            InitializeComponent();
            this.Icon = Properties.Resources.logo;

            _MyDocument = new GraphDocument(drawingSpace);
        }