namespace IStation.WinFrmUI { public class SkinStyleHelper { /// /// 初始化 /// public static void Initial() { var textSize = 10f; var font = IStation.WinFrmUI.SkinStyleHelper.GetCnDefaultFont(textSize); if (font != null) { DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font; DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font; DevExpress.Utils.AppearanceObject.DefaultFont = font; } #region 设置默认字体、日期格式 var culture_info = "zh-CN"; 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 void Initial( eLocalizationType location) { var textSize = 10f; #region 设置默认字体 //字体等环境 if (location == eLocalizationType.zhCN) { var font = IStation.WinFrmUI.SkinStyleHelper.GetCnDefaultFont(textSize); if (font != null) { DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font; DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font; //System.Windows.Forms.Form.ActiveForm.Font = font; //System.Windows.Forms.Form.ActiveForm. DevExpress.Utils.AppearanceObject.DefaultFont = font; } } else if (location == eLocalizationType.enUS) { var font = IStation.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(eLocalizationType location) { if (location == eLocalizationType.zhCN) return "zh-CN"; if (location == eLocalizationType.enUS) return "en-US"; if (location == eLocalizationType.enGB) return "en-US"; if (location == eLocalizationType.ru) return "ru-RU"; if (location == eLocalizationType.ja) return "ja-JP"; if (location == eLocalizationType.es) return "es-ES"; if (location == eLocalizationType.ko) return "ko-KR"; return location.ToString(); } */ #region 字体 public static System.Drawing.Font GetDefaultFont() { //if (IStation.WinFrmUI.Localization.IsCN) return GetCnDefaultFont(); //else // return GetEnDefaultFont(); } public static System.Drawing.Font GetDefaultFont(float size = 9) { //if (IStation.WinFrmUI.Localization.IsCN) return GetCnDefaultFont(size); //else // return GetEnDefaultFont(size); } private static System.Drawing.Font GetCnDefaultFont(float size = 9) { return new System.Drawing.Font("微软雅黑", size); //路径 //string path = System.IO.Path.Combine(IStation.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 } }