⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit.cs

📁 不错的人事管理系统
💻 CS
字号:
using System;
using System.Globalization;
using System.ComponentModel;

namespace System.Web.UI.WebControls
{
	/// <summary>
	/// Summary description for Unit.
	/// </summary>
	// .custom instance void [System]System.ComponentModel.TypeConverterAttribute::.ctor(class [mscorlib]System.Type)
	public struct Unit
	{
		public static System.Web.UI.WebControls.Unit Empty;
		private const int MaxValue = 32767;
		private const uint MinValue = 4294934528;
		private System.Web.UI.WebControls.UnitType type;
		private double value;

		static Unit() 
		{
			//			<{ class ILEngineer::Ops::MSIL::InitObj }>;
		}

		public Unit(string value) 
		{
			this = new System.Web.UI.WebControls.Unit(value, CultureInfo.CurrentCulture, UnitType.Pixel);
		}

		public Unit(string value, CultureInfo culture) 
		{
			this = new System.Web.UI.WebControls.Unit(value, culture, UnitType.Pixel);
		}

		public Unit(double value, UnitType type) 
		{
			if (value < -32768 || value > 32767)
				throw new ArgumentOutOfRangeException("value");
			if (type == UnitType.Pixel)
				this.value = (double) (int) value;
			else
				this.value = value;
			this.type = type;
		}

		public Unit(double value) 
		{
			if (value < -32768 || value > 32767)
				throw new ArgumentOutOfRangeException("value");
			this.value = (double) (int) value;
			this.type = UnitType.Pixel;
		}

		public Unit(int value) 
		{
			if (value < -32768 || value > 32767)
				throw new ArgumentOutOfRangeException("value");
			this.value = (double) value;
			this.type = UnitType.Pixel;
		}

		internal Unit(string value, CultureInfo culture, UnitType defaultType) 
		{
			string local0;
			int local1;
			int local2;
			int local3;
			char local4;
			string local5;
			TypeConverter local6;
			TypeConverter local7;
			object[] local8;

			if (value == null || value.Length == 0) 
			{
				this.value = 0;
				this.type = 0;
				return;
			}
			if (culture == null)
				culture = CultureInfo.CurrentCulture;
			local0 = value.Trim().ToLower();
			local1 = local0.Length;
			local2 = -1;
			local3 = 0;
			while (local3 < local1) 
			{
				local4 = local0[local3];
				if (local4 >= 48 && local4 <= 57 || local4 == 45 || local4 == 46 || local4 == 44) 
				{
					local2 = local3;
					local3++;
				}
			}
			if (local2 == -1) 
			{
				local8 = new Object[1];
				local8[0] = value;
				throw new FormatException(System.Web.SR.GetString("UnitParseNoDigits", local8));
			}
			if (local2 < local1 - 1)
				this.type = Unit.GetTypeFromString(local0.Substring(local2 + 1).Trim());
			else
				this.type = defaultType;
			local5 = local0.Substring(0, local2 + 1);
			try 
			{
				if (this.type == UnitType.Pixel) 
				{
					local6 = new Int32Converter();
					this.value = (double) (Int32) local6.ConvertFromString(null, culture, local5);
				}
				else 
				{
					local7 = new SingleConverter();
					this.value = (double) (Single) local7.ConvertFromString(null, culture, local5);
				}
			}
			catch  
			{
				local8 = new Object[3];
				local8[0] = value;
				local8[1] = local5;
				local8[2] = this.type.ToString("G");
				throw new FormatException(System.Web.SR.GetString("UnitParseNumericPart", local8));
			}
			if (this.value < -32768 || this.value > 32767)
				throw new ArgumentOutOfRangeException("value");
		}

		public override bool Equals(object obj) 
		{
			Unit local0;

//			if (obj == null || obj as Unit == null)
//				return false;
			local0 = (Unit) obj;
			if (local0.type == this.type && local0.value == this.value)
				return true;
			return false;
		}

		public override int GetHashCode() 
		{
			throw new Exception("");
			//			return <{ class ILEngineer::Ops::MSIL::XOr }>;
		}

		private static string GetStringFromType(UnitType type) 
		{
			UnitType local0;

			local0 = type;
			switch (local0 - 1) 
			{
				case 0:
					return "px";
					break;
				case (UnitType)1:
					return "pt";
					break;
				case (UnitType)2:
					return "pc";
					break;
				case (UnitType)3:
					return "in";
					break;
				case (UnitType)4:
					return "mm";
					break;
				case (UnitType)5:
					return "cm";
					break;
				case (UnitType)6:
					return "%";
					break;
				case (UnitType)7:
					return "em";
					break;
				case (UnitType)8:
					return "ex";
					break;
			}
			return System.String.Empty;
		}

		private static UnitType GetTypeFromString(string value) 
		{
			if (value != null && value.Length > 0) 
			{
				if (value == "px")
					return (UnitType)1;
				if (value == "pt")
					return (UnitType)2;
				if (value == "%")
					return (UnitType)7;
				if (value == "pc")
					return (UnitType)3;
				if (value == "in")
					return (UnitType)4;
				if (value == "mm")
					return (UnitType)5;
				if (value == "cm")
					return (UnitType)6;
				if (value == "em")
					return (UnitType)8;
				if (value == "ex")
					return (UnitType)9;
				throw new ArgumentOutOfRangeException("value");
			}
			return (UnitType)1;
		}
		public static bool op_Equality(Unit left, Unit right) 
		{
			if (left.type == right.type)
				return left.value == right.value;
			return false;
		}

		public static Unit op_Implicit(int n) 
		{
			return Unit.Pixel(n);
		}

		public static bool op_Inequality(Unit left, Unit right) 
		{
			if (left.type == right.type)
				return left.value != right.value ;
			return true;
		}
 
		public static Unit Parse(string s) 
		{
			return new Unit(s);
		}

		public static Unit Parse(string s, CultureInfo culture) 
		{
			return new Unit(s, culture);
		}
	
		public static Unit Percentage(double n) 
		{
			return new Unit(n, (UnitType)7);
		}

		public static Unit Pixel(int n) 
		{
			return new Unit(n);
		}

		public static Unit Point(int n) 
		{
			return new Unit((double) n, (UnitType)2);
		}

		public override string ToString() 
		{
			string local0;
			int local1;
			float local2;

			if (this.IsEmpty)
				return System.String.Empty;
			if (this.type == UnitType.Pixel) 
			{
				local1 = (int) this.value;
				local0 = local1.ToString();
			}
			else 
			{
				local2 = (float) this.value;
				local0 = local2.ToString();
			}
			return local0 + Unit.GetStringFromType(this.type);
		}
 
		public string ToString(CultureInfo culture) 
		{
			string local0;
			int local1;
			float local2;

			if (this.IsEmpty)
				return System.String.Empty;
			if (this.type == UnitType.Pixel) 
			{
				local1 = (int) this.value;
				local0 = local1.ToString(culture);
			}
			else 
			{
				local2 = (float) this.value;
				local0 = local2.ToString(culture);
			}
			return local0 + Unit.GetStringFromType(this.type);
		}

		public bool IsEmpty 
		{
			get
			{
				return this.type == 0;
			}
		}
 
		public UnitType Type 
		{
			get
			{
				if (!(this.IsEmpty))
					return this.type;
				return UnitType.Pixel;
			}
		}

		public double Value
		{
			get
			{
				return this.value;
			}
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -