Fix profile selection issues

Fixed the profiles selection so it doesn't change
when you swap screens. Made the 'View
current display' button refresh the profile validity
too, so that a user now only has to change their
display settings in Windows and then swap back
DisplayMagician and click the View Current Display
button and the profiles will be updated.
This commit is contained in:
Terry MacDonald 2021-03-05 10:34:51 +13:00
parent fad79cd315
commit f22450b9a0
5 changed files with 32 additions and 15 deletions

View File

@ -166,11 +166,11 @@ namespace DisplayMagician.UIForms
this.btn_view_current.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_view_current.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_view_current.ForeColor = System.Drawing.Color.White;
this.btn_view_current.Location = new System.Drawing.Point(796, 12);
this.btn_view_current.Location = new System.Drawing.Point(712, 12);
this.btn_view_current.Name = "btn_view_current";
this.btn_view_current.Size = new System.Drawing.Size(168, 39);
this.btn_view_current.Size = new System.Drawing.Size(252, 39);
this.btn_view_current.TabIndex = 6;
this.btn_view_current.Text = "View &Current";
this.btn_view_current.Text = "View &Current Display";
this.btn_view_current.UseVisualStyleBackColor = true;
this.btn_view_current.Click += new System.EventHandler(this.btn_view_current_Click);
//
@ -328,8 +328,7 @@ namespace DisplayMagician.UIForms
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "DisplayMagician - Setup Display Profiles";
this.Activated += new System.EventHandler(this.DisplayProfileForm_Activated);
this.Text = "DisplayMagician - Display Profiles";
this.Load += new System.EventHandler(this.DisplayProfileForm_Load);
this.menu_profiles.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).EndInit();

View File

@ -51,7 +51,6 @@ namespace DisplayMagician.UIForms
}
// Apply the Profile
//ProfileRepository.ApplyProfile(_selectedProfile);
Program.ApplyProfile(_selectedProfile);
}
@ -120,21 +119,36 @@ namespace DisplayMagician.UIForms
// To stop the display showing all sorts of changes happening
ilv_saved_profiles.SuspendLayout();
// Figure out if anything is selected at the moment
// and if it is save it to reselect it after the refresh
// We only take the first as there is only one thing selected at a time
/*string lastSelectedItemName = "";
if (ilv_saved_profiles.SelectedItems.Count > 0)
lastSelectedItemName = ilv_saved_profiles.SelectedItems[0].Text;
*/
// Empty the imageListView
ilv_saved_profiles.Items.Clear();
profileValidity.Clear();
//IOrderedEnumerable<ProfileItem> orderedProfiles = ProfileRepository.AllProfiles.OrderBy(p => p.Name);
// Check if the last selected profile is still in the list of profiles
//bool lastSelectedItemStillThere = (from profile in orderedProfiles select profile.Name).Contains(lastSelectedItemName);
// Fill it back up with the Profiles we have
foreach (ProfileItem profile in ProfileRepository.AllProfiles.OrderBy(p=>p.Name))
foreach (ProfileItem profile in ProfileRepository.AllProfiles.OrderBy(p => p.Name))
{
// Create a new ImageListViewItem from the profile
newItem = new ImageListViewItem(profile, profile.Name);
// Select it if its the selectedProfile
// if the item was removed from the list during this
// list refresh, then we select this profile only if it
// is the currently used Profile
if (_selectedProfile is ProfileItem && _selectedProfile.Equals(profile))
newItem.Selected = true;
profileValidity[profile.Name] = profile.IsPossible;
// Add it to the list!
@ -147,7 +161,7 @@ namespace DisplayMagician.UIForms
}
private void DisplayProfileForm_Activated(object sender, EventArgs e)
/*private void DisplayProfileForm_Activated(object sender, EventArgs e)
{
// We handle the UI updating in DisplayProfileForm_Activated so that
// the app will check for changes to the current profile when the
@ -159,11 +173,14 @@ namespace DisplayMagician.UIForms
ChangeSelectedProfile(ProfileRepository.CurrentProfile);
// Refresh the Profile UI
RefreshDisplayProfileUI();
}
}*/
private void DisplayProfileForm_Load(object sender, EventArgs e)
{
// Refresh the profiles to see whats valid
ProfileRepository.IsPossibleRefresh();
// Update the Current Profile
ProfileRepository.UpdateActiveProfile();
@ -341,8 +358,9 @@ namespace DisplayMagician.UIForms
private void btn_view_current_Click(object sender, EventArgs e)
{
// Reload the profiles in case we swapped to another program to change it
//ProfileRepository.UpdateCurrentProfile();
ProfileRepository.GetActiveProfile();
// Refresh the profiles to see whats valid
ProfileRepository.IsPossibleRefresh();
// Change to the current selected Profile
ChangeSelectedProfile(ProfileRepository.GetActiveProfile());
// Refresh the Profile UI

View File

@ -304,7 +304,7 @@ namespace DisplayMagician.UIForms
using (Pen pSelectedBorder = new Pen(Color.Brown, 4))
{
//DrawRoundedRectangle(g, pSelectedBorder, bounds, 9);
Utility.DrawRoundedRectangle(g, pSelectedBorder, imageBounds.Left + 3, imageBounds.Top + 3, imageBounds.Width - 5, imageBounds.Height - 5, 10);
Utility.DrawRoundedRectangle(g, pSelectedBorder, imageBounds.Left + 1, imageBounds.Top + 1, imageBounds.Width, imageBounds.Height, 10);
}
}
}

View File

@ -268,7 +268,7 @@
this.Name = "ShortcutLibraryForm";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "DisplayMagician - Setup Game Shortcuts";
this.Text = "DisplayMagician - Game Shortcuts";
this.Activated += new System.EventHandler(this.ShortcutLibraryForm_Activated);
this.Load += new System.EventHandler(this.ShortcutLibraryForm_Load);
this.cms_shortcuts.ResumeLayout(false);

View File

@ -673,7 +673,7 @@ namespace DisplayMagicianShared
}
}
public static void IsPossibleRefresh ()
public static void IsPossibleRefresh()
{
// We need to refresh the cached answer
// Get the list of connected devices