/// <summary> /// Считывает модель из диалога /// </summary> /// <param name="Object"></param> /// <param name="openFileDialog1"></param> /// <returns></returns> public static bool OpenAndLoad(ref List <Object> Object, OpenFileDialog openFileDialog1) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamReader sr = new StreamReader(openFileDialog1.FileName); int count = Object.Count(); if (LoadModel.load(ref Object, sr) != 1) { sr.Close(); if (Object.Count() > count) { Object.RemoveAt(Object.Count() - 1); } MessageBox.Show("Не удалось считать файл"); sr.Close(); return(false); } MessageBox.Show("Файл загружен"); sr.Close(); return(true); } return(false); }
public GUIForm() { InitializeComponent(); try { LoadModel.load(ref Object, new StreamReader(Directory.GetCurrentDirectory() + "\\Aquarium.txt")); if (Math.Abs(Object[Object.Count - 1].refraction - 1) < 0.0001) { Object[Object.Count - 1].refraction = 1.0001; } textBox2.Enabled = true; textBox2.Text = Convert.ToString(Object[0].absorp); LoadModel.load(ref Object, new StreamReader(Directory.GetCurrentDirectory() + "\\Water.txt")); button15.Enabled = true; button1.Enabled = true; textBox1.Enabled = true; textBox1.Text = Convert.ToString(Object[Trace.IND_WATER].absorp); Water.FullWater(Object[Trace.IND_WATER].tops); textBox3.Text = Convert.ToString("0.1"); } catch (Exception) { MessageBox.Show("Не удалось загрузить исходные файлы"); button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; button6.Enabled = false; button7.Enabled = false; return; } }