public Form3(bool writeorread) { InitializeComponent(); this.FormClosed += Form3_FormClosed; XMLUnit xmlUnit = new XMLUnit(); _moduleList = xmlUnit.QueryModuleList(); if (writeorread) { button1.Text = "保存"; button1.Click += ButtonWrite_Click; button3.Click += btnAddMoudle; //读取列表 } else { this.Text = "读取"; button1.Text = "读取"; button1.Click += ButtonRead_Click; button3.Visible = false; button4.Visible = false; panel1.Size = new Size(panel1.Size.Width, 260); panel2.Size = new Size(panel2.Size.Width, 260); //读取列表 } AddModuleRB(_moduleList, 0); }
private void Rb_MouseClick(object sender, MouseEventArgs e) { if (startTime == 0) { startTime = (long)DateTime.UtcNow.Ticks / 10000; } else { long endTime = (long)DateTime.UtcNow.Ticks / 10000; if (endTime - startTime < 500) { RadioButton rb = sender as RadioButton; //处理双击事件 Form2 form = new Form2((sender as RadioButton).Text); Label label = form.Controls.Find("label1", true)[0] as Label; //label.Text = _moduleList[checkedNum].Module; ModuleCommand oldM = _moduleList[checkedNum]; ModuleCommand newM = new ModuleCommand(); form.StartPosition = FormStartPosition.CenterParent; TextBox tBoxNote = form.Controls.Find("textBox1", true)[0] as TextBox; Button btnSave = form.Controls.Find("button1", true)[0] as Button; Button btnCancel = form.Controls.Find("button2", true)[0] as Button; tBoxNote.TextChanged += TBoxNote_TextChanged; btnSave.DialogResult = DialogResult.Yes; btnCancel.DialogResult = DialogResult.No; DialogResult result = form.ShowDialog(); if (result == DialogResult.Yes) { if (rb.Name.StartsWith("rbf")) { newM = new ModuleCommand(oldM.Module, newFunction == null?oldM.Function:newFunction); foreach (ModuleCommand mb in _moduleList) { if (mb.Function.ToUpper() == newM.Function.ToUpper() && mb.Module.ToUpper() == newM.Module.ToUpper()) { DialogResult RESULT = MessageBox.Show("模块" + mb.Module + "下的功能" + mb.Function + "已存在.", "警告!!!", MessageBoxButtons.OK); return; } } XMLUnit xml = new XMLUnit(); xml.ChangeModultList(oldM, newM); _moduleList = xml.QueryModuleList(); AddModuleRB(_moduleList, checkedNum); } } else { Console.WriteLine("不保存列表"); } } startTime = 0; } }
public Form3(List <ATCommand> CommandList) { atCommands = CommandList; XMLUnit xmlUnit = new XMLUnit(); _moduleList = xmlUnit.QueryModuleList(); for (int i = 0; i < _moduleList.Count; i++) { if (_moduleList[i].Function == atCommands[0].Function && _moduleList[i].Module == atCommands[0].Module) { checkedNum = i; break; } } InitializeComponent(); this.FormClosed += Form3_FormClosed; button1.Text = "保存"; button1.Click += ButtonWrite_Click; button3.Click += btnAddMoudle; button4.Click += btnAddMoudle; AddModuleRB(_moduleList, checkedNum); this.Text = "保存"; }