using System; using System.ComponentModel; using System.Drawing; using System.Threading; using System.Windows.Forms; namespace LP; public class FormCreateXianLu : Form { private delegate void delegateFormHide(Form form); public FormDesktop desktop = null; private XianLuData mXianLuData = null; private string mTitle = ""; public bool mFirst_Enter = true; private int mIndex_List_DYDJ = -1; private IContainer components = null; private TextBox textBox_Name_XianLu; private Label label1; private Label label2; private Button button_GanTa_LieBiao; private Button buttonCancel; private ComboBox comboBox_DYDJ; public FormCreateXianLu() { InitializeComponent(); if (string.IsNullOrEmpty(mTitle)) { mTitle = "创建线路"; } if (mXianLuData == null) { mXianLuData = new XianLuData(); } if (mIndex_List_DYDJ < 0) { mIndex_List_DYDJ = 0; } } private void FormCreateXianLu_Load(object sender, EventArgs e) { Text = mTitle; string[] array = new string[14] { "直流500kV", "直流800kV", "直流1000kV", "交流35kV", "交流66kV", "交流110kV", "交流220kV", "交流330kV", "交流500kV", "交流750kV", "交流800kV", "交流1000kV", "交流110kV|交流110kV|交流110kV|交流110kV", "交流220kV|交流220kV|交流220kV|交流220kV" }; comboBox_DYDJ.Items.Clear(); ComboBox.ObjectCollection items = comboBox_DYDJ.Items; object[] items2 = array; items.AddRange(items2); comboBox_DYDJ.SelectedIndex = mIndex_List_DYDJ; mFirst_Enter = true; } public void MyInput_XianLuData() { mXianLuData.CopyPrimaryFrom_XianLuData(desktop.mTheXianLuData); } public void MyOutput_XianLuData() { desktop.mTheXianLuData.CopyPrimaryFrom_XianLuData(mXianLuData); } public void Destroy() { comboBox_DYDJ.Items.Clear(); mXianLuData = null; desktop = null; } private void button_GanTa_LieBiao_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(textBox_Name_XianLu.Text)) { MessageBox.Show("“线路名称”为空!", "提示信息:发现输入错误"); textBox_Name_XianLu.Focus(); return; } int num = -1; num = comboBox_DYDJ.SelectedIndex; if (num < 0 || num >= comboBox_DYDJ.Items.Count) { MyLog.AddLog($"FormCreateXianLu.cs button_GanTa_LieBiao_Click() comboBox_DYDJ.SelectedIndex={num}"); return; } mIndex_List_DYDJ = num; string[] separator = new string[3] { "|", "\r", "\n" }; string[] array = null; string text = comboBox_DYDJ.Items[num].ToString(); array = text.Split(separator, StringSplitOptions.RemoveEmptyEntries); text = array[0]; string text2 = ""; text2 = text.Substring(0, 2); text = text.Replace("交流", ""); text = text.Replace("直流", ""); text = text.Replace("kV", ""); int num2 = -1; try { num2 = Convert.ToInt32(text); } catch (Exception) { num2 = -2; } if (mXianLuData == null) { mXianLuData = new XianLuData(); } mXianLuData.mHuiLuNo_XianLu = ((array.Length == 0) ? 1 : array.Length); mXianLuData.mName_XianLu = textBox_Name_XianLu.Text.Trim(); mXianLuData.mJLZL_XianLu = text2; mXianLuData.mDYDJ_XianLu = num2; mXianLuData.mGanTaNumber_XianLu = 0; Thread thread = new Thread(MyThreadOK); thread.Start(); } catch (Exception ex2) { MyLog.AddLog("FormCreateXianLu.cs button_GanTa_LieBiao_Click() Exception=" + ex2.Message); } } private void MyThreadOK() { try { mFirst_Enter = false; base.DialogResult = DialogResult.OK; MyFormHide(this); } catch (Exception ex) { MyLog.AddLog("FormCreateXianLu.cs MyThreadOK() Exception=" + ex.Message); } } private void buttonCancel_Click(object sender, EventArgs e) { try { MyFormHide(this); } catch (Exception ex) { MyLog.AddLog("FormCreateXianLu.cs buttonCancel_Click() Exception=" + ex.Message); } } public void MyFormHide(Form form) { try { if (form.InvokeRequired) { delegateFormHide method = MyFormHide; form.Invoke(method, form); } else { form.Hide(); } } catch (Exception) { } } protected override void Dispose(bool disposing) { if (disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.textBox_Name_XianLu = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.button_GanTa_LieBiao = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.comboBox_DYDJ = new System.Windows.Forms.ComboBox(); base.SuspendLayout(); this.textBox_Name_XianLu.Location = new System.Drawing.Point(39, 31); this.textBox_Name_XianLu.Name = "textBox_Name_XianLu"; this.textBox_Name_XianLu.Size = new System.Drawing.Size(196, 29); this.textBox_Name_XianLu.TabIndex = 0; this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(35, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(104, 19); this.label1.TabIndex = 1; this.label1.Text = "线路名称:"; this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(35, 71); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(104, 19); this.label2.TabIndex = 1; this.label2.Text = "电压等级:"; this.button_GanTa_LieBiao.AutoSize = true; this.button_GanTa_LieBiao.Location = new System.Drawing.Point(39, 136); this.button_GanTa_LieBiao.Name = "button_GanTa_LieBiao"; this.button_GanTa_LieBiao.Size = new System.Drawing.Size(133, 33); this.button_GanTa_LieBiao.TabIndex = 3; this.button_GanTa_LieBiao.Text = "跳转杆塔列表"; this.button_GanTa_LieBiao.UseVisualStyleBackColor = true; this.button_GanTa_LieBiao.Click += new System.EventHandler(button_GanTa_LieBiao_Click); this.buttonCancel.AutoSize = true; this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttonCancel.Location = new System.Drawing.Point(178, 136); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(133, 33); this.buttonCancel.TabIndex = 3; this.buttonCancel.Text = "取消"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(buttonCancel_Click); this.comboBox_DYDJ.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox_DYDJ.FormattingEnabled = true; this.comboBox_DYDJ.Location = new System.Drawing.Point(12, 93); this.comboBox_DYDJ.Name = "comboBox_DYDJ"; this.comboBox_DYDJ.Size = new System.Drawing.Size(327, 27); this.comboBox_DYDJ.TabIndex = 4; base.AutoScaleDimensions = new System.Drawing.SizeF(10f, 19f); base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; base.CancelButton = this.buttonCancel; base.ClientSize = new System.Drawing.Size(351, 181); base.Controls.Add(this.comboBox_DYDJ); base.Controls.Add(this.buttonCancel); base.Controls.Add(this.button_GanTa_LieBiao); base.Controls.Add(this.label2); base.Controls.Add(this.label1); base.Controls.Add(this.textBox_Name_XianLu); this.Font = new System.Drawing.Font("宋体", 14.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134); base.Margin = new System.Windows.Forms.Padding(5); base.Name = "FormCreateXianLu"; base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "CreateXianLu"; base.Load += new System.EventHandler(FormCreateXianLu_Load); base.ResumeLayout(false); base.PerformLayout(); } }