From c0351a534d691c42562ad0b3a7504a4d54c393a5 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Fri, 10 Dec 2021 15:20:24 +0100 Subject: [PATCH] [Feature] Generate shortcuts to drives (#259), version 1.1.2.4 --- Business/Menus.cs | 5 ++ Properties/AssemblyInfo.cs | 4 +- Properties/Settings.Designer.cs | 16 ++++++ Resources/lang.Designer.cs | 9 +++ Resources/lang.cs-CZ.resx | 3 + Resources/lang.de-DE.resx | 3 + Resources/lang.es-ES.resx | 3 + Resources/lang.fa-IR.resx | 3 + Resources/lang.fr-FR.resx | 3 + Resources/lang.it-IT.resx | 3 + Resources/lang.ja-JP.resx | 3 + Resources/lang.ko-KR.resx | 3 + Resources/lang.nl-NL.resx | 3 + Resources/lang.pt-BR.resx | 3 + Resources/lang.resx | 3 + Resources/lang.ru-RU.resx | 3 + Resources/lang.tr-TR.resx | 3 + Resources/lang.vi-VN.resx | 3 + Resources/lang.zh-CN.resx | 3 + UserInterface/SettingsForm.Designer.cs | 79 +++++++++++++++----------- UserInterface/SettingsForm.cs | 4 ++ Utilities/GenerateDriveShortcuts.cs | 50 ++++++++++++++++ 22 files changed, 178 insertions(+), 34 deletions(-) create mode 100644 Utilities/GenerateDriveShortcuts.cs diff --git a/Business/Menus.cs b/Business/Menus.cs index 241ac9e..7771e23 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -693,6 +693,11 @@ namespace SystemTrayMenu.Business level = rowData.MenuLevel + 1; } + if (Properties.Settings.Default.GenerateShortcutsToDrives) + { + GenerateDriveShortcuts.Start(); + } + MenuData menuData = GetData((BackgroundWorker)senderDoWork, path, level); menuData.RowDataParent = rowData; eDoWork.Result = menuData; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index d9ff304..3ad6de1 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.1.2.3")] -[assembly: AssemblyFileVersion("1.1.2.3")] +[assembly: AssemblyVersion("1.1.2.4")] +[assembly: AssemblyFileVersion("1.1.2.4")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index c260ec7..0733530 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -187,6 +187,22 @@ namespace SystemTrayMenu.Properties } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("false")] + public bool GenerateShortcutsToDrives + { + get + { + return ((bool)(this["GenerateShortcutsToDrives"])); + } + set + { + this["GenerateShortcutsToDrives"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] diff --git a/Resources/lang.Designer.cs b/Resources/lang.Designer.cs index 9a6a629..357bf22 100644 --- a/Resources/lang.Designer.cs +++ b/Resources/lang.Designer.cs @@ -456,6 +456,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Generate shortcuts to drives. + /// + internal static string Generate_shortcuts_to_drives { + get { + return ResourceManager.GetString("Generate shortcuts to drives", resourceCulture); + } + } + /// /// Looks up a localized string similar to Help / FAQ. /// diff --git a/Resources/lang.cs-CZ.resx b/Resources/lang.cs-CZ.resx index f9e63bb..e4bdbbb 100644 --- a/Resources/lang.cs-CZ.resx +++ b/Resources/lang.cs-CZ.resx @@ -417,4 +417,7 @@ elementy + + Vygenerujte zástupce jednotek + \ No newline at end of file diff --git a/Resources/lang.de-DE.resx b/Resources/lang.de-DE.resx index e54a51f..dbc104c 100644 --- a/Resources/lang.de-DE.resx +++ b/Resources/lang.de-DE.resx @@ -417,4 +417,7 @@ Elemente + + Verknüpfungen zu Laufwerken erstellen + \ No newline at end of file diff --git a/Resources/lang.es-ES.resx b/Resources/lang.es-ES.resx index dafb98f..6d36efd 100644 --- a/Resources/lang.es-ES.resx +++ b/Resources/lang.es-ES.resx @@ -417,4 +417,7 @@ elementos + + Generar accesos directos a las unidades + \ No newline at end of file diff --git a/Resources/lang.fa-IR.resx b/Resources/lang.fa-IR.resx index 4f15d23..ffbb43c 100644 --- a/Resources/lang.fa-IR.resx +++ b/Resources/lang.fa-IR.resx @@ -417,4 +417,7 @@ عناصر + + ایجاد میانبر برای درایوها + \ No newline at end of file diff --git a/Resources/lang.fr-FR.resx b/Resources/lang.fr-FR.resx index 016a149..6a91f53 100644 --- a/Resources/lang.fr-FR.resx +++ b/Resources/lang.fr-FR.resx @@ -417,4 +417,7 @@ éléments + + Générer des raccourcis vers les lecteurs + \ No newline at end of file diff --git a/Resources/lang.it-IT.resx b/Resources/lang.it-IT.resx index af8d3c2..2a7c56a 100644 --- a/Resources/lang.it-IT.resx +++ b/Resources/lang.it-IT.resx @@ -417,4 +417,7 @@ elementi + + Genera collegamenti alle unità + \ No newline at end of file diff --git a/Resources/lang.ja-JP.resx b/Resources/lang.ja-JP.resx index b6aae48..e6d1145 100644 --- a/Resources/lang.ja-JP.resx +++ b/Resources/lang.ja-JP.resx @@ -417,4 +417,7 @@ 要素 + + ドライブへのショートカットを生成する + \ No newline at end of file diff --git a/Resources/lang.ko-KR.resx b/Resources/lang.ko-KR.resx index 0e011d4..63a255d 100644 --- a/Resources/lang.ko-KR.resx +++ b/Resources/lang.ko-KR.resx @@ -417,4 +417,7 @@ 집단 + + 드라이브에 대한 바로 가기 생성 + \ No newline at end of file diff --git a/Resources/lang.nl-NL.resx b/Resources/lang.nl-NL.resx index 6576a72..f67d723 100644 --- a/Resources/lang.nl-NL.resx +++ b/Resources/lang.nl-NL.resx @@ -417,4 +417,7 @@ elementen + + Genereer snelkoppelingen naar stations + \ No newline at end of file diff --git a/Resources/lang.pt-BR.resx b/Resources/lang.pt-BR.resx index 61d50a1..2aad87a 100644 --- a/Resources/lang.pt-BR.resx +++ b/Resources/lang.pt-BR.resx @@ -417,4 +417,7 @@ elementos + + Gerar atalhos para drives + \ No newline at end of file diff --git a/Resources/lang.resx b/Resources/lang.resx index abe6a41..53f7140 100644 --- a/Resources/lang.resx +++ b/Resources/lang.resx @@ -417,4 +417,7 @@ items + + Generate shortcuts to drives + \ No newline at end of file diff --git a/Resources/lang.ru-RU.resx b/Resources/lang.ru-RU.resx index b300f2e..79a11dc 100644 --- a/Resources/lang.ru-RU.resx +++ b/Resources/lang.ru-RU.resx @@ -417,4 +417,7 @@ элементы + + Создавайте ярлыки для дисков + \ No newline at end of file diff --git a/Resources/lang.tr-TR.resx b/Resources/lang.tr-TR.resx index f8cc7fd..a8b9248 100644 --- a/Resources/lang.tr-TR.resx +++ b/Resources/lang.tr-TR.resx @@ -417,4 +417,7 @@ elementler + + Sürücüler için kısayollar oluşturun + \ No newline at end of file diff --git a/Resources/lang.vi-VN.resx b/Resources/lang.vi-VN.resx index 59220ce..b999cd8 100644 --- a/Resources/lang.vi-VN.resx +++ b/Resources/lang.vi-VN.resx @@ -417,4 +417,7 @@ các yếu tố + + Tạo lối tắt cho ổ đĩa + \ No newline at end of file diff --git a/Resources/lang.zh-CN.resx b/Resources/lang.zh-CN.resx index 6586b96..eff7b21 100644 --- a/Resources/lang.zh-CN.resx +++ b/Resources/lang.zh-CN.resx @@ -417,4 +417,7 @@ 元素 + + 生成驱动器的快捷方式 + \ No newline at end of file diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index 457c1d0..57909d3 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -73,11 +73,12 @@ namespace SystemTrayMenu.UserInterface this.ColumnOnlyFiles = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.tableLayoutPanelAddSampleStartMenuFolder = new System.Windows.Forms.TableLayoutPanel(); this.buttonAddSampleStartMenuFolder = new System.Windows.Forms.Button(); - this.checkBoxCacheMainMenu = new System.Windows.Forms.CheckBox(); + this.buttonDefaultFolders = new System.Windows.Forms.Button(); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.TableLayoutPanel(); this.labelClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.Label(); this.numericUpDownClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.NumericUpDown(); - this.buttonDefaultFolders = new System.Windows.Forms.Button(); + this.checkBoxCacheMainMenu = new System.Windows.Forms.CheckBox(); + this.checkBoxGenerateShortcutsToDrives = new System.Windows.Forms.CheckBox(); this.tabPageAdvanced = new System.Windows.Forms.TabPage(); this.tableLayoutPanelAdvanced = new System.Windows.Forms.TableLayoutPanel(); this.groupBoxClick = new System.Windows.Forms.GroupBox(); @@ -872,13 +873,16 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelFoldersInRootFolder.ColumnCount = 1; this.tableLayoutPanelFoldersInRootFolder.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.groupBoxFoldersInRootFolder, 0, 0); - this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.checkBoxCacheMainMenu, 0, 1); - this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems, 0, 2); - this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.buttonDefaultFolders, 0, 3); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.buttonDefaultFolders, 0, 4); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems, 0, 3); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.checkBoxCacheMainMenu, 0, 2); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.checkBoxGenerateShortcutsToDrives, 0, 1); this.tableLayoutPanelFoldersInRootFolder.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanelFoldersInRootFolder.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanelFoldersInRootFolder.Name = "tableLayoutPanelFoldersInRootFolder"; - this.tableLayoutPanelFoldersInRootFolder.RowCount = 4; + this.tableLayoutPanelFoldersInRootFolder.RowCount = 6; + this.tableLayoutPanelFoldersInRootFolder.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelFoldersInRootFolder.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelFoldersInRootFolder.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelFoldersInRootFolder.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelFoldersInRootFolder.RowStyles.Add(new System.Windows.Forms.RowStyle()); @@ -895,7 +899,7 @@ namespace SystemTrayMenu.UserInterface this.groupBoxFoldersInRootFolder.MaximumSize = new System.Drawing.Size(400, 0); this.groupBoxFoldersInRootFolder.MinimumSize = new System.Drawing.Size(400, 0); this.groupBoxFoldersInRootFolder.Name = "groupBoxFoldersInRootFolder"; - this.groupBoxFoldersInRootFolder.Size = new System.Drawing.Size(400, 284); + this.groupBoxFoldersInRootFolder.Size = new System.Drawing.Size(400, 274); this.groupBoxFoldersInRootFolder.TabIndex = 0; this.groupBoxFoldersInRootFolder.TabStop = false; this.groupBoxFoldersInRootFolder.Text = "groupBox1"; @@ -915,9 +919,9 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelFolderToRootFoldersList7.RowCount = 4; this.tableLayoutPanelFolderToRootFoldersList7.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelFolderToRootFoldersList7.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelFolderToRootFoldersList7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanelFolderToRootFoldersList7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 190F)); this.tableLayoutPanelFolderToRootFoldersList7.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelFolderToRootFoldersList7.Size = new System.Drawing.Size(394, 262); + this.tableLayoutPanelFolderToRootFoldersList7.Size = new System.Drawing.Size(394, 252); this.tableLayoutPanelFolderToRootFoldersList7.TabIndex = 0; // // tableLayoutPanelFolderToRootFolder @@ -984,7 +988,7 @@ namespace SystemTrayMenu.UserInterface this.dataGridViewFolders.RowHeadersVisible = false; this.dataGridViewFolders.RowTemplate.Height = 25; this.dataGridViewFolders.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridViewFolders.Size = new System.Drawing.Size(388, 194); + this.dataGridViewFolders.Size = new System.Drawing.Size(388, 184); this.dataGridViewFolders.TabIndex = 6; this.dataGridViewFolders.TabStop = false; this.dataGridViewFolders.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.DataGridViewFolders_CellValidating); @@ -1028,7 +1032,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelAddSampleStartMenuFolder.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanelAddSampleStartMenuFolder.Controls.Add(this.buttonAddSampleStartMenuFolder, 0, 0); this.tableLayoutPanelAddSampleStartMenuFolder.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanelAddSampleStartMenuFolder.Location = new System.Drawing.Point(0, 231); + this.tableLayoutPanelAddSampleStartMenuFolder.Location = new System.Drawing.Point(0, 221); this.tableLayoutPanelAddSampleStartMenuFolder.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanelAddSampleStartMenuFolder.Name = "tableLayoutPanelAddSampleStartMenuFolder"; this.tableLayoutPanelAddSampleStartMenuFolder.RowCount = 1; @@ -1050,15 +1054,19 @@ namespace SystemTrayMenu.UserInterface this.buttonAddSampleStartMenuFolder.UseVisualStyleBackColor = true; this.buttonAddSampleStartMenuFolder.Click += new System.EventHandler(this.ButtonAddSampleStartMenuFolder_Click); // - // checkBoxCacheMainMenu + // buttonDefaultFolders // - this.checkBoxCacheMainMenu.AutoSize = true; - this.checkBoxCacheMainMenu.Location = new System.Drawing.Point(3, 293); - this.checkBoxCacheMainMenu.Name = "checkBoxCacheMainMenu"; - this.checkBoxCacheMainMenu.Size = new System.Drawing.Size(168, 19); - this.checkBoxCacheMainMenu.TabIndex = 3; - this.checkBoxCacheMainMenu.Text = "checkBoxCacheMainMenu"; - this.checkBoxCacheMainMenu.UseVisualStyleBackColor = true; + this.buttonDefaultFolders.AutoSize = true; + this.buttonDefaultFolders.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonDefaultFolders.Location = new System.Drawing.Point(9, 368); + this.buttonDefaultFolders.Margin = new System.Windows.Forms.Padding(9, 9, 3, 9); + this.buttonDefaultFolders.MinimumSize = new System.Drawing.Size(75, 25); + this.buttonDefaultFolders.Name = "buttonDefaultFolders"; + this.buttonDefaultFolders.Size = new System.Drawing.Size(129, 25); + this.buttonDefaultFolders.TabIndex = 6; + this.buttonDefaultFolders.Text = "buttonDefaultFolders"; + this.buttonDefaultFolders.UseVisualStyleBackColor = true; + this.buttonDefaultFolders.Click += new System.EventHandler(this.ButtonClearFolders_Click); // // tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems // @@ -1070,7 +1078,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Controls.Add(this.labelClearCacheIfMoreThanThisNumberOfItems, 1, 0); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Controls.Add(this.numericUpDownClearCacheIfMoreThanThisNumberOfItems, 0, 0); - this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Location = new System.Drawing.Point(0, 315); + this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Location = new System.Drawing.Point(0, 330); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Name = "tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems"; this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.RowCount = 1; @@ -1111,19 +1119,25 @@ namespace SystemTrayMenu.UserInterface 0, 0}); // - // buttonDefaultFolders + // checkBoxCacheMainMenu // - this.buttonDefaultFolders.AutoSize = true; - this.buttonDefaultFolders.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonDefaultFolders.Location = new System.Drawing.Point(9, 353); - this.buttonDefaultFolders.Margin = new System.Windows.Forms.Padding(9, 9, 3, 9); - this.buttonDefaultFolders.MinimumSize = new System.Drawing.Size(75, 25); - this.buttonDefaultFolders.Name = "buttonDefaultFolders"; - this.buttonDefaultFolders.Size = new System.Drawing.Size(129, 25); - this.buttonDefaultFolders.TabIndex = 6; - this.buttonDefaultFolders.Text = "buttonDefaultFolders"; - this.buttonDefaultFolders.UseVisualStyleBackColor = true; - this.buttonDefaultFolders.Click += new System.EventHandler(this.ButtonClearFolders_Click); + this.checkBoxCacheMainMenu.AutoSize = true; + this.checkBoxCacheMainMenu.Location = new System.Drawing.Point(3, 308); + this.checkBoxCacheMainMenu.Name = "checkBoxCacheMainMenu"; + this.checkBoxCacheMainMenu.Size = new System.Drawing.Size(168, 19); + this.checkBoxCacheMainMenu.TabIndex = 3; + this.checkBoxCacheMainMenu.Text = "checkBoxCacheMainMenu"; + this.checkBoxCacheMainMenu.UseVisualStyleBackColor = true; + // + // checkBoxGenerateShortcutsToDrives + // + this.checkBoxGenerateShortcutsToDrives.AutoSize = true; + this.checkBoxGenerateShortcutsToDrives.Location = new System.Drawing.Point(3, 283); + this.checkBoxGenerateShortcutsToDrives.Name = "checkBoxGenerateShortcutsToDrives"; + this.checkBoxGenerateShortcutsToDrives.Size = new System.Drawing.Size(195, 19); + this.checkBoxGenerateShortcutsToDrives.TabIndex = 7; + this.checkBoxGenerateShortcutsToDrives.Text = "checkBoxGenerateShortcutsToDrives"; + this.checkBoxGenerateShortcutsToDrives.UseVisualStyleBackColor = true; // // tabPageAdvanced // @@ -4524,5 +4538,6 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.RadioButton radioButtonAppearAtTheBottomRight; private System.Windows.Forms.RadioButton radioButtonAppearAtMouseLocation; private System.Windows.Forms.RadioButton radioButtonUseCustomLocation; + private System.Windows.Forms.CheckBox checkBoxGenerateShortcutsToDrives; } } \ No newline at end of file diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index e900102..98b1e37 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -135,6 +135,7 @@ namespace SystemTrayMenu.UserInterface ColumnOnlyFiles.HeaderText = Translator.GetText("Only Files"); buttonAddSampleStartMenuFolder.Text = Translator.GetText("Add sample 'Start Menu' folder"); buttonDefaultFolders.Text = Translator.GetText("Default"); + checkBoxGenerateShortcutsToDrives.Text = Translator.GetText("Generate shortcuts to drives"); checkBoxCacheMainMenu.Text = Translator.GetText("Cache main menu"); labelClearCacheIfMoreThanThisNumberOfItems.Text = Translator.GetText("Clear cache if more than this number of items"); groupBoxClick.Text = Translator.GetText("Click"); @@ -298,6 +299,7 @@ namespace SystemTrayMenu.UserInterface Log.Warn("PathsAddToMainMenu", ex); } + checkBoxGenerateShortcutsToDrives.Checked = Settings.Default.GenerateShortcutsToDrives; checkBoxCacheMainMenu.Checked = Settings.Default.CacheMainMenu; numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = Settings.Default.ClearCacheIfMoreThanThisNumberOfItems; @@ -713,6 +715,7 @@ namespace SystemTrayMenu.UserInterface } } + Settings.Default.GenerateShortcutsToDrives = checkBoxGenerateShortcutsToDrives.Checked; Settings.Default.CacheMainMenu = checkBoxCacheMainMenu.Checked; Settings.Default.ClearCacheIfMoreThanThisNumberOfItems = (int)numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value; @@ -909,6 +912,7 @@ namespace SystemTrayMenu.UserInterface private void ButtonClearFolders_Click(object sender, EventArgs e) { dataGridViewFolders.Rows.Clear(); + checkBoxGenerateShortcutsToDrives.Checked = false; checkBoxCacheMainMenu.Checked = true; numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = 200; } diff --git a/Utilities/GenerateDriveShortcuts.cs b/Utilities/GenerateDriveShortcuts.cs new file mode 100644 index 0000000..39c46b8 --- /dev/null +++ b/Utilities/GenerateDriveShortcuts.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace SystemTrayMenu.Utilities +{ + using System.Collections.Generic; + using System.IO; + using System.Linq; + using IWshRuntimeLibrary; + + internal class GenerateDriveShortcuts + { + public static void Start() + { + List driveNamesToRemove = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray().ToList(); + + DriveInfo[] driveInfos = DriveInfo.GetDrives(); + foreach (DriveInfo driveInfo in driveInfos) + { + driveNamesToRemove.Remove(driveInfo.Name[0]); + string linkPath = GetLinkPathFromDriveName(driveInfo.Name.Substring(0, 1)); + if (!System.IO.File.Exists(linkPath)) + { + CreateShortcut(linkPath, driveInfo.Name); + } + } + + foreach (char driveName in driveNamesToRemove) + { + string possibleShortcut = GetLinkPathFromDriveName(driveName.ToString()); + System.IO.File.Delete(possibleShortcut); + } + } + + private static void CreateShortcut(string linkPath, string targetPath) + { + WshShell shell = new WshShell(); + IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(linkPath); + shortcut.Description = "Generated by SystemTrayMenu"; + shortcut.TargetPath = targetPath; + shortcut.Save(); + } + + private static string GetLinkPathFromDriveName(string driveName) + { + return Path.Combine(Config.Path, $" {driveName} .lnk"); + } + } +}