From f14aac14a954a22c3f4c2343f34f528a6a723856 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Wed, 28 Dec 2022 11:12:33 +0800 Subject: [PATCH] perf: rename (un)topmost --- .../Button_Default/{lock.png => topmost.png} | Bin .../{unlock.png => untopmost.png} | Bin STranslate/MainWindow.xaml.cs | 12 ++++----- STranslate/Properties/Resources.Designer.cs | 24 +++++++++--------- STranslate/Properties/Resources.resx | 10 ++++---- STranslate/STranslate.csproj | 4 +-- 6 files changed, 25 insertions(+), 25 deletions(-) rename STranslate/Images/Button_Default/{lock.png => topmost.png} (100%) rename STranslate/Images/Button_Default/{unlock.png => untopmost.png} (100%) diff --git a/STranslate/Images/Button_Default/lock.png b/STranslate/Images/Button_Default/topmost.png similarity index 100% rename from STranslate/Images/Button_Default/lock.png rename to STranslate/Images/Button_Default/topmost.png diff --git a/STranslate/Images/Button_Default/unlock.png b/STranslate/Images/Button_Default/untopmost.png similarity index 100% rename from STranslate/Images/Button_Default/unlock.png rename to STranslate/Images/Button_Default/untopmost.png diff --git a/STranslate/MainWindow.xaml.cs b/STranslate/MainWindow.xaml.cs index 6b98f57..335b73b 100644 --- a/STranslate/MainWindow.xaml.cs +++ b/STranslate/MainWindow.xaml.cs @@ -101,7 +101,7 @@ namespace STranslate this.Hide(); //取消置顶 - vm.TopImgSource = UnLockImgPath; + vm.TopImgSource = _UnTopmost; } //置顶 Ctrl+Shift+T if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) @@ -174,7 +174,7 @@ namespace STranslate /// private void Window_Deactivated(object sender, EventArgs e) { - if (vm.TopImgSource == UnLockImgPath) + if (vm.TopImgSource == _UnTopmost) { this.Hide(); } @@ -259,7 +259,7 @@ namespace STranslate /// private void Top_Click(object sender, RoutedEventArgs e) { - vm.TopImgSource = vm.TopImgSource == LockImgPath ? UnLockImgPath : LockImgPath; + vm.TopImgSource = vm.TopImgSource == _Topmost ? _UnTopmost : _Topmost; } /// /// 退出 @@ -274,13 +274,13 @@ namespace STranslate } private void InitView() { - vm.TopImgSource = UnLockImgPath; + vm.TopImgSource = _UnTopmost; this.Activate(); this.TextBoxInput.Focus(); } - private BitmapImage LockImgPath = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/lock.png")); - private BitmapImage UnLockImgPath = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/unlock.png")); + private static readonly BitmapImage _Topmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/topmost.png")); + private static readonly BitmapImage _UnTopmost = new BitmapImage(new Uri("pack://application:,,,/STranslate;component/Images/Button_Default/untopmost.png")); private System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon(); } } \ No newline at end of file diff --git a/STranslate/Properties/Resources.Designer.cs b/STranslate/Properties/Resources.Designer.cs index e0d0fe9..d1d0166 100644 --- a/STranslate/Properties/Resources.Designer.cs +++ b/STranslate/Properties/Resources.Designer.cs @@ -60,16 +60,6 @@ namespace STranslate.Properties { } } - /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 - /// - internal static System.Drawing.Bitmap _lock { - get { - object obj = ResourceManager.GetObject("_lock", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// @@ -140,6 +130,16 @@ namespace STranslate.Properties { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap topmost { + get { + object obj = ResourceManager.GetObject("topmost", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 /// @@ -153,9 +153,9 @@ namespace STranslate.Properties { /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// - internal static System.Drawing.Bitmap unlock { + internal static System.Drawing.Bitmap untopmost { get { - object obj = ResourceManager.GetObject("unlock", resourceCulture); + object obj = ResourceManager.GetObject("untopmost", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/STranslate/Properties/Resources.resx b/STranslate/Properties/Resources.resx index 4d0554b..a67d5b1 100644 --- a/STranslate/Properties/Resources.resx +++ b/STranslate/Properties/Resources.resx @@ -139,16 +139,16 @@ ..\images\tray\screenshot.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\images\button_default\topmost.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\images\translate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\images\button_default\unlock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\images\button_default\untopmost.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\images\tray\window.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\images\button_default\lock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj index 6cc0289..551891a 100644 --- a/STranslate/STranslate.csproj +++ b/STranslate/STranslate.csproj @@ -153,10 +153,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest