//System.Math.Cos(33);
//Type theMathType = Type.GetType("System.Math");
//Type[] parameterTypes = new Type[1];
//parameterTypes[0] = Type.GetType("System.Double");
//MethodInfo CosinInfo = theMathType.GetMethod("Cos", parameterTypes);
//Object[] parameters = new Object[1];
//parameters[0] = 45;
//Object result = CosinInfo.Invoke(null, parameters);
//Console.WriteLine(result.ToString());
/*
Type BstrType = typeof(ButtonImages);
FieldInfo finfo = BstrType.GetField("Btn_" + text);
string img = finfo.GetValue(null) as string;
*/
{
public static string ImgBasePath = " ~/Images/site/Buttons/ " ;
private const string Pattern = " <img src='/Images/site/Buttons/{0}' border='0' οnerrοr='setButtonImg(this)' /> " ;
private const string PatternMethod = " <img src='/Images/site/Buttons/{0}' alt='{1}' title='{1}' border='0' οnerrοr='setButtonImg(this)' /> " ;
#region
/// <summary>
/// Btn-bc.gif
/// </summary>
public static string Btn_bc = string .Format(Pattern, " Btn-bc.gif " );
/// <summary>
/// Btn-bcdd.gif
/// </summary>
public static string Btn_bcdd = string .Format(Pattern, " Btn-bcdd.gif " );
/// <summary>
/// Btn-bj.gif
/// </summary>
public static string Btn_bj = string .Format(Pattern, " Btn-bj.gif " );
/// <summary>
/// Btn-cfdd.gif
/// </summary>
public static string Btn_cfdd = string .Format(Pattern, " Btn-cfdd.gif " );
/// <summary>
/// Btn-cjcgry.gif
/// </summary>
public static string Btn_cjcgry = string .Format(Pattern, " Btn-cjcgry.gif " );
/// <summary>
/// Btn-cjjtgly.gif
/// </summary>
public static string Btn_cjjtgly = string .Format(Pattern, " Btn-cjjtgly.gif " );
/// <summary>
/// Btn-cjxsry.gif
/// </summary>
public static string Btn_cjxsry = string .Format(Pattern, " Btn-cjxsry.gif " );
/// <summary>
/// Btn-ck.gif
/// </summary>
public static string Btn_ck = string .Format(Pattern, " Btn-ck.gif " );
/// <summary>
/// Btn-DownArrow.gif
/// </summary>
public static string Btn_DownArrow = string .Format(Pattern, " Btn-DownArrow.gif " );
/// <summary>
/// Btn-drdd.gif
/// </summary>
public static string Btn_drdd = string .Format(Pattern, " Btn-drdd.gif " );
/// <summary>
/// Btn-fb.gif
/// </summary>
public static string Btn_fb = string .Format(Pattern, " Btn-fb.gif " );
/// <summary>
/// Btn-fbgszx.gif
/// </summary>
public static string Btn_fbgszx = string .Format(Pattern, " Btn-fbgszx.gif " );
/// <summary>
/// Btn-fbxcpxx.gif
/// </summary>
public static string Btn_fbxcpxx = string .Format(Pattern, " Btn-fbxcpxx.gif " );
/// <summary>
/// Btn-fh.gif
/// </summary>
public static string Btn_fh = string .Format(Pattern, " Btn-fh.gif " );
/// <summary>
/// Btn-fk.gif
/// </summary>
public static string Btn_fk = string .Format(Pattern, " Btn-fk.gif " );
/// <summary>
/// Btn-fsly.gif
/// </summary>
public static string Btn_fsly = string .Format(Pattern, " Btn-fsly.gif " );
/// <summary>
/// Btn-fszgys.gif
/// </summary>
public static string Btn_fszgys = string .Format(Pattern, " Btn-fszgys.gif " );
/// <summary>
/// Btn-gl.gif
/// </summary>
public static string Btn_gl = string .Format(Pattern, " Btn-gl.gif " );
/// <summary>
/// Btn-gx.gif
/// </summary>
public static string Btn_gx = string .Format(Pattern, " Btn-gx.gif " );
/// <summary>
/// Btn-gxsl.gif
/// </summary>
public static string Btn_gxsl = string .Format(Pattern, " Btn-gxsl.gif " );
/// <summary>
/// Btn-hbsxdd.gif
/// </summary>
public static string Btn_hbsxdd = string .Format(Pattern, " Btn-hbsxdd.gif " );
/// <summary>
/// Btn-hf.gif
/// </summary>
public static string Btn_hf = string .Format(Pattern, " Btn-hf.gif " );
/// <summary>
/// Btn-jj.gif
/// </summary>
public static string Btn_jj = string .Format(Pattern, " Btn-jj.gif " );
/// <summary>
/// Btn-jy.gif
/// </summary>
public static string Btn_jy = string .Format(Pattern, " Btn-jy.gif " );
/// <summary>
/// Btn-ll.gif
/// </summary>
public static string Btn_ll = string .Format(Pattern, " Btn-ll.gif " );
/// <summary>
/// Btn-psfs.gif
/// </summary>
public static string Btn_psfs = string .Format(Pattern, " Btn-psfs.gif " );
/// <summary>
/// Btn-qd.gif
/// </summary>
public static string Btn_qd = string .Format(Pattern, " Btn-qd.gif " );
/// <summary>
/// Btn-qr.gif
/// </summary>
public static string Btn_qr = string .Format(Pattern, " Btn-qr.gif " );
/// <summary>
/// Btn-qrdd.gif
/// </summary>
public static string Btn_qrdd = string .Format(Pattern, " Btn-qrdd.gif " );
/// <summary>
/// Btn-qrwwtj.gif
/// </summary>
public static string Btn_qrwwtj = string .Format(Pattern, " Btn-qrwwtj.gif " );
/// <summary>
/// Btn-qx.gif
/// </summary>
public static string Btn_qx = string .Format(Pattern, " Btn-qx.gif " );
/// <summary>
/// Btn-qy.gif
/// </summary>
public static string Btn_qy = string .Format(Pattern, " Btn-qy.gif " );
/// <summary>
/// Btn-sc.gif
/// </summary>
public static string Btn_sc = string .Format(Pattern, " Btn-sc.gif " );
/// <summary>
/// Btn-scsxdd.gif
/// </summary>
public static string Btn_scsxdd = string .Format(Pattern, " Btn-scsxdd.gif " );
/// <summary>
/// Btn-scxz.gif
/// </summary>
public static string Btn_scxz = string .Format(Pattern, " Btn-scxz.gif " );
/// <summary>
/// Btn-sqrz.gif
/// </summary>
public static string Btn_sqrz = string .Format(Pattern, " Btn-sqrz.gif " );
/// <summary>
/// Btn-syb.gif
/// </summary>
public static string Btn_syb = string .Format(Pattern, " Btn-syb.gif " );
/// <summary>
/// Btn-syy.gif
/// </summary>
public static string Btn_syy = string .Format(Pattern, " Btn-syy.gif " );
/// <summary>
/// Btn-tg.gif
/// </summary>
public static string Btn_tg = string .Format(Pattern, " Btn-tg.gif " );
/// <summary>
/// Btn-tijiao.gif
/// </summary>
public static string Btn_tijiao = string .Format(Pattern, " Btn-tijiao.gif " );
/// <summary>
/// Btn-tj.gif
/// </summary>
public static string Btn_tj = string .Format(Pattern, " Btn-tj.gif " );
/// <summary>
/// Btn-tjbbc.gif
/// </summary>
public static string Btn_tjbbc = string .Format(Pattern, " Btn-tjbbc.gif " );
/// <summary>
/// Btn-tjdd.gif
/// </summary>
public static string Btn_tjdd = string .Format(Pattern, " Btn-tjdd.gif " );
/// <summary>
/// Btn-wfk.gif
/// </summary>
public static string Btn_wfk = string .Format(Pattern, " Btn-wfk.gif " );
/// <summary>
/// Btn-wqr.gif
/// </summary>
public static string Btn_wqr = string .Format(Pattern, " Btn-wqr.gif " );
/// <summary>
/// Btn-xg.gif
/// </summary>
public static string Btn_xg = string .Format(Pattern, " Btn-xg.gif " );
/// <summary>
/// Btn-xyb.gif
/// </summary>
public static string Btn_xyb = string .Format(Pattern, " Btn-xyb.gif " );
/// <summary>
/// Btn-xyy.gif
/// </summary>
public static string Btn_xyy = string .Format(Pattern, " Btn-xyy.gif " );
/// <summary>
/// Btn-yc.gif
/// </summary>
public static string Btn_yc = string .Format(Pattern, " Btn-yc.gif " );
/// <summary>
/// Btn-yfk.gif
/// </summary>
public static string Btn_yfk = string .Format(Pattern, " Btn-yfk.gif " );
/// <summary>
/// Btn-zffs.gif
/// </summary>
public static string Btn_zffs = string .Format(Pattern, " Btn-zffs.gif " );
#endregion
public static string ResolveBtnImg( string text)
{
// text = GetPYString(text);
// System.Math.Cos(33);
// Type theMathType = Type.GetType("System.Math");
// Type[] parameterTypes = new Type[1];
// parameterTypes[0] = Type.GetType("System.Double");
// MethodInfo CosinInfo = theMathType.GetMethod("Cos", parameterTypes);
// Object[] parameters = new Object[1];
// parameters[0] = 45;
// Object result = CosinInfo.Invoke(null, parameters);
// Console.WriteLine(result.ToString());
/*
Type BstrType = typeof(ButtonImages);
FieldInfo finfo = BstrType.GetField("Btn_" + text);
string img = finfo.GetValue(null) as string;
*/
string py = GetPYString(text);
return string .Format(PatternMethod, " Btn- " + py + " .gif " ,text);
}
/// <summary>
/// 汉字转拼音缩写
/// </summary>
/// <param name="str"> 要转换的汉字字符串 </param>
/// <returns> 拼音缩写 </returns>
private static string GetPYString( string str)
{
string tempStr = "" ;
foreach ( char c in str)
{
if (( int )c >= 33 && ( int )c <= 126 )
{ // 字母和符号原样保留
tempStr += c.ToString();
}
else
{ // 累加拼音声母
tempStr += GetPYChar(c.ToString());
}
}
return tempStr;
}
/// <summary>
/// 取单个字符的拼音声母
/// </summary>
/// <param name="c"> 要转换的单个汉字 </param>
/// <returns> 拼音声母 </returns>
private static string GetPYChar( string c)
{
byte [] array = new byte [ 2 ];
array = System.Text.Encoding.Default.GetBytes(c);
int i = ( short )(array[ 0 ] - ' \0 ' ) * 256 + (( short )(array[ 1 ] - ' \0 ' ));
if (i < 0xB0A1 ) return " * " ;
if (i < 0xB0C5 ) return " a " ;
if (i < 0xB2C1 ) return " b " ;
if (i < 0xB4EE ) return " c " ;
if (i < 0xB6EA ) return " d " ;
if (i < 0xB7A2 ) return " e " ;
if (i < 0xB8C1 ) return " f " ;
if (i < 0xB9FE ) return " g " ;
if (i < 0xBBF7 ) return " h " ;
if (i < 0xBFA6 ) return " g " ;
if (i < 0xC0AC ) return " k " ;
if (i < 0xC2E8 ) return " l " ;
if (i < 0xC4C3 ) return " m " ;
if (i < 0xC5B6 ) return " n " ;
if (i < 0xC5BE ) return " o " ;
if (i < 0xC6DA ) return " p " ;
if (i < 0xC8BB ) return " q " ;
if (i < 0xC8F6 ) return " r " ;
if (i < 0xCBFA ) return " s " ;
if (i < 0xCDDA ) return " t " ;
if (i < 0xCEF4 ) return " w " ;
if (i < 0xD1B9 ) return " x " ;
if (i < 0xD4D1 ) return " y " ;
if (i < 0xD7FA ) return " z " ;
return " * " ;
}
}