private void checkBoxSetWallpaper_CheckedChangedAsync(object sender, EventArgs e) { if (((CheckBox)sender).Checked) { this._settings.SetAsWallpaper = true; SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); } }
private void comboBoxImageSource_SelectedIndexChanged(object sender, EventArgs e) { var cb = (ComboBox)sender; string selected = cb.Items[cb.SelectedIndex].ToString(); this._settings.ImageSource = _imageSources.First <SourceImages>(x => x.name == selected).url.full; SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); }
private void comboBoxInterval_SelectedIndexChanged(object sender, EventArgs e) { var cb = (ComboBox)sender; string selected = cb.Items[cb.SelectedIndex].ToString(); this._settings.UpdateInterval = SettingsFileUtils.ConvertIntervalFromControl(selected); SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); // Reset timer InitTimer(); }
private void checkBoxStartAutomatically_CheckedChanged(object sender, EventArgs e) { // Command to run var command = "\"" + AppDomain.CurrentDomain.BaseDirectory + "GOES.exe\" --min"; // Update settings file this._settings.RunOnStartup = ((CheckBox)sender).Checked; SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); if (this._settings.RunOnStartup) { RunOnStartup.AddToStartup("GOES Wallpaper", command); } else { RunOnStartup.RemoveFromStartup(command); } }
public MainForm(bool startMinimized) { InitializeComponent(); if (startMinimized) { this.WindowState = FormWindowState.Minimized; Form1_Resize(null, null); } try { // Image sources location this._imageSourcesFile = "sources.json"; // Settings this._settingsFile = "settings.json"; // Image save locations this._imageSavePath = AppDomain.CurrentDomain.BaseDirectory + "images\\"; // Load up combo box data this.LoadImageSources(); this.LoadUpdateIntervals(); // Check if save directory exists, create if not if (!Directory.Exists(_imageSavePath)) { Directory.CreateDirectory(this._imageSavePath); } // Check is settings file exists, create if not if (!File.Exists(_settingsFile)) { // Create default settings this._settings = new Settings(); this._settings.ImageSource = this._imageSources[0].url.full; this._settings.UpdateInterval = IntervalUtils.INTERVAL_5_MINUTES; this._settings.KeepOldImages = false; this._settings.SetAsWallpaper = false; this._settings.RunOnStartup = false; // File the settings out SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); // Set controls default values comboBoxImageSource.SelectedIndex = 0; comboBoxInterval.SelectedIndex = 0; } else { // Read settings from file this._settings = SettingsFileUtils.LoadSettings(this._settingsFile); // Set control values comboBoxImageSource.SelectedIndex = comboBoxImageSource.FindStringExact((this._imageSources.First(x => x.url.full == this._settings.ImageSource).name)); comboBoxInterval.SelectedIndex = comboBoxInterval.FindStringExact(SettingsFileUtils.ConvertIntervalFromSettingsFile(this._settings.UpdateInterval)); checkBoxKeepOldImages.Checked = this._settings.KeepOldImages; checkBoxSetWallpaper.Checked = this._settings.SetAsWallpaper; //checkBoxStartAutomatically.Checked = this._settings.RunOnStartup; } } catch (Exception e) { MessageBox.Show("An unexpected error has occured! The app will now close.\n\n" + e); Application.Exit(); } }
private void checkBoxKeepOldImages_CheckedChanged(object sender, EventArgs e) { this._settings.KeepOldImages = ((CheckBox)sender).Checked; SettingsFileUtils.SaveSettings(this._settings, this._settingsFile); }