diff --git a/Business/KeyboardInput.cs b/Business/KeyboardInput.cs index f72f6c8..bbdd562 100644 --- a/Business/KeyboardInput.cs +++ b/Business/KeyboardInput.cs @@ -304,6 +304,9 @@ namespace SystemTrayMenu.Handler { ClosePressed?.Invoke(); } + + // Raise Dgv_RowPostPaint to show ProcessStarted + dgv.InvalidateRow(iRowKey); } else { diff --git a/Business/Menus.cs b/Business/Menus.cs index 142804d..9cad9b9 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -29,6 +29,7 @@ namespace SystemTrayMenu.Business private readonly DgvMouseRow dgvMouseRow = new DgvMouseRow(); private readonly WaitToLoadMenu waitToOpenMenu = new WaitToLoadMenu(); private readonly KeyboardInput keyboardInput; + private readonly Timer timerShowProcessStartedAsLoadingIcon = new Timer(); private readonly Timer timerStillActiveCheck = new Timer(); private readonly WaitLeave waitLeave = new WaitLeave(Properties.Settings.Default.TimeUntilCloses); private DateTime deactivatedTime = DateTime.MinValue; @@ -243,6 +244,7 @@ namespace SystemTrayMenu.Business menu.AdjustScrollbar(); } + timerShowProcessStartedAsLoadingIcon.Interval = 250; timerStillActiveCheck.Interval = 1000; timerStillActiveCheck.Tick += StillActiveTick; void StillActiveTick(object senderTimer, EventArgs eTimer) @@ -282,6 +284,7 @@ namespace SystemTrayMenu.Business waitToOpenMenu.Dispose(); keyboardInput.Dispose(); + timerShowProcessStartedAsLoadingIcon.Dispose(); timerStillActiveCheck.Dispose(); waitLeave.Dispose(); IconReader.Dispose(); @@ -867,6 +870,21 @@ namespace SystemTrayMenu.Business ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorOpenFolderBorder, ButtonBorderStyle.Solid); row.DefaultCellStyle.SelectionBackColor = MenuDefines.ColorOpenFolder; } + + if (rowData.ProcessStarted) + { + rowData.ProcessStarted = false; + row.Cells[0].Value = Resources.StaticResources.LoadingIcon; + timerShowProcessStartedAsLoadingIcon.Tick += Tick; + void Tick(object sender, EventArgs e) + { + row.Cells[0].Value = rowData.ReadLoadedIcon(); + timerShowProcessStartedAsLoadingIcon.Tick -= Tick; + timerShowProcessStartedAsLoadingIcon.Stop(); + } + + timerShowProcessStartedAsLoadingIcon.Start(); + } } } diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index bcc822b..a0b298f 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -52,6 +52,8 @@ namespace SystemTrayMenu.DataClasses internal string FilePathIcon { get; set; } + internal bool ProcessStarted { get; set; } + internal void SetText(string text) { this.text = text; @@ -245,6 +247,7 @@ namespace SystemTrayMenu.DataClasses if (!ContainsMenu && (e == null || e.Button == MouseButtons.Left)) { + ProcessStarted = true; Log.ProcessStart(TargetFilePathOrig, string.Empty, false, string.Empty, true); if (!Properties.Settings.Default.StaysOpenWhenItemClicked) { diff --git a/Helpers/DragDropHelper.cs b/Helpers/DragDropHelper.cs index 4f5c7f7..b525ca1 100644 --- a/Helpers/DragDropHelper.cs +++ b/Helpers/DragDropHelper.cs @@ -2,7 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace SystemTrayMenu.Helpers +namespace SystemTrayMenu.Helper { using System; using System.IO; diff --git a/Helpers/Fading.cs b/Helpers/Fading.cs index 6a81580..c9b0d56 100644 --- a/Helpers/Fading.cs +++ b/Helpers/Fading.cs @@ -2,7 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace SystemTrayMenu.UserInterface +namespace SystemTrayMenu.Helper { using System; using System.Windows.Forms; diff --git a/Helpers/ImagingHelper.cs b/Helpers/ImagingHelper.cs index b6b5cf1..0167123 100644 --- a/Helpers/ImagingHelper.cs +++ b/Helpers/ImagingHelper.cs @@ -2,7 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace SystemTrayMenu.Helpers +namespace SystemTrayMenu.Helper { using System.Drawing; using System.Drawing.Drawing2D; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index bf453d2..1769fab 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.24.1")] -[assembly: AssemblyFileVersion("1.0.24.1")] +[assembly: AssemblyVersion("1.0.24.2")] +[assembly: AssemblyFileVersion("1.0.24.2")] diff --git a/Resources/StaticResources.cs b/Resources/StaticResources.cs new file mode 100644 index 0000000..3f6461d --- /dev/null +++ b/Resources/StaticResources.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace SystemTrayMenu.Resources +{ + using System.Drawing; + + public class StaticResources + { + public static readonly Icon LoadingIcon = Properties.Resources.Loading; + } +} diff --git a/UserInterface/AppNotifyIcon.cs b/UserInterface/AppNotifyIcon.cs index d2e19c8..94ced53 100644 --- a/UserInterface/AppNotifyIcon.cs +++ b/UserInterface/AppNotifyIcon.cs @@ -8,13 +8,11 @@ namespace SystemTrayMenu.UserInterface using System.Drawing; using System.Windows.Forms; using SystemTrayMenu.Helper; - using SystemTrayMenu.Helpers; using SystemTrayMenu.Utilities; using Timer = System.Windows.Forms.Timer; internal class AppNotifyIcon : IDisposable { - private static readonly Icon LoadingIcon = Properties.Resources.Loading; private static Icon systemTrayMenu = Properties.Resources.SystemTrayMenu; private readonly Timer load = new Timer(); private readonly NotifyIcon notifyIcon = new NotifyIcon(); @@ -23,7 +21,7 @@ namespace SystemTrayMenu.UserInterface public AppNotifyIcon() { - notifyIcon.Icon = LoadingIcon; + notifyIcon.Icon = Resources.StaticResources.LoadingIcon; load.Tick += Load_Tick; load.Interval = 15; notifyIcon.Text = Translator.GetText("SystemTrayMenu"); @@ -112,7 +110,7 @@ namespace SystemTrayMenu.UserInterface if (threadsLoading) { rotationAngle += 5; - using Bitmap bitmapLoading = LoadingIcon.ToBitmap(); + using Bitmap bitmapLoading = Resources.StaticResources.LoadingIcon.ToBitmap(); using Bitmap bitmapLoadingRotated = new Bitmap(ImagingHelper.RotateImage(bitmapLoading, rotationAngle)); DisposeIconIfNotDefaultIcon(); IntPtr hIcon = bitmapLoadingRotated.GetHicon(); diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 12a1af8..f679865 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -12,12 +12,11 @@ namespace SystemTrayMenu.UserInterface using System.Windows.Forms; using SystemTrayMenu.DataClasses; using SystemTrayMenu.DllImports; - using SystemTrayMenu.Helpers; + using SystemTrayMenu.Helper; using SystemTrayMenu.Utilities; internal partial class Menu : Form { - private static readonly Icon LoadingIcon = Properties.Resources.Loading; private readonly Fading fading = new Fading(); private bool isShowing; private bool directionToRight; @@ -801,7 +800,7 @@ namespace SystemTrayMenu.UserInterface PictureBox pictureBox = (PictureBox)sender; rotationAngle += 5; e.Graphics.DrawImage( - ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle), + ImagingHelper.RotateImage(Resources.StaticResources.LoadingIcon.ToBitmap(), rotationAngle), new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2))); } diff --git a/Utilities/File/IconReader.cs b/Utilities/File/IconReader.cs index f470f25..eeccb83 100644 --- a/Utilities/File/IconReader.cs +++ b/Utilities/File/IconReader.cs @@ -23,7 +23,6 @@ namespace SystemTrayMenu.Utilities public static class IconReader { private static readonly ConcurrentDictionary DictIconCache = new ConcurrentDictionary(); - private static readonly Icon LoadingIcon = Properties.Resources.Loading; public enum IconSize { @@ -78,7 +77,7 @@ namespace SystemTrayMenu.Utilities if (!DictIconCache.TryGetValue(key, out Icon icon)) { - icon = LoadingIcon; + icon = Resources.StaticResources.LoadingIcon; loading = true; if (updateIconInBackground) @@ -160,7 +159,7 @@ namespace SystemTrayMenu.Utilities if (!DictIconCache.TryGetValue(key, out Icon icon)) { - icon = LoadingIcon; + icon = Resources.StaticResources.LoadingIcon; loading = true; if (updateIconInBackground) @@ -218,7 +217,7 @@ namespace SystemTrayMenu.Utilities if (!DictIconCache.TryGetValue(key, out Icon icon)) { - icon = LoadingIcon; + icon = Resources.StaticResources.LoadingIcon; loading = true; if (updateIconInBackground)