diff --git a/src/AboutAppInfoPopup.cs b/src/AboutAppInfoPopup.cs index 9d2bfea9e..2a907d2b4 100644 --- a/src/AboutAppInfoPopup.cs +++ b/src/AboutAppInfoPopup.cs @@ -121,7 +121,7 @@ namespace System.Application.UI string? clrVersion; try { - clrVersion = typeof(object).Assembly.GetRequiredCustomAttribute().InformationalVersion.Split('+', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); + clrVersion = GetAssemblyVersion(typeof(object).Assembly); } catch { @@ -178,24 +178,24 @@ namespace System.Application.UI } #endif - b.Append("[time] "); - GetTime(b); - static void GetTime(StringBuilder b) + b.Append("[time.start] "); + GetStartTime(b); + static void GetStartTime(StringBuilder b) { - string timeString; + string startTimeStr; const string f = "yy-MM-dd HH:mm:ss"; const string f2 = "HH:mm:ss"; const string f3 = "dd HH:mm:ss"; - var time = Process.GetCurrentProcess().StartTime; - time = time.ToLocalTime(); - var utc_time = time.ToUniversalTime(); + var starttime = Process.GetCurrentProcess().StartTime; + starttime = starttime.ToLocalTime(); + var utc_time = starttime.ToUniversalTime(); var local = TimeZoneInfo.Local; - timeString = utc_time.Hour == time.Hour - ? time.ToString(time.Year >= 2100 ? DateTimeFormat.Standard : f) - : utc_time.Day == time.Day - ? $"{utc_time.ToString(f)}({time.ToString(f2)} {local.StandardName})" - : $"{utc_time.ToString(f)}({time.ToString(f3)} {local.StandardName})"; - b.Append(timeString); + startTimeStr = utc_time.Hour == starttime.Hour + ? starttime.ToString(starttime.Year >= 2100 ? DateTimeFormat.Standard : f) + : utc_time.Day == starttime.Day + ? $"{utc_time.ToString(f)}({starttime.ToString(f2)} {local.StandardName})" + : $"{utc_time.ToString(f)}({starttime.ToString(f3)} {local.StandardName})"; + b.Append(startTimeStr); } b.AppendLine(); @@ -358,7 +358,13 @@ namespace System.Application.UI b.AppendLine(); #endif - b.Append("[essentials] "); +#if AVALONIA + b.Append("[avalonia.ver] "); + b.Append(GetAssemblyVersion(typeof(global::Avalonia.Application).Assembly)); + b.AppendLine(); +#endif + + b.Append("[essentials.supported] "); b.Append(Essentials.IsSupported.ToLowerString()); b.AppendLine(); @@ -366,5 +372,11 @@ namespace System.Application.UI MessageBox.Show(b_str, ""); } } + + static string? GetAssemblyVersion(Assembly assembly) + => assembly.GetCustomAttribute()? + .InformationalVersion + .Split('+', StringSplitOptions.RemoveEmptyEntries) + .FirstOrDefault(); } } \ No newline at end of file diff --git a/src/Common.ClientLib/Application/Essentials/MainThread2.cs b/src/Common.ClientLib/Application/Essentials/MainThread2.cs index a67950a82..b41f1f8f0 100644 --- a/src/Common.ClientLib/Application/Essentials/MainThread2.cs +++ b/src/Common.ClientLib/Application/Essentials/MainThread2.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using System.Windows.Threading; using Xamarin.Essentials; using System.Application.Services; @@ -27,7 +26,7 @@ namespace System.Application } } - public static void BeginInvokeOnMainThread(Action action, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + public static void BeginInvokeOnMainThread(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { if (Essentials.IsSupported) { @@ -46,7 +45,7 @@ namespace System.Application } } - public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { if (Essentials.IsSupported) { @@ -83,7 +82,7 @@ namespace System.Application } } - public static Task InvokeOnMainThreadAsync(Func func, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + public static Task InvokeOnMainThreadAsync(Func func, DispatcherPriority priority = DispatcherPriority.Normal) { if (Essentials.IsSupported) { @@ -115,7 +114,7 @@ namespace System.Application } } - public static Task InvokeOnMainThreadAsync(Func funcTask, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + public static Task InvokeOnMainThreadAsync(Func funcTask, DispatcherPriority priority = DispatcherPriority.Normal) { if (Essentials.IsSupported) { @@ -148,7 +147,7 @@ namespace System.Application } } - public static Task InvokeOnMainThreadAsync(Func> funcTask, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + public static Task InvokeOnMainThreadAsync(Func> funcTask, DispatcherPriority priority = DispatcherPriority.Normal) { if (Essentials.IsSupported) { @@ -180,81 +179,78 @@ namespace System.Application return tcs.Task; } } - } -} - -namespace System.Windows.Threading -{ - /// - /// An enunmeration describing the priorities at which - /// operations can be invoked via the Dispatcher. - /// - /// - /// - public enum DispatcherPriorityCompat - { - /// - /// Operations at this priority are processed when the system - /// is idle. - /// - SystemIdle, /// - /// Minimum possible priority + /// An enunmeration describing the priorities at which + /// operations can be invoked via the Dispatcher. + /// /// - MinValue = SystemIdle, + /// + public enum DispatcherPriority + { + /// + /// Operations at this priority are processed when the system + /// is idle. + /// + SystemIdle, - /// - /// Operations at this priority are processed when the application - /// is idle. - /// - ApplicationIdle, + /// + /// Minimum possible priority + /// + MinValue = SystemIdle, - /// - /// Operations at this priority are processed when the context - /// is idle. - /// - ContextIdle, + /// + /// Operations at this priority are processed when the application + /// is idle. + /// + ApplicationIdle, - /// - /// Operations at this priority are processed after all other - /// non-idle operations are done. - /// - Background, + /// + /// Operations at this priority are processed when the context + /// is idle. + /// + ContextIdle, - /// - /// Operations at this priority are processed at the same - /// priority as input. - /// - Input, + /// + /// Operations at this priority are processed after all other + /// non-idle operations are done. + /// + Background, - /// - /// Operations at this priority are processed when layout and render is - /// done but just before items at input priority are serviced. Specifically - /// this is used while firing the Loaded event - /// - Loaded, + /// + /// Operations at this priority are processed at the same + /// priority as input. + /// + Input, - /// - /// Operations at this priority are processed at the same - /// priority as rendering. - /// - Render, + /// + /// Operations at this priority are processed when layout and render is + /// done but just before items at input priority are serviced. Specifically + /// this is used while firing the Loaded event + /// + Loaded, - /// - /// Operations at this priority are processed at normal priority. - /// - Normal, + /// + /// Operations at this priority are processed at the same + /// priority as rendering. + /// + Render, - /// - /// Operations at this priority are processed before other - /// asynchronous operations. - /// - Send, + /// + /// Operations at this priority are processed at normal priority. + /// + Normal, - /// - /// Maximum possible priority - /// - MaxValue = Send, + /// + /// Operations at this priority are processed before other + /// asynchronous operations. + /// + Send, + + /// + /// Maximum possible priority + /// + MaxValue = Send, + } } } \ No newline at end of file diff --git a/src/Common.ClientLib/Application/Services/IMainThreadPlatformService.cs b/src/Common.ClientLib/Application/Services/IMainThreadPlatformService.cs index 7519868dc..dd54bec94 100644 --- a/src/Common.ClientLib/Application/Services/IMainThreadPlatformService.cs +++ b/src/Common.ClientLib/Application/Services/IMainThreadPlatformService.cs @@ -1,4 +1,4 @@ -using System.Windows.Threading; +using static System.Application.MainThread2; namespace System.Application.Services { @@ -9,6 +9,6 @@ namespace System.Application.Services { bool PlatformIsMainThread { get; } - void PlatformBeginInvokeOnMainThread(Action action, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal); + void PlatformBeginInvokeOnMainThread(Action action, DispatcherPriority priority = DispatcherPriority.Normal); } } \ No newline at end of file diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/MainThreadPlatformServiceImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/MainThreadPlatformServiceImpl.cs index d62402260..1e634d049 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/MainThreadPlatformServiceImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/MainThreadPlatformServiceImpl.cs @@ -1,5 +1,4 @@ using Avalonia.Threading; -using System.Windows.Threading; namespace System.Application.Services.Implementation { @@ -8,23 +7,23 @@ namespace System.Application.Services.Implementation public bool PlatformIsMainThread => Dispatcher.UIThread.CheckAccess(); public void PlatformBeginInvokeOnMainThread(Action action, - DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal) + MainThread2.DispatcherPriority priority = MainThread2.DispatcherPriority.Normal) { var priority_ = GetPriority(priority); Dispatcher.UIThread.Post(action, priority_); } - static DispatcherPriority GetPriority(DispatcherPriorityCompat priority) => priority switch + static DispatcherPriority GetPriority(MainThread2.DispatcherPriority priority) => priority switch { - DispatcherPriorityCompat.SystemIdle => DispatcherPriority.SystemIdle, - DispatcherPriorityCompat.ApplicationIdle => DispatcherPriority.ApplicationIdle, - DispatcherPriorityCompat.ContextIdle => DispatcherPriority.ContextIdle, - DispatcherPriorityCompat.Background => DispatcherPriority.Background, - DispatcherPriorityCompat.Input => DispatcherPriority.Input, - DispatcherPriorityCompat.Loaded => DispatcherPriority.Loaded, - DispatcherPriorityCompat.Render => DispatcherPriority.Render, - DispatcherPriorityCompat.Normal => DispatcherPriority.Normal, - DispatcherPriorityCompat.Send => DispatcherPriority.Send, + MainThread2.DispatcherPriority.SystemIdle => DispatcherPriority.SystemIdle, + MainThread2.DispatcherPriority.ApplicationIdle => DispatcherPriority.ApplicationIdle, + MainThread2.DispatcherPriority.ContextIdle => DispatcherPriority.ContextIdle, + MainThread2.DispatcherPriority.Background => DispatcherPriority.Background, + MainThread2.DispatcherPriority.Input => DispatcherPriority.Input, + MainThread2.DispatcherPriority.Loaded => DispatcherPriority.Loaded, + MainThread2.DispatcherPriority.Render => DispatcherPriority.Render, + MainThread2.DispatcherPriority.Normal => DispatcherPriority.Normal, + MainThread2.DispatcherPriority.Send => DispatcherPriority.Send, _ => throw new ArgumentOutOfRangeException(nameof(priority), priority, null), }; } diff --git a/src/ST.Client.Desktop.Avalonia/ST.Client.Avalonia.csproj b/src/ST.Client.Desktop.Avalonia/ST.Client.Avalonia.csproj index 1167735cf..26b98019e 100644 --- a/src/ST.Client.Desktop.Avalonia/ST.Client.Avalonia.csproj +++ b/src/ST.Client.Desktop.Avalonia/ST.Client.Avalonia.csproj @@ -7,6 +7,7 @@ System.Application.SteamTools.Client.Desktop.Avalonia true + AVALONIA;$(DefineConstants) diff --git a/src/ST.Client/UI/ViewModels/Windows/TaskBarWindowViewModel.cs b/src/ST.Client/UI/ViewModels/Windows/TaskBarWindowViewModel.cs index a893a3bb3..5d14509ab 100644 --- a/src/ST.Client/UI/ViewModels/Windows/TaskBarWindowViewModel.cs +++ b/src/ST.Client/UI/ViewModels/Windows/TaskBarWindowViewModel.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Properties; using System.Reactive; -using System.Windows.Threading; +using static System.Application.MainThread2; // ReSharper disable once CheckNamespace namespace System.Application.UI.ViewModels @@ -75,7 +75,7 @@ namespace System.Application.UI.ViewModels IApplication.Instance.Shutdown(); return true; default: - MainThread2.BeginInvokeOnMainThread(() => + BeginInvokeOnMainThread(() => { if (tabItemId != default) OnMenuClick(s => @@ -83,7 +83,7 @@ namespace System.Application.UI.ViewModels item.Id == tabItemId, hideTaskBarWindow); else OnMenuClick(s => s.Name == tag, hideTaskBarWindow); - }, DispatcherPriorityCompat.MaxValue); + }, DispatcherPriority.MaxValue); break; } return false;