From c41779281e22d194528972e9c74dd489d2e291c8 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Sat, 25 Apr 2026 20:42:00 -0400 Subject: [PATCH] Format Options dialog: split PascalCase parameter names; suppress spurious dirty state - Show "Keyword Casing" instead of "KeywordCasing" in the Parameter column - Row setters were firing PropertyChanged unconditionally; TwoWay bindings on ToggleSwitch / ComboBox write the bound value back during DataGrid row materialization (post-virtualization), tripping the dirty flag without any user action. Setters now compare and short-circuit when the value is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Dialogs/FormatOptionsWindow.axaml.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/PlanViewer.App/Dialogs/FormatOptionsWindow.axaml.cs b/src/PlanViewer.App/Dialogs/FormatOptionsWindow.axaml.cs index 0e4e24a..60cb457 100644 --- a/src/PlanViewer.App/Dialogs/FormatOptionsWindow.axaml.cs +++ b/src/PlanViewer.App/Dialogs/FormatOptionsWindow.axaml.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Text; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Interactivity; @@ -44,6 +45,19 @@ public FormatOptionsWindow() "NewLineBeforeWhereClause", "NewLineBeforeWindowClause", ]; + private static string SplitPascalCase(string name) + { + var sb = new StringBuilder(name.Length + 8); + for (int i = 0; i < name.Length; i++) + { + var c = name[i]; + if (i > 0 && char.IsUpper(c) && !char.IsUpper(name[i - 1])) + sb.Append(' '); + sb.Append(c); + } + return sb.ToString(); + } + private static readonly Dictionary ChoiceOptionsMap = new() { ["KeywordCasing"] = ["Uppercase", "Lowercase", "PascalCase"], @@ -73,7 +87,7 @@ private void LoadSettings() _rows.Add(new FormatOptionRow { - Name = prop.Name, + Name = SplitPascalCase(prop.Name), CurrentValue = currentVal?.ToString() ?? "", DefaultValue = defaultVal?.ToString() ?? "", IsBool = isBool, @@ -289,6 +303,7 @@ public bool BoolValue get => _boolValue; set { + if (_boolValue == value) return; _boolValue = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BoolValue))); // Keep CurrentValue in sync for serialization @@ -313,6 +328,7 @@ public string CurrentValue get => _currentValue; set { + if (_currentValue == value) return; _currentValue = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentValue))); }