| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620 |
-
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Globalization;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using Dongke.WinForm.Utilities;
- namespace Dongke.WinForm.Controls
- {
- /// <summary>
- /// 数值输入文本框
- /// </summary>
- public abstract class TextBoxNumerical : TextBox, IDKControl,
- IDataVerifiable, IAsyncControl
- {
- #region 常量
- /// <summary>
- /// [^0-9]
- /// </summary>
- private const string REJECT_CHARS = "[^0-9]";
- /// <summary>
- /// [^-.0-9]
- /// </summary>
- private const string REJECT_CHARS_ALL = "[^-.0-9]";
- /// <summary>
- /// [-.]
- /// </summary>
- private const string REJECT_CHARS_NP = "-.";
- /// <summary>
- /// [#,##]
- /// </summary>
- private const string COMMA_HAS = "#,##";
- /// <summary>
- /// [####]
- /// </summary>
- private const string COMMA_NOT = "####";
- #endregion
- #region 事件声明
- /*
- #region TextPaste
- /// <summary>
- /// 当输入文本粘贴后发生
- /// </summary>
- private static readonly object EventTextPaste = new object();
- /// <summary>
- /// TextPaste 事件
- /// </summary>
- public event TextPasteEventHandler TextPaste
- {
- add
- {
- base.Events.AddHandler(EventTextPaste, value);
- }
- remove
- {
- base.Events.RemoveHandler(EventTextPaste, value);
- }
- }
- #endregion
- */
- #region HasErrorChanged
- /// <summary>
- /// 当 HasError 属性的值更改时发生。
- /// </summary>
- private static readonly object EventHasErrorChanged = new object();
- /// <summary>
- /// 当 HasError 属性的值更改时发生。
- /// </summary>
- [Description("当 HasError 属性的值更改时发生。"), Category("CustomerEx")]
- public event EventHandler HasErrorChanged
- {
- add
- {
- base.Events.AddHandler(EventHasErrorChanged, value);
- }
- remove
- {
- base.Events.RemoveHandler(EventHasErrorChanged, value);
- }
- }
- #endregion
- #endregion
- #region 成员变量
- /// <summary>
- /// 验证不通过,焦点不离开
- /// </summary>
- private bool _validatingCancel = false;
- /// <summary>
- /// 焦点是否进入控件
- /// </summary>
- private bool _entered = false;
- /// <summary>
- /// 鼠标是否进入控件
- /// </summary>
- private bool _mouseOver = false;
- /// <summary>
- /// 边框颜色
- /// </summary>
- private Color? _borderColor = null;
- /// <summary>
- /// 控件在获得焦点时,文本内容的选择方式。
- /// </summary>
- private EnteredSelectTextStyle _enteredSelectTextStyle = EnteredSelectTextStyle.None;
- /// <summary>
- /// 数值精度
- /// </summary>
- //private DNumber _number = DNumber.Empty;
- private Point _number = Point.Empty;
- /// <summary>
- /// 输入最大值
- /// </summary>
- private decimal _maxValue = 70000000000000000000000000000m;
- /// <summary>
- /// 输入最小值
- /// </summary>
- private decimal _minValue = -70000000000000000000000000000m;
- /// <summary>
- /// 数值精度最大值
- /// </summary>
- private decimal _maxDNumberValue = decimal.MaxValue;
- /// <summary>
- /// 数值精度最小值
- /// </summary>
- private decimal _minDNumberValue = decimal.MinValue;
- /// <summary>
- /// 最大值
- /// </summary>
- private decimal _maxNumberValue = decimal.MaxValue;
- /// <summary>
- /// 最小值
- /// </summary>
- private decimal _minNumberValue = decimal.MinValue;
- /// <summary>
- /// 数值
- /// </summary>
- protected decimal? _dataValue = null;
- /// <summary>
- /// 允许负数
- /// </summary>
- private bool _allowNegative = true;
- /// <summary>
- /// 是否显示千分隔符(逗号)
- /// </summary>
- private ShowDigitalKind _thousandsSeparator = ShowDigitalKind.Always;
- /// <summary>
- /// 补齐小数位数
- /// </summary>
- private ShowDigitalKind _showDecimalPlaces = ShowDigitalKind.Always;
- /// <summary>
- /// 限制数值输入方式
- /// </summary>
- private LimitInputKind _limitInputKind = LimitInputKind.None;
- /// <summary>
- /// 正在设置文本
- /// </summary>
- private bool _isSettingText = false;
- #endregion
- #region 构造函数
- /// <summary>
- /// 数值输入文本框
- /// </summary>
- public TextBoxNumerical()
- {
- base.TextAlign = HorizontalAlignment.Right;
- base.ImeMode = ImeMode.Off;
- CommonSetting.InitControls(this);
- }
- #endregion
- #region 属性
- /// <summary>
- /// 获取一个值,该值指示控件是否有输入焦点。
- /// </summary>
- [DefaultValue(false)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public virtual bool Entered
- {
- get
- {
- return this._entered;
- }
- protected set
- {
- if (this._entered != value)
- {
- this._entered = value;
- this.InvalidateBorder();
- }
- }
- }
- /// <summary>
- /// 获取一个值,该值指示鼠标是否在控件上方。
- /// </summary>
- [DefaultValue(false)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public virtual bool MouseOver
- {
- get
- {
- return this._mouseOver;
- }
- protected set
- {
- if (this._mouseOver != value)
- {
- this._mouseOver = value;
- this.InvalidateBorder();
- }
- }
- }
- /// <summary>
- /// 获取或设置数字的精度,DNumber.X为整数位的有效位数,DNumber.Y为小数位的有效位数
- /// </summary>
- [Description("获取或设置数字的精度,DNumber.X为整数位的有效位数,DNumber.Y为小数位的有效位数"), Category("CustomerEx")]
- [DefaultValue(typeof(Point), "0, 0")]
- public virtual Point Number
- {
- get
- {
- return this._number;
- }
- set
- {
- if (this._number != value)
- {
- this._number = value;
- this.SetDNumberValue();
- this.SetTextValue();
- }
- }
- }
- /// <summary>
- /// 获取或设置允许输入的数字最大值
- /// </summary>
- [Description("获取或设置允许输入的数字最大值"), Category("CustomerEx")]
- //[DefaultValue(typeof(decimal), "79228162514264337593543950335")]
- [DefaultValue(typeof(decimal), "70000000000000000000000000000")]
- [Localizable(true)]
- public virtual decimal MaxValue
- {
- get
- {
- return this._maxValue;
- }
- set
- {
- if (value < this._minValue)
- {
- return;
- }
- if (this._maxValue != value)
- {
- this._maxValue = value;
- if (this.SetMaxOrMinValue())
- {
- this.SetTextValue();
- }
- }
- }
- }
- /// <summary>
- /// 获取或设置允许输入的数字最小值
- /// </summary>
- [Description("获取或设置允许输入的数字最小值"), Category("CustomerEx")]
- //[DefaultValue(typeof(decimal), "-79228162514264337593543950335")]
- [DefaultValue(typeof(decimal), "-70000000000000000000000000000")]
- [Localizable(true)]
- public virtual decimal MinValue
- {
- get
- {
- return this._minValue;
- }
- set
- {
- if (value > this._maxValue)
- {
- return;
- }
- if (this._minValue != value)
- {
- this._minValue = value;
- if (this.SetMaxOrMinValue())
- {
- this.SetTextValue();
- }
- }
- }
- }
- /// <summary>
- /// 获取或设置文本框的数值
- /// </summary>
- [Description("获取或设置文本框的数值"), Category("CustomerEx")]
- [DefaultValue(null)]
- public decimal? DataValue
- {
- get
- {
- return this._dataValue;
- }
- set
- {
- if (this._dataValue != value)
- {
- //this._dataValue = value;
- this.SetTextValue(value.HasValue ? value.ToString() : string.Empty);
- }
- }
- }
- /// <summary>
- /// 获取或设置是否允许输入负数
- /// </summary>
- [Description("获取或设置是否允许输入负数"), Category("CustomerEx")]
- [DefaultValue(true)]
- public virtual bool AllowNegative
- {
- get
- {
- return this._allowNegative;
- }
- set
- {
- if (this._allowNegative != value)
- {
- this._allowNegative = value;
- bool needReset = this.SetDNumberValue();
- //needReset = this.SetRejectedChars() || needReset;
- if (needReset)
- {
- this.SetTextValue();
- }
- }
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指示如何显示千位分隔符(逗号)。
- /// </summary>
- [Description("获取或设置一个值,该值指示如何显示千位分隔符(逗号)。"), Category("CustomerEx")]
- [DefaultValue(typeof(ShowDigitalKind), "Always")]
- public virtual ShowDigitalKind ThousandsSeparator
- {
- get
- {
- return this._thousandsSeparator;
- }
- set
- {
- if (!Enum.IsDefined(typeof(ShowDigitalKind), value))
- {
- return;
- }
- if (this._thousandsSeparator != value)
- {
- this._thousandsSeparator = value;
- this.SetTextValue();
- }
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指示如何显示小数位数。
- /// </summary>
- [Description("获取或设置一个值,该值指示如何显示小数位数。"), Category("CustomerEx")]
- [DefaultValue(typeof(ShowDigitalKind), "Always")]
- public virtual ShowDigitalKind ShowDecimalPlaces
- {
- get
- {
- return this._showDecimalPlaces;
- }
- set
- {
- if (!Enum.IsDefined(typeof(ShowDigitalKind), value))
- {
- return;
- }
- if (this._showDecimalPlaces != value)
- {
- this._showDecimalPlaces = value;
- this.SetTextValue();
- }
- }
- }
- /// <summary>
- /// 获取或设置输入限制种类
- /// </summary>
- [Description("获取或设置输入限制种类"), Category("CustomerEx")]
- [DefaultValue(typeof(LimitInputKind), "None")]
- public virtual LimitInputKind LimitInputKind
- {
- get
- {
- return this._limitInputKind;
- }
- set
- {
- if (!Enum.IsDefined(typeof(LimitInputKind), value))
- {
- return;
- }
- if (this._limitInputKind != value)
- {
- this._limitInputKind = value;
- this.SetTextValue();
- }
- }
- }
- #endregion
- #region 重写属性
- /// <summary>
- /// 获取或设置在 System.Windows.Forms.TextBox.AutoCompleteSource 属性设置为 CustomSource
- /// 时使用的自定义 System.Collections.Specialized.StringCollection。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new AutoCompleteStringCollection AutoCompleteCustomSource
- {
- get
- {
- return base.AutoCompleteCustomSource;
- }
- set
- {
- base.AutoCompleteCustomSource = value;
- }
- }
- /// <summary>
- /// 获取或设置控制自动完成如何作用于 System.Windows.Forms.TextBox 的选项。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new AutoCompleteMode AutoCompleteMode
- {
- get
- {
- return base.AutoCompleteMode;
- }
- set
- {
- base.AutoCompleteMode = value;
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指定用于自动完成的完整字符串源。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new AutoCompleteSource AutoCompleteSource
- {
- get
- {
- return base.AutoCompleteSource;
- }
- set
- {
- base.AutoCompleteSource = value;
- }
- }
- /// <summary>
- /// 获取或设置 System.Windows.Forms.TextBox 控件是否在字符键入时修改其大小写格式。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new CharacterCasing CharacterCasing
- {
- get
- {
- return base.CharacterCasing;
- }
- set
- {
- base.CharacterCasing = value;
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指示此控件是否为多行控件。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override bool Multiline
- {
- get
- {
- return base.Multiline;
- }
- set
- {
- base.Multiline = value;
- }
- }
- /// <summary>
- /// 获取或设置控件中文本的对齐方式。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new HorizontalAlignment TextAlign
- {
- get
- {
- return base.TextAlign;
- }
- set
- {
- base.TextAlign = value;
- }
- }
- /// <summary>
- /// 获取或设置控件的输入法编辑器 (IME) 模式。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new ImeMode ImeMode
- {
- get
- {
- return base.ImeMode;
- }
- set
- {
- base.ImeMode = value;
- }
- }
- /// <summary>
- /// 获取一个用以指示是否可以将 System.Windows.Forms.Control.ImeMode 属性设置为活动值的值,以启用 IME 支持。
- /// </summary>
- protected override bool CanEnableIme
- {
- get
- {
- return false;
- }
- }
- /// <summary>
- /// 获取或设置用户可在文本框控件中键入或粘贴的最大字符数
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override int MaxLength
- {
- get
- {
- return base.MaxLength;
- }
- set
- {
- base.MaxLength = value;
- }
- }
- /// <summary>
- /// 获取或设置当前文本。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override string Text
- {
- get
- {
- return base.Text;
- }
- set
- {
- this.SetTextValue(value);
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指示控件中当前选定的文本。
- /// </summary>
- public override string SelectedText
- {
- get
- {
- return base.SelectedText;
- }
- set
- {
- this.PasteChars(value);
- }
- }
- /// <summary>
- /// 获取或设置字符,该字符用于屏蔽单行控件中的密码字符。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new char PasswordChar
- {
- get
- {
- return base.PasswordChar;
- }
- set
- {
- base.PasswordChar = value;
- }
- }
- /// <summary>
- /// 获取或设置哪些滚动条应出现在多行 System.Windows.Forms.TextBox 控件中。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new ScrollBars ScrollBars
- {
- get
- {
- return base.ScrollBars;
- }
- set
- {
- base.ScrollBars = value;
- }
- }
- /// <summary>
- /// 获取或设置一个值,该值指示 System.Windows.Forms.TextBox 控件中的文本是否应该以默认的密码字符显示。
- /// </summary>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new bool UseSystemPasswordChar
- {
- get
- {
- return base.UseSystemPasswordChar;
- }
- set
- {
- base.UseSystemPasswordChar = value;
- }
- }
- #endregion
- #region 重写事件
- #region 属性改变
- /// <summary>
- /// 引发 HasErrorChanged 事件
- /// </summary>
- /// <param name="e">包含事件数据的 EventArgs</param>
- protected virtual void OnHasErrorChanged(EventArgs e)
- {
- EventHandler eventHandler = (EventHandler)base.Events[EventHasErrorChanged];
- if (eventHandler != null)
- {
- eventHandler(this, e);
- }
- }
- /// <summary>
- /// 文本改变事件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnTextChanged(EventArgs e)
- {
- if (!this._isSettingText)
- {
- this.SetTextValue();
- return;
- }
- this._isSettingText = false;
- base.OnTextChanged(EventArgs.Empty);
- // TODO 实时验证?
- if (true)
- {
- this.ValidateData();
- }
- }
- #endregion
- #region 行为事件
- /// <summary>
- /// 引发 TextPaste 事件
- /// </summary>
- /// <param name="e">包含事件数据的 TextPasteEventArgs</param>
- protected virtual void OnPaste(TextPasteEventArgs e)
- {
- //TextPasteEventHandler eventHandler = (TextPasteEventHandler)base.Events[EventTextPaste];
- //if (eventHandler != null)
- //{
- // eventHandler(this, e);
- //}
- }
- #endregion
- #region 键盘事件
- /// <summary>
- /// 键盘输入
- /// </summary>
- /// <param name="e"></param>
- protected override void OnKeyPress(KeyPressEventArgs e)
- {
- base.OnKeyPress(e);
- if (e.Handled)
- {
- return;
- }
- if (!this.Enabled || this.ReadOnly || char.IsControl(e.KeyChar))
- {
- // Back
- if (e.KeyChar == (char)8)
- {
- int ss = base.SelectionStart;
- int sl = base.SelectionLength;
- int tl = base.TextLength;
- if (ss == 0 || (ss == 1 && tl == 1) || sl == tl)
- {
- return;
- }
- e.Handled = true;
- }
- return;
- }
- if (!this.PressChar(e.KeyChar))
- {
- WindowsAPI.MessageBeep(BeepType.MB_OK);
- }
- e.Handled = true;
- return;
- }
- /// <summary>
- /// 键盘点击
- /// </summary>
- /// <param name="e"></param>
- protected override void OnKeyDown(KeyEventArgs e)
- {
- base.OnKeyDown(e);
- if (e.Handled)
- {
- return;
- }
- if (e.KeyCode != Keys.Back && e.KeyCode != Keys.Delete)
- {
- return;
- }
- int ss = base.SelectionStart;
- int sl = base.SelectionLength;
- int tl = base.TextLength;
- #region Back
- if (e.KeyCode == Keys.Back)
- {
- // 删除空白
- if (ss == 0 || (ss == 1 && tl == 1) || sl == tl)
- {
- return;
- }
- this.BackChars();
- e.Handled = true;
- return;
- }
- #endregion
- #region Delete
- if (e.KeyCode == Keys.Delete)
- {
- // 删除空白
- if (ss == tl || (ss == 0 && tl == 1) || sl == tl)
- {
- return;
- }
- this.DeleteChars();
- e.Handled = true;
- return;
- }
- #endregion
- }
- #endregion
- #region 焦点事件
- /// <summary>
- /// 输入焦点进入控件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnEnter(EventArgs e)
- {
- this.Entered = true;
- base.OnEnter(e);
- }
- /// <summary>
- /// 获得焦点
- /// </summary>
- /// <param name="e"></param>
- protected override void OnGotFocus(EventArgs e)
- {
- base.OnGotFocus(e);
- if (this._validatingCancel)
- {
- this._validatingCancel = false;
- return;
- }
- // 格式化显示文本
- if (this._showDecimalPlaces != ShowDigitalKind.Always ||
- this._thousandsSeparator != ShowDigitalKind.Always)
- {
- this.SetText(this.FormatText(base.Text));
- }
- //this.SelectAll();
- int textLength = base.Text.Length;
- if (textLength > 0)
- {
- switch (this._enteredSelectTextStyle)
- {
- case EnteredSelectTextStyle.Left:
- this.Select(0, 0);
- break;
- case EnteredSelectTextStyle.Right:
- this.Select(textLength, 0);
- break;
- case EnteredSelectTextStyle.All:
- this.SelectAll();
- break;
- default:
- break;
- }
- }
- }
- /// <summary>
- /// 失去焦点
- /// </summary>
- /// <param name="e"></param>
- protected override void OnLostFocus(EventArgs e)
- {
- base.OnLostFocus(e);
- }
- /// <summary>
- /// 输入焦点离开控件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnLeave(EventArgs e)
- {
- base.OnLeave(e);
- //this.Entered = false;
- }
- /// <summary>
- /// 控件正在验证
- /// </summary>
- /// <param name="e"></param>
- protected override void OnValidating(CancelEventArgs e)
- {
- base.OnValidating(e);
- if (this.HasError && !this._canLostFocusOnError)
- {
- e.Cancel = true;
- }
- this._validatingCancel = e.Cancel;
- }
- /// <summary>
- /// 控件完成验证
- /// </summary>
- /// <param name="e"></param>
- protected override void OnValidated(EventArgs e)
- {
- this.Entered = false;
- this.SetText(this.FormatText(base.Text));
- this._validatingCancel = false;
- base.OnValidated(e);
- }
- #endregion
- #region 鼠标事件
- /// <summary>
- /// 鼠标进入控件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnMouseEnter(EventArgs e)
- {
- this.MouseOver = true;
- base.OnMouseEnter(e);
- }
- /// <summary>
- /// 鼠标离开控件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- this.MouseOver = false;
- }
- /// <summary>
- /// 鼠标移动
- /// </summary>
- /// <param name="e"></param>
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- }
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="e"></param>
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="e"></param>
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- }
- #endregion
- #endregion
- #region 重写方法
- /// <summary>
- /// 处理 Windows 消息
- /// </summary>
- /// <param name="m">要处理的 Windows System.Windows.Forms.Message</param>
- protected override void WndProc(ref Message m)
- {
- switch (m.Msg)
- {
- case (int)WindowsMessage.WM_PASTE:
- // 粘贴
- this.PasteChars();
- return;
- case (int)WindowsMessage.WM_CUT:
- // 右键菜单 剪切
- this.CutChars();
- break;
- case (int)WindowsMessage.WM_CHAR:
- if (m.WParam.ToInt32() == 18)
- {
- // Ctrl + X 18
- this.CutChars();
- }
- break;
- default:
- break;
- }
- base.WndProc(ref m);
- if ((int)m.Result == 1)
- {
- // 剪切、back、delete 等操作没有改变Text时,设置 _isSettingText = false。
- switch (m.Msg)
- {
- //case (int)WindowsMessage.WM_CUT:
- //// 剪切空白
- case (int)WindowsMessage.WM_CHAR:
- // 输入达到最大长度,back 8
- this._isSettingText = false;
- break;
- case (int)WindowsMessage.WM_KEYDOWN:
- //if (m.WParam.ToInt32() == 46)
- //{
- // // delete 46
- // this._isSettingText = false;
- //}
- break;
- default:
- break;
- }
- }
- if (m.Msg == (int)WindowsMessage.WM_PAINT ||
- m.Msg == (int)WindowsMessage.WM_NCPAINT ||
- m.Msg == (int)WindowsMessage.WM_CTLCOLOREDIT)
- {
- BorderColorPaint.WmBorderPaint(this._borderColor, this.Width, this.Height, ref m);
- }
- }
- #endregion
- #region 公有方法
- #endregion
- #region 保护方法
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置文本(过滤限制输入字符,并验证是否符合正则表达式)
- /// </summary>
- private void SetTextValue()
- {
- this.SetTextValue(base.Text);
- }
- /// <summary>
- /// 设置文本(过滤限制输入字符,并验证是否符合正则表达式)
- /// </summary>
- /// <param name="text">文本</param>
- private void SetTextValue(string text)
- {
- text = this.RejectChars(ref text, string.Empty);
- text = this.FormatText(text);
- this.SetText(text);
- }
- /// <summary>
- /// 设置文本(修改base.Text属性)
- /// </summary>
- /// <param name="text">文本</param>
- private void SetText(string text)
- {
- if (base.Text != text)
- {
- this._isSettingText = true;
- base.Text = text;
- this._isSettingText = false;
- }
- }
- /// <summary>
- /// Delete删除文本
- /// </summary>
- private void DeleteChars()
- {
- // 原文本
- string baseText = base.Text;
- // 选定的文本
- string seletedText = base.SelectedText;
- // 选定文本起始位置
- int selectionStart = base.SelectionStart;
- // 选定文本长度
- int selectionLength = base.SelectionLength;
- // 删除的文本
- string removedText = seletedText;
- // 输入后选定文本起始位置
- int start = selectionStart + 1;
- if (selectionLength == 0)
- {
- removedText = baseText.Substring(selectionStart, 1);
- }
- // 删除字符为千分符【,】时,文本不变,输入焦点后移一位。
- if (Constant.S_COMMA == removedText)
- {
- this.Select(start, 0);
- return;
- }
- // 删除字符为小数点【.】时,如果只有【.】或不补齐小数位数时,删除字符;其他情况不删除,输入焦点后移一位。
- if (baseText.Length > 1 &&
- this._showDecimalPlaces == ShowDigitalKind.Always &&
- Constant.S_POINT == removedText)
- {
- this.Select(start, 0);
- return;
- }
- // 新文本
- string text = null;
- // 去掉选定的字符
- if (selectionLength > 0)
- {
- text = baseText.Remove(selectionStart, selectionLength);
- }
- else
- {
- text = baseText.Remove(selectionStart, 1);
- }
- text = text.Replace(Constant.S_COMMA, string.Empty);
- // 验证输入后字符
- if (this.CheckInputedText(text))
- {
- // 格式化输入后字符
- text = this.FormatText(text);
- // 输入后光标位置
- start = this.GetDeleteSelectionStart(baseText, selectionStart, selectionLength, removedText, text);
- // 设置文本
- if (baseText != text)
- {
- this._isSettingText = true;
- base.Text = text;
- this._isSettingText = false;
- }
- }
- // 设置输入光标
- if (base.SelectionStart != start || selectionLength > 0)
- {
- this.Select(start, 0);
- }
- }
- /// <summary>
- /// Back删除文本
- /// </summary>
- private void BackChars()
- {
- // 原文本
- string baseText = base.Text;
- // 选定的文本
- string seletedText = base.SelectedText;
- // 选定文本起始位置
- int selectionStart = base.SelectionStart;
- // 选定文本长度
- int selectionLength = base.SelectionLength;
- // 删除的文本
- string removedText = seletedText;
- // 输入后选定文本起始位置
- int start = selectionStart;
- if (selectionLength == 0)
- {
- start = selectionStart - 1;
- removedText = baseText.Substring(start, 1);
- }
- // 删除字符为千分符【,】时,文本不变,输入焦点前移一位。
- if (Constant.S_COMMA == removedText)
- {
- this.Select(start, 0);
- return;
- }
- // 删除字符为小数点【.】时,如果只有【.】或不补齐小数位数时,删除字符;其他情况不删除,输入焦点前移一位。
- if (baseText.Length > 1 &&
- this._showDecimalPlaces == ShowDigitalKind.Always &&
- Constant.S_POINT == removedText)
- {
- this.Select(start, 0);
- return;
- }
- // 新文本
- string text = null;
- // 去掉选定的字符
- if (selectionLength > 0)
- {
- text = baseText.Remove(selectionStart, selectionLength);
- }
- else
- {
- text = baseText.Remove(start, 1);
- }
- text = text.Replace(Constant.S_COMMA, string.Empty);
- // 验证输入后字符
- if (this.CheckInputedText(text))
- {
- // 格式化输入后字符
- text = this.FormatText(text);
- // 输入后光标位置
- start = this.GetBackSelectionStart(baseText, selectionStart, selectionLength, removedText, text);
- // 设置文本
- if (baseText != text)
- {
- this._isSettingText = true;
- base.Text = text;
- this._isSettingText = false;
- }
- }
- // 设置输入光标
- if (base.SelectionStart != start || selectionLength > 0)
- {
- this.Select(start, 0);
- }
- }
- /// <summary>
- /// 剪切文本
- /// </summary>
- private void CutChars()
- {
- if (!this.Enabled || this.ReadOnly)
- {
- return;
- }
- if (base.SelectionLength == 0)
- {
- return;
- }
- // 复制到剪切板
- Clipboard.SetText(base.SelectedText);
- this.DeleteChars();
- }
- /// <summary>
- /// 输入字符串
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- private bool PressChar(char key)
- {
- // 原文本
- string baseText = base.Text;
- // 选定的文本
- string seletedText = base.SelectedText;
- // 选定文本起始位置
- int selectionStart = base.SelectionStart;
- // 选定文本长度
- int selectionLength = base.SelectionLength;
- // 输入后选定文本起始位置
- int start = selectionStart + selectionLength;
- if (selectionLength == 1 && seletedText[0] == key)
- {
- this.Select(start, 0);
- return true;
- }
- if (selectionLength == 2 &&
- ((seletedText[0] == Constant.C_COMMA && seletedText[1] == key) ||
- (seletedText[0] == key && seletedText[1] == Constant.C_COMMA)))
- {
- this.Select(start, 0);
- return true;
- }
- if (key == Constant.C_POINT)
- {
- if (this._number.Y > 0)
- {
- int indexPoint = baseText.IndexOf(Constant.C_POINT);
- if (selectionLength == 0 && indexPoint == selectionStart)
- {
- this.Select(start + 1, 0);
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- string chars = key.ToString();
- string text = this.RejectChars(ref chars, baseText, selectionStart, selectionLength);
- if (this.CheckInputedText(text))
- {
- text = this.FormatText(text);
- // 输入后光标位置
- start = this.GetKeySelectionStart(baseText, selectionStart,
- selectionLength, seletedText, text, chars);
- // 设置文本
- if (baseText != text)
- {
- this._isSettingText = true;
- base.Text = text;
- this._isSettingText = false;
- }
- // 设置输入光标
- if (base.SelectionStart != start || selectionLength > 0)
- {
- this.Select(start, 0);
- }
- return true;
- }
- return false;
- }
- /// <summary>
- /// 粘贴文本
- /// </summary>
- private void PasteChars()
- {
- if (!this.Enabled || this.ReadOnly)
- {
- return;
- }
- object clipboardChars = Clipboard.GetDataObject().GetData(DataFormats.UnicodeText);
- if (clipboardChars == null)
- {
- clipboardChars = Clipboard.GetDataObject().GetData(DataFormats.Text);
- if (clipboardChars == null)
- {
- return;
- }
- }
- if (!this.PasteChars(clipboardChars.ToString()))
- {
- WindowsAPI.MessageBeep(BeepType.MB_OK);
- }
- }
- /// <summary>
- /// 粘贴文本
- /// </summary>
- /// <param name="chars"></param>
- private bool PasteChars(string chars)
- {
- if (string.IsNullOrEmpty(chars))
- {
- return false;
- }
- // 原文本
- string baseText = base.Text;
- // 选定的文本
- string seletedText = base.SelectedText;
- // 选定文本起始位置
- int selectionStart = base.SelectionStart;
- // 选定文本长度
- int selectionLength = base.SelectionLength;
- // 输入后选定文本起始位置
- int start = selectionStart + selectionLength;
- if (selectionLength > 0 &&
- (seletedText == chars ||
- seletedText.Replace(Constant.S_COMMA, string.Empty) == chars.Replace(Constant.S_COMMA, string.Empty)))
- {
- this.Select(start, 0);
- return true;
- }
- string text = this.RejectChars(ref chars, baseText, selectionStart, selectionLength);
- if (this.CheckInputedText(text))
- {
- text = this.FormatText(text);
- TextPasteEventArgs pasteEventArgs = new TextPasteEventArgs(chars);
- this.OnPaste(pasteEventArgs);
- if (pasteEventArgs.Cancel)
- {
- return false;
- }
- // 输入后光标位置
- start = this.GetKeySelectionStart(baseText, selectionStart,
- selectionLength, seletedText, text, chars);
- // 设置文本
- if (baseText != text)
- {
- this._isSettingText = true;
- base.Text = text;
- this._isSettingText = false;
- }
- // 设置输入光标
- if (base.SelectionStart != start || selectionLength > 0)
- {
- this.Select(start, 0);
- }
- return true;
- }
- return false;
- }
- /// <summary>
- /// 取得Delete删除文本后光标位置
- /// </summary>
- /// <param name="baseText"></param>
- /// <param name="selectionStart"></param>
- /// <param name="selectionLength"></param>
- /// <param name="removedText"></param>
- /// <param name="text"></param>
- /// <returns></returns>
- private int GetDeleteSelectionStart(string baseText, int selectionStart,
- int selectionLength, string removedText, string text)
- {
- int start = selectionStart;
- if (Constant.S_NEGATIVE == removedText || // 删除负号
- Constant.S_NEGATIVE == text ||
- Constant.S_POINT == text ||
- Constant.S_POINT == baseText)
- {
- return start;
- }
- int baseTextLength = baseText.Length;
- int textLength = text.Length;
- int baseTextPointIndex = baseText.IndexOf(Constant.C_POINT);
- int textPointIndex = text.IndexOf(Constant.C_POINT);
- #region 无选定文本
- if (selectionLength == 0)
- {
- // 无效操作
- if (selectionStart == baseTextLength)
- {
- return selectionStart;
- }
- int selectionEnd = selectionStart + 1;
- #region 删除整数部分(无小数点 或 光标在小数点前)
- if (baseTextPointIndex < 0 || selectionStart < baseTextPointIndex)
- {
- // 输入焦点距离字符右侧间隔 + 1
- start = textLength - (baseTextLength - selectionEnd);
- // 光标后移一位,在【,】后面。
- int startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionEnd : baseTextPointIndex - selectionEnd;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- #endregion
- #region 删除小数点
- else if (selectionStart == baseTextPointIndex)
- {
- // 小数变为整数
- int lastLength = baseTextLength - selectionEnd;
- if (lastLength > 0 &&
- (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered)))
- {
- lastLength = lastLength + lastLength / 3;
- }
- // 右侧字符长度不变
- start = textLength - lastLength;
- // 光标后移一位,在【,】后面。
- if (lastLength % 4 == 0)
- {
- start++;
- }
- }
- #endregion
- #region 删除小数
- else
- {
- if (baseText != text)
- {
- // 光标位置不变
- start = selectionStart;
- }
- else
- {
- // 小数位全为【0】时,光标后移一位。
- start++;
- }
- }
- #endregion
- }
- #endregion
- #region 选定文本
- else
- {
- int selectionEnd = selectionStart + selectionLength;
- #region 删除整数部分(无小数点 或 选定文本在小数点前)
- if (baseTextPointIndex < 0 || selectionEnd <= baseTextPointIndex)
- {
- // 输入焦点(末尾)距离字符右侧间隔不变。
- start = textLength - (baseTextLength - selectionEnd);
- // 光标后移一位,在【,】后面。
- int startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionEnd : baseTextPointIndex - selectionEnd;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- #endregion
- #region 选定文本包括小数点
- else if (selectionStart <= baseTextPointIndex && baseTextPointIndex < selectionEnd)
- {
- // 小数变为整数
- int lastLength = baseTextLength - selectionEnd;
- if (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered))
- {
- lastLength = lastLength + lastLength / 3;
- }
- // 补齐小数位
- if (textPointIndex > -1)
- {
- // 右侧字符长度加上补齐的小数部分
- start = textLength - lastLength - (textLength - textPointIndex);
- }
- // 变为整数
- else
- {
- // 右侧字符长度不变
- start = textLength - lastLength;
- }
- // 光标后移一位,在【,】后面。
- if (lastLength % 4 == 0)
- {
- start++;
- }
- }
- #endregion
- #region 删除小数
- else
- {
- if (baseText != text)
- {
- // 光标位置不变
- start = selectionStart;
- }
- else
- {
- // 小数位全为【0】时,光标后移。
- start = selectionStart + selectionLength;
- }
- }
- #endregion
- }
- #endregion
- return start;
- }
- /// <summary>
- /// 取得Back删除文本后光标位置
- /// </summary>
- /// <param name="baseText"></param>
- /// <param name="selectionStart"></param>
- /// <param name="selectionLength"></param>
- /// <param name="removedText"></param>
- /// <param name="text"></param>
- /// <returns></returns>
- private int GetBackSelectionStart(string baseText, int selectionStart,
- int selectionLength, string removedText, string text)
- {
- int start = selectionStart - 1;
- if (Constant.S_NEGATIVE == removedText || // 删除负号
- Constant.S_NEGATIVE == text ||
- Constant.S_POINT == text ||
- Constant.S_POINT == baseText)
- {
- return (selectionLength > 0 ? selectionStart : start);
- }
- int baseTextLength = baseText.Length;
- int textLength = text.Length;
- int baseTextPointIndex = baseText.IndexOf(Constant.C_POINT);
- int textPointIndex = text.IndexOf(Constant.C_POINT);
- #region 无选定文本
- if (selectionLength == 0)
- {
- // 无效操作
- if (selectionStart == 0)
- {
- return 0;
- }
- #region 删除整数部分(无小数点 或 光标在小数点前)
- else if (baseTextPointIndex < 0 || selectionStart <= baseTextPointIndex)
- {
- // 输入焦点距离字符右侧间隔不变。
- start = textLength - (baseTextLength - selectionStart);
- int startIndex = 1;
- if (text[0] == Constant.C_NEGATIVE)
- {
- startIndex++;
- }
- // 光标在除负号外的第二位(1),并且光标后字符是【,】,光标后移一位,在【-】后面或第一位(0)。
- if (selectionStart == startIndex)
- {
- startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionStart : baseTextPointIndex - selectionStart;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- }
- #endregion
- #region 删除小数点
- else if (selectionStart == baseTextPointIndex + 1)
- {
- // 小数变为整数
- int lastLength = baseTextLength - selectionStart;
- if (lastLength > 0 &&
- (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered)))
- {
- lastLength = lastLength + lastLength / 3;
- }
- // 右侧字符长度不变
- start = textLength - lastLength;
- }
- #endregion
- #region 删除小数
- else
- {
- // 光标前移一位
- start = selectionStart - 1;
- }
- #endregion
- }
- #endregion
- #region 选定文本
- else
- {
- int selectionEnd = selectionStart + selectionLength;
- #region 删除整数部分(无小数点 或 选定文本在小数点前)
- if (baseTextPointIndex < 0 || selectionEnd <= baseTextPointIndex)
- {
- // 输入焦点(末尾)距离字符右侧间隔不变。
- start = textLength - (baseTextLength - selectionEnd);
- int startIndex = 0;
- if (text[0] == Constant.C_NEGATIVE)
- {
- startIndex++;
- }
- // 光标在除负号外的第二位(1),并且光标后字符是【,】,光标后移一位,在【-】后面或第一位(0)。
- if (selectionStart == startIndex)
- {
- startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionEnd : baseTextPointIndex - selectionEnd;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- else
- {
- if (removedText.EndsWith(Constant.S_COMMA))
- {
- start--;
- }
- }
- }
- #endregion
- #region 选定文本包括小数点
- else if (selectionStart <= baseTextPointIndex && baseTextPointIndex < selectionEnd)
- {
- // 小数变为整数
- int lastLength = baseTextLength - selectionEnd;
- if (lastLength > 0 &&
- (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered)))
- {
- lastLength = lastLength + lastLength / 3;
- }
- // 补齐小数位
- if (textPointIndex > -1)
- {
- // 右侧字符长度加上补齐的小数部分
- start = textLength - lastLength - (textLength - textPointIndex);
- }
- // 变为整数
- else
- {
- // 右侧字符长度不变
- start = textLength - lastLength;
- }
- }
- #endregion
- #region 删除小数
- else
- {
- // 输入焦点不变。
- start = selectionStart;
- }
- #endregion
- }
- #endregion
- return start;
- }
- /// <summary>
- /// 取得输入文本后光标位置
- /// </summary>
- /// <param name="baseText"></param>
- /// <param name="selectionStart"></param>
- /// <param name="selectionLength"></param>
- /// <param name="removedText"></param>
- /// <param name="text"></param>
- /// <param name="chars"></param>
- /// <returns></returns>
- private int GetKeySelectionStart(string baseText, int selectionStart,
- int selectionLength, string removedText, string text, string chars)
- {
- int start = selectionStart + 1;
- if (Constant.S_NEGATIVE == chars ||
- Constant.S_POINT == text)
- {
- return start;
- }
- if (REJECT_CHARS_NP == chars)
- {
- return start + 1;
- }
- int baseTextLength = baseText.Length;
- int textLength = text.Length;
- int charsLength = chars.Length;
- int baseTextPointIndex = baseText.IndexOf(Constant.C_POINT);
- int textPointIndex = text.IndexOf(Constant.C_POINT);
- int charsPointIndex = chars.IndexOf(Constant.C_POINT);
- // 无文本或全选时
- if (baseTextLength == 0 || baseTextLength == selectionLength)
- {
- // 新文本没有小数部分,光标在新文本末尾
- if (textPointIndex < 0)
- {
- return textLength;
- }
- // 输入字符没有小数部分,光标在小数点前
- if (charsPointIndex < 0)
- {
- return textPointIndex;
- }
- // 输入字符有小数部分,光标在补齐位数前
- if (charsPointIndex > -1)
- {
- return textPointIndex + charsLength - charsPointIndex;
- }
- }
- #region 无选定文本(插入)
- if (selectionLength == 0)
- {
- #region 输入字符不带小数点
- if (charsPointIndex < 0)
- {
- #region 整数部分(无小数点 或 光标在小数点前)
- if (baseTextPointIndex < 0 || selectionStart <= baseTextPointIndex)
- {
- // 输入前无小数,输入后有小数
- if (baseTextPointIndex < 0 && textPointIndex >= 0)
- {
- start = textPointIndex;
- }
- else
- {
- // 输入焦点距离字符右侧间隔不变。
- start = textLength - (baseTextLength - selectionStart);
- if (baseTextPointIndex == baseTextLength - 1 &&
- textPointIndex != textLength - 1)
- {
- start = start - textLength + textPointIndex + 1;
- }
- else
- {
- // 光标后移一位,在【,】后面。
- int startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionStart : baseTextPointIndex - selectionStart;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- }
- }
- #endregion
- #region 小数部分
- else
- {
- // 光标后移输入字符串长度
- start = selectionStart + charsLength;
- }
- #endregion
- }
- #endregion
- #region 输入字符带小数点
- else
- {
- // 光标在输入字符串末尾
- start = textPointIndex + charsLength - charsPointIndex;
- }
- #endregion
- }
- #endregion
- #region 选定文本(替换)
- else
- {
- int selectionEnd = selectionStart + selectionLength;
- #region 输入字符不带小数点
- if (charsPointIndex < 0)
- {
- #region 整数部分(无小数点 或 光标在小数点前)
- if (baseTextPointIndex < 0 || selectionEnd <= baseTextPointIndex)
- {
- // 输入焦点距离字符右侧间隔不变。
- start = textLength - (baseTextLength - selectionEnd);
- if (baseTextPointIndex == baseTextLength - 1 &&
- textPointIndex != textLength - 1)
- {
- start = start - textLength + textPointIndex + 1;
- }
- else
- {
- // 光标后移一位,在【,】后面。
- int startIndex = baseTextPointIndex < 0 ? baseTextLength - selectionStart : baseTextPointIndex - selectionStart;
- if (startIndex > 0 && startIndex % 4 == 0)
- {
- start++;
- }
- }
- }
- #endregion
- #region 小数部分
- else if (selectionStart > baseTextPointIndex)
- {
- // 光标后移输入字符串长度。
- start = selectionStart + charsLength;
- }
- #endregion
- #region 选定小数点
- else
- {
- // 小数变为整数
- int lastLength = baseTextLength - selectionEnd;
- if (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered))
- {
- lastLength = lastLength + lastLength / 3;
- }
- // 补齐小数位
- if (textPointIndex > -1)
- {
- // 右侧字符长度加上补齐的小数部分
- start = textLength - lastLength - (textLength - textPointIndex);
- }
- // 变为整数
- else
- {
- // 右侧字符长度不变
- start = textLength - lastLength;
- }
- // 右侧字符长度不变
- //start = textLength - lastLength;
- // 光标后移一位,在【,】后面。
- if (lastLength % 4 == 0)
- {
- start++;
- }
- }
- #endregion
- }
- #endregion
- #region 输入字符带小数点
- else
- {
- // 光标在输入字符串末尾
- start = textPointIndex + charsLength - charsPointIndex;
- }
- #endregion
- }
- #endregion
- return start;
- }
- /// <summary>
- /// 将数值转换为字符串表示形式
- /// </summary>
- /// <param name="value"></param>
- /// <param name="hasNegatve"></param>
- /// <param name="hasPoint"></param>
- /// <param name="pointLength"></param>
- /// <returns></returns>
- private string ToText(decimal value, bool hasNegatve, int hasPoint, int pointLength)
- {
- string dec = null;
- if (this._number.Y > 0)
- {
- if (this._showDecimalPlaces == ShowDigitalKind.Always ||
- (this._showDecimalPlaces == ShowDigitalKind.NoFocus && !this._entered))
- {
- dec = Constant.S_POINT.PadRight(this._number.Y + 1, Constant.C_0);
- }
- else
- {
- if (this._entered)
- {
- if (this._limitInputKind.HasFlag(LimitInputKind.Decimal))
- {
- pointLength = Math.Min(pointLength, this._number.Y);
- }
- dec = Constant.S_POINT.PadRight(pointLength + 1, Constant.C_0);
- }
- else
- {
- dec = Constant.S_POINT.PadRight(this._number.Y + 1, Constant.C_WELL);
- }
- }
- }
- string comma = null;
- if (this._thousandsSeparator == ShowDigitalKind.Always ||
- (this._thousandsSeparator == ShowDigitalKind.NoFocus && !this._entered))
- {
- comma = COMMA_HAS + ((this._entered && hasPoint == -1) ? Constant.S_WELL : Constant.S_0) + dec;
- }
- else
- {
- comma = COMMA_NOT + ((this._entered && hasPoint == -1) ? Constant.S_WELL : Constant.S_0) + dec;
- }
- string text = value.ToString(comma, CultureInfo.CurrentCulture);
- if (hasPoint == -2 && text.IndexOf(Constant.C_POINT) < 0)
- {
- text += Constant.S_POINT;
- }
- return (value < 0 || !hasNegatve) ? text : Constant.S_NEGATIVE + text;
- }
- /// <summary>
- /// 验证输入后的新文本(OnKeyDown delete or back)
- /// </summary>
- /// <param name="text">输入后的新文本</param>
- /// <returns>是否通过验证,true 通过,false 不通过</returns>
- private bool CheckInputedText(string text)
- {
- if (text.Length == 0)
- {
- return true;
- }
- if (text.Length == 1)
- {
- char t1 = text[0];
- // 是否可以输入小数点
- if (Constant.C_POINT == t1)
- {
- return this._number.Y > 0;
- }
- // 是否可以输入负号
- if (Constant.C_NEGATIVE == t1)
- {
- return this._minNumberValue < 0;
- }
- }
- // 【-.】
- if (text == TextBoxNumerical.REJECT_CHARS_NP)
- {
- return true;
- }
- decimal d = 0;
- if (!decimal.TryParse(text, out d))
- {
- // 不能转为数值
- return false;
- }
- int pointIndex = text.IndexOf(Constant.S_POINT);
- // 有小数点
- if (pointIndex > -1)
- {
- // 不能输入小数
- if (this._number.Y == 0)
- {
- return false;
- }
- // todo ?
- text = d.ToString();
- pointIndex = text.IndexOf(Constant.S_POINT);
- // 去掉小数部分多余的【0】
- if (pointIndex > -1)
- {
- text = text.TrimEnd(Constant.C_0);
- }
- // 验证整数部分长度
- if (this._number.X > 0 && this._limitInputKind.HasFlag(LimitInputKind.Integer))
- {
- int textStart = (text[0] == Constant.C_NEGATIVE ? 1 : 0);
- if (pointIndex - textStart > this._number.X)
- {
- return false;
- }
- }
- // 验证小数部分长度
- if (this._number.Y > 0 && this._limitInputKind.HasFlag(LimitInputKind.Decimal))
- {
- if (text.Length - pointIndex - 1 > this._number.Y)
- {
- return false;
- }
- }
- }
- else
- {
- // 无小数点时,验证整数部分长度
- if (this._number.X > 0 && this._limitInputKind.HasFlag(LimitInputKind.Integer))
- {
- int textStart = (text[0] == Constant.C_NEGATIVE ? 1 : 0);
- if (text.Length - textStart > this._number.X)
- {
- return false;
- }
- }
- }
- // 验证数据范围
- if (this._limitInputKind.HasFlag(LimitInputKind.Range))
- {
- if (d > this._maxNumberValue)
- {
- return false;
- }
- if (d < this._minNumberValue)
- {
- return false;
- }
- //if (!this._allowZero && d == 0)
- //{
- // return false;
- //}
- if (!this._allowNegative && d < 0)
- {
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 验证数值
- /// </summary>
- /// <param name="value"></param>
- private decimal CheckDataValue(decimal value)
- {
- if (value > this._maxNumberValue)
- {
- value = this._maxNumberValue;
- }
- if (value < this._minNumberValue)
- {
- value = this._minNumberValue;
- }
- return value;
- }
- /// <summary>
- /// 验证输入的字符(paste or check all text)
- /// </summary>
- /// <param name="chars">输入的字符</param>
- /// <param name="text">现有文本</param>
- /// <param name="selectionStart">选定文本的起始点</param>
- /// <param name="selectionLength">选定的字符数</param>
- /// <returns>是否通过验证的文本</returns>
- private string RejectChars(ref string chars, string text,
- int selectionStart = 0, int selectionLength = 0)
- {
- // 去掉选定的字符
- if (selectionLength > 0)
- {
- text = text.Remove(selectionStart, selectionLength);
- }
- if (string.IsNullOrEmpty(chars))
- {
- chars = string.Empty;
- }
- else
- {
- //chars = chars.Replace(REJECT_CHARS_ALL, string.Empty);
- chars = Regex.Replace(chars, REJECT_CHARS_ALL, string.Empty);
- }
- // 过滤输入字符
- if (chars.Length > 0)
- {
- // 过滤负号
- bool noNegatve = selectionStart > 0 || !this._allowNegative;
- // 过滤小数点
- bool noPoint = this._number.Y == 0;
- if (text.Length > 0)
- {
- // 文本中已经有负号
- noNegatve = noNegatve || text[0] == Constant.C_NEGATIVE;
- // 文本中已经有小数点
- noPoint = noPoint || text.Contains(Constant.S_POINT);
- }
- //string rejected = TextBoxDigital.REJECT_CHARS_ALL;
- // 输入字符中是否有负号
- bool hasNegatve = (chars[0] == Constant.C_NEGATIVE);
- // 过滤掉无用字符
- chars = chars.Replace(Constant.S_NEGATIVE, string.Empty);
- if (noPoint)
- {
- //chars = chars.Replace(Constant.S_POINT, string.Empty);
- int indexPoint = chars.IndexOf(Constant.S_POINT);
- if (indexPoint > -1)
- {
- chars = chars.Remove(indexPoint);
- }
- }
- // 允许为负数并且输入负号
- if (!noNegatve && hasNegatve)
- {
- chars = chars + Constant.C_NEGATIVE;
- }
- // 允许为小数并且输入小数点
- if (!noPoint)
- {
- string[] p = chars.Split(Constant.C_POINT);
- if (p.Length > 2)
- {
- chars = string.Join(Constant.S_POINT, p, 0, 2) + string.Join(string.Empty, p, 2, p.Length);
- }
- }
- }
- if (text.Length > 0 && chars.Length > 0)
- {
- text = text.Insert(selectionStart, chars);
- }
- else if (text.Length == 0)
- {
- text = chars;
- }
- return text.Replace(Constant.S_COMMA, string.Empty);
- }
- /// <summary>
- /// 格式化显示文本
- /// </summary>
- /// <param name="text">文本</param>
- /// <returns>格式化后的文本</returns>
- private string FormatText(string text)
- {
- if (string.IsNullOrEmpty(text))
- {
- this._dataValue = null;
- return string.Empty;
- }
- if (Constant.S_NEGATIVE == text ||
- Constant.S_POINT == text ||
- TextBoxNumerical.REJECT_CHARS_NP == text)
- {
- this._dataValue = 0;
- if (this._entered)
- {
- return text;
- }
- else
- {
- if (this._showDecimalPlaces == ShowDigitalKind.Always ||
- this._showDecimalPlaces == ShowDigitalKind.NoFocus)
- {
- return Constant.S_0 + Constant.S_POINT.PadRight(Number.Y + 1, Constant.C_0);
- }
- else
- {
- return Constant.S_0;
- }
- }
- }
- decimal d = 0;
- if (!decimal.TryParse(text, out d))
- {
- this._dataValue = null;
- return text;
- }
- // 负号
- bool hasNegative = (text[0] == Constant.C_NEGATIVE);
- // 小数点(0:无特殊处理;-1:开始位置;-2:结束位置)
- int pointIndex = text.IndexOf(Constant.C_POINT);
- int hasPoint = 0;
- int pointLength = 0;
- if (pointIndex > -1)
- {
- pointLength = text.Length - pointIndex - 1;
- if (pointIndex == 0 || (hasNegative && pointIndex == 1))
- {
- hasPoint = -1;
- }
- else if (pointLength == 0)
- {
- hasPoint = -2;
- }
- }
- this._dataValue = this.CheckDataValue(d);
- return this.ToText(this._dataValue.Value, hasNegative, hasPoint, pointLength);
- }
- /// <summary>
- /// 确定最大最小值
- /// </summary>
- /// <returns></returns>
- private bool SetDNumberValue()
- {
- if (this._number.X > 0)
- {
- this._maxDNumberValue = DNumber.ToDecimal(this._number);
- this._minDNumberValue = (this._allowNegative ? 0 - this._maxDNumberValue : 0);
- }
- else
- {
- this._maxDNumberValue = decimal.MaxValue;
- this._minDNumberValue = (this._allowNegative ? decimal.MinValue : 0);
- }
- return this.SetMaxOrMinValue();
- }
- /// <summary>
- /// 确定最大最小值
- /// </summary>
- /// <returns></returns>
- private bool SetMaxOrMinValue()
- {
- bool isChanged = false;
- decimal value = Math.Min(this._maxValue, this._maxDNumberValue);
- if (this._maxNumberValue != value)
- {
- isChanged = true;
- this._maxNumberValue = value;
- }
- value = Math.Max(this._minValue, this._minDNumberValue);
- if (this._minNumberValue != value)
- {
- isChanged = true;
- this._minNumberValue = value;
- }
- return isChanged;
- }
- /// <summary>
- /// 使父控件的指定区域无效(将其添加到控件的更新区域,下次绘制操作时将重新绘制更新区域),并向父控件发送绘制消息。
- /// </summary>
- private void InvalidateBorder()
- {
- Color? borderColor = BorderColorPaint.GetBorderColor(this as IDataVerifiable, this._entered, this._mouseOver);
- if (borderColor != this._borderColor)
- {
- this._borderColor = borderColor;
- if (this.Parent == null)
- {
- this.Invalidate();
- }
- else
- {
- this.Parent.Invalidate(this.Bounds, true);
- }
- }
- }
- #endregion
- #region IDataVerifiable 成员
- #region 成员变量
- /// <summary>
- /// 显示边框颜色
- /// </summary>
- private bool _showBorderColor = true;
- /// <summary>
- /// 控件的项目名
- /// </summary>
- private string _itemName = null;
- /// <summary>
- /// 控件是否是必须输入项目
- /// </summary>
- private bool _mustInput = false;
- /// <summary>
- /// 控件在验证输入错误时,如何提示
- /// </summary>
- private InputErrorAlert _errorAlert = InputErrorAlert.Validated;
- /// <summary>
- /// 是否显示必须输入项目的提示
- /// </summary>
- private bool _showMustInputAlert = true;
- /// <summary>
- /// 验证不通过时,焦点能否离开
- /// </summary>
- private bool _canLostFocusOnError = true;
- /// <summary>
- /// 验证是否有错误
- /// </summary>
- private bool _hasError = false;
- /// <summary>
- /// 是否自定义错误
- /// </summary>
- private bool _hasCustomerError = false;
- /// <summary>
- /// 错误编码
- /// </summary>
- private ControlErrorCode _errorCode = ControlErrorCode.DKC_0000;
- /// <summary>
- /// 错误消息
- /// </summary>
- private string _errorMessage = null;
- /// <summary>
- /// 自定义错误消息
- /// </summary>
- private string _customerErrorMessage = null;
- #endregion
- #region 属性
- /// <summary>
- /// 获取或设置控件是否显示边框颜色。
- /// </summary>
- [Description("获取或设置控件是否显示边框颜色。"), Category("IDataVerifiable")]
- [DefaultValue(true)]
- public bool ShowBorderColor
- {
- get
- {
- return this._showBorderColor;
- }
- set
- {
- if (this._showBorderColor != value)
- {
- this._showBorderColor = value;
- this.InvalidateBorder();
- }
- }
- }
- /// <summary>
- /// 获取或设置控件的项目名
- /// </summary>
- [Description("获取或设置控件的项目名。"), Category("IDataVerifiable")]
- [DefaultValue(null)]
- public string CDItemName
- {
- get
- {
- return this._itemName;
- }
- set
- {
- this._itemName = value;
- }
- }
- /// <summary>
- /// 获取或设置控件是否必须选中项目。
- /// </summary>
- [Description("获取或设置控件是否必须选中项目。"), Category("IDataVerifiable")]
- [DefaultValue(false)]
- public bool MustInput
- {
- get
- {
- return this._mustInput;
- }
- set
- {
- if (this._mustInput != value)
- {
- if (!this._mustInput && value)
- {
- this._mustInput = value;
- this.SetTextValue();
- }
- else
- {
- this._mustInput = value;
- }
- this.ValidateData();
- if (value && this._showMustInputAlert)
- {
- this.InvalidateBorder();
- }
- }
- }
- }
- /// <summary>
- /// 获取或设置控件是否必须选中项目。
- /// </summary>
- [Description("获取或设置控件在验证输入错误时,如何提示。"), Category("IDataVerifiable")]
- [DefaultValue(typeof(InputErrorAlert), "Validated")]
- public InputErrorAlert InputErrorAlert
- {
- get
- {
- return this._errorAlert;
- }
- set
- {
- if (this._errorAlert != value)
- {
- this._errorAlert = value;
- this.InvalidateBorder();
- }
- }
- }
- /// <summary>
- /// 获取或设置控件是否显示必须输入项目提示
- /// </summary>
- [Description("获取或设置控件是否显示必须输入项目提示。"), Category("IDataVerifiable")]
- [DefaultValue(true)]
- public bool ShowMustInputAlert
- {
- get
- {
- return this._showMustInputAlert;
- }
- set
- {
- if (this._showMustInputAlert != value)
- {
- this._showMustInputAlert = value;
- this.InvalidateBorder();
- }
- }
- }
- /// <summary>
- /// 获取或设置当验证不通过时,控件是否可以失去焦点
- /// </summary>
- [Description("获取或设置当验证不通过时,控件是否可以失去焦点。"), Category("IDataVerifiable")]
- [DefaultValue(true)]
- public bool CanLostFocusOnError
- {
- get
- {
- return this._canLostFocusOnError;
- }
- set
- {
- this._canLostFocusOnError = value;
- }
- }
- /// <summary>
- /// 获取控件校验时是否有错误
- /// </summary>
- [Description("获取控件校验时是否有错误。"), Category("IDataVerifiable")]
- [DefaultValue(false)]
- public bool HasError
- {
- get
- {
- return this._hasCustomerError || this._hasError;
- }
- }
- /// <summary>
- /// 获取控件校验时的错误编码
- /// </summary>
- [Description("获取控件校验时的错误编码。"), Category("IDataVerifiable")]
- [DefaultValue(typeof(ControlErrorCode), "DKC_0000")]
- public ControlErrorCode ErrorCode
- {
- get
- {
- return this._hasCustomerError ? ControlErrorCode.DKC_C001 : this._errorCode;
- }
- }
- /// <summary>
- /// 获取控件校验时的错误消息
- /// </summary>
- [Description("获取控件校验时的错误编码。"), Category("IDataVerifiable")]
- [DefaultValue(null)]
- public string ErrorMessage
- {
- get
- {
- return this._hasCustomerError ? this._customerErrorMessage : this._errorMessage;
- }
- }
- #endregion
- #region 公有方法
- /// <summary>
- /// 设置自定义错误
- /// </summary>
- /// <param name="hasError">输入是否有错误</param>
- /// <param name="errorMessage">错误消息</param>
- public virtual void SetCustomerError(bool hasError, string errorMessage)
- {
- if (this._hasCustomerError != hasError ||
- this._customerErrorMessage != errorMessage)
- {
- this._hasCustomerError = hasError;
- this._customerErrorMessage = errorMessage;
- this.OnHasErrorChanged(EventArgs.Empty);
- this.InvalidateBorder();
- }
- }
- /// <summary>
- /// 清除自定义错误
- /// </summary>
- public virtual void ClearCustomerError()
- {
- this.SetCustomerError(false, null);
- }
- /// <summary>
- /// 验证输入内容
- /// </summary>
- /// <returns>验证结果</returns>
- public virtual bool ValidateData()
- {
- string text = base.Text;
- if (this._mustInput && text.Length == 0)
- {
- this.SetError(true, ControlErrorCode.DKC_0001, this._itemName);
- return false;
- }
- this.ClearError();
- return true;
- }
- /// <summary>
- /// 清除输入项
- /// </summary>
- public virtual void ClearValue()
- {
- this.Clear();
- }
- #endregion
- #region 保护方法
- /// <summary>
- /// 设置验证不通过错误
- /// </summary>
- /// <param name="hasError">是否有错误</param>
- /// <param name="code">错误编码</param>
- /// <param name="args">设置格式的对象</param>
- protected void SetError(bool hasError, ControlErrorCode code, params object[] args)
- {
- if (this._hasError != hasError ||
- this._errorCode != code)
- {
- this._hasError = hasError;
- this._errorCode = code;
- if (args != null && args.Length > 0)
- {
- this._errorMessage = string.Format(code.GetDescription(), args);
- }
- else
- {
- this._errorMessage = code.GetDescription();
- }
- this.OnHasErrorChanged(EventArgs.Empty);
- this.InvalidateBorder();
- }
- }
- /// <summary>
- /// 清除验证不通过错误
- /// </summary>
- protected void ClearError()
- {
- this.SetError(false, ControlErrorCode.DKC_0000);
- }
- #endregion
- #endregion
- #region IAsyncControl 成员
- #region 成员变量
- /// <summary>
- /// 异步处理开始时,控件状态
- /// </summary>
- private bool _asyncBeginStatus = false;
- private bool _asyncBeginFocused = false;
- #endregion
- #region 公有方法
- /// <summary>
- /// 开始异步处理
- /// </summary>
- /// <param name="doFocus">是否处理焦点</param>
- public virtual void BeginAsync(ref bool doFocus)
- {
- this._asyncBeginFocused = false;
- if (doFocus && this.Focused)
- {
- this._asyncBeginFocused = true;
- doFocus = false;
- }
- this._asyncBeginStatus = this.ReadOnly;
- this.ReadOnly = true;
- }
- /// <summary>
- /// 结束异步处理
- /// </summary>
- public virtual void EndAsync()
- {
- this.ReadOnly = this._asyncBeginStatus;
- if (this._asyncBeginFocused)
- {
- this.Focus();
- }
- }
- #endregion
- #endregion
- }
- }
|