From e8d7057c2f34c2d239e775d9fe4ede7f0d956f38 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 11 Oct 2018 17:19:09 -0700 Subject: [PATCH] Make the codeListView column-width setting work like the others Don't serialize on every column change, just mark app settings as "dirty" and box it up before writing the settings file. --- SourceGen/AppForms/EditAppSettings.cs | 2 +- SourceGen/AppForms/ProjectView.cs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/SourceGen/AppForms/EditAppSettings.cs b/SourceGen/AppForms/EditAppSettings.cs index baf55a8..e2ec8b7 100644 --- a/SourceGen/AppForms/EditAppSettings.cs +++ b/SourceGen/AppForms/EditAppSettings.cs @@ -82,7 +82,7 @@ namespace SourceGen.AppForms { mInitialTab = initialTab; // Make a work copy, so we can discard changes if the user cancels out of the dialog. - projectView.SaveCodeListColumnWidths(); + projectView.SerializeCodeListColumnWidths(); mSettings = AppSettings.Global.GetCopy(); // Put buttons in an array. diff --git a/SourceGen/AppForms/ProjectView.cs b/SourceGen/AppForms/ProjectView.cs index 4fb3934..5a3e201 100644 --- a/SourceGen/AppForms/ProjectView.cs +++ b/SourceGen/AppForms/ProjectView.cs @@ -402,6 +402,7 @@ namespace SourceGen.AppForms { AppSettings.Global.SetBool(AppSettings.MAIN_WINDOW_MAXIMIZED, false); } + SerializeCodeListColumnWidths(); SerializeReferencesColumnWidths(); SerializeNotesColumnWidths(); SerializeSymbolColumnWidths(); @@ -3369,7 +3370,7 @@ namespace SourceGen.AppForms { /// Saves the code list column widths into AppSettings. /// /// - public void SaveCodeListColumnWidths() { + public void SerializeCodeListColumnWidths() { CodeListColumnWidths widths = new CodeListColumnWidths(); for (int i = 0; i < CodeListColumnWidths.NUM_COLUMNS; i++) { widths.Width[i] = codeListView.Columns[i].Width; @@ -3391,11 +3392,7 @@ namespace SourceGen.AppForms { private void codeListView_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e) { - //Debug.WriteLine("Column width changed: " + e.ColumnIndex); - // This fires during initial setup when things don't have widths. A little - // risky to save the widths off now; would be safer to do it right before we write - // the settings file. - SaveCodeListColumnWidths(); + AppSettings.Global.Dirty = true; } private void codeListView_DrawColumnHeader(object sender,