mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-29 07:27:36 +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
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Application.Services;
|
||||
using System.Application.Services.Implementation;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddDesktopPlatformService(this IServiceCollection services)
|
||||
{
|
||||
if (DI.Platform == Platform.Windows)
|
||||
{
|
||||
services.AddSingleton<IDesktopPlatformService, WindowsDesktopPlatformServiceImpl>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>System.Application.Services</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\System.Common.CoreLib\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\System.Application.SteamTools.Client.Desktop.Platform\System.Application.SteamTools.Client.Desktop.Platform.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user