孙世强
2025-11-14 a0597a2720e9d5061d5de16bf683183618ad5356
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
using directPacking;
using ng.optima.config;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Threading;
using System.Windows.Forms;
using Utility;
 
namespace MyGlassEdit
{
    public partial class 初始配置 : Form
    {
 
 
        string serverIpCheck = "IP不可为空";//
        string strIPCheck = "IP无法访问";
        public 初始配置()
        {
            switch (Setting.language)
            {
                case 1:
                    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
                    serverIpCheck = "The server address cannot be empty";
                    break;
                case 2:
                    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ru");
 
                    break;
                default:
                    break;
            }
            InitializeComponent();
            lblBtnPaint();
        }
 
 
        public bool initSet = true;
       
        //The server address cannot be empty
        private void lblCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void lblSure_Click(object sender, EventArgs e)
        {
            string erpIp = txtServerIP.Text.Trim();
            string mesIp = txtMESIP.Text.Trim();
 
            if (string.IsNullOrEmpty(erpIp)|| string.IsNullOrEmpty(mesIp))
            {
                globel.ShowFromWarningMessage(serverIpCheck);
                return;
            }
 
            if (!Service.checkIPPing(erpIp))
            {
 
                txtServerIP.Focus();
                globel.ShowFromWarningMessage(strIPCheck);
                return;
            }
 
            if (!int.TryParse(txtServerPort.Text, out int port) || port < 1 || port > 65535)
            {
                MessageBox.Show("请输入有效的端口号 (1-65535)", "无效端口", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtServerPort.Focus();
                return;
            }
            if (!Service.checkIPPing(mesIp))
            {
 
                txtMESIP.Focus();
                globel.ShowFromWarningMessage(strIPCheck);
                return;
            }
 
            if (!int.TryParse(txtMesPort.Text, out int mesPort) || port < 1 || port > 65535)
            {
                MessageBox.Show("请输入有效的端口号 (1-65535)", "无效端口", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMesPort.Focus();
                return;
            }
 
 
            Service.ERPService = erpIp;
            Service.MESService = mesIp;
            Service.ERPServicePort = port;
            Service.MESServicePort = mesPort;
            if (Service.SaveServiceConfig())
            {
                this.Hide();
            }
        }
 
        private void 初始配置_Load(object sender, EventArgs e)
        {
            txtServerIP.Text = Service.ERPService;
            txtMESIP.Text = Service.MESService;
            txtServerPort.Text = Service.ERPServicePort.ToString();
            txtMesPort.Text = Service.MESServicePort.ToString();
        }
 
 
        private void lblBtn_MouseEnter(object sender, EventArgs e)
        {
            Label label = (Label)sender;
            ColorUtil.EnterColor(sender);
            labelUtil.setLabelName(ref label);
        }
        private void lblBtn_MouseLeave(object sender, EventArgs e)
        {
            Label label = (Label)sender;
            ColorUtil.LeaveColor(sender);
            labelUtil.setLabelName(ref label);
        }
 
 
        private void lblBtnPaint()
        {
            labelUtil.setLabelName(ref lblCancel);
            labelUtil.setLabelName(ref lblSure);
 
            lblCancel.Paint += new PaintEventHandler(labelUtil.label_Paint);
            lblSure.Paint += new PaintEventHandler(labelUtil.label_Paint);
        }
 
        private void lblFWQIP_DoubleClick(object sender, EventArgs e)
        {
            //txtServerPort.Visible = !txtServerPort.Visible;
            //label1.Visible = !label1.Visible;
        }
    }
}