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); } }
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); } }
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("ОШИБКА: файл не существует"); } } }