From 4919aa9afda13ed74a3b87339ceee1d146aef355 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sun, 10 Oct 2021 17:33:54 +0200 Subject: [PATCH] [Feature] Fix warnings / clean code (#215), version 1.0.21.0 --- Business/Menus.cs | 10 +- Config/Config.cs | 26 ++- DataClasses/RowData.cs | 12 +- Helpers/DragDropHelper.cs | 18 +- Helpers/ImagingHelper.cs | 78 ++++----- Properties/AssemblyInfo.cs | 4 +- Properties/Resources.Designer.cs | 10 -- Properties/Resources.resx | 3 - Resources/search.ico | Bin 116323 -> 0 bytes UserInterface/AppNotifyIcon.cs | 10 +- .../HotkeyTextboxControl/HotkeyControl.cs | 6 +- UserInterface/Menu.cs | 3 +- UserInterface/SettingsForm.cs | 158 +++++++++--------- Utilities/File/FileLnk.cs | 2 +- Utilities/File/IconReader.cs | 2 - Utilities/Log.cs | 2 +- 16 files changed, 155 insertions(+), 189 deletions(-) delete mode 100644 Resources/search.ico diff --git a/Business/Menus.cs b/Business/Menus.cs index 0bb0560..f216975 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -206,12 +206,12 @@ namespace SystemTrayMenu.Business waitToOpenMenu.CloseMenu += CloseMenu; void CloseMenu(int level) { - if (level < menus.Count() && menus[level] != null) + if (level < menus.Length && menus[level] != null) { HideOldMenu(menus[level]); } - if (level - 1 < menus.Count() && menus[level - 1] != null) + if (level - 1 < menus.Length && menus[level - 1] != null) { menus[level - 1].FocusTextBox(); } @@ -571,7 +571,7 @@ namespace SystemTrayMenu.Business if (FileUrl.GetDefaultBrowserPath(out string browserPath)) { - IconReader.GetFileIconWithCache(browserPath, true, true, out bool loading); + IconReader.GetFileIconWithCache(browserPath, true, true, out _); } } @@ -612,7 +612,7 @@ namespace SystemTrayMenu.Business { string path = rowData.FileInfo.FullName; int directoryNameBegin = path.LastIndexOf(@"\", StringComparison.InvariantCulture) + 1; - rowData.SetText(path.Substring(directoryNameBegin)); + rowData.SetText(path[directoryNameBegin..]); } else { @@ -1054,7 +1054,7 @@ namespace SystemTrayMenu.Business searchTextChanging = false; // if any open menu close - if (menu.Level + 1 < menus.Count()) + if (menu.Level + 1 < menus.Length) { Menu menuToClose = menus[menu.Level + 1]; if (menuToClose != null) diff --git a/Config/Config.cs b/Config/Config.cs index 2ca6b47..640b47b 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -73,17 +73,15 @@ namespace SystemTrayMenu public static void SetFolderByUser(bool save = true) { - using (FolderDialog dialog = new FolderDialog()) - { - dialog.InitialFolder = Path; + using FolderDialog dialog = new FolderDialog(); + dialog.InitialFolder = Path; - if (dialog.ShowDialog() == DialogResult.OK) + if (dialog.ShowDialog() == DialogResult.OK) + { + Settings.Default.PathDirectory = dialog.Folder; + if (save) { - Settings.Default.PathDirectory = dialog.Folder; - if (save) - { - Settings.Default.Save(); - } + Settings.Default.Save(); } } } @@ -424,12 +422,10 @@ namespace SystemTrayMenu str = str.Replace("#585858", htmlColorCode); byteArray = Encoding.UTF8.GetBytes(str); - using (MemoryStream stream = new MemoryStream(byteArray)) - { - SvgDocument svgDocument = SvgDocument.Open(stream); - svgDocument.Color = new SvgColourServer(Color.Black); - return svgDocument.Draw(); - } + using MemoryStream stream = new MemoryStream(byteArray); + SvgDocument svgDocument = SvgDocument.Open(stream); + svgDocument.Color = new SvgColourServer(Color.Black); + return svgDocument.Draw(); } private static bool IsRegistryValueThisValue(string keyName, string valueName, string value) diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index e48af33..b923cc3 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -144,7 +144,7 @@ namespace SystemTrayMenu.DataClasses try { icon = IconReader.GetFileIconWithCache( - TargetFilePath, + TargetFilePathOrig, showOverlay, true, out bool loading); @@ -153,7 +153,7 @@ namespace SystemTrayMenu.DataClasses } catch (Exception ex) { - Log.Warn($"path:'{TargetFilePath}'", ex); + Log.Warn($"path:'{TargetFilePathOrig}'", ex); } } } @@ -235,14 +235,8 @@ namespace SystemTrayMenu.DataClasses showOverlay = true; } - string path = TargetFilePath; - if (ContainsMenu) - { - path = TargetFilePathOrig; - } - icon = IconReader.GetFileIconWithCache( - path, + TargetFilePathOrig, showOverlay, false, out bool loading); diff --git a/Helpers/DragDropHelper.cs b/Helpers/DragDropHelper.cs index 5ad739e..8bc47a6 100644 --- a/Helpers/DragDropHelper.cs +++ b/Helpers/DragDropHelper.cs @@ -96,16 +96,14 @@ namespace SystemTrayMenu.Helpers return value; } - using (StreamWriter writer = new StreamWriter(pathToStoreFile + "\\" + title.Trim() + ".url")) - { - writer.WriteLine("[InternetShortcut]"); - writer.WriteLine($"URL={url.TrimEnd('\0')}"); - writer.WriteLine("IconIndex=0"); - writer.WriteLine($"HotKey=0"); - writer.WriteLine($"IDList="); - writer.WriteLine($"IconFile={pathIcon}"); - writer.Flush(); - } + using StreamWriter writer = new StreamWriter(pathToStoreFile + "\\" + title.Trim() + ".url"); + writer.WriteLine("[InternetShortcut]"); + writer.WriteLine($"URL={url.TrimEnd('\0')}"); + writer.WriteLine("IconIndex=0"); + writer.WriteLine($"HotKey=0"); + writer.WriteLine($"IDList="); + writer.WriteLine($"IconFile={pathIcon}"); + writer.Flush(); } } } diff --git a/Helpers/ImagingHelper.cs b/Helpers/ImagingHelper.cs index 2a7f8db..b6b5cf1 100644 --- a/Helpers/ImagingHelper.cs +++ b/Helpers/ImagingHelper.cs @@ -42,56 +42,54 @@ namespace SystemTrayMenu.Helpers if (newBitmap != null) { // save the resized png into a memory stream for future use - using (MemoryStream memoryStream = new MemoryStream()) + using MemoryStream memoryStream = new MemoryStream(); + newBitmap.Save(memoryStream, ImageFormat.Png); + + BinaryWriter iconWriter = new BinaryWriter(output); + if (output != null && iconWriter != null) { - newBitmap.Save(memoryStream, ImageFormat.Png); + // 0-1 reserved, 0 + iconWriter.Write((byte)0); + iconWriter.Write((byte)0); - BinaryWriter iconWriter = new BinaryWriter(output); - if (output != null && iconWriter != null) - { - // 0-1 reserved, 0 - iconWriter.Write((byte)0); - iconWriter.Write((byte)0); + // 2-3 image type, 1 = icon, 2 = cursor + iconWriter.Write((short)1); - // 2-3 image type, 1 = icon, 2 = cursor - iconWriter.Write((short)1); + // 4-5 number of images + iconWriter.Write((short)1); - // 4-5 number of images - iconWriter.Write((short)1); + // image entry 1 + // 0 image width + iconWriter.Write((byte)width); - // image entry 1 - // 0 image width - iconWriter.Write((byte)width); + // 1 image height + iconWriter.Write((byte)height); - // 1 image height - iconWriter.Write((byte)height); + // 2 number of colors + iconWriter.Write((byte)0); - // 2 number of colors - iconWriter.Write((byte)0); + // 3 reserved + iconWriter.Write((byte)0); - // 3 reserved - iconWriter.Write((byte)0); + // 4-5 color planes + iconWriter.Write((short)0); - // 4-5 color planes - iconWriter.Write((short)0); + // 6-7 bits per pixel + iconWriter.Write((short)32); - // 6-7 bits per pixel - iconWriter.Write((short)32); + // 8-11 size of image data + iconWriter.Write((int)memoryStream.Length); - // 8-11 size of image data - iconWriter.Write((int)memoryStream.Length); + // 12-15 offset of image data + iconWriter.Write(6 + 16); - // 12-15 offset of image data - iconWriter.Write(6 + 16); + // write image data + // png data must contain the whole png data file + iconWriter.Write(memoryStream.ToArray()); - // write image data - // png data must contain the whole png data file - iconWriter.Write(memoryStream.ToArray()); + iconWriter.Flush(); - iconWriter.Flush(); - - return true; - } + return true; } } @@ -111,11 +109,9 @@ namespace SystemTrayMenu.Helpers /// Wether or not the icon was succesfully generated. public static bool ConvertToIcon(string inputPath, string outputPath, int size = 16, bool preserveAspectRatio = false) { - using (FileStream inputStream = new FileStream(inputPath, FileMode.Open)) - using (FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate)) - { - return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); - } + using FileStream inputStream = new FileStream(inputPath, FileMode.Open); + using FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate); + return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); } public static Image RotateImage(Image img, float rotationAngle) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 3350939..b119f4d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.20.5")] -[assembly: AssemblyFileVersion("1.0.20.5")] +[assembly: AssemblyVersion("1.0.21.0")] +[assembly: AssemblyFileVersion("1.0.21.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 8fd10b9..24e81c0 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -140,16 +140,6 @@ namespace SystemTrayMenu.Properties { } } - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// - public static System.Drawing.Icon search { - get { - object obj = ResourceManager.GetObject("search", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 6ede001..556eced 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -124,9 +124,6 @@ ..\Resources\SystemTrayMenu.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\search.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\ic_fluent_pin_48_filled.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 diff --git a/Resources/search.ico b/Resources/search.ico deleted file mode 100644 index 8f22a4f9f3a4d507ebaf56f7a7d206b0c170a211..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 116323 zcmeHQ30zFuAHQu{P!ZWHJ11i-WaLmq5oNvuAPs}tJE32&h?&=JqHCThGRVyn$qCCR{&jlw7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=i3AL&}n{AW0cNBqnyUZSjo1mJZgus z7*MtgTTw>#?qJ(+QqqP^C%;%wz7F{in7I^_1xoZ9%Vg1be;O2YkC}`djOH3 zA#8naiaIm~5YAi3UbdWkhhs}YF*yFy_w7)}97H}KtjJ!{ITG{~B-e8ml8w3pK{R%5 z01c5Pm(^9?6jNMgGiWL33g{&$5l=5t5Tz+NgQk39nAFrPqTh5Z17%rz1u)G20d7dg A#Q*>R diff --git a/UserInterface/AppNotifyIcon.cs b/UserInterface/AppNotifyIcon.cs index 51dbb85..10fed5c 100644 --- a/UserInterface/AppNotifyIcon.cs +++ b/UserInterface/AppNotifyIcon.cs @@ -111,12 +111,10 @@ namespace SystemTrayMenu.UserInterface { if (threadsLoading) { - rotationAngle = rotationAngle + 5; - using (Bitmap bitmapLoading = new Bitmap(ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle))) - { - DisposeIconIfNotDefaultIcon(); - notifyIcon.Icon = Icon.FromHandle(bitmapLoading.GetHicon()); - } + rotationAngle += 5; + using Bitmap bitmapLoading = new Bitmap(ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle)); + DisposeIconIfNotDefaultIcon(); + notifyIcon.Icon = Icon.FromHandle(bitmapLoading.GetHicon()); } else { diff --git a/UserInterface/HotkeyTextboxControl/HotkeyControl.cs b/UserInterface/HotkeyTextboxControl/HotkeyControl.cs index a58f7a0..6caeb2a 100644 --- a/UserInterface/HotkeyTextboxControl/HotkeyControl.cs +++ b/UserInterface/HotkeyTextboxControl/HotkeyControl.cs @@ -393,7 +393,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl return "* " + keyString; } - keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString.Substring(1).ToLowerInvariant(); + keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString[1..].ToLowerInvariant(); } return keyString + " *"; @@ -406,7 +406,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl return "/ " + keyString; } - keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString.Substring(1).ToLowerInvariant(); + keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString[1..].ToLowerInvariant(); } return keyString + " /"; @@ -444,7 +444,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl string visibleName = keyName.ToString(); if (visibleName.Length > 1) { - visibleName = visibleName.Substring(0, 1) + visibleName.Substring(1).ToLowerInvariant(); + visibleName = visibleName.Substring(0, 1) + visibleName[1..].ToLowerInvariant(); } return visibleName; diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 5a7fddb..af43fbe 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -18,7 +18,6 @@ namespace SystemTrayMenu.UserInterface internal partial class Menu : Form { private static readonly Icon LoadingIcon = Properties.Resources.Loading; - private static readonly Icon Search = Properties.Resources.search; private readonly Fading fading = new Fading(); private bool isShowing; private bool directionToRight; @@ -789,7 +788,7 @@ namespace SystemTrayMenu.UserInterface private void LoadingMenu_Paint(object sender, PaintEventArgs e) { PictureBox pictureBox = (PictureBox)sender; - rotationAngle = rotationAngle + 5; + rotationAngle += 5; e.Graphics.DrawImage( ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle), new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2))); diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index 2b92fec..80c571d 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -256,7 +256,7 @@ namespace SystemTrayMenu.UserInterface decimal newValue = numericUpDownSizeInPercentage.Value; if (e.Delta > 0) { - newValue = newValue + numericUpDownSizeInPercentage.Increment; + newValue += numericUpDownSizeInPercentage.Increment; if (newValue > numericUpDownSizeInPercentage.Maximum) { newValue = (int)numericUpDownSizeInPercentage.Maximum; @@ -264,7 +264,7 @@ namespace SystemTrayMenu.UserInterface } else { - newValue = newValue - numericUpDownSizeInPercentage.Increment; + newValue -= numericUpDownSizeInPercentage.Increment; if (newValue < numericUpDownSizeInPercentage.Minimum) { newValue = (int)numericUpDownSizeInPercentage.Minimum; @@ -473,6 +473,83 @@ namespace SystemTrayMenu.UserInterface return success; } + private static void AdjustControlMultilineIfNecessary(Control control) + { + if (control.Width > control.Parent.Width) + { + control.MaximumSize = new Size(control.Parent.Width, 0); + control.MinimumSize = new Size(0, control.Height * 2); + } + } + + private static void AddPossibilityToSelectFolderByWindowsContextMenu() + { + RegistryKey registryKeyContextMenu = null; + RegistryKey registryKeyContextMenuCommand = null; + + try + { + registryKeyContextMenu = Registry.CurrentUser.CreateSubKey(MenuName); + string binLocation = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; + if (registryKeyContextMenu != null) + { + registryKeyContextMenu.SetValue(string.Empty, Translator.GetText("Set as SystemTrayMenu folder")); + registryKeyContextMenu.SetValue("Icon", binLocation); + } + + registryKeyContextMenuCommand = Registry.CurrentUser.CreateSubKey(Command); + + if (registryKeyContextMenuCommand != null) + { + registryKeyContextMenuCommand.SetValue(string.Empty, binLocation + " \"%1\""); + } + + Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = true; + } + catch (Exception ex) + { + Log.Warn("SavePossibilityToSelectFolderByWindowsContextMenu failed", ex); + } + finally + { + if (registryKeyContextMenu != null) + { + registryKeyContextMenu.Close(); + } + + if (registryKeyContextMenuCommand != null) + { + registryKeyContextMenuCommand.Close(); + } + } + } + + private static void RemovePossibilityToSelectFolderByWindowsContextMenu() + { + try + { + RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(Command); + if (registryKey != null) + { + registryKey.Close(); + Registry.CurrentUser.DeleteSubKey(Command); + } + + registryKey = Registry.CurrentUser.OpenSubKey(MenuName); + if (registryKey != null) + { + registryKey.Close(); + Registry.CurrentUser.DeleteSubKey(MenuName); + } + + Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = false; + } + catch (Exception ex) + { + Log.Warn("DeletePossibilityToSelectFolderByWindowsContextMenu failed", ex); + } + } + private void SettingsForm_Load(object sender, EventArgs e) { AdjustControlMultilineIfNecessary(checkBoxStayOpenWhenFocusLost); @@ -482,15 +559,6 @@ namespace SystemTrayMenu.UserInterface tableLayoutPanelGeneral.Size.Height + 50); } - private void AdjustControlMultilineIfNecessary(Control control) - { - if (control.Width > control.Parent.Width) - { - control.MaximumSize = new Size(control.Parent.Width, 0); - control.MinimumSize = new Size(0, control.Height * 2); - } - } - private void ButtonOk_Click(object sender, EventArgs e) { Settings.Default.UseIconFromRootFolder = @@ -573,74 +641,6 @@ namespace SystemTrayMenu.UserInterface Close(); } - private void AddPossibilityToSelectFolderByWindowsContextMenu() - { - RegistryKey registryKeyContextMenu = null; - RegistryKey registryKeyContextMenuCommand = null; - - try - { - registryKeyContextMenu = Registry.CurrentUser.CreateSubKey(MenuName); - string binLocation = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; - if (registryKeyContextMenu != null) - { - registryKeyContextMenu.SetValue(string.Empty, Translator.GetText("Set as SystemTrayMenu folder")); - registryKeyContextMenu.SetValue("Icon", binLocation); - } - - registryKeyContextMenuCommand = Registry.CurrentUser.CreateSubKey(Command); - - if (registryKeyContextMenuCommand != null) - { - registryKeyContextMenuCommand.SetValue(string.Empty, binLocation + " \"%1\""); - } - - Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = true; - } - catch (Exception ex) - { - Log.Warn("SavePossibilityToSelectFolderByWindowsContextMenu failed", ex); - } - finally - { - if (registryKeyContextMenu != null) - { - registryKeyContextMenu.Close(); - } - - if (registryKeyContextMenuCommand != null) - { - registryKeyContextMenuCommand.Close(); - } - } - } - - private void RemovePossibilityToSelectFolderByWindowsContextMenu() - { - try - { - RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(Command); - if (registryKey != null) - { - registryKey.Close(); - Registry.CurrentUser.DeleteSubKey(Command); - } - - registryKey = Registry.CurrentUser.OpenSubKey(MenuName); - if (registryKey != null) - { - registryKey.Close(); - Registry.CurrentUser.DeleteSubKey(MenuName); - } - - Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = false; - } - catch (Exception ex) - { - Log.Warn("DeletePossibilityToSelectFolderByWindowsContextMenu failed", ex); - } - } - private void ButtonHotkeyDefault_Click(object sender, EventArgs e) { textBoxHotkey.SetHotkey("Ctrl+LWin"); diff --git a/Utilities/File/FileLnk.cs b/Utilities/File/FileLnk.cs index b1ca89f..23ac8ed 100644 --- a/Utilities/File/FileLnk.cs +++ b/Utilities/File/FileLnk.cs @@ -38,7 +38,7 @@ namespace SystemTrayMenu.Utilities public static bool IsNetworkRoot(string path) { return path.StartsWith(@"\\", StringComparison.InvariantCulture) && - !path.Substring(2).Contains(@"\", StringComparison.InvariantCulture); + !path[2..].Contains(@"\", StringComparison.InvariantCulture); } public static bool PingHost(string nameOrAddress) diff --git a/Utilities/File/IconReader.cs b/Utilities/File/IconReader.cs index bc8b004..4ccb93e 100644 --- a/Utilities/File/IconReader.cs +++ b/Utilities/File/IconReader.cs @@ -101,7 +101,6 @@ namespace SystemTrayMenu.Utilities return icon; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")] public static Icon GetFolderIconSTA( string directoryPath, FolderType folderType, @@ -210,7 +209,6 @@ namespace SystemTrayMenu.Utilities return isExtensionWithSameIcon; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")] private static Icon GetFileIconSTA(string filePath, bool linkOverlay, IconSize size = IconSize.Small) { Icon icon = null; diff --git a/Utilities/Log.cs b/Utilities/Log.cs index 0819902..93a22dd 100644 --- a/Utilities/Log.cs +++ b/Utilities/Log.cs @@ -110,7 +110,7 @@ namespace SystemTrayMenu.Utilities if (ex.Message == "The system cannot find the file specified.") { new Thread(ShowProblemWithShortcut).Start(); - void ShowProblemWithShortcut() + static void ShowProblemWithShortcut() { _ = MessageBox.Show( Translator.GetText("The item that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly."),