private void openManoeuvre_Click(object sender, RoutedEventArgs e) { var openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Filter = @"Параметры маневра (*.manoeuvre)|*.manoeuvre"; openFileDialog.InitialDirectory = File.Exists((string)manoeuvreFileName.ToolTip) ? Path.GetFullPath((string)manoeuvreFileName.ToolTip) : Directory.GetCurrentDirectory(); if (System.Windows.Forms.DialogResult.OK != openFileDialog.ShowDialog()) { return; } try { GetManoeuvreParameters(SimulatorManoeuvre.LoadFromFile(openFileDialog.FileName)); } catch (InvalidOperationException) { MessageBox.Show("Неправильный формат входных данных.", "Ошибка"); } catch (Exception ex) { MessageBox.Show("При загрузке параметров маневра возникла ошибка: " + ex.Message, "Ошибка"); } }
private void GetManoeuvreParameters(SimulatorManoeuvre man) { if (man == null) { return; } manoeuvreName.Text = (man.Name != string.Empty ? man.Name : "Введите название маневра"); manoeuvreType.SelectedIndex = (int)man.Type; }
private void buttonManoeuvre_Click(object sender, RoutedEventArgs e) { var manoeuvreEditor = new ManoeuvreEditor(this, manoeuvre); if (true == manoeuvreEditor.ShowDialog()) { manoeuvre = manoeuvreEditor.Result; simulatorUpdate(); } }
private SimulatorManoeuvre SetManoeuvreParameters() { try { var newManoeuvre = new SimulatorManoeuvre(); newManoeuvre.Name = (manoeuvreName.Text == "Введите название маневра" ? string.Empty : manoeuvreName.Text); newManoeuvre.Type = (SimulatorManoeuvreType)manoeuvreType.SelectedIndex; return(newManoeuvre); } catch (Exception) { MessageBox.Show("Проверьте правильность параметров маневра.", "Ошибка"); return(null); } }
public ManoeuvreEditor(MainWindow mainWindow, SimulatorManoeuvre man) : this() { Owner = mainWindow; GetManoeuvreParameters(man); }