From 504ac79448e6a4a6354155ada1c19a193d10cff4 Mon Sep 17 00:00:00 2001 From: noberumotto Date: Sat, 11 Jun 2022 21:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=90=AF=E5=8A=A8=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E7=8A=B6=E6=80=81=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/AppState.cs | 20 ++++++++++++++++++++ Core/Core.csproj | 1 + Core/Servicers/Instances/Main.cs | 2 ++ UI/App.xaml.cs | 12 ++++++------ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 Core/AppState.cs diff --git a/Core/AppState.cs b/Core/AppState.cs new file mode 100644 index 0000000..25c7fc8 --- /dev/null +++ b/Core/AppState.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core +{ + /// + /// app状态 + /// + public class AppState + { + /// + /// 是否正在加载中 + /// + public static bool IsLoading { get; set; } = true; + + } +} diff --git a/Core/Core.csproj b/Core/Core.csproj index 7c1005b..fe0f560 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -106,6 +106,7 @@ + diff --git a/Core/Servicers/Instances/Main.cs b/Core/Servicers/Instances/Main.cs index 64bafe1..d61fee6 100644 --- a/Core/Servicers/Instances/Main.cs +++ b/Core/Servicers/Instances/Main.cs @@ -140,6 +140,8 @@ namespace Core.Servicers.Instances // 加载分类信息 categories.Load(); + + AppState.IsLoading = false; }); diff --git a/UI/App.xaml.cs b/UI/App.xaml.cs index dafb8be..689137f 100644 --- a/UI/App.xaml.cs +++ b/UI/App.xaml.cs @@ -1,4 +1,5 @@ -using Core.Librarys; +using Core; +using Core.Librarys; using Core.Librarys.SQLite; using Core.Servicers.Instances; using Core.Servicers.Interfaces; @@ -42,7 +43,6 @@ namespace UI private IAppData appData; - public App() { InitStatusBarIcon(); @@ -119,7 +119,7 @@ namespace UI CreateStatusBarIconMenu(); statusBarIcon = new System.Windows.Forms.NotifyIcon(); - statusBarIcon.Text = "Tai! [数据加载中...请稍后]"; + statusBarIcon.Text = "Tai! [加载中,请稍后...]"; Stream iconStream = GetResourceStream(new Uri("pack://application:,,,/Tai;component/Resources/Icons/taibusy.ico")).Stream; statusBarIcon.Icon = new Icon(iconStream); //statusBarIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name); @@ -130,7 +130,7 @@ namespace UI } private void NotifyIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { - if (e.Button == System.Windows.Forms.MouseButtons.Right && !SQLiteBuilder.IsSelfChecking) + if (e.Button == System.Windows.Forms.MouseButtons.Right && !AppState.IsLoading) { //右键单击弹出托盘菜单 contextMenu.IsOpen = true; @@ -138,7 +138,7 @@ namespace UI } private void NotifyIcon_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) { - if (e.Button == System.Windows.Forms.MouseButtons.Left && !SQLiteBuilder.IsSelfChecking) + if (e.Button == System.Windows.Forms.MouseButtons.Left && !AppState.IsLoading) { //双击托盘图标显示主窗口 ShowMainWindow(); @@ -271,7 +271,7 @@ namespace UI { await Task.Run(() => { - while (SQLiteBuilder.IsSelfChecking) + while (AppState.IsLoading) { } statusBarIcon.Text = "Tai!"; -- GitLab