📄 fontunitconverter.cs
字号:
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for FontUnitConverter.
/// </summary>
public class FontUnitConverter : TypeConverter
{
private System.ComponentModel.TypeConverter.StandardValuesCollection values;
public FontUnitConverter() : base()
{
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(String))
return true;
return this.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string local0;
if (value == null)
return null;
if (value as String != null)
{
local0 = ((String) value).Trim();
if (local0.Length == 0)
return System.Web.UI.WebControls.FontUnit.Empty;
return System.Web.UI.WebControls.FontUnit.Parse(local0, culture);
}
return this.ConvertFrom(context, culture, value);
}
public virtual object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
FontUnit local0;
if (destinationType == typeof(String))
{
if (value != null)
{
local0 = (FontUnit) value;
if (local0.Type != 0)
goto i0;
}
return System.String.Empty;
i0: local0 = (FontUnit) value;
return local0.ToString(culture);
}
return this.ConvertTo(context, culture, value, destinationType);
}
public virtual StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
object[] local0;
object[] local1;
if (this.values == null)
{
local1 = new Object[9];
local1[0] = System.Web.UI.WebControls.FontUnit.Smaller;
local1[1] = System.Web.UI.WebControls.FontUnit.Larger;
local1[2] = System.Web.UI.WebControls.FontUnit.XXSmall;
local1[3] = System.Web.UI.WebControls.FontUnit.XSmall;
local1[4] = System.Web.UI.WebControls.FontUnit.Small;
local1[5] = System.Web.UI.WebControls.FontUnit.Medium;
local1[6] = System.Web.UI.WebControls.FontUnit.Large;
local1[7] = System.Web.UI.WebControls.FontUnit.XLarge;
local1[8] = System.Web.UI.WebControls.FontUnit.XXLarge;
local0 = local1;
this.values = new StandardValuesCollection(local0);
}
return this.values;
}
public virtual bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return false;
}
public virtual bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -