public Settings() { InitializeComponent(); panel.AutoScroll = true; config = WorkspaceConfig.Load(); TextBoxOutputDirectory.Text = config.outputDirectory; TextBoxExcludedExtensions.Text = config.excludedExtensions; foreach (var link in config.encoders) { AddItem(link.extension, link.encoder); } FormClosing += (_, e) => { config.encoders.Clear(); foreach (EncoderEntry entry in entries) { config.encoders.Add(new EncoderLink { extension = entry.extension, encoder = entry.encoder }); } config.Save(); }; }
static public WorkspaceConfig Load() { WorkspaceConfig config; try { using (var myFileStream = File.OpenRead("config.workspace")) { var mySerializer = new XmlSerializer(typeof(WorkspaceConfig)); config = (WorkspaceConfig)mySerializer.Deserialize(myFileStream); } } catch (System.Exception) { config = new WorkspaceConfig(); config.Reset(); } return(config); }
private void buttonSettings_Click(object sender, EventArgs e) { ButtonPack.Enabled = false; ButtonSettings.Enabled = false; var settingsForm = new Settings(); settingsForm.Show(); settingsForm.BringToFront(); settingsForm.FormClosed += delegate { ButtonPack.Enabled = true; ButtonSettings.Enabled = true; // Refresh settings. config = WorkspaceConfig.Load(); RefreshWorkspace(); }; }
private void buttonSettings_Click(object sender, EventArgs e) { ButtonPack.Enabled = false; ButtonUpdate.Enabled = false; ButtonSettings.Enabled = false; var settingsForm = new Settings(); settingsForm.Show(); settingsForm.BringToFront(); settingsForm.FormClosed += delegate { ButtonPack.Enabled = true; ButtonUpdate.Enabled = true; ButtonSettings.Enabled = true; // Refresh settings. config = WorkspaceConfig.Load(); outputPath = Path.GetFullPath(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + config.outputDirectory); RefreshWorkspace(); }; }