Esempio n. 1
0
 private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Topology.Topology topology = topologyBuilder.ToTopology();
         TopologySaverAndLoader.Save(fullFilePath, topology);
         MessageBox.Show("Топология сохраненена в\n" + fullFilePath);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Esempio n. 2
0
        private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                DefaultExt = TopologySaverAndLoader.DotExt,
                Filter     = TopologySaverAndLoader.Filter
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                fullFilePath = sfd.FileName;
                Topology.Topology topology = topologyBuilder.ToTopology();
                TopologySaverAndLoader.Save(fullFilePath, topology);
            }
        }
Esempio n. 3
0
        private void btnLoadTopology_Click(object sender, EventArgs e)
        {
            string fullFilePath;
            string dotExt = TopologySaverAndLoader.DotExt;
            string filter = TopologySaverAndLoader.Filter;

            OpenFileDialog ofd = new OpenFileDialog
            {
                DefaultExt = dotExt,
                Filter     = filter
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                fullFilePath = ofd.FileName;

                if (File.Exists(fullFilePath))
                {
                    try
                    {
                        Topology.Topology topology = TopologySaverAndLoader.Load(fullFilePath);

                        Constructor.Constructor constructor = new Constructor.Constructor(fullFilePath, topology);
                        constructor.ShowDialog();
                    }
                    catch (SerializationException)
                    {
                        MessageBox.Show("ОШИБКА: файл повреждён");
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.StackTrace);
                    }
                }
                else
                {
                    MessageBox.Show("ОШИБКА: файл не существует");
                }
            }
        }