From b05c82e903ed684a8b4e61873bd3faf18f7d744f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 21 Nov 2024 11:49:14 -0500 Subject: [PATCH] Remove usages of `this.` from UI code --- CHANGELIST.md | 1 + MPF.UI/UserControls/LogOutput.xaml.cs | 8 ++++---- MPF.UI/Windows/CheckDumpWindow.xaml.cs | 2 +- MPF.UI/Windows/MainWindow.xaml.cs | 16 ++++++++-------- MPF.UI/Windows/OptionsWindow.xaml.cs | 2 +- MPF.UI/Windows/WindowBase.cs | 6 +++--- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 83cc1ad0..46fe42af 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -16,6 +16,7 @@ - Use expanded version of split regex - Update packages for bugfixes - Fix minor efficiency issues +- Remove usages of `this.` from UI code ### 3.2.3 (2024-11-06) diff --git a/MPF.UI/UserControls/LogOutput.xaml.cs b/MPF.UI/UserControls/LogOutput.xaml.cs index fc6f1f6b..71533398 100644 --- a/MPF.UI/UserControls/LogOutput.xaml.cs +++ b/MPF.UI/UserControls/LogOutput.xaml.cs @@ -107,8 +107,8 @@ namespace MPF.UI.UserControls public LogLine(string text, LogLevel logLevel) { - this.Text = text; - this.LogLevel = logLevel; + Text = text; + LogLevel = logLevel; } /// @@ -117,7 +117,7 @@ namespace MPF.UI.UserControls /// Brush representing the color public Brush GetForegroundColor() { - return this.LogLevel switch + return LogLevel switch { LogLevel.SECRET => Brushes.Blue, LogLevel.ERROR => Brushes.Red, @@ -132,7 +132,7 @@ namespace MPF.UI.UserControls /// Run object based on internal values public Run GenerateRun() { - return new Run { Text = this.Text, Foreground = GetForegroundColor() }; + return new Run { Text = Text, Foreground = GetForegroundColor() }; } } diff --git a/MPF.UI/Windows/CheckDumpWindow.xaml.cs b/MPF.UI/Windows/CheckDumpWindow.xaml.cs index 7239ce97..53899177 100644 --- a/MPF.UI/Windows/CheckDumpWindow.xaml.cs +++ b/MPF.UI/Windows/CheckDumpWindow.xaml.cs @@ -192,7 +192,7 @@ namespace MPF.UI.Windows WindowStartupLocation = WindowStartupLocation.CenterOwner, }; - discInformationWindow.Closed += delegate { this.Activate(); }; + discInformationWindow.Closed += delegate { Activate(); }; bool? result = discInformationWindow.ShowDialog(); // Copy back the submission info changes, if necessary diff --git a/MPF.UI/Windows/MainWindow.xaml.cs b/MPF.UI/Windows/MainWindow.xaml.cs index 43ae4ee8..cdd95bad 100644 --- a/MPF.UI/Windows/MainWindow.xaml.cs +++ b/MPF.UI/Windows/MainWindow.xaml.cs @@ -310,7 +310,7 @@ namespace MPF.UI.Windows WindowStartupLocation = WindowStartupLocation.CenterOwner, }; - discInformationWindow.Closed += delegate { this.Activate(); }; + discInformationWindow.Closed += delegate { Activate(); }; bool? result = discInformationWindow.ShowDialog(); // Copy back the submission info changes, if necessary @@ -326,7 +326,7 @@ namespace MPF.UI.Windows public void ShowCheckDumpWindow() { // Hide MainWindow while Check GUI is open - this.Hide(); + Hide(); var checkDumpWindow = new CheckDumpWindow(this) { @@ -340,8 +340,8 @@ namespace MPF.UI.Windows checkDumpWindow.Closed += delegate { // Unhide Main window after Check window has been closed - this.Show(); - this.Activate(); + Show(); + Activate(); }; checkDumpWindow.Show(); } @@ -352,7 +352,7 @@ namespace MPF.UI.Windows public void ShowCreateIRDWindow() { // Hide MainWindow while Create IRD UI is open - this.Hide(); + Hide(); var createIRDWindow = new CreateIRDWindow(this) { @@ -366,8 +366,8 @@ namespace MPF.UI.Windows createIRDWindow.Closed += delegate { // Unhide Main window after Create IRD window has been closed - this.Show(); - this.Activate(); + Show(); + Activate(); }; createIRDWindow.Show(); } @@ -387,7 +387,7 @@ namespace MPF.UI.Windows WindowStartupLocation = WindowStartupLocation.CenterOwner, }; - optionsWindow.Closed += delegate { this.Activate(); }; + optionsWindow.Closed += delegate { Activate(); }; optionsWindow.Closed += OnOptionsUpdated; optionsWindow.Show(); } diff --git a/MPF.UI/Windows/OptionsWindow.xaml.cs b/MPF.UI/Windows/OptionsWindow.xaml.cs index e7131509..452a3ad1 100644 --- a/MPF.UI/Windows/OptionsWindow.xaml.cs +++ b/MPF.UI/Windows/OptionsWindow.xaml.cs @@ -102,7 +102,7 @@ namespace MPF.UI.Windows base.OnContentRendered(e); // Set the window title - OptionsViewModel.Title = this.Title; + OptionsViewModel.Title = Title; } #region UI Commands diff --git a/MPF.UI/Windows/WindowBase.cs b/MPF.UI/Windows/WindowBase.cs index ccc83fa9..5bc3eb01 100644 --- a/MPF.UI/Windows/WindowBase.cs +++ b/MPF.UI/Windows/WindowBase.cs @@ -14,7 +14,7 @@ namespace MPF.UI.Windows { try { - this.DialogResult = false; + DialogResult = false; } catch { } @@ -26,7 +26,7 @@ namespace MPF.UI.Windows /// public void MinimizeButtonClick(object sender, RoutedEventArgs e) { - this.WindowState = WindowState.Minimized; + WindowState = WindowState.Minimized; } /// @@ -35,7 +35,7 @@ namespace MPF.UI.Windows public void TitleMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) - this.DragMove(); + DragMove(); } #endregion