mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixed ProfileSettingsForm logic
This commit is contained in:
parent
93c85d7d87
commit
bb1fa73c7f
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -16,6 +16,7 @@ namespace DisplayMagician.UIForms
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
private Dictionary<Wallpaper.Style, string> wallpaperStyleText = new Dictionary<Wallpaper.Style, string>();
|
||||
private bool _profileSettingChanged = false;
|
||||
|
||||
public ProfileSettingsForm()
|
||||
{
|
||||
@ -28,10 +29,9 @@ namespace DisplayMagician.UIForms
|
||||
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<Wallpaper.Style, string>)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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user