private void saveFileDialog_FileOk(object sender, CancelEventArgs e) { var profile = (Profile)profileComboBox.SelectedItem; var dest = Path.Combine(flashpointPath, profile.DestinationPath); var commandLine = GetLaunchCommand(profile.CommandLine, executable, dest); Curation curation = new Curation { Title = titleTextBox.Text, Genre = genreComboBox.SelectedItem.ToString(), Developer = developerTextBox.Text, Series = seriesTextBox.Text, PlayMode = playModeComboBox.SelectedItem.ToString(), Status = statusComboBox.SelectedItem.ToString(), Source = sourceTextBox.Text, Extreme = extremeCheckBox.Checked ? "Yes" : "No", Platform = profile.Platform, Publisher = publisherTextBox.Text, LaunchCommand = commandLine, Notes = notesTextBox.Text, AuthorNotes = authorNotesTextBox.Text }; if (dateTimePicker.Checked) { curation.ReleaseDate = dateTimePicker.Value; } string meta = MetaParser.Serialize(curation); var ms = new MemoryStream(); using (var zip = new ZipArchive(ms, ZipArchiveMode.Create, true)) { var metaStream = new MemoryStream(Encoding.UTF8.GetBytes(meta)); var name = new string(curation.Title.Select(c => Path.GetInvalidPathChars().Contains(c) ? '_' : c).ToArray()); var metaEntry = zip.CreateEntry(name + "/meta.txt"); using (var entryStream = metaEntry.Open()) { metaStream.CopyTo(entryStream); } var logoEntry = zip.CreateEntry(name + "/logo.png"); using (var entryStream = logoEntry.Open()) { logoPictureBox.Image.Save(entryStream, ImageFormat.Png); } var ssEntry = zip.CreateEntry(name + "/ss.png"); using (var entryStream = ssEntry.Open()) { screenshotPictureBox.Image.Save(entryStream, ImageFormat.Png); } source.CopyToZip(zip, name); } File.WriteAllBytes(saveFileDialog.FileName, ms.ToArray()); }
public void LoadCuration(Curation curation) { titleTextBox.Text = curation.Title; if (curation.ReleaseDate.HasValue) { dateTimePicker.Value = curation.ReleaseDate.Value; dateTimePicker.Checked = true; } genreComboBox.SelectedIndex = Math.Max(0, genreComboBox.FindString(curation.Genre)); developerTextBox.Text = curation.Developer; seriesTextBox.Text = curation.Series; playModeComboBox.SelectedIndex = Math.Max(0, playModeComboBox.FindString(curation.PlayMode)); statusComboBox.SelectedIndex = Math.Max(0, statusComboBox.FindString(curation.Status)); sourceTextBox.Text = curation.Source; publisherTextBox.Text = curation.Publisher; notesTextBox.Text = curation.Notes; authorNotesTextBox.Text = curation.AuthorNotes; this.curation = curation; }