From b5d35ea0d59193f2a45a17b8efd68ae776178604 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sun, 3 Oct 2021 20:24:22 +0200 Subject: [PATCH] [Feature] Show loading menu (#161), version 1.0.19.4 --- Business/Menus.cs | 41 +++++++++-- Properties/AssemblyInfo.cs | 4 +- Properties/Resources.resx | 6 +- Resources/Loading.ico | Bin 4286 -> 4286 bytes Resources/lang.Designer.cs | 9 +++ Resources/lang.cs-CZ.resx | 3 + Resources/lang.de-DE.resx | 3 + Resources/lang.es-ES.resx | 3 + Resources/lang.fr-FR.resx | 3 + Resources/lang.it-IT.resx | 3 + Resources/lang.ja-JP.resx | 3 + Resources/lang.ko-KR.resx | 3 + Resources/lang.nl-NL.resx | 3 + Resources/lang.pt-BR.resx | 3 + Resources/lang.resx | 3 + Resources/lang.ru-RU.resx | 3 + Resources/lang.vi-VN.resx | 3 + Resources/lang.zh-CN.resx | 3 + UserInterface/AppNotifyIcon.cs | 1 - .../Menu.ControlsTheDesignerRemoves.cs | 2 + UserInterface/Menu.cs | 68 +++++++++++++++++- 21 files changed, 159 insertions(+), 11 deletions(-) diff --git a/Business/Menus.cs b/Business/Menus.cs index 5c7ec66..bba78a8 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -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(), + 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) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index b8269fc..839ca49 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.19.3")] -[assembly: AssemblyFileVersion("1.0.19.3")] +[assembly: AssemblyVersion("1.0.19.4")] +[assembly: AssemblyFileVersion("1.0.19.4")] diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 7682f88..db9c720 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -199,10 +199,10 @@ ..\Resources\ic_fluent_folder_arrow_right_48_regular.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\Loading.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\NotFound.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Loading.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/Loading.ico b/Resources/Loading.ico index f8e548902d9d25efa335dec6b015e0bd0590e80a..11f83497a08a4cc873706cf3ba730b8e9fb69aec 100644 GIT binary patch literal 4286 zcmeH@ZBSHY6vvNV!I?7cQ{NP38VyhumesP!5rSPLGki@8d&9z#J{TlLVxy*}Iap?D zS%ZM1Op22;%~VrrZ917|WxT}PySuL2%b2*nz@oD5u08$F-Cex<2pi~E5A$2@J?H%Y z|L3_xgYcJ}O#Dlq-c5855v2gMC4c^R+R;%T_UunxI+jkCe;!AdkEin)a<7~i+l=#zn*rJ;c;s9@4nKIZcf9I6l0nWL zll491=R)HFA`T(Un0PyGc;#@m_ke{sqp#{XoJqbPP1JSNbRTHxI+iZ3V-o1``&oGH zx%5-|D_~B9GW7Oh=8fzabnrN8YVsX5jb?Ao=&jCwYsM^tN$mU~qYem(5YFBRj|sjb z8AFguM$k*ZY$A5{L3d5kvR4hf6F7sj<)*1pX4FnUE|%KHJG#H@_ub0kmUWw;s(ON8E7o$4rI{_wb6Gy8#}z~ z-EWx)53j+8JzdBc$ysu>e>t8&0q_H1prQS%@d}{c&Mo`!4)1~lcr+S(*s~khfGneb zKEIzS1ww**bhei>-(V7H;GR*xGRcd*7qXvRe}DD>fhr&j1o2!5=*$-rWJ#azyvrIe z2ZVspvyx|W{ki8s0#!g52;jL8(5d>#vZT*<-enD#4MM=^S;;fGJi8{5XV*ieK*Ta> z5zkJ3k}FI4eCOS;-=xK{Ub^>-Jd^8GT{eLNcWt&G2m?Fa+jA5^t}Xep?1p#V;axBU z9=i=b?AeVB8)wPIX9me9KhARlVc@iDTb|kVp_QEPKSIv;rpnTucb@SM??N*H9_EV+iT$ zx`MM=u(KPwkfdd=T6~{GNA+XGS-lm`j(hR_W~Sh7t=gK|B9>YFep*{Sd#AQ)&LU74 zp%lFa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; z?8~-f6TC>-l08A$oUJLF=ZfwnTY>j@&M4bFSI=zy2gEaMeVLF4vPpSsewwmr!3E{b z1)^Knw7?5br|!)eTj#WmZhcqYo`>vtq;8r|%EpBQm5qybDjOEn0P&bq!^5Mzv2cLy z32)BmXyJPa{W|KZ9E-AU@hElOlEdojODaJWh)!rky#ks;(57iCms;X}?A?`xZzXm8 zD>};h#pGMHyob6r$EvQ$Spkl#YhG1B2t;G>yV6q2$whCHf8}cy)~Xv~KJb*SFwvkO zQDPNQPcP9ETlv2W+Aa%DdRCzWU4zi=iV|&UZb1klCcfvIE9S@=*0x#LS-i-of+J^g F=f74?sL22T diff --git a/Resources/lang.Designer.cs b/Resources/lang.Designer.cs index d23f857..b25ee9e 100644 --- a/Resources/lang.Designer.cs +++ b/Resources/lang.Designer.cs @@ -411,6 +411,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to loading. + /// + internal static string loading { + get { + return ResourceManager.GetString("loading", resourceCulture); + } + } + /// /// Looks up a localized string similar to Log File. /// diff --git a/Resources/lang.cs-CZ.resx b/Resources/lang.cs-CZ.resx index 23384a7..3e87785 100644 --- a/Resources/lang.cs-CZ.resx +++ b/Resources/lang.cs-CZ.resx @@ -336,4 +336,7 @@ Nastavit jako složku SystemTrayMenu + + načítání + \ No newline at end of file diff --git a/Resources/lang.de-DE.resx b/Resources/lang.de-DE.resx index 96bae8f..e485f63 100644 --- a/Resources/lang.de-DE.resx +++ b/Resources/lang.de-DE.resx @@ -336,4 +336,7 @@ Als SystemTrayMenu-Ordner festlegen + + Wird geladen + \ No newline at end of file diff --git a/Resources/lang.es-ES.resx b/Resources/lang.es-ES.resx index 896870c..33f70cf 100644 --- a/Resources/lang.es-ES.resx +++ b/Resources/lang.es-ES.resx @@ -336,4 +336,7 @@ Establecer como carpeta SystemTrayMenu + + cargando + \ No newline at end of file diff --git a/Resources/lang.fr-FR.resx b/Resources/lang.fr-FR.resx index 4ebeaf0..8995355 100644 --- a/Resources/lang.fr-FR.resx +++ b/Resources/lang.fr-FR.resx @@ -336,4 +336,7 @@ Définir comme dossier SystemTrayMenu + + Chargement en cours + \ No newline at end of file diff --git a/Resources/lang.it-IT.resx b/Resources/lang.it-IT.resx index ed4e317..9b8c670 100644 --- a/Resources/lang.it-IT.resx +++ b/Resources/lang.it-IT.resx @@ -336,4 +336,7 @@ Imposta come cartella SystemTrayMenu + + Caricamento in corso + \ No newline at end of file diff --git a/Resources/lang.ja-JP.resx b/Resources/lang.ja-JP.resx index c796dc9..68248fa 100644 --- a/Resources/lang.ja-JP.resx +++ b/Resources/lang.ja-JP.resx @@ -336,4 +336,7 @@ SystemTrayMenuフォルダーとして設定 + + 読み込み中 + \ No newline at end of file diff --git a/Resources/lang.ko-KR.resx b/Resources/lang.ko-KR.resx index ae29b50..866591e 100644 --- a/Resources/lang.ko-KR.resx +++ b/Resources/lang.ko-KR.resx @@ -336,4 +336,7 @@ SystemTrayMenu 폴더로 설정 + + 로딩 + \ No newline at end of file diff --git a/Resources/lang.nl-NL.resx b/Resources/lang.nl-NL.resx index da1f8f5..42dc735 100644 --- a/Resources/lang.nl-NL.resx +++ b/Resources/lang.nl-NL.resx @@ -336,4 +336,7 @@ Instellen als SystemTrayMenu-map + + bezig met laden + \ No newline at end of file diff --git a/Resources/lang.pt-BR.resx b/Resources/lang.pt-BR.resx index 554e54e..81515e3 100644 --- a/Resources/lang.pt-BR.resx +++ b/Resources/lang.pt-BR.resx @@ -336,4 +336,7 @@ Definir como pasta SystemTrayMenu + + Carregando + \ No newline at end of file diff --git a/Resources/lang.resx b/Resources/lang.resx index cc74ef9..84a0d46 100644 --- a/Resources/lang.resx +++ b/Resources/lang.resx @@ -336,4 +336,7 @@ Set as SystemTrayMenu folder + + loading + \ No newline at end of file diff --git a/Resources/lang.ru-RU.resx b/Resources/lang.ru-RU.resx index 60da43b..20ae354 100644 --- a/Resources/lang.ru-RU.resx +++ b/Resources/lang.ru-RU.resx @@ -336,4 +336,7 @@ Установить как папку SystemTrayMenu + + загрузка + \ No newline at end of file diff --git a/Resources/lang.vi-VN.resx b/Resources/lang.vi-VN.resx index 9ac9b51..9866e66 100644 --- a/Resources/lang.vi-VN.resx +++ b/Resources/lang.vi-VN.resx @@ -336,4 +336,7 @@ Đặt làm thư mục SystemTrayMenu + + Đang tải + \ No newline at end of file diff --git a/Resources/lang.zh-CN.resx b/Resources/lang.zh-CN.resx index 2298f94..824f51f 100644 --- a/Resources/lang.zh-CN.resx +++ b/Resources/lang.zh-CN.resx @@ -336,4 +336,7 @@ 设置为 SystemTrayMenu 文件夹 + + 加载 + \ No newline at end of file diff --git a/UserInterface/AppNotifyIcon.cs b/UserInterface/AppNotifyIcon.cs index c807b5b..1ef5afa 100644 --- a/UserInterface/AppNotifyIcon.cs +++ b/UserInterface/AppNotifyIcon.cs @@ -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]; } } diff --git a/UserInterface/Menu.ControlsTheDesignerRemoves.cs b/UserInterface/Menu.ControlsTheDesignerRemoves.cs index 9c3744d..ecc954d 100644 --- a/UserInterface/Menu.ControlsTheDesignerRemoves.cs +++ b/UserInterface/Menu.ControlsTheDesignerRemoves.cs @@ -11,6 +11,8 @@ namespace SystemTrayMenu.UserInterface internal partial class Menu { + public bool IsLoadingMenu { get; internal set; } + private void InitializeComponentControlsTheDesignerRemoves() { DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 78cdac0..5a945f1 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -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;