public StageWindow(MainWindowManager manager, bool edit, Stage stage) { InitializeComponent(); this.manager = manager; openFileManager = new OpenFileManager(); this.edit = edit; this.stage = stage; if (edit) { SetValues(); } }
/// <summary> /// Saves the stage's information and closes the window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AcceptStage_Click(object sender, RoutedEventArgs e) { string errorMessage = null; try { if (String.IsNullOrEmpty(image)) { errorMessage = "You have to select an image for the stage."; throw new NullReferenceException(); } if (edit) { stage.Background = image; stage.Music = music; } else { manager.ID++; Stage auxStage = new Stage(manager.ID, image, music); manager.Stages.Add(auxStage); } this.Close(); } catch (NullReferenceException) { MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning); } }