namespace TProduct.WinFrmUI { public class SkinStyleHelper { /// /// 初始化 /// /// 皮肤名 public static void Initial( Eventech.Model.eLocalizationType location) { var textSize = 9f; //if (TProduct.WinFrmUI.GlobeParas.ScreenScale > 1.0) // textSize = textSize / TProduct.WinFrmUI.GlobeParas.ScreenScale; #region 设置默认字体 //字体等环境 //if (location == Eventech.Model.eLocalizationType.zhCN) //{ // var font = TProduct.WinFrmUI.SkinStyleHelper.GetCnDefaultFont(textSize); // if (font != null) // { // DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font; // DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font; // DevExpress.Utils.AppearanceObject.DefaultFont = font; // } //} //else if (location == Eventech.Model.eLocalizationType.enUS) //{ // var font = TProduct.WinFrmUI.SkinStyleHelper.GetDefaultFont(textSize); // if (font != null) // { // DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font; // DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font; // DevExpress.Utils.AppearanceObject.DefaultFont = font; // } //} #endregion #region 设置默认字体、日期格式 var culture_info = GetCultureInfo(location); var uiCulture = new System.Globalization.CultureInfo(culture_info); uiCulture.NumberFormat.CurrencyDecimalSeparator = ".";//俄文用逗号,表示小数点 uiCulture.NumberFormat.NumberDecimalSeparator = ".";//俄文用逗号,表示小数点 System.Threading.Thread.CurrentThread.CurrentUICulture = uiCulture; var cuurentCulture = new System.Globalization.CultureInfo(culture_info); cuurentCulture.NumberFormat.CurrencyDecimalSeparator = ".";//俄文用逗号,表示小数点 cuurentCulture.NumberFormat.NumberDecimalSeparator = ".";//俄文用逗号,表示小数点 System.Threading.Thread.CurrentThread.CurrentCulture = cuurentCulture; ////使用DEV汉化资源文件 ////设置程序区域语言设置中日期格式 //System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-CHS"); //System.Globalization.DateTimeFormatInfo di = (System.Globalization.DateTimeFormatInfo)System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.Clone(); //di.DateSeparator = "-"; //di.ShortDatePattern = "yyyy-MM-dd"; //di.LongDatePattern = "yyyy'年'M'月'd'日'"; //di.ShortTimePattern = "H:mm:ss"; //di.LongTimePattern = "H'时'mm'分'ss'秒'"; //ci.DateTimeFormat = di; //System.Threading.Thread.CurrentThread.CurrentCulture = ci; //CultureInfo current = CultureInfo.CurrentUICulture; //current.NumberFormat.NumberDecimalSeparator // CultureInfo.InvariantCulture #endregion } public static string GetCultureInfo(Eventech.Model.eLocalizationType location) { if (location == Eventech.Model.eLocalizationType.zhCN) return "zh-CN"; if (location == Eventech.Model.eLocalizationType.enUS) return "en-US"; if (location == Eventech.Model.eLocalizationType.enGB) return "en-US"; if (location == Eventech.Model.eLocalizationType.ru) return "ru-RU"; if (location == Eventech.Model.eLocalizationType.ja) return "ja-JP"; if (location == Eventech.Model.eLocalizationType.es) return "es-ES"; if (location == Eventech.Model.eLocalizationType.ko) return "ko-KR"; return location.ToString(); } #region 字体 public static System.Drawing.Font GetDefaultFont() { //if (TProduct.WinFrmUI.Localization.IsCN) return GetCnDefaultFont(); //else // return GetEnDefaultFont(); } public static System.Drawing.Font GetDefaultFont(float size = 9) { //if (TProduct.WinFrmUI.Localization.IsCN) return GetCnDefaultFont(size); //else // return GetEnDefaultFont(size); } private static System.Drawing.Font GetCnDefaultFont(float size = 9) { //CourierNew / calibri //if (TProduct.GlobeParas.CorpName == Model.eCorpName.南方安美) // return new System.Drawing.Font("等线", size); //if (TProduct.GlobeParas.CorpName == Model.eCorpName.南元泵业) return new System.Drawing.Font("微软雅黑", size); //路径 //string path = System.IO.Path.Combine(TProduct.GlobeParas.DataFolder, "fonts", "刘欢卡通手书1.07.ttf"); //if (System.IO.File.Exists(path)) //{ // //读取字体文件 // System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); // pfc.AddFontFile(path); // //实例化字体 // return new Font(pfc.Families[0], size); //} } private static System.Drawing.Font GetEnDefaultFont(float size = 9) { return new System.Drawing.Font("Calibri", size); } #endregion } }