diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs index 228493a..273d6d5 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.cs @@ -539,7 +539,11 @@ namespace DisplayMagician.UIForms ProfileSettingsForm profileSettingsForm = new ProfileSettingsForm(); profileSettingsForm.Profile = _selectedProfile; profileSettingsForm.ShowDialog(this); - //_selectedProfile = profileSettingsForm.Profile; + // If the profile was changed then save all the profiles + if (profileSettingsForm.ProfileSettingChanged) + { + ProfileRepository.SaveProfiles(); + } } } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/ProfileSettingsForm.Designer.cs b/DisplayMagician/UIForms/ProfileSettingsForm.Designer.cs index 1b5113b..a22b95c 100644 --- a/DisplayMagician/UIForms/ProfileSettingsForm.Designer.cs +++ b/DisplayMagician/UIForms/ProfileSettingsForm.Designer.cs @@ -86,6 +86,7 @@ namespace DisplayMagician.UIForms this.btn_select_wallpaper.TabIndex = 16; this.btn_select_wallpaper.Text = "&Select"; this.btn_select_wallpaper.UseVisualStyleBackColor = true; + this.btn_select_wallpaper.Click += new System.EventHandler(this.btn_select_wallpaper_Click); // // txt_wallpaper_filename // @@ -107,6 +108,7 @@ namespace DisplayMagician.UIForms this.cb_set_wallpaper.TabIndex = 14; this.cb_set_wallpaper.Text = "Set wallpaper when applying this profile"; this.cb_set_wallpaper.UseVisualStyleBackColor = true; + this.cb_set_wallpaper.CheckedChanged += new System.EventHandler(this.cb_set_wallpaper_CheckedChanged); // // label1 // @@ -123,10 +125,6 @@ namespace DisplayMagician.UIForms // this.cmb_wallpaper_display_mode.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmb_wallpaper_display_mode.FormattingEnabled = true; - this.cmb_wallpaper_display_mode.Items.AddRange(new object[] { - "Centered", - "Stretched", - "Tiled"}); this.cmb_wallpaper_display_mode.Location = new System.Drawing.Point(203, 108); this.cmb_wallpaper_display_mode.Name = "cmb_wallpaper_display_mode"; this.cmb_wallpaper_display_mode.Size = new System.Drawing.Size(219, 24); diff --git a/DisplayMagician/UIForms/ProfileSettingsForm.cs b/DisplayMagician/UIForms/ProfileSettingsForm.cs index 4d96d3e..4341f80 100644 --- a/DisplayMagician/UIForms/ProfileSettingsForm.cs +++ b/DisplayMagician/UIForms/ProfileSettingsForm.cs @@ -16,6 +16,7 @@ namespace DisplayMagician.UIForms private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private Dictionary wallpaperStyleText = new Dictionary(); + private bool _profileSettingChanged = false; public ProfileSettingsForm() { @@ -27,11 +28,10 @@ namespace DisplayMagician.UIForms wallpaperStyleText.Add(Wallpaper.Style.Centered, "Center the Wallpaper"); wallpaperStyleText.Add(Wallpaper.Style.Stretched, "Stretch the Wallpaper"); wallpaperStyleText.Add(Wallpaper.Style.Tiled, "Tile the Wallpaper"); - - // Now use it to populate the Style Dropdown - cmb_wallpaper_display_mode.Items.Clear(); - cmb_wallpaper_display_mode.Items.AddRange(wallpaperStyleText.Values.ToArray()); - cmb_wallpaper_display_mode.SelectedIndex = 0; + + cmb_wallpaper_display_mode.DisplayMember = "Value"; + cmb_wallpaper_display_mode.ValueMember = "Text"; + cmb_wallpaper_display_mode.DataSource = new BindingSource(wallpaperStyleText, null); } public ProfileItem Profile @@ -40,36 +40,63 @@ namespace DisplayMagician.UIForms set; } + public bool ProfileSettingChanged + { + get + { + return _profileSettingChanged; + } + set + { + _profileSettingChanged = value; + } + } + private void ProfileSettingsForm_Load(object sender, EventArgs e) { if (Profile.SetWallpaper) { logger.Info($"ProfileSettingsForm/ProfileSettingsForm_Load: Profile {Profile.Name} has loaded with Set Wallpaper enabled and Wallpaper Style {Profile.WallpaperStyle.ToString("G")} and Wallpaper Filename of {Profile.WallpaperBitmapFilename}."); + cb_set_wallpaper.Checked = true; cmb_wallpaper_display_mode.SelectedIndex = cmb_wallpaper_display_mode.FindStringExact(wallpaperStyleText[Profile.WallpaperStyle]); if (Profile.WallpaperBitmapFilename != "") { txt_wallpaper_filename.Text = Profile.WallpaperBitmapFilename; } } + else + { + cb_set_wallpaper.Checked = false; + } } private void ProfileSettingsForm_FormClosing(object sender, FormClosingEventArgs e) - { + { + Profile.SetWallpaper = cb_set_wallpaper.Checked; + Profile.WallpaperStyle = ((KeyValuePair)cmb_wallpaper_display_mode.SelectedItem).Key; + Profile.WallpaperBitmapFilename = txt_wallpaper_filename.Text; } private void btn_back_Click(object sender, EventArgs e) { - Profile.SetWallpaper = cb_set_wallpaper.Checked; - Profile.WallpaperStyle = (Wallpaper.Style)cmb_wallpaper_display_mode.SelectedValue; - Profile.WallpaperBitmapFilename = txt_wallpaper_filename.Text; this.Close(); } + private void cb_set_wallpaper_CheckedChanged(object sender, EventArgs e) + { + _profileSettingChanged = true; + } + private void cmb_wallpaper_display_mode_SelectedIndexChanged(object sender, EventArgs e) { + _profileSettingChanged = true; + } + private void btn_select_wallpaper_Click(object sender, EventArgs e) + { + _profileSettingChanged = true; } } }