Esempio n. 1
0
        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++;
        }
Esempio n. 2
0
 private void создатьНовыйГрафToolStripMenuItem_Click(object sender, EventArgs e)
 {
     primGraph = new CGraph();
     graph     = new CGraph();
     PutMessage("");
     panel1.Invalidate();
 }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Clear();
            DeleteHighlight();
            DeleteTopsHighlight();
            DeleteTopsColors();
            DeleteEdgesColors();
            panel1.Invalidate();
            PutMessage("");

            primGraph = new CGraph();
            PaintGraph();
            checkBox1.Enabled = true;
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        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();
            }
        }
Esempio n. 6
0
        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();
            }
        }