fix window issue

This commit is contained in:
DismissedLight
2022-09-27 14:36:13 +08:00
parent e925c5909c
commit c0ddb24825
4 changed files with 17 additions and 5 deletions

View File

@@ -4,6 +4,7 @@
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Snap.Hutao.Core.Setting;
using Snap.Hutao.Win32;
using System.Runtime.InteropServices;
using Windows.Graphics;
using Windows.Win32.Foundation;
@@ -25,11 +26,11 @@ internal static class Persistence
// Set first launch size.
HWND hwnd = (HWND)Win32Interop.GetWindowFromWindowId(appWindow.Id);
SizeInt32 size = TransformSizeForWindow(new(1200, 741), hwnd);
RectInt32 rect = new(0, 0, size.Width, size.Height);
RectInt32 rect = StructMarshal.RectInt32(size);
// Make it centralized
TransformToCenterScreen(ref rect);
RectInt32 target = (CompactRect)LocalSetting.Get(SettingKeys.WindowRect, (ulong)(CompactRect)rect);
//if(target.Width*target.Height)
TransformToCenterScreen(ref target);
appWindow.MoveAndResize(target);
}

View File

@@ -12,7 +12,7 @@ public class DetailedCertification : Certification
/// Id
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
public string Id { get; set; } = default!;
/// <summary>
/// 认证Id

View File

@@ -7,7 +7,7 @@ using Windows.Win32.System.Diagnostics.ToolHelp;
namespace Snap.Hutao.Win32;
/// <summary>
/// 内存拓展
/// 内存拓展 for <see cref="Memory{T}"/> <see cref="Span{T}"/>
/// </summary>
internal static class MemoryExtensions
{

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Windows.Graphics;
using Windows.Win32.System.Diagnostics.ToolHelp;
namespace Snap.Hutao.Win32;
@@ -19,6 +20,16 @@ internal static class StructMarshal
return new() { dwSize = (uint)sizeof(MODULEENTRY32) };
}
/// <summary>
/// 构造一个新的<see cref="Windows.Graphics.RectInt32"/>
/// </summary>
/// <param name="size">尺寸</param>
/// <returns>新的实例</returns>
public static RectInt32 RectInt32(SizeInt32 size)
{
return new(0, 0, size.Width, size.Height);
}
/// <summary>
/// 判断结构实例是否为默认结构
/// </summary>