alielie
2026-04-16 1afe548ac40cc7f975917ef9bf2e156595cf81f3
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
using System;
using System.IO;
using HMI.Core.Entity;
using HMI.Core.Util;
 
namespace HMI.Core.Setting
{
    public class SystemSetting
    {
        public static SystemSetting Instance { get; private set; }
        /// <summary>
        /// 系统设置改变事件
        /// </summary>
        public static event EventHandler<SystemSetting> SystemSettingChanged;
 
        private static string FilePath = Path.Combine(PathHelper.SettingFolder, "SystemConfig.xml");
 
        static SystemSetting()
        {
            LoadFromXml();
        }
 
        private SystemSetting()
        {
 
        }
 
        public string LogoPath { get; private set; } = ".\\Logo.png";
        public string LoginLogoPath { get; private set; } = ".\\LoginLogo.png";
        public string WindowTitle { get; private set; } = "产品测试平台";
        public string PlcIp { get; private set; } = "127.0.0.1";
        public int PlcPort { get; private set; } = 102;
        public bool PlcEnabled { get; private set; }
        public string CurrentLanguage { get; private set; } = "zh-CN";
        public int LogExpiredDays { get; private set; } = 7;
 
        private static void LoadFromXml()
        {
            if (Instance != null) return;
            if (!File.Exists(FilePath))
            {
                Instance = new SystemSetting();
            }
            else
            {
                SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath);
                SystemSetting setting = new SystemSetting();
                BeanUtil.Copy(model, setting);
                Instance = setting;
            }
        }
 
        public static SystemSettingModel GetModel()
        {
            return XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath);
        }
 
        public static void ReLoad()
        {
            if (!File.Exists(FilePath))
            {
                return;
            }
            else
            {
                SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath);
                SystemSetting setting = new SystemSetting();
                BeanUtil.Copy(model, setting);
                Instance = setting;
            }
            SystemSettingChanged?.Invoke(null, Instance);
        }
    }
 
 
    public class SystemSettingModel : NotifyBase
    {
        private string logoPath;
        public string LogoPath
        {
            get => logoPath;
            set { Set(ref logoPath, value); }
        }
 
        private string loginLogoPath;
        public string LoginLogoPath
        {
            get => loginLogoPath;
            set { Set(ref loginLogoPath, value); }
        }
 
        private string windowTitle;
        public string WindowTitle
        {
            get => windowTitle;
            set { Set(ref windowTitle, value); }
        }
 
        private string plcIp;
        public string PlcIp
        {
            get => plcIp;
            set { Set(ref plcIp, value); }
        }
 
        private int plcPort;
        public int PlcPort
        {
            get => plcPort;
            set { Set(ref plcPort, value); }
        }
 
        private bool plcEnabled;
        public bool PlcEnabled
        {
            get => plcEnabled;
            set { Set(ref plcEnabled, value); }
        }
 
        private string currentLanguage;
        public string CurrentLanguage
        {
            get => currentLanguage;
            set { Set(ref currentLanguage, value); }
        }
 
        private int logExpiredDays;
        public int LogExpiredDays
        {
            get => logExpiredDays;
            set { Set(ref logExpiredDays, value); }
        }
    }
}