mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-03-24 00:36:41 +08:00
1、优化LOG显示与引用
2、添加PMA工具,工具内容待完善 3、修复流程树显示 4、添加开源项目,优化UI空间 5、其他BUG更改
This commit is contained in:
49
UsingControl/HZHControls/Controls/Text/KeyBoardType.cs
Normal file
49
UsingControl/HZHControls/Controls/Text/KeyBoardType.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="KeyBoardType.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum KeyBoardType
|
||||
/// </summary>
|
||||
public enum KeyBoardType
|
||||
{
|
||||
/// <summary>
|
||||
/// The null
|
||||
/// </summary>
|
||||
Null = 1,
|
||||
/// <summary>
|
||||
/// The uc key border all en
|
||||
/// </summary>
|
||||
UCKeyBorderAll_EN = 2,
|
||||
/// <summary>
|
||||
/// The uc key border all number
|
||||
/// </summary>
|
||||
UCKeyBorderAll_Num = 4,
|
||||
/// <summary>
|
||||
/// The uc key border number
|
||||
/// </summary>
|
||||
UCKeyBorderNum = 8,
|
||||
/// <summary>
|
||||
/// The uc key border hand
|
||||
/// </summary>
|
||||
UCKeyBorderHand = 16
|
||||
}
|
||||
}
|
||||
56
UsingControl/HZHControls/Controls/Text/TextBoxEx.Designer.cs
generated
Normal file
56
UsingControl/HZHControls/Controls/Text/TextBoxEx.Designer.cs
generated
Normal file
@@ -0,0 +1,56 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="TextBoxEx.Designer.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TextBoxEx.
|
||||
/// Implements the <see cref="System.Windows.Forms.TextBox" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.TextBox" />
|
||||
partial class TextBoxEx
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
392
UsingControl/HZHControls/Controls/Text/TextBoxEx.cs
Normal file
392
UsingControl/HZHControls/Controls/Text/TextBoxEx.cs
Normal file
@@ -0,0 +1,392 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="TextBoxEx.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TextBoxEx.
|
||||
/// Implements the <see cref="System.Windows.Forms.TextBox" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.TextBox" />
|
||||
public partial class TextBoxEx : TextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// The BLN focus
|
||||
/// </summary>
|
||||
private bool blnFocus = false;
|
||||
|
||||
/// <summary>
|
||||
/// The prompt text
|
||||
/// </summary>
|
||||
private string _promptText = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The prompt font
|
||||
/// </summary>
|
||||
private Font _promptFont = new Font("微软雅黑", 15f, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
|
||||
/// <summary>
|
||||
/// The prompt color
|
||||
/// </summary>
|
||||
private Color _promptColor = Color.Gray;
|
||||
|
||||
/// <summary>
|
||||
/// My rectangle
|
||||
/// </summary>
|
||||
private Rectangle _myRectangle = Rectangle.FromLTRB(1, 3, 1000, 3);
|
||||
|
||||
/// <summary>
|
||||
/// The input type
|
||||
/// </summary>
|
||||
private TextInputType _inputType = TextInputType.NotControl;
|
||||
|
||||
/// <summary>
|
||||
/// The regex pattern
|
||||
/// </summary>
|
||||
private string _regexPattern = "";
|
||||
|
||||
/// <summary>
|
||||
/// The m string old value
|
||||
/// </summary>
|
||||
private string m_strOldValue = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value
|
||||
/// </summary>
|
||||
private decimal _maxValue = 1000000m;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum value
|
||||
/// </summary>
|
||||
private decimal _minValue = -1000000m;
|
||||
|
||||
/// <summary>
|
||||
/// The decimal length
|
||||
/// </summary>
|
||||
private int _decLength = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 水印文字
|
||||
/// </summary>
|
||||
/// <value>The prompt text.</value>
|
||||
[Description("水印文字"), Category("自定义")]
|
||||
public string PromptText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._promptText;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._promptText = value;
|
||||
this.OnPaint(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prompt font.
|
||||
/// </summary>
|
||||
/// <value>The prompt font.</value>
|
||||
[Description("水印字体"), Category("自定义")]
|
||||
public Font PromptFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._promptFont;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._promptFont = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the prompt.
|
||||
/// </summary>
|
||||
/// <value>The color of the prompt.</value>
|
||||
[Description("水印颜色"), Category("自定义")]
|
||||
public Color PromptColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._promptColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._promptColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets my rectangle.
|
||||
/// </summary>
|
||||
/// <value>My rectangle.</value>
|
||||
public Rectangle MyRectangle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the old text.
|
||||
/// </summary>
|
||||
/// <value>The old text.</value>
|
||||
public string OldText
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the input.
|
||||
/// </summary>
|
||||
/// <value>The type of the input.</value>
|
||||
[Description("获取或设置一个值,该值指示文本框中的文本输入类型。")]
|
||||
public TextInputType InputType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._inputType;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._inputType = value;
|
||||
if (value != TextInputType.NotControl)
|
||||
{
|
||||
TextChanged -= new EventHandler(this.TextBoxEx_TextChanged);
|
||||
TextChanged += new EventHandler(this.TextBoxEx_TextChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextChanged -= new EventHandler(this.TextBoxEx_TextChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示当输入类型InputType=Regex时,使用的正则表达式。
|
||||
/// </summary>
|
||||
/// <value>The regex pattern.</value>
|
||||
[Description("获取或设置一个值,该值指示当输入类型InputType=Regex时,使用的正则表达式。")]
|
||||
public string RegexPattern
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._regexPattern;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._regexPattern = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最大值
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最大值。")]
|
||||
public decimal MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._maxValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._maxValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最小值
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最小值。")]
|
||||
public decimal MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._minValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._minValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最小值
|
||||
/// </summary>
|
||||
/// <value>The length of the decimal.</value>
|
||||
[Description("当InputType为数字类型时,小数位数。")]
|
||||
public int DecLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._decLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._decLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextBoxEx" /> class.
|
||||
/// </summary>
|
||||
public TextBoxEx()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
base.GotFocus += new EventHandler(this.TextBoxEx_GotFocus);
|
||||
base.MouseUp += new MouseEventHandler(this.TextBoxEx_MouseUp);
|
||||
base.KeyPress += TextBoxEx_KeyPress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the KeyPress event of the TextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="KeyPressEventArgs" /> instance containing the event data.</param>
|
||||
void TextBoxEx_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//以下代码 取消按下回车或esc的“叮”声
|
||||
if (e.KeyChar == System.Convert.ToChar(13) || e.KeyChar == System.Convert.ToChar(27))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseUp event of the TextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void TextBoxEx_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (this.blnFocus)
|
||||
{
|
||||
base.SelectAll();
|
||||
this.blnFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the GotFocus event of the TextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void TextBoxEx_GotFocus(object sender, EventArgs e)
|
||||
{
|
||||
this.blnFocus = true;
|
||||
base.SelectAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the TextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void TextBoxEx_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Text == "")
|
||||
{
|
||||
this.m_strOldValue = this.Text;
|
||||
}
|
||||
else if (this.m_strOldValue != this.Text)
|
||||
{
|
||||
if (!ControlHelper.CheckInputType(this.Text, this._inputType, this._maxValue, this._minValue, this._decLength, this._regexPattern))
|
||||
{
|
||||
int num = base.SelectionStart;
|
||||
if (this.m_strOldValue.Length < this.Text.Length)
|
||||
{
|
||||
num--;
|
||||
}
|
||||
else
|
||||
{
|
||||
num++;
|
||||
}
|
||||
base.TextChanged -= new EventHandler(this.TextBoxEx_TextChanged);
|
||||
this.Text = this.m_strOldValue;
|
||||
base.TextChanged += new EventHandler(this.TextBoxEx_TextChanged);
|
||||
if (num < 0)
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
base.SelectionStart = num;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_strOldValue = this.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (string.IsNullOrEmpty(this.Text) && !string.IsNullOrEmpty(this._promptText))
|
||||
{
|
||||
if (e == null)
|
||||
{
|
||||
using (Graphics graphics = Graphics.FromHwnd(base.Handle))
|
||||
{
|
||||
if (this.Text.Length == 0 && !string.IsNullOrEmpty(this.PromptText))
|
||||
{
|
||||
TextFormatFlags textFormatFlags = TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter;
|
||||
if (this.RightToLeft == RightToLeft.Yes)
|
||||
{
|
||||
textFormatFlags |= (TextFormatFlags.Right | TextFormatFlags.RightToLeft);
|
||||
}
|
||||
TextRenderer.DrawText(graphics, this.PromptText, this._promptFont, base.ClientRectangle, this._promptColor, textFormatFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 Windows 消息。
|
||||
/// </summary>
|
||||
/// <param name="m">一个 Windows 消息对象。</param>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
if (m.Msg == 15 || m.Msg == 7 || m.Msg == 8)
|
||||
{
|
||||
this.OnPaint(null);
|
||||
//Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="E:TextChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected override void OnTextChanged(EventArgs e)
|
||||
{
|
||||
base.OnTextChanged(e);
|
||||
base.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
756
UsingControl/HZHControls/Controls/Text/TextBoxTransparent.cs
Normal file
756
UsingControl/HZHControls/Controls/Text/TextBoxTransparent.cs
Normal file
@@ -0,0 +1,756 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="TextBoxTransparent.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TextBoxTransparent.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.TextBoxEx" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.TextBoxEx" />
|
||||
public class TextBoxTransparent : TextBoxEx
|
||||
{
|
||||
#region private variables
|
||||
|
||||
/// <summary>
|
||||
/// My PictureBox
|
||||
/// </summary>
|
||||
private uPictureBox myPictureBox;
|
||||
/// <summary>
|
||||
/// My up to date
|
||||
/// </summary>
|
||||
private bool myUpToDate = false;
|
||||
/// <summary>
|
||||
/// My caret up to date
|
||||
/// </summary>
|
||||
private bool myCaretUpToDate = false;
|
||||
/// <summary>
|
||||
/// My bitmap
|
||||
/// </summary>
|
||||
private Bitmap myBitmap;
|
||||
/// <summary>
|
||||
/// My alpha bitmap
|
||||
/// </summary>
|
||||
private Bitmap myAlphaBitmap;
|
||||
|
||||
/// <summary>
|
||||
/// My font height
|
||||
/// </summary>
|
||||
private int myFontHeight = 10;
|
||||
|
||||
/// <summary>
|
||||
/// My timer1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Timer myTimer1;
|
||||
|
||||
/// <summary>
|
||||
/// My caret state
|
||||
/// </summary>
|
||||
private bool myCaretState = true;
|
||||
|
||||
/// <summary>
|
||||
/// My painted first time
|
||||
/// </summary>
|
||||
private bool myPaintedFirstTime = false;
|
||||
|
||||
/// <summary>
|
||||
/// My back color
|
||||
/// </summary>
|
||||
private Color myBackColor = Color.White;
|
||||
/// <summary>
|
||||
/// My back alpha
|
||||
/// </summary>
|
||||
private int myBackAlpha = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
#endregion // end private variables
|
||||
|
||||
|
||||
#region public methods and overrides
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextBoxTransparent" /> class.
|
||||
/// </summary>
|
||||
public TextBoxTransparent()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
// TODO: Add any initialization after the InitializeComponent call
|
||||
|
||||
this.BackColor = myBackColor;
|
||||
|
||||
this.SetStyle(ControlStyles.UserPaint, false);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
|
||||
|
||||
myPictureBox = new uPictureBox();
|
||||
this.Controls.Add(myPictureBox);
|
||||
myPictureBox.Dock = DockStyle.Fill;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.Resize" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
|
||||
base.OnResize(e);
|
||||
this.myBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);//(this.Width,this.Height);
|
||||
this.myAlphaBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);//(this.Width,this.Height);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
//Some of these should be moved to the WndProc later
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.KeyDown" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.KeyEventArgs" />。</param>
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.KeyUp" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.KeyEventArgs" />。</param>
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyUp(e);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.KeyPress" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.KeyPressEventArgs" />。</param>
|
||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
base.OnKeyPress(e);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseUp" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.GiveFeedback" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="gfbevent">包含事件数据的 <see cref="T:System.Windows.Forms.GiveFeedbackEventArgs" />。</param>
|
||||
protected override void OnGiveFeedback(GiveFeedbackEventArgs gfbevent)
|
||||
{
|
||||
base.OnGiveFeedback(gfbevent);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseLeave" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
//found this code to find the current cursor location
|
||||
//at http://www.syncfusion.com/FAQ/WinForms/FAQ_c50c.asp#q597q
|
||||
|
||||
Point ptCursor = Cursor.Position;
|
||||
|
||||
Form f = this.FindForm();
|
||||
ptCursor = f.PointToClient(ptCursor);
|
||||
if (!this.Bounds.Contains(ptCursor))
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.ChangeUICues" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.UICuesEventArgs" />。</param>
|
||||
protected override void OnChangeUICues(UICuesEventArgs e)
|
||||
{
|
||||
base.OnChangeUICues(e);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
//--
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.GotFocus" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
myCaretUpToDate = false;
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
|
||||
|
||||
myTimer1 = new System.Windows.Forms.Timer(this.components);
|
||||
myTimer1.Interval = (int)win32.GetCaretBlinkTime(); // usually around 500;
|
||||
|
||||
myTimer1.Tick += new EventHandler(myTimer1_Tick);
|
||||
myTimer1.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.LostFocus" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
myCaretUpToDate = false;
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
|
||||
myTimer1.Dispose();
|
||||
}
|
||||
|
||||
//--
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.FontChanged" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
||||
protected override void OnFontChanged(EventArgs e)
|
||||
{
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, false);
|
||||
|
||||
base.OnFontChanged(e);
|
||||
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
|
||||
|
||||
myFontHeight = GetFontHeight();
|
||||
|
||||
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="E:TextChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected override void OnTextChanged(EventArgs e)
|
||||
{
|
||||
base.OnTextChanged(e);
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理 Windows 消息。
|
||||
/// </summary>
|
||||
/// <param name="m">一个 Windows 消息对象。</param>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
|
||||
base.WndProc(ref m);
|
||||
|
||||
// need to rewrite as a big switch
|
||||
|
||||
if (m.Msg == win32.WM_PAINT)
|
||||
{
|
||||
|
||||
myPaintedFirstTime = true;
|
||||
|
||||
if (!myUpToDate || !myCaretUpToDate)
|
||||
GetBitmaps();
|
||||
myUpToDate = true;
|
||||
myCaretUpToDate = true;
|
||||
|
||||
if (myPictureBox.Image != null) myPictureBox.Image.Dispose();
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(this.Text) && !string.IsNullOrEmpty(this.PromptText))
|
||||
{
|
||||
Bitmap bit = (Bitmap)myAlphaBitmap.Clone();
|
||||
Graphics g = Graphics.FromImage(bit);
|
||||
SizeF sizet1 = g.MeasureString(this.PromptText, this.PromptFont);
|
||||
g.DrawString(this.PromptText, this.PromptFont, new SolidBrush(PromptColor), new PointF(3, (bit.Height - sizet1.Height) / 2));
|
||||
g.Dispose();
|
||||
myPictureBox.Image = bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPictureBox.Image = (Image)myAlphaBitmap.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
else if (m.Msg == win32.WM_HSCROLL || m.Msg == win32.WM_VSCROLL)
|
||||
{
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
else if (m.Msg == win32.WM_LBUTTONDOWN
|
||||
|| m.Msg == win32.WM_RBUTTONDOWN
|
||||
|| m.Msg == win32.WM_LBUTTONDBLCLK
|
||||
// || m.Msg == win32.WM_MOUSELEAVE ///****
|
||||
)
|
||||
{
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
else if (m.Msg == win32.WM_MOUSEMOVE)
|
||||
{
|
||||
if (m.WParam.ToInt32() != 0) //shift key or other buttons
|
||||
{
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (m.Msg == 15 || m.Msg == 7 || m.Msg == 8)
|
||||
{
|
||||
base.OnPaint(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">为 true 则释放托管资源和非托管资源;为 false 则仅释放非托管资源。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
//this.BackColor = Color.Pink;
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion //end public method and overrides
|
||||
|
||||
|
||||
#region public property overrides
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文本框控件的边框类型。
|
||||
/// </summary>
|
||||
/// <value>The border style.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public new BorderStyle BorderStyle
|
||||
{
|
||||
get { return base.BorderStyle; }
|
||||
set
|
||||
{
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, false);
|
||||
|
||||
base.BorderStyle = value;
|
||||
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
|
||||
this.myBitmap = null;
|
||||
this.myAlphaBitmap = null;
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的背景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the back.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public new Color BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.FromArgb(base.BackColor.R, base.BackColor.G, base.BackColor.B);
|
||||
}
|
||||
set
|
||||
{
|
||||
myBackColor = value;
|
||||
base.BackColor = value;
|
||||
myUpToDate = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示此控件是否为多行 <see cref="T:System.Windows.Forms.TextBox" /> 控件。
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if multiline; otherwise, <c>false</c>.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override bool Multiline
|
||||
{
|
||||
get { return base.Multiline; }
|
||||
set
|
||||
{
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, false);
|
||||
|
||||
base.Multiline = value;
|
||||
|
||||
if (this.myPaintedFirstTime)
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
|
||||
this.myBitmap = null;
|
||||
this.myAlphaBitmap = null;
|
||||
myUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion //end public property overrides
|
||||
|
||||
|
||||
#region private functions and classes
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the font.
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetFontHeight()
|
||||
{
|
||||
Graphics g = this.CreateGraphics();
|
||||
SizeF sf_font = g.MeasureString("X", this.Font);
|
||||
g.Dispose();
|
||||
return (int)sf_font.Height;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bitmaps.
|
||||
/// </summary>
|
||||
private void GetBitmaps()
|
||||
{
|
||||
|
||||
if (myBitmap == null
|
||||
|| myAlphaBitmap == null
|
||||
|| myBitmap.Width != Width
|
||||
|| myBitmap.Height != Height
|
||||
|| myAlphaBitmap.Width != Width
|
||||
|| myAlphaBitmap.Height != Height)
|
||||
{
|
||||
myBitmap = null;
|
||||
myAlphaBitmap = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (myBitmap == null)
|
||||
{
|
||||
myBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);//(Width,Height);
|
||||
myUpToDate = false;
|
||||
}
|
||||
|
||||
|
||||
if (!myUpToDate)
|
||||
{
|
||||
//Capture the TextBox control window
|
||||
|
||||
this.SetStyle(ControlStyles.UserPaint, false);
|
||||
|
||||
win32.CaptureWindow(this, ref myBitmap);
|
||||
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
this.BackColor = Color.FromArgb(myBackAlpha, myBackColor);
|
||||
|
||||
}
|
||||
//--
|
||||
|
||||
|
||||
|
||||
Rectangle r2 = new Rectangle(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
|
||||
ImageAttributes tempImageAttr = new ImageAttributes();
|
||||
|
||||
|
||||
//Found the color map code in the MS Help
|
||||
|
||||
ColorMap[] tempColorMap = new ColorMap[1];
|
||||
tempColorMap[0] = new ColorMap();
|
||||
tempColorMap[0].OldColor = Color.FromArgb(255, myBackColor);
|
||||
tempColorMap[0].NewColor = Color.FromArgb(myBackAlpha, myBackColor);
|
||||
|
||||
tempImageAttr.SetRemapTable(tempColorMap);
|
||||
|
||||
if (myAlphaBitmap != null)
|
||||
myAlphaBitmap.Dispose();
|
||||
|
||||
|
||||
myAlphaBitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);//(Width,Height);
|
||||
|
||||
Graphics tempGraphics1 = Graphics.FromImage(myAlphaBitmap);
|
||||
|
||||
tempGraphics1.DrawImage(myBitmap, r2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, GraphicsUnit.Pixel, tempImageAttr);
|
||||
|
||||
tempGraphics1.Dispose();
|
||||
|
||||
//----
|
||||
|
||||
if (this.Focused && (this.SelectionLength == 0))
|
||||
{
|
||||
Graphics tempGraphics2 = Graphics.FromImage(myAlphaBitmap);
|
||||
if (myCaretState)
|
||||
{
|
||||
//Draw the caret
|
||||
Point caret = this.findCaret();
|
||||
Pen p = new Pen(this.ForeColor, 3);
|
||||
tempGraphics2.DrawLine(p, caret.X + 2, caret.Y + 0, caret.X + 2, caret.Y + myFontHeight);
|
||||
tempGraphics2.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds the caret.
|
||||
/// </summary>
|
||||
/// <returns>Point.</returns>
|
||||
private Point findCaret()
|
||||
{
|
||||
/* Find the caret translated from code at
|
||||
* http://www.vb-helper.com/howto_track_textbox_caret.html
|
||||
*
|
||||
* and
|
||||
*
|
||||
* http://www.microbion.co.uk/developers/csharp/textpos2.htm
|
||||
*
|
||||
* Changed to EM_POSFROMCHAR
|
||||
*
|
||||
* This code still needs to be cleaned up and debugged
|
||||
* */
|
||||
|
||||
Point pointCaret = new Point(0);
|
||||
int i_char_loc = this.SelectionStart;
|
||||
IntPtr pi_char_loc = new IntPtr(i_char_loc);
|
||||
|
||||
int i_point = win32.SendMessage(this.Handle, win32.EM_POSFROMCHAR, pi_char_loc, IntPtr.Zero);
|
||||
pointCaret = new Point(i_point);
|
||||
|
||||
if (i_char_loc == 0)
|
||||
{
|
||||
pointCaret = new Point(0);
|
||||
}
|
||||
else if (i_char_loc >= this.Text.Length)
|
||||
{
|
||||
pi_char_loc = new IntPtr(i_char_loc - 1);
|
||||
i_point = win32.SendMessage(this.Handle, win32.EM_POSFROMCHAR, pi_char_loc, IntPtr.Zero);
|
||||
pointCaret = new Point(i_point);
|
||||
|
||||
Graphics g = this.CreateGraphics();
|
||||
String t1 = this.Text.Substring(this.Text.Length - 1, 1) + "X";
|
||||
SizeF sizet1 = g.MeasureString(t1, this.Font);
|
||||
SizeF sizex = g.MeasureString("X", this.Font);
|
||||
g.Dispose();
|
||||
int xoffset = (int)(sizet1.Width - sizex.Width);
|
||||
pointCaret.X = pointCaret.X + xoffset;
|
||||
|
||||
if (i_char_loc == this.Text.Length)
|
||||
{
|
||||
String slast = this.Text.Substring(Text.Length - 1, 1);
|
||||
if (slast == "\n")
|
||||
{
|
||||
pointCaret.X = 1;
|
||||
pointCaret.Y = pointCaret.Y + myFontHeight;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return pointCaret;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Tick event of the myTimer1 control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void myTimer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
//Timer used to turn caret on and off for focused control
|
||||
|
||||
myCaretState = !myCaretState;
|
||||
myCaretUpToDate = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Class uPictureBox.
|
||||
/// Implements the <see cref="System.Windows.Forms.PictureBox" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.PictureBox" />
|
||||
private class uPictureBox : PictureBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="uPictureBox" /> class.
|
||||
/// </summary>
|
||||
public uPictureBox()
|
||||
{
|
||||
this.SetStyle(ControlStyles.Selectable, false);
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
|
||||
this.Cursor = null;
|
||||
this.Enabled = true;
|
||||
this.SizeMode = PictureBoxSizeMode.Normal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//uPictureBox
|
||||
/// <summary>
|
||||
/// 处理 Windows 消息。
|
||||
/// </summary>
|
||||
/// <param name="m">要处理的 Windows<see cref="T:System.Windows.Forms.Message" />。</param>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == win32.WM_LBUTTONDOWN
|
||||
|| m.Msg == win32.WM_RBUTTONDOWN
|
||||
|| m.Msg == win32.WM_LBUTTONDBLCLK
|
||||
|| m.Msg == win32.WM_MOUSELEAVE
|
||||
|| m.Msg == win32.WM_MOUSEMOVE)
|
||||
{
|
||||
//Send the above messages back to the parent control
|
||||
win32.PostMessage(this.Parent.Handle, (uint)m.Msg, m.WParam, m.LParam);
|
||||
}
|
||||
|
||||
else if (m.Msg == win32.WM_LBUTTONUP)
|
||||
{
|
||||
//?? for selects and such
|
||||
this.Parent.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
|
||||
} // End uPictureBox Class
|
||||
|
||||
|
||||
#endregion // end private functions and classes
|
||||
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region New Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the back alpha.
|
||||
/// </summary>
|
||||
/// <value>The back alpha.</value>
|
||||
[
|
||||
Category("Appearance"),
|
||||
Description("The alpha value used to blend the control's background. Valid values are 0 through 255."),
|
||||
Browsable(true),
|
||||
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
|
||||
|
||||
]
|
||||
public int BackAlpha
|
||||
{
|
||||
get { return myBackAlpha; }
|
||||
set
|
||||
{
|
||||
int v = value;
|
||||
if (v > 255)
|
||||
v = 255;
|
||||
myBackAlpha = v;
|
||||
myUpToDate = false;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
} // End AlphaTextBox Class
|
||||
}
|
||||
123
UsingControl/HZHControls/Controls/Text/TextBoxTransparent.resx
Normal file
123
UsingControl/HZHControls/Controls/Text/TextBoxTransparent.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
145
UsingControl/HZHControls/Controls/Text/UCNumTextBox.Designer.cs
generated
Normal file
145
UsingControl/HZHControls/Controls/Text/UCNumTextBox.Designer.cs
generated
Normal file
@@ -0,0 +1,145 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCNumTextBox.Designer.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCNumTextBox.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCNumTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtNum = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.btnMinus = new System.Windows.Forms.Panel();
|
||||
this.btnAdd = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtNum
|
||||
//
|
||||
this.txtNum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtNum.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.txtNum.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtNum.DecLength = 3;
|
||||
this.txtNum.Font = new System.Drawing.Font("Arial Unicode MS", 15F);
|
||||
this.txtNum.InputType = TextInputType.Number;
|
||||
this.txtNum.Location = new System.Drawing.Point(37, 11);
|
||||
this.txtNum.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.txtNum.MaxValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtNum.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtNum.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtNum.Name = "txtNum";
|
||||
this.txtNum.OldText = null;
|
||||
this.txtNum.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtNum.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtNum.PromptText = "";
|
||||
this.txtNum.RegexPattern = "";
|
||||
this.txtNum.Size = new System.Drawing.Size(78, 27);
|
||||
this.txtNum.TabIndex = 9;
|
||||
this.txtNum.Text = "1";
|
||||
this.txtNum.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtNum.FontChanged += new System.EventHandler(this.txtNum_FontChanged);
|
||||
this.txtNum.MouseDown += new System.Windows.Forms.MouseEventHandler(this.txtNum_MouseDown);
|
||||
//
|
||||
// btnMinus
|
||||
//
|
||||
this.btnMinus.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnMinus.BackgroundImage = global::HZH_Controls.Properties.Resources.ic_remove_black_18dp;
|
||||
this.btnMinus.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnMinus.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnMinus.Location = new System.Drawing.Point(2, 2);
|
||||
this.btnMinus.Name = "btnMinus";
|
||||
this.btnMinus.Size = new System.Drawing.Size(32, 40);
|
||||
this.btnMinus.TabIndex = 6;
|
||||
this.btnMinus.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnMinus_MouseDown);
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
this.btnAdd.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnAdd.BackgroundImage = global::HZH_Controls.Properties.Resources.ic_add_black_18dp;
|
||||
this.btnAdd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnAdd.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.btnAdd.Location = new System.Drawing.Point(118, 2);
|
||||
this.btnAdd.Name = "btnAdd";
|
||||
this.btnAdd.Size = new System.Drawing.Size(32, 40);
|
||||
this.btnAdd.TabIndex = 5;
|
||||
this.btnAdd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnAdd_MouseDown);
|
||||
//
|
||||
// UCNumTextBox
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Controls.Add(this.txtNum);
|
||||
this.Controls.Add(this.btnMinus);
|
||||
this.Controls.Add(this.btnAdd);
|
||||
this.Name = "UCNumTextBox";
|
||||
this.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.Size = new System.Drawing.Size(152, 44);
|
||||
this.Load += new System.EventHandler(this.UCNumTextBox_Load);
|
||||
this.BackColorChanged += new System.EventHandler(this.UCNumTextBox_BackColorChanged);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The BTN add
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel btnAdd;
|
||||
/// <summary>
|
||||
/// The BTN minus
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel btnMinus;
|
||||
/// <summary>
|
||||
/// The text number
|
||||
/// </summary>
|
||||
private TextBoxEx txtNum;
|
||||
}
|
||||
}
|
||||
364
UsingControl/HZHControls/Controls/Text/UCNumTextBox.cs
Normal file
364
UsingControl/HZHControls/Controls/Text/UCNumTextBox.cs
Normal file
@@ -0,0 +1,364 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCNumTextBox.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCNumTextBox.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("NumChanged")]
|
||||
public partial class UCNumTextBox : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [show key border event].
|
||||
/// </summary>
|
||||
[Description("弹出输入键盘时发生"), Category("自定义")]
|
||||
public event EventHandler ShowKeyBorderEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [hide key border event].
|
||||
/// </summary>
|
||||
[Description("关闭输入键盘时发生"), Category("自定义")]
|
||||
public event EventHandler HideKeyBorderEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [number changed].
|
||||
/// </summary>
|
||||
[Description("数字改变时发生"), Category("自定义")]
|
||||
public event EventHandler NumChanged;
|
||||
/// <summary>
|
||||
/// 输入类型
|
||||
/// </summary>
|
||||
/// <value>The type of the input.</value>
|
||||
[Description("输入类型"), Category("自定义")]
|
||||
public TextInputType InputType
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtNum.InputType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == TextInputType.NotControl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
txtNum.InputType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is number can input.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is number can input; otherwise, <c>false</c>.</value>
|
||||
[Description("数字是否可手动编辑"), Category("自定义")]
|
||||
public bool IsNumCanInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtNum.Enabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
txtNum.Enabled = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最大值
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最大值。")]
|
||||
public decimal MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtNum.MaxValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtNum.MaxValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最小值
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最小值。")]
|
||||
public decimal MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtNum.MinValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtNum.MinValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The key board type
|
||||
/// </summary>
|
||||
private KeyBoardType keyBoardType = KeyBoardType.UCKeyBorderNum;
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the key board.
|
||||
/// </summary>
|
||||
/// <value>The type of the key board.</value>
|
||||
[Description("键盘样式"), Category("自定义")]
|
||||
public KeyBoardType KeyBoardType
|
||||
{
|
||||
get { return keyBoardType; }
|
||||
set { keyBoardType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number.
|
||||
/// </summary>
|
||||
/// <value>The number.</value>
|
||||
[Description("数值"), Category("自定义")]
|
||||
public decimal Num
|
||||
{
|
||||
get { return txtNum.Text.ToDecimal(); }
|
||||
set { txtNum.Text = value.ToString(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("字体"), Category("自定义")]
|
||||
public new Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtNum.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
txtNum.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [add click].
|
||||
/// </summary>
|
||||
[Description("增加按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler AddClick;
|
||||
/// <summary>
|
||||
/// Occurs when [minus click].
|
||||
/// </summary>
|
||||
[Description("减少按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler MinusClick;
|
||||
|
||||
private decimal increment = 1;
|
||||
[Description("递增量,大于0的数值"), Category("自定义")]
|
||||
public decimal Increment
|
||||
{
|
||||
get { return increment; }
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
increment = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCNumTextBox" /> class.
|
||||
/// </summary>
|
||||
public UCNumTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
txtNum.TextChanged += txtNum_TextChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtNum control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void txtNum_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (NumChanged != null)
|
||||
{
|
||||
NumChanged(txtNum.Text.ToString(), e);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor m_frmAnchor;
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the txtNum control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void txtNum_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (IsNumCanInput)
|
||||
{
|
||||
if (KeyBoardType != HZH_Controls.Controls.KeyBoardType.Null)
|
||||
{
|
||||
switch (keyBoardType)
|
||||
{
|
||||
case KeyBoardType.UCKeyBorderAll_EN:
|
||||
|
||||
UCKeyBorderAll keyAll = new UCKeyBorderAll();
|
||||
keyAll.RetractClike += (a, b) => { m_frmAnchor.Hide(); };
|
||||
keyAll.EnterClick += (a, b) => { m_frmAnchor.Hide(); };
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, keyAll);
|
||||
m_frmAnchor.VisibleChanged += m_frmAnchor_VisibleChanged;
|
||||
|
||||
m_frmAnchor.Show(this.FindForm());
|
||||
break;
|
||||
case KeyBoardType.UCKeyBorderNum:
|
||||
|
||||
UCKeyBorderNum keyNum = new UCKeyBorderNum();
|
||||
keyNum.EnterClick += (a, b) => { m_frmAnchor.Hide(); };
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, keyNum);
|
||||
m_frmAnchor.VisibleChanged += m_frmAnchor_VisibleChanged;
|
||||
m_frmAnchor.Show(this.FindForm());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the VisibleChanged event of the m_frmAnchor control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void m_frmAnchor_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
if (ShowKeyBorderEvent != null)
|
||||
{
|
||||
ShowKeyBorderEvent(this, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HideKeyBorderEvent != null)
|
||||
{
|
||||
HideKeyBorderEvent(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Numbers the add click.
|
||||
/// </summary>
|
||||
public void NumAddClick()
|
||||
{
|
||||
btnAdd_MouseDown(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Numbers the minus click.
|
||||
/// </summary>
|
||||
public void NumMinusClick()
|
||||
{
|
||||
btnMinus_MouseDown(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the btnAdd control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void btnAdd_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (AddClick != null)
|
||||
{
|
||||
AddClick(this, e);
|
||||
}
|
||||
decimal dec = this.txtNum.Text.ToDecimal();
|
||||
dec += increment;
|
||||
txtNum.Text = dec.ToString();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the btnMinus control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void btnMinus_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (MinusClick != null)
|
||||
{
|
||||
MinusClick(this, e);
|
||||
}
|
||||
decimal dec = this.txtNum.Text.ToDecimal();
|
||||
dec -= increment; ;
|
||||
txtNum.Text = dec.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCNumTextBox control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCNumTextBox_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.txtNum.BackColor = this.BackColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the FontChanged event of the txtNum control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtNum_FontChanged(object sender, EventArgs e)
|
||||
{
|
||||
txtNum.Location = new Point(txtNum.Location.X, (this.Height - txtNum.Height) / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BackColorChanged event of the UCNumTextBox control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCNumTextBox_BackColorChanged(object sender, EventArgs e)
|
||||
{
|
||||
Color c = this.BackColor;
|
||||
Control control = this;
|
||||
while (c == Color.Transparent)
|
||||
{
|
||||
control = control.Parent;
|
||||
if (control == null)
|
||||
break;
|
||||
c = control.BackColor;
|
||||
}
|
||||
if (c == Color.Transparent)
|
||||
return;
|
||||
txtNum.BackColor = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/Text/UCNumTextBox.resx
Normal file
120
UsingControl/HZHControls/Controls/Text/UCNumTextBox.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
181
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.Designer.cs
generated
Normal file
181
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.Designer.cs
generated
Normal file
@@ -0,0 +1,181 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCTextBoxEx.Designer.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCTextBoxEx.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
partial class UCTextBoxEx
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UCTextBoxEx));
|
||||
this.txtInput = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList();
|
||||
this.btnClear = new System.Windows.Forms.Panel();
|
||||
this.btnKeybord = new System.Windows.Forms.Panel();
|
||||
this.btnSearch = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtInput
|
||||
//
|
||||
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtInput.DecLength = 2;
|
||||
this.txtInput.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtInput.InputType = TextInputType.NotControl;
|
||||
this.txtInput.Location = new System.Drawing.Point(8, 9);
|
||||
this.txtInput.Margin = new System.Windows.Forms.Padding(3, 3, 10, 3);
|
||||
this.txtInput.MaxValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtInput.MinValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
-2147483648});
|
||||
this.txtInput.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtInput.Name = "txtInput";
|
||||
this.txtInput.OldText = null;
|
||||
this.txtInput.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtInput.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtInput.PromptText = "";
|
||||
this.txtInput.RegexPattern = "";
|
||||
this.txtInput.Size = new System.Drawing.Size(309, 24);
|
||||
this.txtInput.TabIndex = 0;
|
||||
this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "ic_cancel_black_24dp.png");
|
||||
this.imageList1.Images.SetKeyName(1, "ic_search_black_24dp.png");
|
||||
this.imageList1.Images.SetKeyName(2, "keyboard.png");
|
||||
//
|
||||
// btnClear
|
||||
//
|
||||
this.btnClear.BackgroundImage = global::HZH_Controls.Properties.Resources.input_clear;
|
||||
this.btnClear.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnClear.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.btnClear.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.btnClear.Location = new System.Drawing.Point(227, 5);
|
||||
this.btnClear.Name = "btnClear";
|
||||
this.btnClear.Size = new System.Drawing.Size(30, 32);
|
||||
this.btnClear.TabIndex = 4;
|
||||
this.btnClear.Visible = false;
|
||||
this.btnClear.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnClear_MouseDown);
|
||||
//
|
||||
// btnKeybord
|
||||
//
|
||||
this.btnKeybord.BackgroundImage = global::HZH_Controls.Properties.Resources.keyboard;
|
||||
this.btnKeybord.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnKeybord.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.btnKeybord.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.btnKeybord.Location = new System.Drawing.Point(257, 5);
|
||||
this.btnKeybord.Name = "btnKeybord";
|
||||
this.btnKeybord.Size = new System.Drawing.Size(30, 32);
|
||||
this.btnKeybord.TabIndex = 6;
|
||||
this.btnKeybord.Visible = false;
|
||||
this.btnKeybord.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnKeybord_MouseDown);
|
||||
//
|
||||
// btnSearch
|
||||
//
|
||||
this.btnSearch.BackgroundImage = global::HZH_Controls.Properties.Resources.ic_search_black_24dp;
|
||||
this.btnSearch.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnSearch.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.btnSearch.Location = new System.Drawing.Point(287, 5);
|
||||
this.btnSearch.Name = "btnSearch";
|
||||
this.btnSearch.Size = new System.Drawing.Size(30, 32);
|
||||
this.btnSearch.TabIndex = 5;
|
||||
this.btnSearch.Visible = false;
|
||||
this.btnSearch.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnSearch_MouseDown);
|
||||
//
|
||||
// UCTextBoxEx
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.ConerRadius = 5;
|
||||
this.Controls.Add(this.btnClear);
|
||||
this.Controls.Add(this.btnKeybord);
|
||||
this.Controls.Add(this.btnSearch);
|
||||
this.Controls.Add(this.txtInput);
|
||||
this.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.IsShowRect = true;
|
||||
this.IsRadius = true;
|
||||
this.Name = "UCTextBoxEx";
|
||||
this.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.Size = new System.Drawing.Size(322, 42);
|
||||
this.Load += new System.EventHandler(this.UCTextBoxEx_Load);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.UCTextBoxEx_MouseDown);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The image list1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
/// <summary>
|
||||
/// The text input
|
||||
/// </summary>
|
||||
public TextBoxEx txtInput;
|
||||
/// <summary>
|
||||
/// The BTN clear
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel btnClear;
|
||||
/// <summary>
|
||||
/// The BTN search
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel btnSearch;
|
||||
/// <summary>
|
||||
/// The BTN keybord
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel btnKeybord;
|
||||
}
|
||||
}
|
||||
757
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.cs
Normal file
757
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.cs
Normal file
@@ -0,0 +1,757 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCTextBoxEx.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCTextBoxEx.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
[DefaultEvent("TextChanged")]
|
||||
public partial class UCTextBoxEx : UCControlBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The m is show clear BTN
|
||||
/// </summary>
|
||||
private bool m_isShowClearBtn = true;
|
||||
/// <summary>
|
||||
/// The m int selection start
|
||||
/// </summary>
|
||||
int m_intSelectionStart = 0;
|
||||
/// <summary>
|
||||
/// The m int selection length
|
||||
/// </summary>
|
||||
int m_intSelectionLength = 0;
|
||||
/// <summary>
|
||||
/// 功能描述:是否显示清理按钮
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-02-28 16:13:52
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show clear BTN; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示清理按钮"), Category("自定义")]
|
||||
public bool IsShowClearBtn
|
||||
{
|
||||
get { return m_isShowClearBtn; }
|
||||
set
|
||||
{
|
||||
m_isShowClearBtn = value;
|
||||
if (value)
|
||||
{
|
||||
btnClear.Visible = !(txtInput.Text == "\r\n") && !string.IsNullOrEmpty(txtInput.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnClear.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m is show search BTN
|
||||
/// </summary>
|
||||
private bool m_isShowSearchBtn = false;
|
||||
/// <summary>
|
||||
/// 是否显示查询按钮
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show search BTN; otherwise, <c>false</c>.</value>
|
||||
|
||||
[Description("是否显示查询按钮"), Category("自定义")]
|
||||
public bool IsShowSearchBtn
|
||||
{
|
||||
get { return m_isShowSearchBtn; }
|
||||
set
|
||||
{
|
||||
m_isShowSearchBtn = value;
|
||||
btnSearch.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show keyboard.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show keyboard; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示键盘"), Category("自定义")]
|
||||
public bool IsShowKeyboard
|
||||
{
|
||||
get
|
||||
{
|
||||
return btnKeybord.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
btnKeybord.Visible = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("字体"), Category("自定义")]
|
||||
public new Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the input.
|
||||
/// </summary>
|
||||
/// <value>The type of the input.</value>
|
||||
[Description("输入类型"), Category("自定义")]
|
||||
public TextInputType InputType
|
||||
{
|
||||
get { return txtInput.InputType; }
|
||||
set { txtInput.InputType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 水印文字
|
||||
/// </summary>
|
||||
/// <value>The prompt text.</value>
|
||||
[Description("水印文字"), Category("自定义")]
|
||||
public string PromptText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.PromptText;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.PromptText = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prompt font.
|
||||
/// </summary>
|
||||
/// <value>The prompt font.</value>
|
||||
[Description("水印字体"), Category("自定义")]
|
||||
public Font PromptFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.PromptFont;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.PromptFont = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the prompt.
|
||||
/// </summary>
|
||||
/// <value>The color of the prompt.</value>
|
||||
[Description("水印颜色"), Category("自定义")]
|
||||
public Color PromptColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.PromptColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.PromptColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示当输入类型InputType=Regex时,使用的正则表达式。
|
||||
/// </summary>
|
||||
/// <value>The regex pattern.</value>
|
||||
[Description("获取或设置一个值,该值指示当输入类型InputType=Regex时,使用的正则表达式。")]
|
||||
public string RegexPattern
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.RegexPattern;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.RegexPattern = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最大值
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最大值。")]
|
||||
public decimal MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.MaxValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.MaxValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最小值
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
[Description("当InputType为数字类型时,能输入的最小值。")]
|
||||
public decimal MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.MinValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.MinValue = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当InputType为数字类型时,能输入的最小值
|
||||
/// </summary>
|
||||
/// <value>The length of the decimal.</value>
|
||||
[Description("当InputType为数字类型时,小数位数。")]
|
||||
public int DecLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.txtInput.DecLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtInput.DecLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The key board type
|
||||
/// </summary>
|
||||
private KeyBoardType keyBoardType = KeyBoardType.UCKeyBorderAll_EN;
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the key board.
|
||||
/// </summary>
|
||||
/// <value>The type of the key board.</value>
|
||||
[Description("键盘打开样式"), Category("自定义")]
|
||||
public KeyBoardType KeyBoardType
|
||||
{
|
||||
get { return keyBoardType; }
|
||||
set { keyBoardType = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when [search click].
|
||||
/// </summary>
|
||||
[Description("查询按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler SearchClick;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [text changed].
|
||||
/// </summary>
|
||||
[Description("文本改变事件"), Category("自定义")]
|
||||
public new event EventHandler TextChanged;
|
||||
/// <summary>
|
||||
/// Occurs when [keyboard click].
|
||||
/// </summary>
|
||||
[Description("键盘按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler KeyboardClick;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the input text.
|
||||
/// </summary>
|
||||
/// <value>The input text.</value>
|
||||
[Description("文本"), Category("自定义")]
|
||||
public string InputText
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtInput.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
txtInput.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The focus border color
|
||||
/// </summary>
|
||||
private Color focusBorderColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the focus border.
|
||||
/// </summary>
|
||||
/// <value>The color of the focus border.</value>
|
||||
[Description("获取焦点时边框颜色,当IsFocusColor=true有效"), Category("自定义")]
|
||||
public Color FocusBorderColor
|
||||
{
|
||||
get { return focusBorderColor; }
|
||||
set { focusBorderColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The is focus color
|
||||
/// </summary>
|
||||
private bool isFocusColor = true;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is focus color.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is focus color; otherwise, <c>false</c>.</value>
|
||||
[Description("获取焦点是否变色"), Category("自定义")]
|
||||
public bool IsFocusColor
|
||||
{
|
||||
get { return isFocusColor; }
|
||||
set { isFocusColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The fill color
|
||||
/// </summary>
|
||||
private Color _FillColor;
|
||||
/// <summary>
|
||||
/// 当使用边框时填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
/// <value>The color of the fill.</value>
|
||||
public new Color FillColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _FillColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_FillColor = value;
|
||||
base.FillColor = value;
|
||||
this.txtInput.BackColor = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCTextBoxEx" /> class.
|
||||
/// </summary>
|
||||
public UCTextBoxEx()
|
||||
{
|
||||
InitializeComponent();
|
||||
txtInput.SizeChanged += UCTextBoxEx_SizeChanged;
|
||||
this.SizeChanged += UCTextBoxEx_SizeChanged;
|
||||
txtInput.GotFocus += (a, b) =>
|
||||
{
|
||||
if (isFocusColor)
|
||||
this.RectColor = focusBorderColor;
|
||||
};
|
||||
txtInput.LostFocus += (a, b) =>
|
||||
{
|
||||
if (isFocusColor)
|
||||
this.RectColor = Color.FromArgb(220, 220, 220);
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCTextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCTextBoxEx_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtInput control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_isShowClearBtn)
|
||||
{
|
||||
btnClear.Visible = !(txtInput.Text == "\r\n") && !string.IsNullOrEmpty(txtInput.Text);
|
||||
}
|
||||
if (TextChanged != null)
|
||||
{
|
||||
TextChanged(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the btnClear control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void btnClear_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
txtInput.Clear();
|
||||
txtInput.Focus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the btnSearch control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void btnSearch_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (SearchClick != null)
|
||||
{
|
||||
SearchClick(sender, e);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor m_frmAnchor;
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the btnKeybord control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void btnKeybord_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (keyBoardType == HZH_Controls.Controls.KeyBoardType.Null)
|
||||
return;
|
||||
m_intSelectionStart = this.txtInput.SelectionStart;
|
||||
m_intSelectionLength = this.txtInput.SelectionLength;
|
||||
this.FindForm().ActiveControl = this;
|
||||
this.FindForm().ActiveControl = this.txtInput;
|
||||
switch (keyBoardType)
|
||||
{
|
||||
case KeyBoardType.UCKeyBorderAll_EN:
|
||||
if (m_frmAnchor == null)
|
||||
{
|
||||
if (m_frmAnchor == null)
|
||||
{
|
||||
UCKeyBorderAll key = new UCKeyBorderAll();
|
||||
key.CharType = KeyBorderCharType.CHAR;
|
||||
key.RetractClike += (a, b) =>
|
||||
{
|
||||
m_frmAnchor.Hide();
|
||||
};
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, key);
|
||||
m_frmAnchor.VisibleChanged += (a, b) =>
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
this.txtInput.SelectionStart = m_intSelectionStart;
|
||||
this.txtInput.SelectionLength = m_intSelectionLength;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyBoardType.UCKeyBorderAll_Num:
|
||||
|
||||
if (m_frmAnchor == null)
|
||||
{
|
||||
UCKeyBorderAll key = new UCKeyBorderAll();
|
||||
key.CharType = KeyBorderCharType.NUMBER;
|
||||
key.RetractClike += (a, b) =>
|
||||
{
|
||||
m_frmAnchor.Hide();
|
||||
};
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, key);
|
||||
m_frmAnchor.VisibleChanged += (a, b) =>
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
this.txtInput.SelectionStart = m_intSelectionStart;
|
||||
this.txtInput.SelectionLength = m_intSelectionLength;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
case KeyBoardType.UCKeyBorderNum:
|
||||
if (m_frmAnchor == null)
|
||||
{
|
||||
UCKeyBorderNum key = new UCKeyBorderNum();
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, key);
|
||||
m_frmAnchor.VisibleChanged += (a, b) =>
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
this.txtInput.SelectionStart = m_intSelectionStart;
|
||||
this.txtInput.SelectionLength = m_intSelectionLength;
|
||||
}
|
||||
};
|
||||
}
|
||||
break;
|
||||
case HZH_Controls.Controls.KeyBoardType.UCKeyBorderHand:
|
||||
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, new Size(504, 361));
|
||||
m_frmAnchor.VisibleChanged += m_frmAnchor_VisibleChanged;
|
||||
m_frmAnchor.Disposed += m_frmAnchor_Disposed;
|
||||
Panel p = new Panel();
|
||||
p.Dock = DockStyle.Fill;
|
||||
p.Name = "keyborder";
|
||||
m_frmAnchor.Controls.Add(p);
|
||||
|
||||
UCBtnExt btnDelete = new UCBtnExt();
|
||||
btnDelete.Name = "btnDelete";
|
||||
btnDelete.Size = new Size(80, 28);
|
||||
btnDelete.FillColor = Color.White;
|
||||
btnDelete.IsRadius = false;
|
||||
btnDelete.ConerRadius = 1;
|
||||
btnDelete.IsShowRect = true;
|
||||
btnDelete.RectColor = Color.FromArgb(189, 197, 203);
|
||||
btnDelete.Location = new Point(198, 332);
|
||||
btnDelete.BtnFont = new System.Drawing.Font("微软雅黑", 8);
|
||||
btnDelete.BtnText = "删除";
|
||||
btnDelete.BtnClick += (a, b) =>
|
||||
{
|
||||
SendKeys.Send("{BACKSPACE}");
|
||||
};
|
||||
m_frmAnchor.Controls.Add(btnDelete);
|
||||
btnDelete.BringToFront();
|
||||
|
||||
UCBtnExt btnEnter = new UCBtnExt();
|
||||
btnEnter.Name = "btnEnter";
|
||||
btnEnter.Size = new Size(82, 28);
|
||||
btnEnter.FillColor = Color.White;
|
||||
btnEnter.IsRadius = false;
|
||||
btnEnter.ConerRadius = 1;
|
||||
btnEnter.IsShowRect = true;
|
||||
btnEnter.RectColor = Color.FromArgb(189, 197, 203);
|
||||
btnEnter.Location = new Point(278, 332);
|
||||
btnEnter.BtnFont = new System.Drawing.Font("微软雅黑", 8);
|
||||
btnEnter.BtnText = "确定";
|
||||
btnEnter.BtnClick += (a, b) =>
|
||||
{
|
||||
SendKeys.Send("{ENTER}");
|
||||
m_frmAnchor.Hide();
|
||||
};
|
||||
m_frmAnchor.Controls.Add(btnEnter);
|
||||
btnEnter.BringToFront();
|
||||
m_frmAnchor.VisibleChanged += (a, b) =>
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
this.txtInput.SelectionStart = m_intSelectionStart;
|
||||
this.txtInput.SelectionLength = m_intSelectionLength;
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
if (!m_frmAnchor.Visible)
|
||||
m_frmAnchor.Show(this.FindForm());
|
||||
if (KeyboardClick != null)
|
||||
{
|
||||
KeyboardClick(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Disposed event of the m_frmAnchor control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void m_frmAnchor_Disposed(object sender, EventArgs e)
|
||||
{
|
||||
if (m_HandAppWin != IntPtr.Zero)
|
||||
{
|
||||
if (m_HandPWin != null && !m_HandPWin.HasExited)
|
||||
m_HandPWin.Kill();
|
||||
m_HandPWin = null;
|
||||
m_HandAppWin = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The m hand application win
|
||||
/// </summary>
|
||||
IntPtr m_HandAppWin;
|
||||
/// <summary>
|
||||
/// The m hand p win
|
||||
/// </summary>
|
||||
Process m_HandPWin = null;
|
||||
/// <summary>
|
||||
/// The m hand executable name
|
||||
/// </summary>
|
||||
string m_HandExeName = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "HandInput\\handinput.exe");
|
||||
|
||||
/// <summary>
|
||||
/// Handles the VisibleChanged event of the m_frmAnchor control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void m_frmAnchor_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_frmAnchor.Visible)
|
||||
{
|
||||
var lstP = Process.GetProcessesByName("handinput");
|
||||
if (lstP.Length > 0)
|
||||
{
|
||||
foreach (var item in lstP)
|
||||
{
|
||||
item.Kill();
|
||||
}
|
||||
}
|
||||
m_HandAppWin = IntPtr.Zero;
|
||||
|
||||
if (m_HandPWin == null)
|
||||
{
|
||||
m_HandPWin = null;
|
||||
|
||||
m_HandPWin = System.Diagnostics.Process.Start(this.m_HandExeName);
|
||||
m_HandPWin.WaitForInputIdle();
|
||||
}
|
||||
while (m_HandPWin.MainWindowHandle == IntPtr.Zero)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
m_HandAppWin = m_HandPWin.MainWindowHandle;
|
||||
Control p = m_frmAnchor.Controls.Find("keyborder", false)[0];
|
||||
SetParent(m_HandAppWin, p.Handle);
|
||||
ControlHelper.SetForegroundWindow(this.FindForm().Handle);
|
||||
MoveWindow(m_HandAppWin, -111, -41, 626, 412, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_HandAppWin != IntPtr.Zero)
|
||||
{
|
||||
if (m_HandPWin != null && !m_HandPWin.HasExited)
|
||||
m_HandPWin.Kill();
|
||||
m_HandPWin = null;
|
||||
m_HandAppWin = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the UCTextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void UCTextBoxEx_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.ActiveControl = txtInput;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCTextBoxEx control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCTextBoxEx_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
base.FillColor = Color.FromArgb(240, 240, 240);
|
||||
txtInput.BackColor = Color.FromArgb(240, 240, 240);
|
||||
}
|
||||
else
|
||||
{
|
||||
FillColor = _FillColor;
|
||||
txtInput.BackColor = _FillColor;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the parent.
|
||||
/// </summary>
|
||||
/// <param name="hWndChild">The h WND child.</param>
|
||||
/// <param name="hWndNewParent">The h WND new parent.</param>
|
||||
/// <returns>System.Int64.</returns>
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|
||||
|
||||
/// <summary>
|
||||
/// Moves the window.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="cx">The cx.</param>
|
||||
/// <param name="cy">The cy.</param>
|
||||
/// <param name="repaint">if set to <c>true</c> [repaint].</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
|
||||
/// <summary>
|
||||
/// Shows the window.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="nCmdShow">The n command show.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
|
||||
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
|
||||
/// <summary>
|
||||
/// Sets the window position.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">The h WND.</param>
|
||||
/// <param name="hWndlnsertAfter">The h wndlnsert after.</param>
|
||||
/// <param name="X">The x.</param>
|
||||
/// <param name="Y">The y.</param>
|
||||
/// <param name="cx">The cx.</param>
|
||||
/// <param name="cy">The cy.</param>
|
||||
/// <param name="Flags">The flags.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, int hWndlnsertAfter, int X, int Y, int cx, int cy, uint Flags);
|
||||
/// <summary>
|
||||
/// The GWL style
|
||||
/// </summary>
|
||||
private const int GWL_STYLE = -16;
|
||||
/// <summary>
|
||||
/// The ws child
|
||||
/// </summary>
|
||||
private const int WS_CHILD = 0x40000000;//设置窗口属性为child
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window long.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="nIndex">Index of the n.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
public static extern int GetWindowLong(IntPtr hwnd, int nIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the window long.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="nIndex">Index of the n.</param>
|
||||
/// <param name="dwNewLong">The dw new long.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
|
||||
public static extern int SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the active window.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle.</param>
|
||||
/// <returns>IntPtr.</returns>
|
||||
[DllImport("user32.dll")]
|
||||
private extern static IntPtr SetActiveWindow(IntPtr handle);
|
||||
}
|
||||
}
|
||||
186
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.resx
Normal file
186
UsingControl/HZHControls/Controls/Text/UCTextBoxEx.resx
Normal file
@@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADy
|
||||
DAAAAk1TRnQBSQFMAgEBAwEAAYgBAAGIAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
|
||||
AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
|
||||
AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
|
||||
ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
|
||||
AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
|
||||
AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
|
||||
AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
|
||||
AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
|
||||
AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
|
||||
AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
|
||||
AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
|
||||
AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
|
||||
ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
|
||||
Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
|
||||
AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
|
||||
AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
|
||||
AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
|
||||
ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
|
||||
Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
|
||||
AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
|
||||
AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
|
||||
AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
|
||||
AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
|
||||
AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
|
||||
AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD//8ADwAB8wHvAewBbQHs
|
||||
AbwB/3YAAfQBEAkAAZJyAAH/ARINAAG8IQAB8QH/BwAB/xrzAfQB/ygAAfEQAAHqAf8eAAEHAQAB6wH/
|
||||
BQAB8AEOGwABEgH/JgAB8BIAARUB/xwAAe8DAAHxBAAB9B4AARIlAAH0FAAB6hsAAe8DAAEHBQABFEQA
|
||||
AQ4VAAG8GQABBwMAAe8NAAESEfIrAAHvBQABEAHzCAAB7QHvHgAB7wMAAe8OAAHrQQABDgH/AQAB/wYA
|
||||
AZIBAAH/Ae8FAAGSDQAB9AHvAusB7wH/AwAB7wMAAQcPAAFtEfQqAAHxBgAB9AIAAf8EAAHsAwAB7REA
|
||||
AfMIAAH0BAAB70wAAW0HAAH0AgAB9AEPAQAB7AMAAZIHAAH/CAAB/wHrCgAB6gIAAe9NAAFDCAAB9AIA
|
||||
Af8B7AMAAewIAAG8BwAB/wHrAwABkgHzAv8B8gHsAwAB6hEAAfAB8gEHAQAC8gETARIC8gEPAfAB8gEH
|
||||
AQAC8gHsAeoC8gEPKAABDgkAAfQFAAHsCQAB7AcAAfADAAH0BgAB9AMAAfQQAAH0AQAB8gMAAm0BAAH/
|
||||
ARAB9AEAAfIBDgIAAfcB6wEAAf8BETMAAfQDAAHsCgABbRMAAfQTAAHyAfQB8AEAAf8B9ALqAvQBDwHz
|
||||
AfQB8AEOAf8B9AHtAW0C9AEQKAABDgkAAewEAAH0AQ8JAAHsBgAB9AIAAQcKAAHsAgAB/00AARAIAAHt
|
||||
AwAB9AIAAf8JAAHvBgAB7AIAAfQKAAHyAgAB700AARMHAAGSAwAB7AEAAfQCAAH/CAAB8wYAAQ8CAAH/
|
||||
CgAB/wIAAesNAAEOAvQB7QFtAvQBEAHxAfQB8wEAAvQB7wFtAvQBFAHvAvQBAAHzAfQB8SYAAZIGAAHs
|
||||
AwAB7AMAAfQCAAH/DgABDgIAAf8KAAH/AgAB6w0AAQ4CAAH3AesBAAH/AREB8wEAAfQBAAH/AQABBwFt
|
||||
AgABFAEHAgABDgH/AQAB8iYAAf8FAAEUAf8CAAGSBQAB9AIAAfMFAAEQBwAB6wIAAf8KAAHzAgAB7w0A
|
||||
AQ4C8wHsAeoB8wHyARABvAHzAfEBAAHyAfMBkgESAvMBQwGSAvMBAAHxAfMBBycAAREFAAHtAf8B7AcA
|
||||
AfQB/wEQBQAB9AcAAfMCAAG8CgABkgIAAfQKAAESQwAB/wYAARQJAAEOBQABEgsAAQ4JAAH0DgAB/x4A
|
||||
ARIlAAHvFQAB/wkAAQcOAAHzDAAB8RwAAUMB/yUAAf8B6hMAAfEKAAH/ARIDAAG8A/8B9AEHAwABbQ4A
|
||||
Af8B8xnyAfQoAAH/AeoRAAHxDAAB/wETCgAB6wH/UwAB/wHvDgABDgH0DgAB/wEHCAAB8AH/VgAB/wER
|
||||
CwAB7xMAAfMB6wEOAQ8B7AH0WwAB/wGSARQBEAEOAQABDgFDAW0B8f8A7AABQgFNAT4HAAE+AwABKAMA
|
||||
AYADAAEgAwABAQEAAQEGAAECFgAD/wEADP8EAAz/BAAB/wH4AQ8J/wQAAf8BwAEDCf8EAAH/AgAE/wGf
|
||||
AcACAAEBBAAB/gIAAT8D/wEPAYAHAAH8AgABHwL/Af4BDwgAAfgCAAEfAv8B/AEfCAAB+AIAAQ8C/wH4
|
||||
AT8IAAHwAgABDwL/AfABfwEAAv8BgAQAAfABEAEIAQcB/wHAAeAB/wgAAeABGAEcAQcB/wEAASEB/wgA
|
||||
AeABDAE4AQMB/AEAAQMB/wgAAeABBgFwAQMB+AEAAQ8B/wgAAeABAwHgAQMB+AE/AQcB/wECAWQBTAGA
|
||||
BAAB4AEBAcABAwH4Af8BhwH/CAAB4AEDAcABAwHwAf8BwwH/CAAB4AEHAWABAwHwAf8BwwH/CAAB4AEO
|
||||
ATABAwHwAf8BwwH/CAAB4AEcARgBBwHwAf8BwwH/AQwBiAGZAZAEAAHgARgBDAEHAfAB/wHDAf8IAAHw
|
||||
AgABBwHwAf8BwwH/CAAB8AIAAQ8B+AH/AYcB/wgAAfgCAAEPAfgBfwGHAf8BgAcAAfgCAAEfAfgBAAEP
|
||||
Af8BwAIAAQMEAAH8AgABPwH8AQABDwX/BAAB/gIAAX8B/gEAAR8F/wQAAf8BgAEBAv8BwAb/BAAB/wHg
|
||||
AQcJ/wQADP8EAAz/BAAM/wQACw==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
225
UsingControl/HZHControls/Controls/Text/win32.cs
Normal file
225
UsingControl/HZHControls/Controls/Text/win32.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="win32.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class win32.
|
||||
/// </summary>
|
||||
public class win32
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The wm mousemove
|
||||
/// </summary>
|
||||
public const int WM_MOUSEMOVE = 0x0200;
|
||||
/// <summary>
|
||||
/// The wm lbuttondown
|
||||
/// </summary>
|
||||
public const int WM_LBUTTONDOWN = 0x0201;
|
||||
/// <summary>
|
||||
/// The wm lbuttonup
|
||||
/// </summary>
|
||||
public const int WM_LBUTTONUP = 0x0202;
|
||||
/// <summary>
|
||||
/// The wm rbuttondown
|
||||
/// </summary>
|
||||
public const int WM_RBUTTONDOWN = 0x0204;
|
||||
/// <summary>
|
||||
/// The wm lbuttondblclk
|
||||
/// </summary>
|
||||
public const int WM_LBUTTONDBLCLK = 0x0203;
|
||||
|
||||
/// <summary>
|
||||
/// The wm mouseleave
|
||||
/// </summary>
|
||||
public const int WM_MOUSELEAVE = 0x02A3;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The wm paint
|
||||
/// </summary>
|
||||
public const int WM_PAINT = 0x000F;
|
||||
/// <summary>
|
||||
/// The wm erasebkgnd
|
||||
/// </summary>
|
||||
public const int WM_ERASEBKGND = 0x0014;
|
||||
|
||||
/// <summary>
|
||||
/// The wm print
|
||||
/// </summary>
|
||||
public const int WM_PRINT = 0x0317;
|
||||
|
||||
//const int EN_HSCROLL = 0x0601;
|
||||
//const int EN_VSCROLL = 0x0602;
|
||||
|
||||
/// <summary>
|
||||
/// The wm hscroll
|
||||
/// </summary>
|
||||
public const int WM_HSCROLL = 0x0114;
|
||||
/// <summary>
|
||||
/// The wm vscroll
|
||||
/// </summary>
|
||||
public const int WM_VSCROLL = 0x0115;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The em getsel
|
||||
/// </summary>
|
||||
public const int EM_GETSEL = 0x00B0;
|
||||
/// <summary>
|
||||
/// The em lineindex
|
||||
/// </summary>
|
||||
public const int EM_LINEINDEX = 0x00BB;
|
||||
/// <summary>
|
||||
/// The em linefromchar
|
||||
/// </summary>
|
||||
public const int EM_LINEFROMCHAR = 0x00C9;
|
||||
|
||||
/// <summary>
|
||||
/// The em posfromchar
|
||||
/// </summary>
|
||||
public const int EM_POSFROMCHAR = 0x00D6;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Posts the message.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="msg">The MSG.</param>
|
||||
/// <param name="wParam">The w parameter.</param>
|
||||
/// <param name="lParam">The l parameter.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
[DllImport("USER32.DLL", EntryPoint = "PostMessage")]
|
||||
public static extern bool PostMessage(IntPtr hwnd, uint msg,
|
||||
IntPtr wParam, IntPtr lParam);
|
||||
|
||||
/*
|
||||
BOOL PostMessage( HWND hWnd,
|
||||
UINT Msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
*/
|
||||
|
||||
// Put this declaration in your class //IntPtr
|
||||
/// <summary>
|
||||
/// Sends the message.
|
||||
/// </summary>
|
||||
/// <param name="hwnd">The HWND.</param>
|
||||
/// <param name="msg">The MSG.</param>
|
||||
/// <param name="wParam">The w parameter.</param>
|
||||
/// <param name="lParam">The l parameter.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
[DllImport("USER32.DLL", EntryPoint = "SendMessage")]
|
||||
public static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wParam,
|
||||
IntPtr lParam);
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the caret blink time.
|
||||
/// </summary>
|
||||
/// <returns>System.UInt32.</returns>
|
||||
[DllImport("USER32.DLL", EntryPoint = "GetCaretBlinkTime")]
|
||||
public static extern uint GetCaretBlinkTime();
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The wm printclient
|
||||
/// </summary>
|
||||
const int WM_PRINTCLIENT = 0x0318;
|
||||
|
||||
/// <summary>
|
||||
/// The PRF checkvisible
|
||||
/// </summary>
|
||||
const long PRF_CHECKVISIBLE = 0x00000001L;
|
||||
/// <summary>
|
||||
/// The PRF nonclient
|
||||
/// </summary>
|
||||
const long PRF_NONCLIENT = 0x00000002L;
|
||||
/// <summary>
|
||||
/// The PRF client
|
||||
/// </summary>
|
||||
const long PRF_CLIENT = 0x00000004L;
|
||||
/// <summary>
|
||||
/// The PRF erasebkgnd
|
||||
/// </summary>
|
||||
const long PRF_ERASEBKGND = 0x00000008L;
|
||||
/// <summary>
|
||||
/// The PRF children
|
||||
/// </summary>
|
||||
const long PRF_CHILDREN = 0x00000010L;
|
||||
/// <summary>
|
||||
/// The PRF owned
|
||||
/// </summary>
|
||||
const long PRF_OWNED = 0x00000020L;
|
||||
|
||||
/* Will clean this up later doing something like this
|
||||
enum CaptureOptions : long
|
||||
{
|
||||
PRF_CHECKVISIBLE= 0x00000001L,
|
||||
PRF_NONCLIENT = 0x00000002L,
|
||||
PRF_CLIENT = 0x00000004L,
|
||||
PRF_ERASEBKGND = 0x00000008L,
|
||||
PRF_CHILDREN = 0x00000010L,
|
||||
PRF_OWNED = 0x00000020L
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Captures the window.
|
||||
/// </summary>
|
||||
/// <param name="control">The control.</param>
|
||||
/// <param name="bitmap">The bitmap.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public static bool CaptureWindow(System.Windows.Forms.Control control,
|
||||
ref System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
//This function captures the contents of a window or control
|
||||
|
||||
Graphics g2 = Graphics.FromImage(bitmap);
|
||||
|
||||
//PRF_CHILDREN // PRF_NONCLIENT
|
||||
int meint = (int)(PRF_CLIENT | PRF_ERASEBKGND); //| PRF_OWNED ); // );
|
||||
System.IntPtr meptr = new System.IntPtr(meint);
|
||||
|
||||
System.IntPtr hdc = g2.GetHdc();
|
||||
win32.SendMessage(control.Handle, win32.WM_PRINT, hdc, meptr);
|
||||
|
||||
g2.ReleaseHdc(hdc);
|
||||
g2.Dispose();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user