private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Filter = "Text|*.txt|Conf|*.config|Conf|*.ini"; of.InitialDirectory = ""; if (of.ShowDialog() == DialogResult.OK) { if (of.FileName != null) { string serialized = System.IO.File.ReadAllText(of.FileName); System_FitzHugh_Nagumo my_system = JsonConvert.DeserializeObject <System_FitzHugh_Nagumo>(serialized); N = my_system.count_elements; iterations = my_system.count_iterations; d = my_system.d; eps = my_system.epsilon; textBox1.Text = N.ToString(); textBox2.Text = iterations.ToString(); textBox6.Text = d.ToString(); textBox7.Text = eps.ToString(); x0.Clear(); y0.Clear(); a0.Clear(); textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; for (int i = 0; i < N; i++) { a0.Add(my_system.elements[i].a); x0.Add(my_system.elements[i].x); y0.Add(my_system.elements[i].y); textBox3.Text += x0[i] + " "; textBox4.Text += y0[i] + " "; textBox5.Text += a0[i] + " "; } } } }
private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e) { Read_options(); if (N == size_x0 && N == size_y0 && N == size_a0) { SaveFileDialog sf = new SaveFileDialog(); sf.Filter = "Text|*.txt|Conf|*.config|Conf|*.ini"; sf.InitialDirectory = ""; if (sf.ShowDialog() == DialogResult.OK) { if (sf.FileName != null) { System_FitzHugh_Nagumo my_system = new System_FitzHugh_Nagumo() { count_iterations = iterations, count_elements = N, d = d, epsilon = eps }; my_system.elements = new Element[N]; for (int i = 0; i < N; i++) { my_system.elements[i] = new Element() { a = a0[i], x = x0[i], y = y0[i] } } ; string serialized = JsonConvert.SerializeObject(my_system); if (serialized != null) { System.IO.File.WriteAllText(sf.FileName, serialized); } } } } else { Form3 new_form = new Form3(N, size_x0, size_y0, size_a0); new_form.ShowDialog(); } } }