tx
2025-04-10 2538101febc78f525945da72c7cdcb2589f9e6ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
namespace TProduct.WinFrmUI
{
    public class SkinStyleHelper
    {
        /// <summary>
        /// 初始化
        /// </summary> 
        /// <param name="skinStyle">皮肤名</param>
        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
    }
}