From 6d8cf4da39c65936300e8b7112cd29bd6a0a8edc Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Wed, 10 Nov 2021 23:39:52 +0100 Subject: [PATCH] [Feature] Search all throughout the subfolders (#211, #232), version 1.0.25.5 --- Business/KeyboardInput.cs | 36 ++- Business/Menus.cs | 219 +++++++++++++---- DataClasses/RowData.cs | 6 +- Properties/AssemblyInfo.cs | 4 +- Properties/Settings.Designer.cs | 48 ++++ Resources/lang.Designer.cs | 81 +++++++ Resources/lang.cs-CZ.resx | 27 +++ Resources/lang.de-DE.resx | 27 +++ Resources/lang.es-ES.resx | 27 +++ Resources/lang.fr-FR.resx | 27 +++ Resources/lang.it-IT.resx | 27 +++ Resources/lang.ja-JP.resx | 27 +++ Resources/lang.ko-KR.resx | 27 +++ Resources/lang.nl-NL.resx | 27 +++ Resources/lang.pt-BR.resx | 27 +++ Resources/lang.resx | 27 +++ Resources/lang.ru-RU.resx | 27 +++ Resources/lang.tr-TR.resx | 27 +++ Resources/lang.vi-VN.resx | 27 +++ Resources/lang.zh-CN.resx | 27 +++ UserInterface/AppNotifyIcon.cs | 11 +- UserInterface/Menu.cs | 5 + UserInterface/SettingsForm.Designer.cs | 312 ++++++++++++++++++++++++- UserInterface/SettingsForm.cs | 110 +++++++++ UserInterface/SettingsForm.resx | 18 ++ Utilities/File/IconReader.cs | 2 +- 26 files changed, 1153 insertions(+), 77 deletions(-) diff --git a/Business/KeyboardInput.cs b/Business/KeyboardInput.cs index 793e680..35a0015 100644 --- a/Business/KeyboardInput.cs +++ b/Business/KeyboardInput.cs @@ -75,16 +75,38 @@ namespace SystemTrayMenu.Handler switch (keys) { case Keys.Enter: + SelectByKey(keys); + menus[iMenuKey].FocusTextBox(); + break; + case Keys.Left: + if (Properties.Settings.Default.AppearAtTheBottomLeft) + { + SelectByKey(Keys.Right); + } + else + { + SelectByKey(keys); + } + + break; + case Keys.Right: + if (Properties.Settings.Default.AppearAtTheBottomLeft) + { + SelectByKey(Keys.Left); + } + else + { + SelectByKey(keys); + } + + break; case Keys.Up: case Keys.Down: - case Keys.Left: - case Keys.Right: case Keys.Escape: SelectByKey(keys); break; case Keys.Control | Keys.F: - Menu menu = menus[iMenuKey]; - menu.FocusTextBox(); + menus[iMenuKey].FocusTextBox(); break; case Keys.Tab: { @@ -215,7 +237,11 @@ namespace SystemTrayMenu.Handler { DataGridViewRow row = dgv.Rows[i]; RowData rowData = (RowData)row.Cells[2].Value; - rowData.IsSelected = true; + if (rowData != null) + { + rowData.IsSelected = true; + } + if (refreshview) { row.Selected = false; diff --git a/Business/Menus.cs b/Business/Menus.cs index 8708ccb..c0014cb 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -45,64 +45,74 @@ namespace SystemTrayMenu.Business { workerMainMenu.WorkerSupportsCancellation = true; workerMainMenu.DoWork += LoadMenu; - static void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork) - { - string path = Config.Path; - int level = 0; - RowData rowData = eDoWork.Argument as RowData; - if (rowData != null) - { - path = rowData.TargetFilePath; - level = rowData.MenuLevel + 1; - } - - MenuData menuData = GetData((BackgroundWorker)senderDoWork, path, level); - menuData.RowDataParent = rowData; - eDoWork.Result = menuData; - } workerMainMenu.RunWorkerCompleted += LoadMainMenuCompleted; void LoadMainMenuCompleted(object sender, RunWorkerCompletedEventArgs e) { keyboardInput.ResetSelectedByKey(); LoadStopped(); - MenuData menuData = (MenuData)e.Result; - switch (menuData.Validity) + + if (e.Result == null) { - case MenuDataValidity.Valid: - DisposeMenu(menus[menuData.Level]); - menus[0] = Create(menuData, Path.GetFileName(Config.Path)); - AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); - break; - case MenuDataValidity.Empty: - if (!showingMessageBox) - { - showingMessageBox = true; - MessageBox.Show(Translator.GetText( - "MessageRootFolderEmpty")); - OpenFolder(); - Config.SetFolderByUser(); - showingMessageBox = false; - } + // Clean up menu status IsMenuOpen for previous one + DataGridView dgvMainMenu = menus[0].GetDataGridView(); + foreach (DataRow row in ((DataTable)dgvMainMenu.DataSource).Rows) + { + RowData rowDataToClear = (RowData)row[2]; + rowDataToClear.IsMenuOpen = false; + rowDataToClear.IsSelected = false; + rowDataToClear.IsContextMenuOpen = false; + } - break; - case MenuDataValidity.NoAccess: - if (!showingMessageBox) - { - showingMessageBox = true; - MessageBox.Show(Translator.GetText( - "MessageRootFolderNoAccess")); - OpenFolder(); - Config.SetFolderByUser(); - showingMessageBox = false; - } + RefreshSelection(dgvMainMenu); - break; - case MenuDataValidity.AbortedOrUnknown: - Log.Info("MenuDataValidity.AbortedOrUnknown"); - break; - default: - break; + AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); + menus[0].ResetSearchText(); + } + else + { + MenuData menuData = (MenuData)e.Result; + switch (menuData.Validity) + { + case MenuDataValidity.Valid: + if (!Properties.Settings.Default.CacheMainMenu) + { + DisposeMenu(menus[menuData.Level]); + menus[0] = Create(menuData, Path.GetFileName(Config.Path)); + } + + AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); + break; + case MenuDataValidity.Empty: + if (!showingMessageBox) + { + showingMessageBox = true; + MessageBox.Show(Translator.GetText( + "MessageRootFolderEmpty")); + OpenFolder(); + Config.SetFolderByUser(); + showingMessageBox = false; + } + + break; + case MenuDataValidity.NoAccess: + if (!showingMessageBox) + { + showingMessageBox = true; + MessageBox.Show(Translator.GetText( + "MessageRootFolderNoAccess")); + OpenFolder(); + Config.SetFolderByUser(); + showingMessageBox = false; + } + + break; + case MenuDataValidity.AbortedOrUnknown: + Log.Info("MenuDataValidity.AbortedOrUnknown"); + break; + default: + break; + } } openCloseState = OpenCloseState.Default; @@ -304,6 +314,14 @@ namespace SystemTrayMenu.Business Validity = MenuDataValidity.AbortedOrUnknown, Level = level, }; + + string[] directoriesToAddToMainMenu = Array.Empty(); + string[] filesToAddToMainMenu = Array.Empty(); + if (level == 0) + { + AddFoldersToMainMenu(ref directoriesToAddToMainMenu, ref filesToAddToMainMenu); + } + if (!worker.CancellationPending) { string[] directories = Array.Empty(); @@ -369,6 +387,7 @@ namespace SystemTrayMenu.Business else { directories = Directory.GetDirectories(path); + directories = directories.Concat(directoriesToAddToMainMenu).ToArray(); } Array.Sort(directories, new WindowsExplorerSort()); @@ -422,6 +441,7 @@ namespace SystemTrayMenu.Business else if (!FileLnk.IsNetworkRoot(path)) { files = Directory.GetFiles(path); + files = files.Concat(filesToAddToMainMenu).ToArray(); } Array.Sort(files, new WindowsExplorerSort()); @@ -572,12 +592,22 @@ namespace SystemTrayMenu.Business internal void MainPreload() { IconReader.SingleThread = true; + LoadStarted(); menus[0] = Create( GetData(workerMainMenu, Config.Path, 0), Path.GetFileName(Config.Path)); IconReader.SingleThread = false; AdjustMenusSizeAndLocation(); - DisposeMenu(menus[0]); + if (Properties.Settings.Default.CacheMainMenu) + { + workerMainMenu.DoWork -= LoadMenu; + } + else + { + DisposeMenu(menus[0]); + } + + LoadStopped(); if (FileUrl.GetDefaultBrowserPath(out string browserPath)) { @@ -603,6 +633,93 @@ namespace SystemTrayMenu.Business } } + private static void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork) + { + string path = Config.Path; + int level = 0; + RowData rowData = eDoWork.Argument as RowData; + if (rowData != null) + { + path = rowData.TargetFilePath; + level = rowData.MenuLevel + 1; + } + + MenuData menuData = GetData((BackgroundWorker)senderDoWork, path, level); + menuData.RowDataParent = rowData; + eDoWork.Result = menuData; + } + + private static void AddFoldersToMainMenu(ref string[] directoriesToAddToMainMenu, ref string[] filesToAddToMainMenu) + { + string pathAddToMainMenu = string.Empty; + bool recursive = false; + try + { + foreach (string pathAndRecursivString in Properties.Settings.Default.PathsAddToMainMenu.Split(@"|")) + { + if (string.IsNullOrEmpty(pathAndRecursivString)) + { + continue; + } + + pathAddToMainMenu = pathAndRecursivString.Split("recursiv:")[0].Trim(); + recursive = pathAndRecursivString.Split("recursiv:")[1].StartsWith("True"); + bool onlyFiles = pathAndRecursivString.Split("onlyFiles:")[1].StartsWith("True"); + + string[] directoriesToConcat = Array.Empty(); + string[] filesToAddToConcat = Array.Empty(); + if (recursive) + { + GetDirectoriesAndFilesRecursive(ref directoriesToConcat, ref filesToAddToConcat, pathAddToMainMenu); + } + else + { + directoriesToConcat = Directory.GetDirectories(pathAddToMainMenu); + filesToAddToConcat = Directory.GetFiles(pathAddToMainMenu); + } + + if (!onlyFiles) + { + directoriesToAddToMainMenu = directoriesToAddToMainMenu.Concat(directoriesToConcat).ToArray(); + } + + filesToAddToMainMenu = filesToAddToMainMenu.Concat(filesToAddToConcat).ToArray(); + } + } + catch (Exception ex) + { + Log.Warn($"path:'{pathAddToMainMenu}' recursiv:{recursive}", ex); + } + } + + private static void GetDirectoriesAndFilesRecursive(ref string[] directoriesToConcat, ref string[] filesToAddToConcat, string pathAddToMainMenu) + { + try + { + string[] directories = Directory.GetDirectories(pathAddToMainMenu); + + try + { + filesToAddToConcat = filesToAddToConcat.Concat(Directory.GetFiles(pathAddToMainMenu)).ToArray(); + } + catch (Exception ex) + { + Log.Warn($"GetDirectoriesAndFilesRecursive path:'{pathAddToMainMenu}'", ex); + } + + foreach (string directory in directories) + { + GetDirectoriesAndFilesRecursive(ref directoriesToConcat, ref filesToAddToConcat, directory); + } + + directoriesToConcat = directoriesToConcat.Concat(directories).ToArray(); + } + catch (Exception ex) + { + Log.Warn($"GetDirectoriesAndFilesRecursive path:'{pathAddToMainMenu}'", ex); + } + } + private static RowData ReadRowData(string fileName, bool isResolvedLnk, RowData rowData = null) { if (rowData == null) @@ -774,7 +891,7 @@ namespace SystemTrayMenu.Business AdjustMenusSizeAndLocation(); } - if (!menu.Visible) + if (!menu.Visible && menu.Level != 0) { DisposeMenu(menu); } diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index 298024b..1432759 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -261,7 +261,11 @@ namespace SystemTrayMenu.DataClasses bool handled = false; resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath); - if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath))) + if (string.IsNullOrEmpty(resolvedLnkPath)) + { + // do nothing + } + else if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath))) { icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Open, true, true, out bool loading); IconLoading = loading; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 981b36d..dfb9833 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.25.3")] -[assembly: AssemblyFileVersion("1.0.25.3")] +[assembly: AssemblyVersion("1.0.25.5")] +[assembly: AssemblyFileVersion("1.0.25.5")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 92cc152..c8f1d43 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -59,6 +59,22 @@ namespace SystemTrayMenu.Properties } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\\ProgramData\\Microsoft\\Windows\\Start Menu recursiv:True onlyFiles:True|")] + public string PathsAddToMainMenu + { + get + { + return ((string)(this["PathsAddToMainMenu"])); + } + set + { + this["PathsAddToMainMenu"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -171,6 +187,22 @@ namespace SystemTrayMenu.Properties } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CacheMainMenu + { + get + { + return ((bool)(this["CacheMainMenu"])); + } + set + { + this["CacheMainMenu"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -187,6 +219,22 @@ namespace SystemTrayMenu.Properties } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1000")] + public int ClearCacheIfMoreThanThisNumberOfItems + { + get + { + return ((int)(this["ClearCacheIfMoreThanThisNumberOfItems"])); + } + set + { + this["ClearCacheIfMoreThanThisNumberOfItems"] = 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 260de75..84c7ef5 100644 --- a/Resources/lang.Designer.cs +++ b/Resources/lang.Designer.cs @@ -78,6 +78,24 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Add folder. + /// + internal static string Add_folder { + get { + return ResourceManager.GetString("Add folder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add folders to main menu. + /// + internal static string Add_folders_to_main_menu { + get { + return ResourceManager.GetString("Add folders to main menu", resourceCulture); + } + } + /// /// Looks up a localized string similar to Advanced. /// @@ -231,6 +249,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Cache main menu. + /// + internal static string Cache_main_menu { + get { + return ResourceManager.GetString("Cache main menu", resourceCulture); + } + } + /// /// Looks up a localized string similar to Change folder. /// @@ -249,6 +276,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Clear cache if more than this number of items. + /// + internal static string Clear_cache_if_more_than_this_number_of_items { + get { + return ResourceManager.GetString("Clear cache if more than this number of items", resourceCulture); + } + } + /// /// Looks up a localized string similar to Click. /// @@ -366,6 +402,24 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Folder paths. + /// + internal static string Folder_paths { + get { + return ResourceManager.GetString("Folder paths", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Folders. + /// + internal static string Folders { + get { + return ResourceManager.GetString("Folders", resourceCulture); + } + } + /// /// Looks up a localized string similar to General. /// @@ -520,6 +574,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Only Files. + /// + internal static string Only_Files { + get { + return ResourceManager.GetString("Only Files", resourceCulture); + } + } + /// /// Looks up a localized string similar to Open Folder. /// @@ -574,6 +637,24 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Recursive. + /// + internal static string Recursive { + get { + return ResourceManager.GetString("Recursive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove folder. + /// + internal static string Remove_folder { + get { + return ResourceManager.GetString("Remove folder", resourceCulture); + } + } + /// /// Looks up a localized string similar to Restart. /// diff --git a/Resources/lang.cs-CZ.resx b/Resources/lang.cs-CZ.resx index 49fd286..a023287 100644 --- a/Resources/lang.cs-CZ.resx +++ b/Resources/lang.cs-CZ.resx @@ -369,4 +369,31 @@ Zobrazí se vlevo dole + + Přidat složku + + + Přidejte složky do hlavní nabídky + + + Cesty složek + + + Složky + + + Rekurzivní + + + Odebrat složku + + + Hlavní nabídka mezipaměti + + + Pokud je více než tento počet položek, vymažte mezipaměť + + + Pouze soubory + \ No newline at end of file diff --git a/Resources/lang.de-DE.resx b/Resources/lang.de-DE.resx index a6dfa3e..51f3c69 100644 --- a/Resources/lang.de-DE.resx +++ b/Resources/lang.de-DE.resx @@ -369,4 +369,31 @@ Erscheine unten links + + Ordner hinzufügen + + + Ordner zum Hauptmenü hinzufügen + + + Ordnerpfade + + + Ordner + + + Rekursiv + + + Ordner entfernen + + + Cache-Hauptmenü + + + Cache leeren, wenn mehr als diese Anzahl von Elementen + + + Nur Dateien + \ No newline at end of file diff --git a/Resources/lang.es-ES.resx b/Resources/lang.es-ES.resx index eae4c0a..54a6d30 100644 --- a/Resources/lang.es-ES.resx +++ b/Resources/lang.es-ES.resx @@ -369,4 +369,31 @@ Aparecen en la parte inferior izquierda + + Agregar carpeta + + + Agregar carpetas al menú principal + + + Rutas de carpeta + + + Carpetas + + + Recursivo + + + Quitar carpeta + + + Menú principal de caché + + + Borrar caché si hay más elementos que este + + + Solo archivos + \ No newline at end of file diff --git a/Resources/lang.fr-FR.resx b/Resources/lang.fr-FR.resx index 1131136..0f31d34 100644 --- a/Resources/lang.fr-FR.resx +++ b/Resources/lang.fr-FR.resx @@ -369,4 +369,31 @@ Apparaît en bas à gauche + + Ajouter le dossier + + + Ajouter des dossiers au menu principal + + + Chemins de dossier + + + Dossiers + + + Récursif + + + Supprimer le dossier + + + Menu principal du cache + + + Vider le cache si plus que ce nombre d'éléments + + + Fichiers uniquement + \ No newline at end of file diff --git a/Resources/lang.it-IT.resx b/Resources/lang.it-IT.resx index 97a7dba..0e76ba5 100644 --- a/Resources/lang.it-IT.resx +++ b/Resources/lang.it-IT.resx @@ -369,4 +369,31 @@ Appari in basso a sinistra + + Aggiungi cartella + + + Aggiungi cartelle al menu principale + + + Percorsi delle cartelle + + + Cartelle + + + Ricorsivo + + + Rimuovi cartella + + + Menu principale della cache + + + Svuota la cache se più di questo numero di elementi + + + Solo file + \ No newline at end of file diff --git a/Resources/lang.ja-JP.resx b/Resources/lang.ja-JP.resx index 10fbe96..893ad6c 100644 --- a/Resources/lang.ja-JP.resx +++ b/Resources/lang.ja-JP.resx @@ -369,4 +369,31 @@ 左下に表示されます + + フォルダーを追加 + + + メインメニューにフォルダを追加する + + + フォルダパス + + + フォルダー + + + 再帰的 + + + フォルダを削除します + + + キャッシュのメインメニュー + + + アイテムの数がこの数を超える場合は、キャッシュをクリアします + + + ファイルのみ + \ No newline at end of file diff --git a/Resources/lang.ko-KR.resx b/Resources/lang.ko-KR.resx index fe920d3..733b0e9 100644 --- a/Resources/lang.ko-KR.resx +++ b/Resources/lang.ko-KR.resx @@ -369,4 +369,31 @@ 왼쪽 하단에 나타남 + + 폴더 추가 + + + 기본 메뉴에 폴더 추가 + + + 폴더 경로 + + + 폴더 + + + 재귀 + + + 폴더 제거 + + + 캐시 메인 메뉴 + + + 이 항목 수보다 많은 경우 캐시 지우기 + + + 파일만 + \ No newline at end of file diff --git a/Resources/lang.nl-NL.resx b/Resources/lang.nl-NL.resx index d03d4a8..9204d98 100644 --- a/Resources/lang.nl-NL.resx +++ b/Resources/lang.nl-NL.resx @@ -369,4 +369,31 @@ Verschijnen linksonder + + Map toevoegen + + + Mappen toevoegen aan hoofdmenu + + + Mappaden + + + Mappen + + + Recursief + + + Map verwijderen + + + Hoofdmenu cache + + + Cache wissen bij meer dan dit aantal items + + + Alleen bestanden + \ No newline at end of file diff --git a/Resources/lang.pt-BR.resx b/Resources/lang.pt-BR.resx index 9b7f5b2..54129c0 100644 --- a/Resources/lang.pt-BR.resx +++ b/Resources/lang.pt-BR.resx @@ -369,4 +369,31 @@ Aparece no canto inferior esquerdo + + Adicionar pasta + + + Adicionar pastas ao menu principal + + + Caminhos de pasta + + + Pastas + + + Recursiva + + + Remover pasta + + + Menu principal do cache + + + Limpe o cache se houver mais do que este número de itens + + + Apenas arquivos + \ No newline at end of file diff --git a/Resources/lang.resx b/Resources/lang.resx index bc023e2..7033257 100644 --- a/Resources/lang.resx +++ b/Resources/lang.resx @@ -369,4 +369,31 @@ Appear at the bottom left + + Add folder + + + Add folders to main menu + + + Folder paths + + + Folders + + + Recursive + + + Remove folder + + + Only Files + + + Cache main menu + + + Clear cache if more than this number of items + \ No newline at end of file diff --git a/Resources/lang.ru-RU.resx b/Resources/lang.ru-RU.resx index 67d07a4..e068c7b 100644 --- a/Resources/lang.ru-RU.resx +++ b/Resources/lang.ru-RU.resx @@ -369,4 +369,31 @@ Появляются внизу слева + + Добавить папку + + + Добавить папки в главное меню + + + Пути к папкам + + + Папки + + + Рекурсивный + + + Удалить папку + + + Главное меню кеширования + + + Очистить кеш, если количество элементов превышает указанное + + + Только файлы + \ No newline at end of file diff --git a/Resources/lang.tr-TR.resx b/Resources/lang.tr-TR.resx index c6994ad..e0bfd2d 100644 --- a/Resources/lang.tr-TR.resx +++ b/Resources/lang.tr-TR.resx @@ -369,4 +369,31 @@ Sol altta görün + + Klasörü eklemek + + + Ana menüye klasörler ekleyin + + + Klasör yolları + + + klasörler + + + Özyinelemeli + + + Klasörü kaldır + + + Önbellek ana menüsü + + + Bu sayıda öğeden fazlaysa önbelleği temizle + + + Yalnızca Dosyalar + \ No newline at end of file diff --git a/Resources/lang.vi-VN.resx b/Resources/lang.vi-VN.resx index 7342877..19546b8 100644 --- a/Resources/lang.vi-VN.resx +++ b/Resources/lang.vi-VN.resx @@ -369,4 +369,31 @@ Xuất hiện ở dưới cùng bên trái + + Thêm thư mục + + + Thêm thư mục vào menu chính + + + Đường dẫn thư mục + + + Thư mục + + + Đệ quy + + + Xóa thư mục + + + Menu chính của bộ nhớ đệm + + + Xóa bộ nhớ cache nếu nhiều hơn số lượng mục này + + + Chỉ tệp + \ No newline at end of file diff --git a/Resources/lang.zh-CN.resx b/Resources/lang.zh-CN.resx index 65fd7fb..25b4842 100644 --- a/Resources/lang.zh-CN.resx +++ b/Resources/lang.zh-CN.resx @@ -369,4 +369,31 @@ 出现在左下角 + + 新增文件夹 + + + 将文件夹添加到主菜单 + + + 文件夹路径 + + + 文件夹 + + + 递归 + + + 删除文件夹 + + + 缓存主菜单 + + + 如果超过此数量的项目,则清除缓存 + + + 只有文件 + \ No newline at end of file diff --git a/UserInterface/AppNotifyIcon.cs b/UserInterface/AppNotifyIcon.cs index 94ced53..5c42bae 100644 --- a/UserInterface/AppNotifyIcon.cs +++ b/UserInterface/AppNotifyIcon.cs @@ -89,6 +89,7 @@ namespace SystemTrayMenu.UserInterface { threadsLoading = true; load.Start(); + Load_Tick(load, null); } public void LoadingStop() @@ -123,13 +124,13 @@ namespace SystemTrayMenu.UserInterface notifyIcon.Icon = systemTrayMenu; load.Stop(); } + } - void DisposeIconIfNotDefaultIcon() + private void DisposeIconIfNotDefaultIcon() + { + if (notifyIcon.Icon.GetHashCode() != systemTrayMenu.GetHashCode()) { - if (notifyIcon.Icon.GetHashCode() != systemTrayMenu.GetHashCode()) - { - notifyIcon.Icon?.Dispose(); - } + notifyIcon.Icon?.Dispose(); } } } diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index a3cb8b0..e1c0e90 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -218,6 +218,11 @@ namespace SystemTrayMenu.UserInterface } } + internal void ResetSearchText() + { + textBoxSearch.Text = string.Empty; + } + internal void FocusTextBox() { textBoxSearch.SelectAll(); diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index 8ca25f1..a7f4941 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -60,6 +60,22 @@ namespace SystemTrayMenu.UserInterface this.groupBoxLanguage = new System.Windows.Forms.GroupBox(); this.tableLayoutPanelLanguage = new System.Windows.Forms.TableLayoutPanel(); this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); + this.tabControlFolders = new System.Windows.Forms.TabPage(); + this.tableLayoutPanelFoldersInRootFolder = new System.Windows.Forms.TableLayoutPanel(); + this.tableLayoutPanel8 = new System.Windows.Forms.TableLayoutPanel(); + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.NumericUpDown(); + this.labelClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.Label(); + this.checkBoxCacheMainMenu = new System.Windows.Forms.CheckBox(); + this.groupBoxFoldersInRootFolder = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel(); + this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); + this.buttonAddFolderToRootFolder = new System.Windows.Forms.Button(); + this.buttonRemoveFolder = new System.Windows.Forms.Button(); + this.dataGridViewFolders = new System.Windows.Forms.DataGridView(); + this.ColumnFolder = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnRecursiveLevel = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.ColumnOnlyFiles = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.buttonDefaultFolders = new System.Windows.Forms.Button(); this.tabPageAdvanced = new System.Windows.Forms.TabPage(); this.tableLayoutPanelAdvanced = new System.Windows.Forms.TableLayoutPanel(); this.groupBoxClick = new System.Windows.Forms.GroupBox(); @@ -67,6 +83,7 @@ namespace SystemTrayMenu.UserInterface this.checkBoxOpenItemWithOneClick = new System.Windows.Forms.CheckBox(); this.groupBoxSizeAndLocation = new System.Windows.Forms.GroupBox(); this.tableLayoutPanelSizeAndLocation = new System.Windows.Forms.TableLayoutPanel(); + this.checkBoxAppearAtTheBottomLeft = new System.Windows.Forms.CheckBox(); this.checkBoxShowInTaskbar = new System.Windows.Forms.CheckBox(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.numericUpDownSizeInPercentage = new System.Windows.Forms.NumericUpDown(); @@ -274,7 +291,6 @@ namespace SystemTrayMenu.UserInterface this.buttonOk = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.colorDialog = new System.Windows.Forms.ColorDialog(); - this.checkBoxAppearAtTheBottomLeft = new System.Windows.Forms.CheckBox(); this.tableLayoutPanelMain.SuspendLayout(); this.tabControl.SuspendLayout(); this.tabPageGeneral.SuspendLayout(); @@ -291,6 +307,14 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelHotkey.SuspendLayout(); this.groupBoxLanguage.SuspendLayout(); this.tableLayoutPanelLanguage.SuspendLayout(); + this.tabControlFolders.SuspendLayout(); + this.tableLayoutPanelFoldersInRootFolder.SuspendLayout(); + this.tableLayoutPanel8.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownClearCacheIfMoreThanThisNumberOfItems)).BeginInit(); + this.groupBoxFoldersInRootFolder.SuspendLayout(); + this.tableLayoutPanel7.SuspendLayout(); + this.tableLayoutPanel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewFolders)).BeginInit(); this.tabPageAdvanced.SuspendLayout(); this.tableLayoutPanelAdvanced.SuspendLayout(); this.groupBoxClick.SuspendLayout(); @@ -422,6 +446,7 @@ namespace SystemTrayMenu.UserInterface // tabControl // this.tabControl.Controls.Add(this.tabPageGeneral); + this.tabControl.Controls.Add(this.tabControlFolders); this.tabControl.Controls.Add(this.tabPageAdvanced); this.tabControl.Controls.Add(this.tabPageExpert); this.tabControl.Controls.Add(this.tabPageCustomize); @@ -833,6 +858,239 @@ namespace SystemTrayMenu.UserInterface this.comboBoxLanguage.Size = new System.Drawing.Size(200, 23); this.comboBoxLanguage.TabIndex = 0; // + // tabControlFolders + // + this.tabControlFolders.Controls.Add(this.tableLayoutPanelFoldersInRootFolder); + this.tabControlFolders.Location = new System.Drawing.Point(4, 24); + this.tabControlFolders.Name = "tabControlFolders"; + this.tabControlFolders.Padding = new System.Windows.Forms.Padding(3); + this.tabControlFolders.Size = new System.Drawing.Size(414, 413); + this.tabControlFolders.TabIndex = 2; + this.tabControlFolders.Text = "tabControlFolders"; + this.tabControlFolders.UseVisualStyleBackColor = true; + // + // tableLayoutPanelFoldersInRootFolder + // + this.tableLayoutPanelFoldersInRootFolder.AutoSize = true; + this.tableLayoutPanelFoldersInRootFolder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanelFoldersInRootFolder.ColumnCount = 1; + this.tableLayoutPanelFoldersInRootFolder.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.tableLayoutPanel8, 0, 2); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.checkBoxCacheMainMenu, 0, 1); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.groupBoxFoldersInRootFolder, 0, 0); + this.tableLayoutPanelFoldersInRootFolder.Controls.Add(this.buttonDefaultFolders, 0, 3); + 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.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.Size = new System.Drawing.Size(408, 407); + this.tableLayoutPanelFoldersInRootFolder.TabIndex = 1; + // + // tableLayoutPanel8 + // + this.tableLayoutPanel8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel8.AutoSize = true; + this.tableLayoutPanel8.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel8.ColumnCount = 2; + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel8.Controls.Add(this.numericUpDownClearCacheIfMoreThanThisNumberOfItems, 0, 0); + this.tableLayoutPanel8.Controls.Add(this.labelClearCacheIfMoreThanThisNumberOfItems, 1, 0); + this.tableLayoutPanel8.Location = new System.Drawing.Point(0, 344); + this.tableLayoutPanel8.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel8.Name = "tableLayoutPanel8"; + this.tableLayoutPanel8.RowCount = 1; + this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel8.Size = new System.Drawing.Size(408, 29); + this.tableLayoutPanel8.TabIndex = 3; + // + // numericUpDownClearCacheIfMoreThanThisNumberOfItems + // + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Location = new System.Drawing.Point(3, 3); + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Maximum = new decimal(new int[] { + 5000, + 0, + 0, + 0}); + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Minimum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Name = "numericUpDownClearCacheIfMoreThanThisNumberOfItems"; + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Size = new System.Drawing.Size(55, 23); + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.TabIndex = 1; + this.numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + // + // labelClearCacheIfMoreThanThisNumberOfItems + // + this.labelClearCacheIfMoreThanThisNumberOfItems.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.labelClearCacheIfMoreThanThisNumberOfItems.AutoSize = true; + this.labelClearCacheIfMoreThanThisNumberOfItems.Location = new System.Drawing.Point(64, 7); + this.labelClearCacheIfMoreThanThisNumberOfItems.MaximumSize = new System.Drawing.Size(330, 0); + this.labelClearCacheIfMoreThanThisNumberOfItems.Name = "labelClearCacheIfMoreThanThisNumberOfItems"; + this.labelClearCacheIfMoreThanThisNumberOfItems.Size = new System.Drawing.Size(260, 15); + this.labelClearCacheIfMoreThanThisNumberOfItems.TabIndex = 0; + this.labelClearCacheIfMoreThanThisNumberOfItems.Text = "labelClearCacheIfMoreThanThisNumberOfItems"; + // + // checkBoxCacheMainMenu + // + this.checkBoxCacheMainMenu.AutoSize = true; + this.checkBoxCacheMainMenu.Location = new System.Drawing.Point(3, 322); + this.checkBoxCacheMainMenu.Name = "checkBoxCacheMainMenu"; + this.checkBoxCacheMainMenu.Size = new System.Drawing.Size(168, 19); + this.checkBoxCacheMainMenu.TabIndex = 2; + this.checkBoxCacheMainMenu.Text = "checkBoxCacheMainMenu"; + this.checkBoxCacheMainMenu.UseVisualStyleBackColor = true; + // + // groupBoxFoldersInRootFolder + // + this.groupBoxFoldersInRootFolder.AutoSize = true; + this.groupBoxFoldersInRootFolder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.groupBoxFoldersInRootFolder.Controls.Add(this.tableLayoutPanel7); + this.groupBoxFoldersInRootFolder.Location = new System.Drawing.Point(3, 3); + 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, 313); + this.groupBoxFoldersInRootFolder.TabIndex = 0; + this.groupBoxFoldersInRootFolder.TabStop = false; + this.groupBoxFoldersInRootFolder.Text = "groupBox1"; + // + // tableLayoutPanel7 + // + this.tableLayoutPanel7.AutoSize = true; + this.tableLayoutPanel7.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel7.ColumnCount = 1; + this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel7.Controls.Add(this.tableLayoutPanel6, 0, 1); + this.tableLayoutPanel7.Controls.Add(this.dataGridViewFolders, 0, 2); + this.tableLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel7.Location = new System.Drawing.Point(3, 19); + this.tableLayoutPanel7.Name = "tableLayoutPanel7"; + this.tableLayoutPanel7.RowCount = 3; + this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 260F)); + this.tableLayoutPanel7.Size = new System.Drawing.Size(394, 291); + this.tableLayoutPanel7.TabIndex = 0; + // + // tableLayoutPanel6 + // + this.tableLayoutPanel6.AutoSize = true; + this.tableLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel6.ColumnCount = 3; + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel6.Controls.Add(this.buttonAddFolderToRootFolder, 0, 0); + this.tableLayoutPanel6.Controls.Add(this.buttonRemoveFolder, 2, 0); + this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel6.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel6.Name = "tableLayoutPanel6"; + this.tableLayoutPanel6.RowCount = 1; + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel6.Size = new System.Drawing.Size(394, 31); + this.tableLayoutPanel6.TabIndex = 2; + // + // buttonAddFolderToRootFolder + // + this.buttonAddFolderToRootFolder.AutoSize = true; + this.buttonAddFolderToRootFolder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonAddFolderToRootFolder.Location = new System.Drawing.Point(2, 3); + this.buttonAddFolderToRootFolder.Margin = new System.Windows.Forms.Padding(2, 3, 3, 3); + this.buttonAddFolderToRootFolder.MinimumSize = new System.Drawing.Size(75, 23); + this.buttonAddFolderToRootFolder.Name = "buttonAddFolderToRootFolder"; + this.buttonAddFolderToRootFolder.Size = new System.Drawing.Size(178, 25); + this.buttonAddFolderToRootFolder.TabIndex = 0; + this.buttonAddFolderToRootFolder.Text = "buttonAddFolderToRootFolder"; + this.buttonAddFolderToRootFolder.UseVisualStyleBackColor = true; + this.buttonAddFolderToRootFolder.Click += new System.EventHandler(this.ButtonAddFolderToRootFolder_Click); + // + // buttonRemoveFolder + // + this.buttonRemoveFolder.AutoSize = true; + this.buttonRemoveFolder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonRemoveFolder.Location = new System.Drawing.Point(262, 3); + this.buttonRemoveFolder.MinimumSize = new System.Drawing.Size(75, 23); + this.buttonRemoveFolder.Name = "buttonRemoveFolder"; + this.buttonRemoveFolder.Size = new System.Drawing.Size(129, 25); + this.buttonRemoveFolder.TabIndex = 2; + this.buttonRemoveFolder.Text = "buttonRemoveFolder"; + this.buttonRemoveFolder.UseVisualStyleBackColor = true; + this.buttonRemoveFolder.Click += new System.EventHandler(this.ButtonRemoveFolder_Click); + // + // dataGridViewFolders + // + this.dataGridViewFolders.AllowUserToAddRows = false; + this.dataGridViewFolders.AllowUserToDeleteRows = false; + this.dataGridViewFolders.AllowUserToResizeColumns = false; + this.dataGridViewFolders.AllowUserToResizeRows = false; + this.dataGridViewFolders.BackgroundColor = System.Drawing.Color.White; + this.dataGridViewFolders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewFolders.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnFolder, + this.ColumnRecursiveLevel, + this.ColumnOnlyFiles}); + this.dataGridViewFolders.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewFolders.Location = new System.Drawing.Point(3, 34); + this.dataGridViewFolders.Name = "dataGridViewFolders"; + 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, 254); + this.dataGridViewFolders.TabIndex = 1; + this.dataGridViewFolders.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.DataGridViewFolders_CellValidating); + this.dataGridViewFolders.SelectionChanged += new System.EventHandler(this.DataGridViewFolders_SelectionChanged); + this.dataGridViewFolders.MouseClick += new System.Windows.Forms.MouseEventHandler(this.DataGridViewFolders_MouseClick); + // + // ColumnFolder + // + this.ColumnFolder.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ColumnFolder.HeaderText = "ColumnFolder"; + this.ColumnFolder.Name = "ColumnFolder"; + // + // ColumnRecursiveLevel + // + this.ColumnRecursiveLevel.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.ColumnRecursiveLevel.HeaderText = "ColumnRecursiveLevel"; + this.ColumnRecursiveLevel.Name = "ColumnRecursiveLevel"; + this.ColumnRecursiveLevel.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnRecursiveLevel.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.ColumnRecursiveLevel.Width = 152; + // + // ColumnOnlyFiles + // + this.ColumnOnlyFiles.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.ColumnOnlyFiles.HeaderText = "ColumnOnlyFiles"; + this.ColumnOnlyFiles.Name = "ColumnOnlyFiles"; + this.ColumnOnlyFiles.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnOnlyFiles.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.ColumnOnlyFiles.Width = 123; + // + // buttonDefaultFolders + // + this.buttonDefaultFolders.AutoSize = true; + this.buttonDefaultFolders.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonDefaultFolders.Location = new System.Drawing.Point(9, 382); + 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 = 0; + this.buttonDefaultFolders.Text = "buttonDefaultFolders"; + this.buttonDefaultFolders.UseVisualStyleBackColor = true; + this.buttonDefaultFolders.Click += new System.EventHandler(this.ButtonClearFolders_Click); + // // tabPageAdvanced // this.tabPageAdvanced.Controls.Add(this.tableLayoutPanelAdvanced); @@ -945,6 +1203,17 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelSizeAndLocation.Size = new System.Drawing.Size(394, 162); this.tableLayoutPanelSizeAndLocation.TabIndex = 0; // + // checkBoxAppearAtTheBottomLeft + // + this.checkBoxAppearAtTheBottomLeft.AutoSize = true; + this.checkBoxAppearAtTheBottomLeft.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBoxAppearAtTheBottomLeft.Location = new System.Drawing.Point(3, 140); + this.checkBoxAppearAtTheBottomLeft.Name = "checkBoxAppearAtTheBottomLeft"; + this.checkBoxAppearAtTheBottomLeft.Size = new System.Drawing.Size(388, 19); + this.checkBoxAppearAtTheBottomLeft.TabIndex = 2; + this.checkBoxAppearAtTheBottomLeft.Text = "checkBoxAppearAtTheBottomLeft"; + this.checkBoxAppearAtTheBottomLeft.UseVisualStyleBackColor = true; + // // checkBoxShowInTaskbar // this.checkBoxShowInTaskbar.AutoSize = true; @@ -3802,17 +4071,6 @@ namespace SystemTrayMenu.UserInterface this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // - // checkBoxAppearAtTheBottomLeft - // - this.checkBoxAppearAtTheBottomLeft.AutoSize = true; - this.checkBoxAppearAtTheBottomLeft.Dock = System.Windows.Forms.DockStyle.Fill; - this.checkBoxAppearAtTheBottomLeft.Location = new System.Drawing.Point(3, 140); - this.checkBoxAppearAtTheBottomLeft.Name = "checkBoxAppearAtTheBottomLeft"; - this.checkBoxAppearAtTheBottomLeft.Size = new System.Drawing.Size(388, 19); - this.checkBoxAppearAtTheBottomLeft.TabIndex = 2; - this.checkBoxAppearAtTheBottomLeft.Text = "checkBoxAppearAtTheBottomLeft"; - this.checkBoxAppearAtTheBottomLeft.UseVisualStyleBackColor = true; - // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -3858,6 +4116,20 @@ namespace SystemTrayMenu.UserInterface this.groupBoxLanguage.ResumeLayout(false); this.groupBoxLanguage.PerformLayout(); this.tableLayoutPanelLanguage.ResumeLayout(false); + this.tabControlFolders.ResumeLayout(false); + this.tabControlFolders.PerformLayout(); + this.tableLayoutPanelFoldersInRootFolder.ResumeLayout(false); + this.tableLayoutPanelFoldersInRootFolder.PerformLayout(); + this.tableLayoutPanel8.ResumeLayout(false); + this.tableLayoutPanel8.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownClearCacheIfMoreThanThisNumberOfItems)).EndInit(); + this.groupBoxFoldersInRootFolder.ResumeLayout(false); + this.groupBoxFoldersInRootFolder.PerformLayout(); + this.tableLayoutPanel7.ResumeLayout(false); + this.tableLayoutPanel7.PerformLayout(); + this.tableLayoutPanel6.ResumeLayout(false); + this.tableLayoutPanel6.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewFolders)).EndInit(); this.tabPageAdvanced.ResumeLayout(false); this.tabPageAdvanced.PerformLayout(); this.tableLayoutPanelAdvanced.ResumeLayout(false); @@ -4286,5 +4558,21 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.CheckBox checkBoxStayOpenWhenFocusLostAfterEnterPressed; private System.Windows.Forms.CheckBox checkBoxShowInTaskbar; private System.Windows.Forms.CheckBox checkBoxAppearAtTheBottomLeft; + private System.Windows.Forms.TabPage tabControlFolders; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelFoldersInRootFolder; + private System.Windows.Forms.GroupBox groupBoxFoldersInRootFolder; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel7; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; + private System.Windows.Forms.Button buttonAddFolderToRootFolder; + private System.Windows.Forms.Button buttonRemoveFolder; + private System.Windows.Forms.DataGridView dataGridViewFolders; + private System.Windows.Forms.Button buttonDefaultFolders; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnFolder; + private System.Windows.Forms.DataGridViewCheckBoxColumn ColumnRecursiveLevel; + private System.Windows.Forms.DataGridViewCheckBoxColumn ColumnOnlyFiles; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel8; + private System.Windows.Forms.NumericUpDown numericUpDownClearCacheIfMoreThanThisNumberOfItems; + private System.Windows.Forms.Label labelClearCacheIfMoreThanThisNumberOfItems; + private System.Windows.Forms.CheckBox checkBoxCacheMainMenu; } } \ No newline at end of file diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index 59d5299..f88c851 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -14,6 +14,7 @@ namespace SystemTrayMenu.UserInterface using System.Windows.Forms; using Microsoft.Win32; using SystemTrayMenu.Properties; + using SystemTrayMenu.UserInterface.FolderBrowseDialog; using SystemTrayMenu.Utilities; using Windows.ApplicationModel; using static SystemTrayMenu.UserInterface.HotkeyTextboxControl.HotkeyControl; @@ -128,7 +129,17 @@ namespace SystemTrayMenu.UserInterface groupBoxHotkey.Text = Translator.GetText("Hotkey"); buttonHotkeyDefault.Text = Translator.GetText("Default"); groupBoxLanguage.Text = Translator.GetText("Language"); + tabControlFolders.Text = Translator.GetText("Folders"); + groupBoxFoldersInRootFolder.Text = Translator.GetText("Add folders to main menu"); + buttonAddFolderToRootFolder.Text = Translator.GetText("Add folder"); + buttonRemoveFolder.Text = Translator.GetText("Remove folder"); + ColumnFolder.HeaderText = Translator.GetText("Folder paths"); + ColumnRecursiveLevel.HeaderText = Translator.GetText("Recursive"); + ColumnOnlyFiles.HeaderText = Translator.GetText("Only Files"); + buttonDefaultFolders.Text = Translator.GetText("Default"); groupBoxClick.Text = Translator.GetText("Click"); + checkBoxCacheMainMenu.Text = Translator.GetText("Cache main menu"); + labelClearCacheIfMoreThanThisNumberOfItems.Text = Translator.GetText("Clear cache if more than this number of items"); checkBoxOpenItemWithOneClick.Text = Translator.GetText("Single click to start item"); groupBoxSizeAndLocation.Text = Translator.GetText("Size and location"); labelSize.Text = $"% {Translator.GetText("Size")}"; @@ -266,6 +277,29 @@ namespace SystemTrayMenu.UserInterface checkBoxStoreConfigAtAssemblyLocation.Checked = CustomSettingsProvider.IsActivatedConfigPathAssembly(); + try + { + foreach (string pathAndRecursivString in Properties.Settings.Default.PathsAddToMainMenu.Split(@"|")) + { + if (string.IsNullOrEmpty(pathAndRecursivString)) + { + continue; + } + + string pathAddToMainMenu = pathAndRecursivString.Split("recursiv:")[0].Trim(); + bool recursive = pathAndRecursivString.Split("recursiv:")[1].StartsWith("True"); + bool onlyFiles = pathAndRecursivString.Split("onlyFiles:")[1].StartsWith("True"); + dataGridViewFolders.Rows.Add(pathAddToMainMenu, recursive, onlyFiles); + } + } + catch (Exception ex) + { + Log.Warn("PathsAddToMainMenu", ex); + } + + checkBoxCacheMainMenu.Checked = Settings.Default.CacheMainMenu; + numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = Settings.Default.ClearCacheIfMoreThanThisNumberOfItems; + checkBoxOpenItemWithOneClick.Checked = Settings.Default.OpenItemWithOneClick; numericUpDownSizeInPercentage.Minimum = 100; @@ -599,6 +633,8 @@ namespace SystemTrayMenu.UserInterface tabControl.Size = new Size( tabControl.Size.Width, tableLayoutPanelGeneral.Size.Height + (int)(50 * Scaling.Factor)); + + dataGridViewFolders.ClearSelection(); } private void ButtonOk_Click(object sender, EventArgs e) @@ -637,6 +673,22 @@ namespace SystemTrayMenu.UserInterface } } + SaveFolders(); + void SaveFolders() + { + Settings.Default.PathsAddToMainMenu = string.Empty; + foreach (DataGridViewRow row in dataGridViewFolders.Rows) + { + string pathAddToMainMenu = row.Cells[0].Value.ToString(); + bool recursiv = (bool)row.Cells[1].Value; + bool onlyFiles = (bool)row.Cells[2].Value; + Settings.Default.PathsAddToMainMenu += $"{pathAddToMainMenu} recursiv:{recursiv} onlyFiles:{onlyFiles}|"; + } + } + + Settings.Default.CacheMainMenu = checkBoxCacheMainMenu.Checked; + Settings.Default.ClearCacheIfMoreThanThisNumberOfItems = (int)numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value; + Settings.Default.OpenItemWithOneClick = checkBoxOpenItemWithOneClick.Checked; Settings.Default.AppearAtMouseLocation = checkBoxAppearAtMouseLocation.Checked; Settings.Default.SizeInPercentage = (int)numericUpDownSizeInPercentage.Value; @@ -974,5 +1026,63 @@ namespace SystemTrayMenu.UserInterface DialogResult = DialogResult.Cancel; Close(); } + + private void ButtonClearFolders_Click(object sender, EventArgs e) + { + dataGridViewFolders.Rows.Clear(); + string folderPathCommonStartMenu = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu); + dataGridViewFolders.Rows.Add(folderPathCommonStartMenu, true, true); + dataGridViewFolders.ClearSelection(); + + checkBoxCacheMainMenu.Checked = true; + numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = 1000; + } + + private void ButtonRemoveFolder_Click(object sender, EventArgs e) + { + int selectedRowCount = dataGridViewFolders.Rows.GetRowCount(DataGridViewElementStates.Selected); + if (selectedRowCount > 0) + { + for (int i = 0; i < selectedRowCount; i++) + { + dataGridViewFolders.Rows.RemoveAt(dataGridViewFolders.SelectedRows[0].Index); + } + } + + dataGridViewFolders.ClearSelection(); + } + + private void DataGridViewFolders_SelectionChanged(object sender, EventArgs e) + { + buttonRemoveFolder.Enabled = dataGridViewFolders.SelectedRows.Count > 0; + } + + private void ButtonAddFolderToRootFolder_Click(object sender, EventArgs e) + { + using FolderDialog dialog = new FolderDialog(); + + if (dialog.ShowDialog() == DialogResult.OK) + { + dataGridViewFolders.Rows.Add(dialog.Folder, false); + } + + dataGridViewFolders.ClearSelection(); + } + + private void DataGridViewFolders_MouseClick(object sender, MouseEventArgs e) + { + if (dataGridViewFolders.HitTest(e.X, e.Y).RowIndex < 0) + { + dataGridViewFolders.ClearSelection(); + } + } + + private void DataGridViewFolders_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) + { + if (e.ColumnIndex == 0) + { + dataGridViewFolders.CancelEdit(); + } + } } } diff --git a/UserInterface/SettingsForm.resx b/UserInterface/SettingsForm.resx index 605c98c..2ee9745 100644 --- a/UserInterface/SettingsForm.resx +++ b/UserInterface/SettingsForm.resx @@ -57,6 +57,24 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + 17, 17 diff --git a/Utilities/File/IconReader.cs b/Utilities/File/IconReader.cs index eeccb83..349facc 100644 --- a/Utilities/File/IconReader.cs +++ b/Utilities/File/IconReader.cs @@ -50,7 +50,7 @@ namespace SystemTrayMenu.Utilities public static bool ClearIfCacheTooBig() { bool cleared = false; - if (DictIconCache.Count > 200) + if (DictIconCache.Count > Properties.Settings.Default.ClearCacheIfMoreThanThisNumberOfItems) { Dispose(); DictIconCache.Clear();