* UITextBox: 修正编辑框高度
This commit is contained in:
parent
b87205d795
commit
7634dedc59
Binary file not shown.
Binary file not shown.
@ -20,13 +20,10 @@
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -38,9 +35,12 @@ namespace Sunny.UI
|
||||
public UIIPTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponentEnd = true;
|
||||
|
||||
SetStyleFlags();
|
||||
ShowText = false;
|
||||
Width = 150;
|
||||
Height = 29;
|
||||
|
||||
UIIPTextBox_SizeChanged(null, null);
|
||||
foreach (TextBox txt in Controls.OfType<TextBox>())
|
||||
@ -53,6 +53,9 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
const int MinHeight = 20;
|
||||
const int MaxHeight = 60;
|
||||
|
||||
private void Txt_Leave(object sender, EventArgs e)
|
||||
{
|
||||
TextBox t = (TextBox)sender;
|
||||
@ -400,9 +403,6 @@ namespace Sunny.UI
|
||||
txt3.Left = txt2.Right + 5;
|
||||
txt4.Left = txt3.Right + 5;
|
||||
|
||||
int MinHeight = txt1.PreferredHeight + RectSize * 2;
|
||||
int MaxHeight = txt1.PreferredHeight * 2;
|
||||
|
||||
if (Height < MinHeight) Height = MinHeight;
|
||||
if (Height > MaxHeight) Height = MaxHeight;
|
||||
|
||||
@ -417,6 +417,7 @@ namespace Sunny.UI
|
||||
protected override void OnFontChanged(EventArgs e)
|
||||
{
|
||||
base.OnFontChanged(e);
|
||||
if (!InitializeComponentEnd) return;
|
||||
if (txt1 == null || txt2 == null || txt3 == null || txt4 == null) return;
|
||||
txt1.Font = txt2.Font = txt3.Font = txt4.Font = Font;
|
||||
UIIPTextBox_SizeChanged(null, null);
|
||||
|
@ -45,6 +45,7 @@ namespace Sunny.UI
|
||||
protected Color rectColor = UIStyles.GetStyleColor(UIStyle.Blue).RectColor;
|
||||
protected Color fillColor = UIStyles.GetStyleColor(UIStyle.Blue).PlainColor;
|
||||
protected Color foreColor = UIStyles.GetStyleColor(UIStyle.Blue).PanelForeColor;
|
||||
protected bool InitializeComponentEnd;
|
||||
|
||||
public UIPanel()
|
||||
{
|
||||
|
@ -49,9 +49,11 @@ namespace Sunny.UI
|
||||
private readonly UIScrollBar bar = new UIScrollBar();
|
||||
private readonly UISymbolButton btn = new UISymbolButton();
|
||||
|
||||
|
||||
public UITextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponentEnd = true;
|
||||
SetStyleFlags();
|
||||
|
||||
ShowText = false;
|
||||
@ -59,6 +61,9 @@ namespace Sunny.UI
|
||||
Padding = new Padding(0);
|
||||
MinimumSize = new Size(1, 16);
|
||||
|
||||
Width = 150;
|
||||
Height = 29;
|
||||
|
||||
edit.AutoSize = false;
|
||||
edit.Top = (Height - edit.Height) / 2;
|
||||
edit.Left = 4;
|
||||
@ -97,8 +102,6 @@ namespace Sunny.UI
|
||||
edit.Invalidate();
|
||||
Controls.Add(edit);
|
||||
fillColor = Color.White;
|
||||
Width = 150;
|
||||
Height = 29;
|
||||
|
||||
bar.Parent = this;
|
||||
bar.Dock = DockStyle.None;
|
||||
@ -281,8 +284,6 @@ namespace Sunny.UI
|
||||
DoubleClick?.Invoke(this, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Click?.Invoke(this, e);
|
||||
@ -502,19 +503,17 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
int MinHeight;
|
||||
int MaxHeight;
|
||||
const int MinHeight = 20;
|
||||
const int MaxHeight = 60;
|
||||
|
||||
private void SizeChange()
|
||||
{
|
||||
if (!InitializeComponentEnd) return;
|
||||
if (edit == null) return;
|
||||
if (btn == null) return;
|
||||
|
||||
if (!multiline)
|
||||
{
|
||||
MinHeight = edit.PreferredHeight + RectSize * 2;
|
||||
MaxHeight = edit.PreferredHeight * 2;
|
||||
|
||||
if (Height < MinHeight) Height = MinHeight;
|
||||
if (Height > MaxHeight) Height = MaxHeight;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user