* 源码兼容VS2019编译,在Nuget发布时增加.Net6目标编译,.Net6应用从Nuget引用。
This commit is contained in:
parent
7bebb67433
commit
4c91c0a976
Binary file not shown.
Binary file not shown.
4
SunnyUI.Demo/Properties/Resources.Designer.cs
generated
4
SunnyUI.Demo/Properties/Resources.Designer.cs
generated
@ -19,7 +19,7 @@ namespace Sunny.UI.Demo.Properties {
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
@ -271,7 +271,7 @@ namespace Sunny.UI.Demo.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 20220105 的本地化字符串。
|
||||
/// 查找类似 20220109 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string BuildDate {
|
||||
get {
|
||||
|
@ -155,7 +155,7 @@
|
||||
<value>..\Resources\brescia.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="BuildDate" xml:space="preserve">
|
||||
<value>20220105</value>
|
||||
<value>20220109</value>
|
||||
</data>
|
||||
<data name="ChartDarkStyle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ChartDarkStyle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -507,7 +507,7 @@ namespace Sunny.UI
|
||||
|
||||
private void CalcEditHeight()
|
||||
{
|
||||
TextBox edt = new();
|
||||
TextBox edt = new TextBox();
|
||||
edt.Font = edit.Font.DPIScaleFont();
|
||||
MinHeight = edt.PreferredHeight;
|
||||
edt.BorderStyle = BorderStyle.None;
|
||||
|
@ -27,6 +27,11 @@ namespace Sunny.UI
|
||||
{
|
||||
public static class UIDPIScale
|
||||
{
|
||||
public static float DPIScale()
|
||||
{
|
||||
return GDI.Graphics().DpiX / 96.0f;
|
||||
}
|
||||
|
||||
public static float DPIScale(this Control control)
|
||||
{
|
||||
try
|
||||
@ -57,9 +62,8 @@ namespace Sunny.UI
|
||||
|
||||
public static float DPIScaleFontSize(this float fontSize)
|
||||
{
|
||||
using Control control = new();
|
||||
if (UIStyles.DPIScale)
|
||||
return fontSize / control.DPIScale();
|
||||
return fontSize / DPIScale();
|
||||
else
|
||||
return fontSize;
|
||||
}
|
||||
@ -69,6 +73,24 @@ namespace Sunny.UI
|
||||
return control.DPIScaleFont(font, font.Size);
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Font font)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
{
|
||||
if (font.GdiCharSet == 134)
|
||||
return new Font(font.FontFamily, font.Size / DPIScale(), font.Style, font.Unit, font.GdiCharSet);
|
||||
else
|
||||
return new Font(font.FontFamily, font.Size / DPIScale());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font.GdiCharSet == 134)
|
||||
return new Font(font.FontFamily, font.Size, font.Style, font.Unit, font.GdiCharSet);
|
||||
else
|
||||
return new Font(font.FontFamily, font.Size);
|
||||
}
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Control control, Font font, float fontSize)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
@ -87,23 +109,10 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Font font)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
{
|
||||
using Control control = new();
|
||||
return control.DPIScaleFont(font);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetDPIScaleFont(this Control control)
|
||||
{
|
||||
if (!UIStyles.DPIScale) return;
|
||||
if (!control.DPIScale().EqualsFloat(1))
|
||||
if (!DPIScale().EqualsFloat(1))
|
||||
{
|
||||
if (control is IStyleInterface ctrl)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0-windows;net5.0-windows;net472;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net5.0-windows;net472;net40</TargetFrameworks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<ProjectGuid>{AB1CB247-E20B-4CBE-B269-570ADDD96C53}</ProjectGuid>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
Loading…
x
Reference in New Issue
Block a user