DesktopBridge Hide Settings_General_UpdateChannel

This commit is contained in:
Aigio Liu
2021-10-02 22:49:31 +08:00
parent 2f0bf8812f
commit 24f9fe2943
10 changed files with 72 additions and 51 deletions
@@ -257,7 +257,7 @@ namespace System.Application.UI
#endif
}
public ContextMenu? NotifyIconContextMenu { get; private set; }
//public ContextMenu? NotifyIconContextMenu { get; private set; }
public override void OnFrameworkInitializationCompleted()
{
@@ -349,10 +349,10 @@ namespace System.Application.UI
#if StartupTrace
StartupTrace.Restart("AppCenterSDK.Init");
#endif
AppHelper.Initialized?.Invoke();
#if StartupTrace
StartupTrace.Restart("Desktop_Startup.AppHelper.Initialized?");
#endif
// AppHelper.Initialized?.Invoke();
//#if StartupTrace
// StartupTrace.Restart("Desktop_Startup.AppHelper.Initialized?");
//#endif
Startup.OnStartup(Program.IsMainProcess);
#if StartupTrace
if (Program.IsMainProcess)
@@ -384,7 +384,7 @@ namespace System.Application.UI
#if WINDOWS
//WpfApplication.Current.Shutdown();
#endif
AppHelper.TryShutdown();
//AppHelper.TryShutdown();
}
internal void NotifyIcon_Click(object? sender, EventArgs e)
@@ -482,7 +482,7 @@ namespace System.Application.UI
if (OperatingSystem2.IsWindows && Instance.MainWindow is MainWindow window)
{
#pragma warning disable CA1416 // 验证平台兼容性
DI.Get<ISystemWindowApiService>().SetDesktopBackgroundToWindow(window._backHandle, Convert.ToInt32(window.Width), Convert.ToInt32(window.Height));
DI.Get<ISystemWindowApiService>().SetDesktopBackgroundToWindow(window.BackHandle, Convert.ToInt32(window.Width), Convert.ToInt32(window.Height));
#pragma warning restore CA1416 // 验证平台兼容性
}
}
@@ -506,7 +506,7 @@ namespace System.Application.UI
void IDesktopAppService.Shutdown() => Shutdown();
bool IDesktopAppService.IsCefInitComplete => false;
//bool IDesktopAppService.IsCefInitComplete => false;
//CefNetApp.InitState == CefNetAppInitState.Complete;
#region IDisposable members
@@ -11,9 +11,6 @@ namespace System.Application.UI
{
static partial class Program
{
static readonly HashSet<Exception> exceptions = new();
static readonly object lock_global_ex_log = new();
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
@@ -7,12 +7,16 @@ using ReactiveUI;
using System.Application.UI.ViewModels;
using System.Application.UI.Views.Controls;
using System.ComponentModel;
using System.Linq;
namespace System.Application.UI.Views
{
public class MainWindow : FluentWindow<MainWindowViewModel>
{
public IntPtr _backHandle;
readonly IntPtr _backHandle;
public IntPtr BackHandle => _backHandle;
public MainWindow() : base()
{
InitializeComponent();
@@ -40,8 +44,8 @@ namespace System.Application.UI.Views
e.Cancel = true;
Hide();
if (this.ViewModel is not null)
foreach (var tab in this.ViewModel.TabItems)
if (ViewModel is not null)
foreach (var tab in ViewModel.TabItems)
tab.Deactivation();
}
#endif
@@ -50,10 +54,13 @@ namespace System.Application.UI.Views
protected override void FluentWindow_Opened(object? sender, EventArgs e)
{
if (this.ViewModel is not null)
foreach (var tab in this.ViewModel.TabItems)
if (tab.IsDeactivation)
tab.Activation();
if (ViewModel is not null)
foreach (var tab in from tab in ViewModel.TabItems
where tab.IsDeactivation
select tab)
{
tab.Activation();
}
base.FluentWindow_Opened(sender, e);
}
@@ -4,6 +4,7 @@
xmlns:resx="clr-namespace:System.Application.UI.Resx;assembly=System.Application.SteamTools.Client.Desktop"
xmlns:ms="clr-namespace:System.Application.Models.Settings;assembly=System.Application.SteamTools.Client.Desktop"
xmlns:sys_os2="clr-namespace:System;assembly=System.OperatingSystem2"
xmlns:sys_common_corelib="clr-namespace:System;assembly=System.Common.CoreLib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@@ -59,7 +60,7 @@
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:GeneralSettings.IsAutoCheckUpdate},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<StackPanel Orientation="Vertical" Spacing="10">
<StackPanel Orientation="Vertical" Spacing="10" IsVisible="{ReflectionBinding Source={x:Static sys_common_corelib:DesktopBridge.IsRunningAsUwp}, Mode=OneTime, Converter={x:Static BoolConverters.Not}}}">
<TextBlock Text="{ReflectionBinding Path=Res.Settings_General_UpdateChannel,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ComboBox x:Name="Themes"
Items="{Binding UpdateChannels}"
@@ -85,7 +85,7 @@ namespace System.Application.Models.Settings
#if !__MOBILE__
/// <summary>
/// 使用硬件加速
/// 使用硬件加速(仅macOS)
/// </summary>
public static SerializableProperty<bool> UseGPURendering { get; }
= GetProperty(defaultValue: true, autoSave: true);
@@ -97,13 +97,13 @@ namespace System.Application.Models.Settings
= GetProperty(defaultValue: default(IHostsFileService.EncodingType), autoSave: true);
///// <summary>
///// 使用 Direct2D1 渲染
///// 使用 Direct2D1 渲染(仅 Windows)
///// </summary>
//public static SerializableProperty<bool> UseDirect2D1 { get; }
// = GetProperty(defaultValue: false, autoSave: true);
/// <summary>
/// Avalonia would try to use native Widows OpenGL when set to true. The default value is false.
/// Avalonia would try to use native Widows OpenGL when set to true. The default value is false.(仅 Windows)
/// </summary>
public static SerializableProperty<bool> UseOpenGL { get; }
= GetProperty(defaultValue: OperatingSystem2.IsWindows7, autoSave: true);
@@ -30,7 +30,7 @@ namespace System.Application.Services
/// </summary>
IReadOnlyDictionary<string, ICommand> NotifyIconMenus { get; }
bool IsCefInitComplete { get; }
//bool IsCefInitComplete { get; }
CompositeDisposable CompositeDisposable { get; }
@@ -84,8 +84,10 @@ namespace System.Application.Services
Auto,
/// <summary>
/// 系统的活动代码页并创建 Encoding 与其对应的对象。
/// (仅 Windows)系统的活动代码页并创建 Encoding 与其对应的对象。
/// 活动代码页可能是 ANSI 代码页,其中包括 ASCII 字符集以及不同于代码页的其他字符。
/// <para></para>
/// 在非 Windows 上此项与 <see cref="UTF8"/> 行为一致。
/// </summary>
ANSICodePage,
+22 -10
View File
@@ -19,19 +19,31 @@ namespace System.Application.UI
/// </summary>
public static bool UseOpenGL { get; set; }
public static bool IsSystemWebViewAvailable { get; set; }
///// <summary>
///// 当前系统WebView是否可用
///// </summary>
//public static bool IsSystemWebViewAvailable { get; set; }
public static Action? Initialized { get; set; }
///// <summary>
///// 初始化完成时事件
///// </summary>
//public static Action? Initialized { get; set; }
public static Action? Shutdown { get; set; }
///// <summary>
///// 关闭程序时事件
///// </summary>
//public static Action? Shutdown { get; set; }
static bool isShutdown = false;
public static void TryShutdown()
{
if (isShutdown) return;
isShutdown = true;
Shutdown?.Invoke();
}
//static bool isShutdown = false;
/// <summary>
/// 关闭应用程序
/// </summary>
//public static void TryShutdown()
//{
// if (isShutdown) return;
// isShutdown = true;
// Shutdown?.Invoke();
//}
static AppHelper()
{
+3 -1
View File
@@ -23,7 +23,9 @@ namespace System.Application.Services
void OpenFileByTextReader(string filePath);
/// <summary>
/// .NET Framework 中 <see cref="Encoding.Default"/> 行为
/// 在 Windows 上时使用 .NET Framework 中 <see cref="Encoding.Default"/> 行为。
/// <para></para>
/// 非 Windows 上等同于 <see cref="Encoding.Default"/>(UTF8)
/// </summary>
Encoding Default => Encoding.Default;
+16 -16
View File
@@ -47,8 +47,7 @@ namespace System.Application
{
lock (lock_global_ex_log)
{
if (exceptions.Contains(ex)) return;
exceptions.Add(ex);
if (!exceptions.Add(ex)) return;
}
AppHelper.TrySetLoggerMinLevel(LogLevel.Trace);
@@ -68,10 +67,11 @@ namespace System.Application
#endif
#if !__MOBILE__
var callTryShutdown = true;
//var callTryShutdown = true;
try
{
callTryShutdown = !App.Shutdown();
/*callTryShutdown = !*/
App.Shutdown();
}
catch (Exception ex_shutdown)
{
@@ -79,18 +79,18 @@ namespace System.Application
"(App)Close exception when exception occurs");
}
if (callTryShutdown)
{
try
{
AppHelper.TryShutdown();
}
catch (Exception ex_shutdown_app_helper)
{
Logger?.Error(ex_shutdown_app_helper,
"(AppHelper)Close exception when exception occurs");
}
}
//if (callTryShutdown)
//{
// try
// {
// AppHelper.TryShutdown();
// }
// catch (Exception ex_shutdown_app_helper)
// {
// Logger?.Error(ex_shutdown_app_helper,
// "(AppHelper)Close exception when exception occurs");
// }
//}
try
{