private void loadStateToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Data File|*.dat"; if (ofd.ShowDialog() == DialogResult.OK) { if (AHP.problemName != null) { DialogResult confirm = MessageBox.Show("Сохранить состояние?", "Загрузка", MessageBoxButtons.YesNoCancel); if (confirm == DialogResult.Yes) { saveStateToolStripMenuItem.PerformClick(); } else if (confirm == DialogResult.Cancel) { return; } } string filename = ofd.FileName; string data = System.IO.File.ReadAllText(filename); AHP.Reset(); DataHandle dh = JsonConvert.DeserializeObject <DataHandle>(data); this.Hide(); this.Controls.Clear(); Form1 f = new Form1(); f.NormalizeSize(); f.Size = this.Size; f.Show(); f.Location = this.Location; f.LoadData(dh); } }
private void NewToolStripMenuItem_Click(object sender, EventArgs e) { if (AHP.problemName != null) { DialogResult confirm = MessageBox.Show("Сохранить состояние?", "Новая задача", MessageBoxButtons.YesNoCancel); if (confirm == DialogResult.Yes) { saveStateToolStripMenuItem.PerformClick(); } else if (confirm == DialogResult.Cancel) { return; } } AHP.Reset(); this.Hide(); this.Controls.Clear(); Form1 f = new Form1(); f.NormalizeSize(); f.Size = this.Size; f.Show(); f.Location = this.Location; }