コード例 #1
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
        public void Prima()
        {
            primGraph = new CGraph();
            Clear();
            DeleteHighlight();
            DeleteTopsHighlight();
            panel1.Invalidate();
            isChoosing                 = true;
            checkBox1.Enabled          = false;
            toolStripStatusLabel3.Text = "";
            toolStripStatusLabel4.Text = "";
            PutMessage("Дан ");
            if (checkBox1.Checked)
            {
                AddMessage("ориентированный");
            }
            else
            {
                AddMessage("неориентированный");
            }


            AddMessage("граф с " + graph.Tops.Count.ToString() + " вершинами" + Environment.NewLine);
            numberOfAction++;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
 private void создатьНовыйГрафToolStripMenuItem_Click(object sender, EventArgs e)
 {
     primGraph = new CGraph();
     graph     = new CGraph();
     PutMessage("");
     panel1.Invalidate();
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
        private void button3_Click(object sender, EventArgs e)
        {
            Clear();
            DeleteHighlight();
            DeleteTopsHighlight();
            DeleteTopsColors();
            DeleteEdgesColors();
            panel1.Invalidate();
            PutMessage("");

            primGraph = new CGraph();
            PaintGraph();
            checkBox1.Enabled = true;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
 public void Clear()
 {
     numberOfAction             = 0;
     chosenEdges                = new List <CGraphEdge>();
     chosenTops                 = new List <CGraphVertex>();
     queue                      = new Queue <CGraphVertex>();
     tGraph                     = new CGraph();
     stack                      = new Stack <CGraphVertex>();
     order                      = new Stack <CGraphVertex>();
     connectetComponentsCount   = 0;
     toolStripStatusLabel3.Text = "";
     toolStripStatusLabel4.Text = "";
     extraEdges                 = null;
     toAdd                      = null;
     startTop                   = null;
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileStream fs = null;

            try
            {
                string pathToExe = Environment.CurrentDirectory;
                pathToExe = pathToExe.Replace("bin\\Debug", "Файлы");
                openFileDialog1.InitialDirectory = pathToExe;
                openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog1.FilterIndex      = 2;


                if (openFileDialog1.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(openFileDialog1.FileName))
                {
                    XmlSerializer formatter = new XmlSerializer(typeof(CGraph));
                    fs    = new FileStream(openFileDialog1.FileName, FileMode.Open);
                    graph = (CGraph)formatter.Deserialize(fs);
                    panel1.Invalidate();
                    PutMessage("");
                }
                Clear();
                DeleteHighlight();
                DeleteTopsHighlight();
                DeleteTopsColors();
                DeleteEdgesColors();
                panel1.Invalidate();
                PutMessage("");

                primGraph = new CGraph();
                PaintGraph();
                checkBox1.Enabled = true;
                Rebote();
                Clear();
                primGraph = new CGraph();
                PutMessage("Граф загружен!");
            }
            catch (Exception exception)
            {
                Console.Error.WriteLine(exception.StackTrace);
                PutMessage("Ошибка при закгрузке графа!");
            }
            finally
            {
                fs?.Close();
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: arck1/visual-graph-algo
        private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileStream fs = null;

            Clear();
            DeleteHighlight();
            DeleteTopsHighlight();
            DeleteTopsColors();
            DeleteEdgesColors();
            panel1.Invalidate();
            PutMessage("");

            primGraph = new CGraph();
            PaintGraph();
            checkBox1.Enabled = true;
            try
            {
                string pathToExe = Environment.CurrentDirectory;

                pathToExe = pathToExe.Replace("bin\\Debug", "Файлы");
                saveFileDialog1.InitialDirectory = pathToExe;
                saveFileDialog1.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                saveFileDialog1.AddExtension     = true;
                saveFileDialog1.FilterIndex      = 2;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(saveFileDialog1.FileName))
                {
                    XmlSerializer formatter = new XmlSerializer(typeof(CGraph));
                    fs = new FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate);
                    formatter.Serialize(fs, graph);
                    PutMessage("Объект сохранен.");
                }
            }
            catch (Exception exception)
            {
                Console.Error.WriteLine(exception.StackTrace);
                PutMessage("Ошибка! Объект не сохранен.");
            }
            finally
            {
                fs?.Close();
            }
        }