[Feature] Generate shortcuts to drives (#259), version 1.1.2.4

This commit is contained in:
Markus Hofknecht 2021-12-10 15:20:24 +01:00
parent a846f1b5e4
commit c0351a534d
22 changed files with 178 additions and 34 deletions

View file

@ -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;

View file

@ -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")]

View file

@ -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()]

View file

@ -456,6 +456,15 @@ namespace SystemTrayMenu.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Generate shortcuts to drives.
/// </summary>
internal static string Generate_shortcuts_to_drives {
get {
return ResourceManager.GetString("Generate shortcuts to drives", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Help / FAQ.
/// </summary>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementy</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Vygenerujte zástupce jednotek</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>Elemente</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Verknüpfungen zu Laufwerken erstellen</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementos</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Generar accesos directos a las unidades</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>عناصر</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>ایجاد میانبر برای درایوها</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>éléments</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Générer des raccourcis vers les lecteurs</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementi</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Genera collegamenti alle unità</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>要素</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>ドライブへのショートカットを生成する</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>집단</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>드라이브에 대한 바로 가기 생성</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementen</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Genereer snelkoppelingen naar stations</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementos</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Gerar atalhos para drives</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>items</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Generate shortcuts to drives</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>элементы</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Создавайте ярлыки для дисков</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>elementler</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Sürücüler için kısayollar oluşturun</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>các yếu tố</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>Tạo lối tắt cho ổ đĩa</value>
</data>
</root>

View file

@ -417,4 +417,7 @@
<data name="elements" xml:space="preserve">
<value>元素</value>
</data>
<data name="Generate shortcuts to drives" xml:space="preserve">
<value>生成驱动器的快捷方式</value>
</data>
</root>

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -0,0 +1,50 @@
// <copyright file="GenerateDriveShortcuts.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.Utilities
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using IWshRuntimeLibrary;
internal class GenerateDriveShortcuts
{
public static void Start()
{
List<char> 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");
}
}
}