private void OnSaveSaveToCareer(object sender, EventArgs e) { if (this.SaveFile == null) { MessageBox.Show( Properties.Localization.Editor_NoActiveSave, Properties.Localization.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (var picker = new SavePicker()) { picker.Owner = this; picker.FileMode = SavePicker.PickerMode.Save; picker.FilePath = this._SavePath; picker.SaveFile = this.SaveFile; var result = picker.ShowDialog(); if (result != DialogResult.OK) { return; } if (string.IsNullOrEmpty(picker.SelectedPath) == false) { var selectedDirectory = Path.GetDirectoryName(picker.SelectedPath); if (selectedDirectory != null) { Directory.CreateDirectory(selectedDirectory); } using (var output = File.Create(picker.SelectedPath)) { SaveFormats.SFXSaveGameFile.Write(this.SaveFile, output); } } else { MessageBox.Show( Properties.Localization.Editor_ThisShouldNeverHappen, Properties.Localization.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void OnSaveOpenFromCareer(object sender, EventArgs e) { using (var picker = new SavePicker()) { picker.Owner = this; picker.FileMode = SavePicker.PickerMode.Load; picker.FilePath = this._SavePath; var result = picker.ShowDialog(); if (result != DialogResult.OK) { return; } if (string.IsNullOrEmpty(picker.SelectedPath) == true) { MessageBox.Show( Properties.Localization.Editor_ThisShouldNeverHappen, Properties.Localization.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (var input = File.OpenRead(picker.SelectedPath)) { this.LoadSaveFromStream(input); } } }