* UIDropControl: 修复在高DPI下,文字垂直不居中的问题
* UIDropControl: 修复在某些字体不显示下划线的问题
This commit is contained in:
parent
65edeffedd
commit
85a56809f1
@ -36,13 +36,11 @@
|
|||||||
//
|
//
|
||||||
// UIDropControl
|
// UIDropControl
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
|
||||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
MinimumSize = new System.Drawing.Size(63, 0);
|
MinimumSize = new System.Drawing.Size(63, 0);
|
||||||
Name = "UIDropControl";
|
Name = "UIDropControl";
|
||||||
Size = new System.Drawing.Size(150, 29);
|
Size = new System.Drawing.Size(194, 29);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
* 2023-05-16: V3.3.6 重构DrawFontImage函数
|
* 2023-05-16: V3.3.6 重构DrawFontImage函数
|
||||||
* 2023-08-24: V3.4.2 修改背景色后编辑框颜色修复
|
* 2023-08-24: V3.4.2 修改背景色后编辑框颜色修复
|
||||||
* 2023-08-28: V3.4.2 下拉框按钮图标增加编辑器
|
* 2023-08-28: V3.4.2 下拉框按钮图标增加编辑器
|
||||||
|
* 2023-10-25: V3.5.1 修复在高DPI下,文字垂直不居中的问题
|
||||||
|
* 2023-10-25: V3.5.1 修复在某些字体不显示下划线的问题
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -47,8 +49,7 @@ namespace Sunny.UI
|
|||||||
SetStyleFlags();
|
SetStyleFlags();
|
||||||
Padding = new Padding(0, 0, 30, 2);
|
Padding = new Padding(0, 0, 30, 2);
|
||||||
|
|
||||||
edit.AutoSize = false;
|
edit.AutoSize = true;
|
||||||
//edit.Font = UIStyles.Font();
|
|
||||||
edit.Left = 4;
|
edit.Left = 4;
|
||||||
edit.Top = 3;
|
edit.Top = 3;
|
||||||
edit.Text = String.Empty;
|
edit.Text = String.Empty;
|
||||||
@ -59,9 +60,14 @@ namespace Sunny.UI
|
|||||||
edit.KeyUp += EditOnKeyUp;
|
edit.KeyUp += EditOnKeyUp;
|
||||||
edit.KeyPress += EditOnKeyPress;
|
edit.KeyPress += EditOnKeyPress;
|
||||||
edit.LostFocus += Edit_LostFocus;
|
edit.LostFocus += Edit_LostFocus;
|
||||||
|
edit.SizeChanged += Edit_SizeChanged;
|
||||||
edit.Invalidate();
|
edit.Invalidate();
|
||||||
Controls.Add(edit);
|
Controls.Add(edit);
|
||||||
|
|
||||||
|
lastEditHeight = edit.Height;
|
||||||
|
Width = 150;
|
||||||
|
Height = 29;
|
||||||
|
|
||||||
TextAlignment = ContentAlignment.MiddleLeft;
|
TextAlignment = ContentAlignment.MiddleLeft;
|
||||||
fillColor = Color.White;
|
fillColor = Color.White;
|
||||||
edit.BackColor = Color.White;
|
edit.BackColor = Color.White;
|
||||||
@ -70,6 +76,16 @@ namespace Sunny.UI
|
|||||||
ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height);
|
ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lastEditHeight = -1;
|
||||||
|
private void Edit_SizeChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lastEditHeight != edit.Height)
|
||||||
|
{
|
||||||
|
lastEditHeight = edit.Height;
|
||||||
|
SizeChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
@ -87,7 +103,6 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
|
if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
|
||||||
SizeChange();
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,19 +386,36 @@ namespace Sunny.UI
|
|||||||
/// <param name="e">参数</param>
|
/// <param name="e">参数</param>
|
||||||
protected override void OnSizeChanged(EventArgs e)
|
protected override void OnSizeChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
SizeChange();
|
base.OnSizeChanged(e);
|
||||||
|
|
||||||
|
if (!NoNeedChange)
|
||||||
|
{
|
||||||
|
SizeChange();
|
||||||
|
}
|
||||||
|
|
||||||
if (tipsBtn != null)
|
if (tipsBtn != null)
|
||||||
{
|
{
|
||||||
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool NoNeedChange = false;
|
||||||
|
|
||||||
private void SizeChange()
|
private void SizeChange()
|
||||||
{
|
{
|
||||||
if (Height < UIGlobal.EditorMinHeight) Height = UIGlobal.EditorMinHeight;
|
if (Height < edit.Height + RectSize * 2 + 2)
|
||||||
if (Height > UIGlobal.EditorMaxHeight) Height = UIGlobal.EditorMaxHeight;
|
{
|
||||||
edit.Height = Math.Min(Height - RectSize * 2, edit.PreferredHeight);
|
NoNeedChange = true;
|
||||||
edit.Top = (Height - edit.Height) / 2;
|
Height = edit.Height + RectSize * 2 + 2;
|
||||||
|
edit.Top = (Height - edit.Height) / 2;
|
||||||
|
NoNeedChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edit.Top != (Height - edit.Height) / 2 + 1)
|
||||||
|
{
|
||||||
|
edit.Top = (Height - edit.Height) / 2 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
edit.Left = 4 + Padding.Left;
|
edit.Left = 4 + Padding.Left;
|
||||||
edit.Width = Width - Padding.Left - Padding.Right - 4;
|
edit.Width = Width - Padding.Left - Padding.Right - 4;
|
||||||
ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height);
|
ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
|
@ -109,9 +109,6 @@ namespace Sunny.UI
|
|||||||
edit.MouseDoubleClick += Edit_MouseDoubleClick;
|
edit.MouseDoubleClick += Edit_MouseDoubleClick;
|
||||||
edit.SizeChanged += Edit_SizeChanged;
|
edit.SizeChanged += Edit_SizeChanged;
|
||||||
|
|
||||||
Width = 150;
|
|
||||||
Height = 29;
|
|
||||||
|
|
||||||
btn.Parent = this;
|
btn.Parent = this;
|
||||||
btn.Visible = false;
|
btn.Visible = false;
|
||||||
btn.Text = "";
|
btn.Text = "";
|
||||||
@ -135,8 +132,10 @@ namespace Sunny.UI
|
|||||||
bar.MouseEnter += Bar_MouseEnter;
|
bar.MouseEnter += Bar_MouseEnter;
|
||||||
TextAlignment = ContentAlignment.MiddleLeft;
|
TextAlignment = ContentAlignment.MiddleLeft;
|
||||||
|
|
||||||
SizeChange();
|
|
||||||
lastEditHeight = edit.Height;
|
lastEditHeight = edit.Height;
|
||||||
|
Width = 150;
|
||||||
|
Height = 29;
|
||||||
|
|
||||||
editCursor = Cursor;
|
editCursor = Cursor;
|
||||||
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
||||||
}
|
}
|
||||||
@ -674,12 +673,8 @@ namespace Sunny.UI
|
|||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
|
|
||||||
if (DefaultFontSize < 0 && edit != null)
|
if (DefaultFontSize < 0 && edit != null)
|
||||||
{
|
|
||||||
edit.Font = this.Font;
|
edit.Font = this.Font;
|
||||||
edit.Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
SizeChange();
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,9 +734,9 @@ namespace Sunny.UI
|
|||||||
NoNeedChange = false;
|
NoNeedChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edit.Top != (Height - edit.Height) / 2)
|
if (edit.Top != (Height - edit.Height) / 2 + 1)
|
||||||
{
|
{
|
||||||
edit.Top = (Height - edit.Height) / 2;
|
edit.Top = (Height - edit.Height) / 2 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon == null && Symbol == 0)
|
if (icon == null && Symbol == 0)
|
||||||
@ -783,7 +778,7 @@ namespace Sunny.UI
|
|||||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
|
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
|
||||||
bar.Top = 2;
|
bar.Top = 2;
|
||||||
bar.Width = barWidth;
|
bar.Width = barWidth;
|
||||||
bar.Left = Width - bar.Width - 1;
|
bar.Left = Width - bar.Width - 2;
|
||||||
bar.Height = Height - 4;
|
bar.Height = Height - 4;
|
||||||
bar.BringToFront();
|
bar.BringToFront();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user