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; } } }