解决了UITextBox粘贴会重复粘贴两次的Bug

This commit is contained in:
Sunny 2020-05-28 23:11:16 +08:00
parent 361af57295
commit 1df5a5adac
7 changed files with 37 additions and 64 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -54,7 +54,6 @@ namespace Sunny.UI
edit.Text = String.Empty;
edit.ForeColor = UIFontColor.Primary;
edit.BorderStyle = BorderStyle.None;
edit.KeyDown += EditOnKeyDown;
edit.TextChanged += EditTextChanged;
edit.Invalidate();
Controls.Add(edit);
@ -216,27 +215,6 @@ namespace Sunny.UI
e.Graphics.DrawFontImage(dropSymbol, 24, color, Width - 28 + (12 - sf.Width / 2.0f), (Height - sf.Height) / 2.0f);
}
private void EditOnKeyDown(object Obj, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A)
{
edit.SelectAll();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.C)
{
edit.Copy();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.V)
{
edit.Paste();
e.SuppressKeyPress = true;
}
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
@ -332,7 +310,6 @@ namespace Sunny.UI
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
[DefaultValue(null)]
public string Watermark
{

View File

@ -71,17 +71,6 @@ namespace Sunny.UI
e.Handled = true;
}
base.OnKeyDown(e);
EditOnKeyDown(e);
}
public bool EnterAsTab { get; set; }
public event EventHandler EnterKeyPress;
private void EditOnKeyDown(KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A)
{
SelectAll();
@ -99,13 +88,21 @@ namespace Sunny.UI
Paste();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.X)
{
Cut();
e.SuppressKeyPress = true;
}
base.OnKeyDown(e);
}
[
DefaultValue(typeof(bool), "false"),
Category("Appearance"),
Description("整型、浮点型可以为空")
]
public bool EnterAsTab { get; set; }
public event EventHandler EnterKeyPress;
[DefaultValue(false), Category("Appearance"), Description("整型、浮点型可以为空")]
public bool CanEmpty
{
get => canEmpty;

View File

@ -129,23 +129,23 @@ namespace Sunny.UI
{
KeyDown?.Invoke(sender, e);
if (e.Control && e.KeyCode == Keys.A)
{
edit.SelectAll();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.C)
{
edit.Copy();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.V)
{
edit.Paste();
e.SuppressKeyPress = true;
}
// if (e.Control && e.KeyCode == Keys.A)
// {
// edit.SelectAll();
// e.SuppressKeyPress = true;
// }
//
// if (e.Control && e.KeyCode == Keys.C)
// {
// edit.Copy();
// e.SuppressKeyPress = true;
// }
//
// if (e.Control && e.KeyCode == Keys.V)
// {
// edit.Paste();
// e.SuppressKeyPress = true;
// }
}
protected override void OnGotFocus(EventArgs e)

View File

@ -584,12 +584,11 @@ namespace Sunny.UI
return;
}
//Color titleColor = rectColor;// IsDesignMode ? rectColor : IsActive ? rectColor : Color.From
//Argb(173, 178, 181);
Color showTitleColor = IsDesignMode || IsActive ? rectColor : Color.FromArgb(173, 178, 181);
if (ShowTitle)
{
e.Graphics.FillRectangle(new SolidBrush(titleColor), 0, 0, Width, TitleHeight);
e.Graphics.FillRectangle(showTitleColor, 0, 0, Width, TitleHeight);
}
if (ShowRect)
@ -626,14 +625,14 @@ namespace Sunny.UI
};
}
e.Graphics.DrawLines(rectColor, points);
e.Graphics.DrawLines(showTitleColor, points);
if (!unShowRadius)
{
e.Graphics.DrawLine(Color.FromArgb(120, rectColor), new Point(2, 1), new Point(1, 2));
e.Graphics.DrawLine(Color.FromArgb(120, rectColor), new Point(2, Height - 1 - 1), new Point(1, Height - 1 - 2));
e.Graphics.DrawLine(Color.FromArgb(120, rectColor), new Point(Width - 1 - 2, 1), new Point(Width - 1 - 1, 2));
e.Graphics.DrawLine(Color.FromArgb(120, rectColor), new Point(Width - 1 - 2, Height - 1 - 1), new Point(Width - 1 - 1, Height - 1 - 2));
e.Graphics.DrawLine(Color.FromArgb(120, showTitleColor), new Point(2, 1), new Point(1, 2));
e.Graphics.DrawLine(Color.FromArgb(120, showTitleColor), new Point(2, Height - 1 - 1), new Point(1, Height - 1 - 2));
e.Graphics.DrawLine(Color.FromArgb(120, showTitleColor), new Point(Width - 1 - 2, 1), new Point(Width - 1 - 1, 2));
e.Graphics.DrawLine(Color.FromArgb(120, showTitleColor), new Point(Width - 1 - 2, Height - 1 - 1), new Point(Width - 1 - 1, Height - 1 - 2));
}
}