* UITextBox: 有水印时,系统响应触摸屏增加了TouchPressClick属性,默认关闭
This commit is contained in:
parent
ce2c7cb55a
commit
5a5d806bc2
@ -23,6 +23,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
@ -61,7 +62,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (this.waterMarkContainer == null && this.TextLength <= 0)
|
if (this.waterMarkContainer == null && this.TextLength <= 0)
|
||||||
{
|
{
|
||||||
waterMarkContainer = new Panel();
|
waterMarkContainer = new PanelEx();
|
||||||
waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint);
|
waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint);
|
||||||
waterMarkContainer.Invalidate();
|
waterMarkContainer.Invalidate();
|
||||||
waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
|
waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
|
||||||
@ -188,7 +189,80 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Panel waterMarkContainer;
|
[Description("开启后可响应某些触屏的点击事件"), Category("SunnyUI")]
|
||||||
|
[DefaultValue(false)]
|
||||||
|
public bool TouchPressClick
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (waterMarkContainer != null)
|
||||||
|
return waterMarkContainer.TouchPressClick;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (waterMarkContainer != null)
|
||||||
|
waterMarkContainer.TouchPressClick = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class PanelEx : Panel
|
||||||
|
{
|
||||||
|
[Description("开启后可响应某些触屏的点击事件"), Category("SunnyUI")]
|
||||||
|
[DefaultValue(false)]
|
||||||
|
public bool TouchPressClick { get; set; } = false;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////// WndProc窗口程序:
|
||||||
|
////// 当按压屏幕时,产生一个WM_POINTERDOWN消息时,我们通过API函数 PostMessage 投送出一个WM_LBUTTONDOWN消息
|
||||||
|
////// WM_LBUTTONDOWN消息会产生一个相对应的鼠标按下左键的事件,于是我们只要在mouse_down事件里写下处理过程即可
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#region WndProc 窗口程序
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int PostMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
||||||
|
|
||||||
|
const int WM_POINTERDOWN = 0x0246;
|
||||||
|
const int WM_POINTERUP = 0x0247;
|
||||||
|
const int WM_LBUTTONDOWN = 0x0201;
|
||||||
|
const int WM_LBUTTONUP = 0x0202;
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
if (TouchPressClick)
|
||||||
|
{
|
||||||
|
switch (m.Msg)
|
||||||
|
{
|
||||||
|
case WM_POINTERDOWN:
|
||||||
|
break;
|
||||||
|
case WM_POINTERUP:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
base.WndProc(ref m);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m.Msg)
|
||||||
|
{
|
||||||
|
case WM_POINTERDOWN:
|
||||||
|
PostMessage(m.HWnd, WM_LBUTTONDOWN, (int)m.WParam, (int)m.LParam);
|
||||||
|
break;
|
||||||
|
case WM_POINTERUP:
|
||||||
|
PostMessage(m.HWnd, WM_LBUTTONUP, (int)m.WParam, (int)m.LParam);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
private PanelEx waterMarkContainer;
|
||||||
private SolidBrush waterMarkBrush;
|
private SolidBrush waterMarkBrush;
|
||||||
|
|
||||||
private string _waterMarkText = "";
|
private string _waterMarkText = "";
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
* 2022-11-12: V3.2.8 删除MaximumEnabled、MinimumEnabled、HasMaximum、HasMinimum属性
|
* 2022-11-12: V3.2.8 删除MaximumEnabled、MinimumEnabled、HasMaximum、HasMinimum属性
|
||||||
* 2022-11-26: V3.2.9 增加MouseClick,MouseDoubleClick事件
|
* 2022-11-26: V3.2.9 增加MouseClick,MouseDoubleClick事件
|
||||||
* 2023-02-07: V3.3.1 增加Tips小红点
|
* 2023-02-07: V3.3.1 增加Tips小红点
|
||||||
|
* 2023-02-10: V3.3.2 有水印时,系统响应触摸屏增加了TouchPressClick属性,默认关闭
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -135,6 +136,14 @@ namespace Sunny.UI
|
|||||||
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Description("开启后可响应某些触屏的点击事件"), Category("SunnyUI")]
|
||||||
|
[DefaultValue(false)]
|
||||||
|
public bool TouchPressClick
|
||||||
|
{
|
||||||
|
get => edit.TouchPressClick;
|
||||||
|
set => edit.TouchPressClick = value;
|
||||||
|
}
|
||||||
|
|
||||||
private UIButton tipsBtn;
|
private UIButton tipsBtn;
|
||||||
public void SetTipsText(ToolTip toolTip, string text)
|
public void SetTipsText(ToolTip toolTip, string text)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user