From f2b34ea33f9a90552b3787d535bf673a0879676c Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sun, 10 Jul 2022 11:40:48 +0200 Subject: [PATCH] [Feature] Refresh root folder on change of contents (#330), version 1.2.9.34 --- Business/Menus.cs | 61 +++++++------------------- Properties/AssemblyInfo.cs | 4 +- Properties/Settings.Designer.cs | 16 ------- Resources/Languages/lang.resx | 3 -- UserInterface/Menu.cs | 9 +--- UserInterface/SettingsForm.Designer.cs | 32 +++++--------- UserInterface/SettingsForm.cs | 4 -- 7 files changed, 29 insertions(+), 100 deletions(-) diff --git a/Business/Menus.cs b/Business/Menus.cs index b7dba59..d82febb 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -72,8 +72,7 @@ namespace SystemTrayMenu.Business RefreshSelection(dgvMainMenu); - if (Properties.Settings.Default.CacheMainMenu && - Properties.Settings.Default.AppearAtMouseLocation) + if (Properties.Settings.Default.AppearAtMouseLocation) { menus[0].Tag = null; } @@ -86,42 +85,20 @@ namespace SystemTrayMenu.Business switch (menuData.Validity) { case MenuDataValidity.Valid: - if (Properties.Settings.Default.CacheMainMenu) + if (IconReader.MainPreload) { - if (IconReader.MainPreload) - { - workerMainMenu.DoWork -= LoadMenu; - menus[0] = Create(menuData, Path.GetFileName(Config.Path)); - menus[0].HandleCreated += (s, e) => ExecuteWatcherHistory(); - IconReader.MainPreload = false; - if (showMenuAfterMainPreload) - { - AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); - } - } - else + workerMainMenu.DoWork -= LoadMenu; + menus[0] = Create(menuData, Path.GetFileName(Config.Path)); + menus[0].HandleCreated += (s, e) => ExecuteWatcherHistory(); + IconReader.MainPreload = false; + if (showMenuAfterMainPreload) { AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); } } else { - DisposeMenu(menus[menuData.Level]); - menus[0] = Create(menuData, Path.GetFileName(Config.Path)); - - if (IconReader.MainPreload) - { - IconReader.MainPreload = false; - - if (showMenuAfterMainPreload) - { - AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); - } - } - else - { - AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); - } + AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); }); } break; @@ -518,15 +495,15 @@ namespace SystemTrayMenu.Business timerShowProcessStartedAsLoadingIcon.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed; SwitchOpenClose(false, true); } - - if (!Properties.Settings.Default.CacheMainMenu) - { - DisposeMenu(menus[0]); - } } internal void StartWorker() { + if (Properties.Settings.Default.GenerateShortcutsToDrives) + { + GenerateDriveShortcuts.Start(); + } + if (!workerMainMenu.IsBusy) { LoadStarted(); @@ -545,7 +522,7 @@ namespace SystemTrayMenu.Business private static void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork) { - string path = Config.Path; + string path; int level = 0; RowData rowData = eDoWork.Argument as RowData; if (rowData != null) @@ -553,10 +530,9 @@ namespace SystemTrayMenu.Business path = rowData.ResolvedPath; level = rowData.Level + 1; } - - if (Properties.Settings.Default.GenerateShortcutsToDrives) + else { - GenerateDriveShortcuts.Start(); + path = Config.Path; } MenuData menuData = GetData((BackgroundWorker)senderDoWork, path, level); @@ -782,11 +758,6 @@ namespace SystemTrayMenu.Business if (IconReader.ClearIfCacheTooBig()) { GC.Collect(); - - if (!Properties.Settings.Default.CacheMainMenu) - { - MainPreload(); - } } openCloseState = OpenCloseState.Default; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 674b25d..32b653b 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.2.9.33")] -[assembly: AssemblyFileVersion("1.2.9.33")] +[assembly: AssemblyVersion("1.2.9.34")] +[assembly: AssemblyFileVersion("1.2.9.34")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index a4a9dcc..b566546 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -764,22 +764,6 @@ 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()] diff --git a/Resources/Languages/lang.resx b/Resources/Languages/lang.resx index e1610d5..7e7bc2d 100644 --- a/Resources/Languages/lang.resx +++ b/Resources/Languages/lang.resx @@ -375,9 +375,6 @@ Only Files - - Cache main menu - Clear cache if more than this number of items diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 9a01b3b..33a9878 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -1088,14 +1088,7 @@ namespace SystemTrayMenu.UserInterface { if (e.Button == MouseButtons.Left) { - if (Properties.Settings.Default.CacheMainMenu) - { - SettingsForm.ShowSingleInstance(this); - } - else - { - SettingsForm.ShowSingleInstance(null); - } + SettingsForm.ShowSingleInstance(this); } } diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index aa212b2..7530576 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -148,7 +148,6 @@ namespace SystemTrayMenu.UserInterface this.textBoxSearchPattern = new System.Windows.Forms.TextBox(); this.groupBoxCache = new System.Windows.Forms.GroupBox(); this.tableLayoutPanelCache = new System.Windows.Forms.TableLayoutPanel(); - this.checkBoxCacheMainMenu = new System.Windows.Forms.CheckBox(); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.TableLayoutPanel(); this.labelClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.Label(); this.numericUpDownClearCacheIfMoreThanThisNumberOfItems = new System.Windows.Forms.NumericUpDown(); @@ -2088,7 +2087,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelExpert.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelExpert.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelExpert.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelExpert.Size = new System.Drawing.Size(345, 412); + this.tableLayoutPanelExpert.Size = new System.Drawing.Size(345, 387); this.tableLayoutPanelExpert.TabIndex = 1; // // groupBoxSearchPattern @@ -2097,7 +2096,7 @@ namespace SystemTrayMenu.UserInterface this.groupBoxSearchPattern.AutoSize = true; this.groupBoxSearchPattern.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.groupBoxSearchPattern.Controls.Add(this.tableLayoutPanelSearchPattern); - this.groupBoxSearchPattern.Location = new System.Drawing.Point(3, 312); + this.groupBoxSearchPattern.Location = new System.Drawing.Point(3, 287); this.groupBoxSearchPattern.Name = "groupBoxSearchPattern"; this.groupBoxSearchPattern.Padding = new System.Windows.Forms.Padding(3, 3, 3, 6); this.groupBoxSearchPattern.Size = new System.Drawing.Size(333, 54); @@ -2137,7 +2136,7 @@ namespace SystemTrayMenu.UserInterface this.groupBoxCache.Location = new System.Drawing.Point(3, 227); this.groupBoxCache.Name = "groupBoxCache"; this.groupBoxCache.Padding = new System.Windows.Forms.Padding(3, 3, 3, 6); - this.groupBoxCache.Size = new System.Drawing.Size(333, 79); + this.groupBoxCache.Size = new System.Drawing.Size(333, 54); this.groupBoxCache.TabIndex = 1; this.groupBoxCache.TabStop = false; this.groupBoxCache.Text = "groupBoxCache"; @@ -2148,27 +2147,16 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelCache.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanelCache.ColumnCount = 1; this.tableLayoutPanelCache.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanelCache.Controls.Add(this.checkBoxCacheMainMenu, 0, 0); - this.tableLayoutPanelCache.Controls.Add(this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems, 0, 1); + this.tableLayoutPanelCache.Controls.Add(this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems, 0, 0); this.tableLayoutPanelCache.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanelCache.Location = new System.Drawing.Point(3, 19); this.tableLayoutPanelCache.Name = "tableLayoutPanelCache"; - this.tableLayoutPanelCache.RowCount = 2; + this.tableLayoutPanelCache.RowCount = 1; this.tableLayoutPanelCache.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelCache.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelCache.Size = new System.Drawing.Size(327, 54); + this.tableLayoutPanelCache.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanelCache.Size = new System.Drawing.Size(327, 29); this.tableLayoutPanelCache.TabIndex = 0; // - // checkBoxCacheMainMenu - // - this.checkBoxCacheMainMenu.AutoSize = true; - this.checkBoxCacheMainMenu.Location = new System.Drawing.Point(3, 3); - 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; - // // tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems // this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -2179,7 +2167,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, 25); + this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.Name = "tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems"; this.tableLayoutPanelClearCacheIfMoreThanThisNumberOfItems.RowCount = 1; @@ -2424,7 +2412,7 @@ namespace SystemTrayMenu.UserInterface // this.buttonExpertDefault.AutoSize = true; this.buttonExpertDefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonExpertDefault.Location = new System.Drawing.Point(9, 378); + this.buttonExpertDefault.Location = new System.Drawing.Point(9, 353); this.buttonExpertDefault.Margin = new System.Windows.Forms.Padding(9, 9, 3, 9); this.buttonExpertDefault.MinimumSize = new System.Drawing.Size(75, 25); this.buttonExpertDefault.Name = "buttonExpertDefault"; @@ -2467,6 +2455,7 @@ namespace SystemTrayMenu.UserInterface // // groupBoxColorsDarkMode // + this.groupBoxColorsDarkMode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxColorsDarkMode.AutoSize = true; this.groupBoxColorsDarkMode.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.groupBoxColorsDarkMode.Controls.Add(this.tableLayoutPanelDarkMode); @@ -5359,7 +5348,6 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.CheckBox checkBoxGenerateShortcutsToDrives; private System.Windows.Forms.GroupBox groupBoxCache; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelCache; - private System.Windows.Forms.CheckBox checkBoxCacheMainMenu; private System.Windows.Forms.TabPage tabPageSizeAndLocation; private System.Windows.Forms.GroupBox groupBoxHiddenFilesAndFolders; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelHiddenFilesAndFolders; diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index ca80d59..33e7d17 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -190,7 +190,6 @@ namespace SystemTrayMenu.UserInterface checkBoxStayOpenWhenFocusLostAfterEnterPressed.Text = Translator.GetText("If the focus is lost and the Enter key was pressed"); labelTimeUntilClosesAfterEnterPressed.Text = Translator.GetText("Milliseconds until the menu closes if in this case the menu is not reactivated"); groupBoxCache.Text = Translator.GetText("Cache"); - checkBoxCacheMainMenu.Text = Translator.GetText("Cache main menu"); labelClearCacheIfMoreThanThisNumberOfItems.Text = Translator.GetText("Clear cache if more than this number of items"); groupBoxSearchPattern.Text = Translator.GetText("Filter menu by file type e.g.: *.exe|*.dll"); buttonExpertDefault.Text = Translator.GetText("Default"); @@ -516,7 +515,6 @@ namespace SystemTrayMenu.UserInterface numericUpDownTimeUntilClosesAfterEnterPressed.Increment = 10; numericUpDownTimeUntilClosesAfterEnterPressed.Value = Settings.Default.TimeUntilClosesAfterEnterPressed; - checkBoxCacheMainMenu.Checked = Settings.Default.CacheMainMenu; numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = Settings.Default.ClearCacheIfMoreThanThisNumberOfItems; textBoxSearchPattern.Text = Settings.Default.SearchPattern; @@ -1000,7 +998,6 @@ namespace SystemTrayMenu.UserInterface Settings.Default.TimeUntilOpens = (int)numericUpDownTimeUntilOpens.Value; Settings.Default.StaysOpenWhenFocusLostAfterEnterPressed = checkBoxStayOpenWhenFocusLostAfterEnterPressed.Checked; Settings.Default.TimeUntilClosesAfterEnterPressed = (int)numericUpDownTimeUntilClosesAfterEnterPressed.Value; - Settings.Default.CacheMainMenu = checkBoxCacheMainMenu.Checked; Settings.Default.ClearCacheIfMoreThanThisNumberOfItems = (int)numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value; Settings.Default.SearchPattern = textBoxSearchPattern.Text; @@ -1320,7 +1317,6 @@ namespace SystemTrayMenu.UserInterface numericUpDownTimeUntilOpens.Value = 100; checkBoxStayOpenWhenFocusLostAfterEnterPressed.Checked = true; numericUpDownTimeUntilClosesAfterEnterPressed.Value = 200; - checkBoxCacheMainMenu.Checked = true; numericUpDownClearCacheIfMoreThanThisNumberOfItems.Value = 200; textBoxSearchPattern.Text = string.Empty; }