/// <summary> /// 保存参数设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_OK_Click(object sender, EventArgs e) { if (this.cb_Index.Text == String.Empty) { this.DialogResult = DialogResult.Cancel; } else { int index = -1; Int32.TryParse(this.cb_Index.Text, out index); PortToIndexFactory.ArrangePortNoToIndex(this.tb_PortNo.Text, index); this.DialogResult = DialogResult.OK; } this.Close(); }
void InitializeData() { this.tb_PortNo.Text = this.ImportPortNumber; int index = PortToIndexFactory.GetIndex(this.tb_PortNo.Text); if (index <= -1) {// 新的端口 var index_list = PortToIndexFactory.GetIdleIndexStringList(); this.cb_Index.Items.Clear(); this.cb_Index.Items.Add(String.Empty); this.cb_Index.Items.AddRange(index_list.ToArray()); this.cb_Index.SelectedIndex = 0; } else {// 如果端口已经被注册, 则关闭页面 this.Close(); } this.chb_isEnabled.Checked = PortToIndexFactory.IsEnabled; }