CommonTools/Editors.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace CommonTools
{
	public abstract class BaseEditor<T> : TextBox
	{
		protected string m_filterString = string.Empty;
		protected T m_lastValue;
		protected virtual bool IsValidChar(char ch)
		{
			if (m_filterString.Length == 0 || m_filterString.IndexOf(ch) >= 0)
				return true;
			return false;
		}
		protected override void OnLeave(EventArgs e)
		{
			SetValue(GetValue());
			base.OnLeave(e);
		}
		protected override void OnKeyPress(KeyPressEventArgs e)
		{
			if (IsValidChar(e.KeyChar) == false)
			{
				e.Handled = true;
				return;
			}
			base.OnKeyPress(e);
		}
		public T Value
		{
			get { return GetValue(); }
			set { SetValue(value); }
		}

		protected virtual T GetValue()
		{
			string s = GetValidatedText();
			try
			{
				return (T)Convert.ChangeType(s, typeof(T));
			}
			catch {};
			return m_lastValue;
		}
		protected virtual void SetValue(T value)
		{
			Text = value.ToString();
			m_lastValue = value;
		}
		protected virtual string GetValidatedText()
		{
			return Text;
		}
	}

	public class IntEditor : BaseEditor<Int32>
	{
后面还有 35 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。