[Feature] Show item which was clicked for 250ms as loading (#224), version 1.0.24.2

This commit is contained in:
Markus Hofknecht 2021-10-25 21:45:49 +02:00
parent 9189b0629d
commit bf1629eb4c
11 changed files with 49 additions and 16 deletions

View file

@ -304,6 +304,9 @@ namespace SystemTrayMenu.Handler
{
ClosePressed?.Invoke();
}
// Raise Dgv_RowPostPaint to show ProcessStarted
dgv.InvalidateRow(iRowKey);
}
else
{

View file

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

View file

@ -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)
{

View file

@ -2,7 +2,7 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.Helpers
namespace SystemTrayMenu.Helper
{
using System;
using System.IO;

View file

@ -2,7 +2,7 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.UserInterface
namespace SystemTrayMenu.Helper
{
using System;
using System.Windows.Forms;

View file

@ -2,7 +2,7 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.Helpers
namespace SystemTrayMenu.Helper
{
using System.Drawing;
using System.Drawing.Drawing2D;

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.0.24.1")]
[assembly: AssemblyFileVersion("1.0.24.1")]
[assembly: AssemblyVersion("1.0.24.2")]
[assembly: AssemblyFileVersion("1.0.24.2")]

View file

@ -0,0 +1,13 @@
// <copyright file="StaticResources.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.Resources
{
using System.Drawing;
public class StaticResources
{
public static readonly Icon LoadingIcon = Properties.Resources.Loading;
}
}

View file

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

View file

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

View file

@ -23,7 +23,6 @@ namespace SystemTrayMenu.Utilities
public static class IconReader
{
private static readonly ConcurrentDictionary<string, Icon> DictIconCache = new ConcurrentDictionary<string, Icon>();
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)