123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- 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;
- namespace LYFZ.ComponentLibrary
- {
- public partial class TextBoxEx : OtherExpansion.SkinControl.SkinTextBox
- {
- #region 声明
- private bool _Isico = false;
- private Bitmap _Ico;
- private Padding _IcoPadding = new Padding(3, 3, 0, 0);
- #endregion
- public TextBoxEx()
- : base()
- {
- this.BaseText.TextChanged += BaseText_TextChanged;
- }
- #region 属性
- // [Obsolete("此属性过期不建议使用")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- [Category("控件扩展属性"), Description("将控件设为密码显示")]
- public bool IsPass
- {
- get
- {
- return this.IsSystemPasswordChar; //BaseText.UseSystemPasswordChar;
- }
- set
- {
- this.IsSystemPasswordChar = value;
- // BaseText.UseSystemPasswordChar = value;
- // Invalidate(false);
- }
- }
- [Category("控件扩展属性"), Description("密码显示字符")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public char PassChar
- {
- get
- {
- return this.IsPasswordChat; //BaseText.PasswordChar;
- }
- set
- {
- this.IsPasswordChat = value;// BaseText.PasswordChar = value;
- Invalidate(false);
- }
- }
- Font _Font = new Font("宋体", 10.5f);
- // [Obsolete("此属性过期不建议使用")]
- [Category("控件扩展属性"), Description("此属性过期不建议使用 设置控件中文本字体")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public Font NewFont
- {
- get
- {
- return _Font;
- }
- set
- {
- _Font = value;
- }
- }
- // [Obsolete("此属性过期不建议使用")]
- [Category("控件扩展属性"), Description("此属性过期不建议使用 多行文本的编辑行")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public String[] lines
- {
- get
- {
- return this.Lines;
- }
- set
- {
- this.Lines = value;
- Invalidate(false);
- }
- }
- // [Obsolete("此属性过期不建议使用")]
- [Category("控件扩展属性"), Description("此属性过期不建议使用 是否显示图标")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public bool Isico
- {
- get
- {
- return _Isico;
- }
- set
- {
- _Isico = value;
- // this.Invalidate();
- }
- }
- // [Obsolete("此属性过期不建议使用")]
- [Category("控件扩展属性"), Description("此属性过期不建议使用 图标文件")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public Bitmap Ico
- {
- get
- {
- return _Ico;
- }
- set
- {
- _Ico = value; //Invalidate(false);
- }
- }
- // [Obsolete("此属性过期不建议使用")]
- [Category("控件扩展属性"), Description("此属性过期不建议使用 控件内部间距,图标文件")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public Padding IcoPadding
- {
- get { return _IcoPadding; }
- set
- {
- _IcoPadding = value;
- //this.Invalidate();
- }
- }
- #region 文本框边框颜色
- [DllImport("user32.dll")]
- private static extern IntPtr GetWindowDC(IntPtr hwnd);
- [DllImport("user32.dll")]
- private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
- private Color _borderColor = Color.Black;
- private int _borderWidth = 1;
- //
- // 摘要:
- // 获取或设置控件的边框颜色。
- //
- // 返回结果:
- // 控件的边框颜色 System.Drawing.Color。默认为 System.Drawing.Color.Black
- // 属性的值。
- // [Obsolete("此属性过期不建议使用")]
- [Description("组件的边框颜色。"), Category("此属性过期不建议使用 Appearance")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public Color BorderColor
- {
- get
- {
- return _borderColor;
- }
- set
- {
- _borderColor = value;
- this.Invalidate();
- }
- }
- //
- // 摘要:
- // 获取或设置控件的边框宽度。
- //
- // 返回结果:
- // 控件的边框宽度 int。默认为 1
- // 属性的值。
- // [Obsolete("此属性过期不建议使用")]
- [Description("组件的边框宽度。"), Category("此属性过期不建议使用 Appearance")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public int BorderWidth
- {
- get
- {
- return _borderWidth;
- }
- set
- {
- _borderWidth = value;
- // this.Invalidate();
- }
- }
- #endregion
- #endregion
- #region 方法
- //private bool _isCloseQaJiaoChar = true;
- ///// <summary>
- ///// 是否限制全角输入
- ///// </summary>
- //[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(true)]
- //[Category("控件扩展属性"), Description("是否限制全角输入")]
- //public bool IsCloseQaJiaoChar
- //{
- // get { return _isCloseQaJiaoChar; }
- // set { _isCloseQaJiaoChar = value; }
- //}
- ///// <summary>
- ///// 重写输入限制
- ///// </summary>
- ///// <param name="e"></param>
- //protected override void OnKeyPress(KeyPressEventArgs e)
- //{
- // if (this.IsCloseQaJiaoChar && LYFZ.BLL.OtherCommonModel.IsQaJiaoChar(e.KeyChar))
- // { e.Handled = true; }
- // else
- // { base.OnKeyPress(e); }
- //}
- ///// <summary>
- ///// 重写离开事件
- ///// </summary>
- ///// <param name="e"></param>
- //protected override void OnLeave(EventArgs e)
- //{
- // if (this.IsCloseQaJiaoChar)
- // {
- // if (LYFZ.BLL.OtherCommonModel.StringContainsQaJiao(this.Text.Trim()))
- // { this.Text = ""; }
- // }
- // base.OnLeave(e);
- //}
- /// <summary>
- /// 定义delegate (定义文本框值更改后触发事件)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public delegate void TextBoxEx_TextChanged(object sender, EventArgs e);
- /// <summary>
- /// 用event 关键字声明事件对象
- /// </summary>
- [Category("控件扩展事件"), Description("文本框值修改时")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public event TextBoxEx_TextChanged EventTextBoxEx_TextChanged;
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BaseText_TextChanged(object sender, EventArgs e)
- {
- if (this.EventTextBoxEx_TextChanged != null)
- EventTextBoxEx_TextChanged(sender, e);
- }
- #endregion
- }
- }
|