mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 05:56:52 +08:00
优化 MSBuild 在 Release 时 不生成PDB
新增平台架构(win/mac/linux) 优化 发布配置
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace System.Application.Services.Implementation
|
||||
{
|
||||
[SupportedOSPlatform("Windows")]
|
||||
internal sealed class WindowsDesktopPlatformServiceImpl : IDesktopPlatformService
|
||||
{
|
||||
#region 窗口右上角的三个按钮(最小化,最大化,关闭)
|
||||
|
||||
// https://stackoverflow.com/questions/339620/how-do-i-remove-minimize-and-maximize-from-a-resizable-window-in-wpf
|
||||
// https://blog.magnusmontin.net/2014/11/30/disabling-or-hiding-the-minimize-maximize-or-close-button-of-a-wpf-window/
|
||||
|
||||
public const int MF_BYCOMMAND = 0x00000000;
|
||||
public const int SC_CLOSE = 0xF060;
|
||||
public const int SC_MINIMIZE = 0xF020;
|
||||
public const int SC_MAXIMIZE = 0xF030;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
public const int GWL_STYLE = -16,
|
||||
WS_MAXIMIZEBOX = 0x10000,
|
||||
WS_MINIMIZEBOX = 0x20000;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public extern static int GetWindowLong(IntPtr hwnd, int index);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public extern static int SetWindowLong(IntPtr hwnd, int index, int value);
|
||||
|
||||
public const int WS_SYSMENU = 0x80000;
|
||||
|
||||
public static void EnableMinimizeButton(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_MINIMIZEBOX);
|
||||
}
|
||||
|
||||
public static void EnableMaximizeButton(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_MAXIMIZEBOX);
|
||||
}
|
||||
|
||||
public static void ShowMinimizeAndMaximizeButtons(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
|
||||
}
|
||||
|
||||
public static void ShowAllButtons(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_SYSMENU);
|
||||
}
|
||||
|
||||
public static void HideMinimizeAndMaximizeButtons(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
|
||||
}
|
||||
|
||||
public static void DisableMinimizeButton(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_MINIMIZEBOX);
|
||||
}
|
||||
|
||||
public static void DisableMaximizeButton(IntPtr hWnd)
|
||||
{
|
||||
_ = SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_MAXIMIZEBOX);
|
||||
}
|
||||
|
||||
public void SetResizeMode(IntPtr hWnd, int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case IDesktopPlatformService.ResizeMode_NoResize:
|
||||
_ = DeleteMenu(GetSystemMenu(hWnd, false), SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
_ = DeleteMenu(GetSystemMenu(hWnd, false), SC_MINIMIZE, MF_BYCOMMAND);
|
||||
HideMinimizeAndMaximizeButtons(hWnd);
|
||||
break;
|
||||
case IDesktopPlatformService.ResizeMode_CanMinimize:
|
||||
_ = DeleteMenu(GetSystemMenu(hWnd, false), SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
DisableMaximizeButton(hWnd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user