[Feature] Show loading menu (#161), version 1.0.19.4

This commit is contained in:
Markus Hofknecht 2021-10-03 20:24:22 +02:00
parent a0cbd533cc
commit b5d35ea0d5
21 changed files with 159 additions and 11 deletions

View file

@ -123,7 +123,27 @@ namespace SystemTrayMenu.Business
menus[rowData.MenuLevel + 1].Tag as RowData != rowData))
{
loadingRowData = rowData;
LoadStarted();
CreateAndShowLoadingMenu(rowData);
void CreateAndShowLoadingMenu(RowData rowData)
{
MenuData menuDataLoading = new MenuData
{
RowDatas = new List<RowData>(),
Validity = MenuDataValidity.Valid,
Level = rowData.MenuLevel + 1,
};
Menu menuLoading = Create(menuDataLoading, Path.GetFileName(Config.Path));
menuLoading.IsLoadingMenu = true;
AdjustMenusSizeAndLocation();
menus[rowData.MenuLevel + 1] = menuLoading;
menuLoading.Tag = menuDataLoading.RowDataParent = rowData;
menuDataLoading.RowDataParent.SubMenu = menuLoading;
menuLoading.SetTypeLoading();
ShowSubMenu(menuLoading);
}
BackgroundWorker workerSubMenu = workersSubMenu.
Where(w => !w.IsBusy).FirstOrDefault();
if (workerSubMenu == null)
@ -142,10 +162,23 @@ namespace SystemTrayMenu.Business
void LoadSubMenuCompleted(object senderCompleted, RunWorkerCompletedEventArgs e)
{
LoadStopped();
MenuData menuData = (MenuData)e.Result;
if (menus[0].IsUsable &&
menuData.Validity != MenuDataValidity.AbortedOrUnknown)
if (menuData.Validity == MenuDataValidity.AbortedOrUnknown)
{
CloseLoadingMenu();
void CloseLoadingMenu()
{
if (loadingRowData != null)
{
Menu menuLoading = menus[loadingRowData.MenuLevel + 1];
if (menuLoading != null && menuLoading.IsLoadingMenu)
{
CloseMenu(loadingRowData.MenuLevel + 1);
}
}
}
}
else if (menus[0].IsUsable)
{
Menu menu = Create(menuData);
switch (menuData.Validity)

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.19.3")]
[assembly: AssemblyFileVersion("1.0.19.3")]
[assembly: AssemblyVersion("1.0.19.4")]
[assembly: AssemblyFileVersion("1.0.19.4")]

View file

@ -199,10 +199,10 @@
<data name="ic_fluent_folder_arrow_right_48_regular" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ic_fluent_folder_arrow_right_48_regular.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Loading" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Loading.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NotFound" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotFound.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Loading" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Loading.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -411,6 +411,15 @@ namespace SystemTrayMenu.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to loading.
/// </summary>
internal static string loading {
get {
return ResourceManager.GetString("loading", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Log File.
/// </summary>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Nastavit jako složku SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>načítání</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Als SystemTrayMenu-Ordner festlegen</value>
</data>
<data name="loading" xml:space="preserve">
<value>Wird geladen</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Establecer como carpeta SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>cargando</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Définir comme dossier SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>Chargement en cours</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Imposta come cartella SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>Caricamento in corso</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>SystemTrayMenuフォルダーとして設定</value>
</data>
<data name="loading" xml:space="preserve">
<value>読み込み中</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>SystemTrayMenu 폴더로 설정</value>
</data>
<data name="loading" xml:space="preserve">
<value>로딩</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Instellen als SystemTrayMenu-map</value>
</data>
<data name="loading" xml:space="preserve">
<value>bezig met laden</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Definir como pasta SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>Carregando</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Set as SystemTrayMenu folder</value>
</data>
<data name="loading" xml:space="preserve">
<value>loading</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Установить как папку SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>загрузка</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>Đặt làm thư mục SystemTrayMenu</value>
</data>
<data name="loading" xml:space="preserve">
<value>Đang tải</value>
</data>
</root>

View file

@ -336,4 +336,7 @@
<data name="Set as SystemTrayMenu folder" xml:space="preserve">
<value>设置为 SystemTrayMenu 文件夹</value>
</data>
<data name="loading" xml:space="preserve">
<value>加载</value>
</data>
</root>

View file

@ -126,7 +126,6 @@ namespace SystemTrayMenu.UserInterface
{
if (DateTime.Now - timeLoadingStart > new TimeSpan(0, 0, 0, 0, 500))
{
Cursor.Current = Cursors.WaitCursor;
notifyIcon.Icon = bitmapsLoading[loadCount++ % indexLoad];
}
}

View file

@ -11,6 +11,8 @@ namespace SystemTrayMenu.UserInterface
internal partial class Menu
{
public bool IsLoadingMenu { get; internal set; }
private void InitializeComponentControlsTheDesignerRemoves()
{
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();

View file

@ -7,6 +7,7 @@ namespace SystemTrayMenu.UserInterface
using System;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO;
using System.Reflection;
@ -19,10 +20,12 @@ namespace SystemTrayMenu.UserInterface
internal partial class Menu : Form
{
private static readonly Icon LoadingIcon = Properties.Resources.Loading;
private static readonly Icon Search = Properties.Resources.search;
private readonly Fading fading = new Fading();
private bool isShowing;
private bool directionToRight;
private int rotationAngle;
internal Menu()
{
@ -178,6 +181,7 @@ namespace SystemTrayMenu.UserInterface
Empty,
NoAccess,
MaxReached,
Loading,
}
internal enum StartLocation
@ -223,6 +227,11 @@ namespace SystemTrayMenu.UserInterface
SetType(MenuType.NoAccess);
}
internal void SetTypeLoading()
{
SetType(MenuType.Loading);
}
internal void SetType(MenuType type)
{
if (type != MenuType.Main)
@ -232,6 +241,8 @@ namespace SystemTrayMenu.UserInterface
switch (type)
{
case MenuType.Main:
break;
case MenuType.Sub:
break;
case MenuType.Empty:
@ -255,7 +266,18 @@ namespace SystemTrayMenu.UserInterface
textBoxSearch.Visible = false;
tableLayoutPanelSearch.Visible = false;
break;
case MenuType.Main:
case MenuType.Loading:
SetTitle(Translator.GetText("loading"));
pictureBoxSearch.Visible = false;
textBoxSearch.Visible = false;
tableLayoutPanelSearch.Visible = false;
pictureBoxOpenFolder.Visible = false;
pictureBoxMenuAlwaysOpen.Paint -= PictureBoxMenuAlwaysOpen_Paint;
pictureBoxMenuAlwaysOpen.Paint += LoadingMenu_Paint;
timerUpdateIcons.Tick -= TimerUpdateIcons_Tick;
timerUpdateIcons.Tick += TimerUpdateLoadingMenu_Tick;
timerUpdateIcons.Interval = 15;
pictureBoxMenuAlwaysOpen.Visible = true;
break;
default:
break;
@ -769,6 +791,50 @@ namespace SystemTrayMenu.UserInterface
}
}
private void TimerUpdateLoadingMenu_Tick(object sender, EventArgs e)
{
pictureBoxMenuAlwaysOpen.Invalidate();
}
private void LoadingMenu_Paint(object sender, PaintEventArgs e)
{
PictureBox pictureBox = (PictureBox)sender;
rotationAngle = rotationAngle + 5;
e.Graphics.DrawImage(
RotateImage(LoadingIcon.ToBitmap(), rotationAngle),
new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2)));
}
private Image RotateImage(Image img, float rotationAngle)
{
// create an empty Bitmap image
Bitmap bmp = new Bitmap(img.Width, img.Height);
// turn the Bitmap into a Graphics object
Graphics gfx = Graphics.FromImage(bmp);
// now we set the rotation point to the center of our image
gfx.TranslateTransform(0.5f + ((float)bmp.Width / 2), 0.5f + ((float)bmp.Height / 2));
// now rotate the image
gfx.RotateTransform(rotationAngle);
gfx.TranslateTransform(0.5f - ((float)bmp.Width / 2), 0.5f - ((float)bmp.Height / 2));
// set the InterpolationMode to HighQualityBicubic so to ensure a high
// quality image once it is transformed to the specified size
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
// now draw our new image onto the graphics object
gfx.DrawImage(img, new Point(0, 0));
// dispose of our Graphics object
gfx.Dispose();
// return the image
return bmp;
}
private void PictureBoxMenuOpenFolder_Paint(object sender, PaintEventArgs e)
{
PictureBox pictureBox = (PictureBox)sender;