提交 00adfa32 编写于 作者: A Aigio Liu

🚧 Misc

上级 77ddd020
Subproject commit b2e7c6a10cb50286da16f00841994366952f9449
Subproject commit a4d992f156a233efad86b30e8ec7fae946d93268
#if DESIGNER
using Moq;
#endif
// ReSharper disable once CheckNamespace
namespace BD.WTTS;
......@@ -7,6 +11,14 @@ partial class Program
[STAThread]
static int Main(string[] args) // Main 函数需要 STA 线程不可更改为 async Task
{
#if DESIGNER
static object? Fallback(Type serviceType, bool required)
{
var moq = (Mock)Activator.CreateInstance(typeof(Mock<>).MakeGenericType(serviceType))!;
return moq.Object;
}
Ioc.Fallback = Fallback;
#endif
instance = new(args);
var exitCode = instance.StartAsync().GetAwaiter().GetResult();
return exitCode;
......
......@@ -67,6 +67,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Moq" />
<PackageReference Include="BD.Common.XmlnsDefinition.Avalonia">
<Aliases>BD_Common_XmlnsDefinition_Avalonia</Aliases>
</PackageReference>
......
namespace BD.WTTS.Extensions;
// ReSharper disable once CheckNamespace
namespace BD.WTTS;
public static class WindowTransparencyLevelExtensions
{
public static WindowTransparencyLevel ToWindowTransparencyLevel(this WindowBackgroundMaterial value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static WindowTransparencyLevel ToWindowTransparencyLevel(
this WindowBackgroundMaterial value)
{
return value switch
{
......
using BD.WTTS.Client.Resources;
using BD.WTTS.Extensions;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using SkiaSharp;
......
using BD.WTTS.Extensions;
namespace BD.WTTS.UI.Views.Windows;
/// <summary>
......
......@@ -694,6 +694,25 @@ publish -c {0} -p:OutputType={1} -p:PublishDir=bin\{0}\Publish\win-any -p:Publis
static void PublishAppHost(string publishDir, Platform platform, bool debug)
{
const string appconfigFileName = "Steam++.exe.config";
var rootPublishDir = Path.Combine(publishDir, "..");
var cacheFilePath = Path.Combine(ProjectUtils.ProjPath,
"res", "windows", "Steam++.apphost");
// 使用缓存文件
if (File.Exists(cacheFilePath))
{
File.Copy(cacheFilePath, Path.Combine(rootPublishDir, "Steam++.exe"));
var sourceFileName = Path.Combine(ProjectUtils.ProjPath, "src", "BD.WTTS.Client.AppHost", "App.config");
var appconfigContent = File.ReadAllText(sourceFileName);
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(appconfigContent);
appconfigContent = xmlDoc.InnerXml;
File.WriteAllText(Path.Combine(rootPublishDir, appconfigFileName), appconfigContent);
return;
}
const string app_host_tfm = "net40"/*"net35"*/; // net35 在 Windows 10 LTSC 上即使 app.config 中配置了 4.x 兼容但依旧会打开设置窗口并且定位在可选功能
var configuration = PublishCommandArg.GetConfiguration(debug);
string? arguments = null;
......@@ -716,10 +735,8 @@ publish -c {0} -p:OutputType={1} -p:PublishDir=bin\{0}\Publish\win-any -p:Publis
arguments ?? // 多次相同的编译产生的文件不会变化
throw new ArgumentOutOfRangeException(nameof(platform), platform, null));
var rootPublishDir = Path.Combine(publishDir, "..");
if (isWindows)
{
const string appconfigFileName = "Steam++.exe.config";
var appHostPublishDir = Path.Combine(projRootPath, "bin", configuration, "Publish", "win-any");
var apphostfilenames = new[]
{
......
......@@ -7,5 +7,6 @@ partial class Startup // 常量
const string help_ = "-h";
const string key_proxy = "proxy";
const string key_shutdown = "shutdown";
const string key_show = "show";
public const string command_main = "main";
}
......@@ -207,6 +207,26 @@ partial class Startup // 配置 Host
var app = await UIApplicationTCS.Task;
app.Shutdown();
return;
case key_show:
try
{
MainThread2.BeginInvokeOnMainThread(() =>
{
try
{
IApplication.Instance.RestoreMainWindow();
}
catch
{
}
});
}
catch
{
}
break;
default:
var args = value.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (args.Length >= 1)
......
......@@ -11,7 +11,7 @@ partial class Startup // 本应用程序单例管道
initSingleInstancePipeline: singleInstancePipeline = new();
if (!singleInstancePipeline.IsFirstSelfApp)
{
if (SingleInstancePipeline.SendMessage(sendMessage?.Invoke() ?? ""))
if (SingleInstancePipeline.SendMessage(sendMessage?.Invoke() ?? (IsMainProcess ? key_show : "")))
{
return false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册