private void GetStepDevice(Control control) { if (control is UCRowComboBox) { UCRowComboBox row = control as UCRowComboBox; RowEntity entity = row.GetRow(); if (entity.Value != null) { Step step = this.testCase.StepList.Where(s => s.Name == entity.Name).FirstOrDefault(); if (step != null) { TestDevice testDevice = (TestDevice)entity.Value; step.TestDeviceId = testDevice.Id; step.TestDeviceModel = testDevice.Model; } } } else if (control.HasChildren) { foreach (Control item in control.Controls) { GetStepDevice(item); } } }
public void Form_Load(object sender, EventArgs e) { List <RowEntity> rowList = new List <RowEntity>(); int j = 0; float f = 100F / this.testCase.StepList.Count; this.tableLayoutPanel2.RowStyles[0].Height = f; this.Height = this.firstHeight + rowHeght * this.testCase.StepList.Count; this.tableLayoutPanel2.RowCount = this.testCase.StepList.Count; for (int i = 1; i < this.testCase.StepList.Count; i++) { this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, f)); } int index = 1; foreach (var step in this.testCase.StepList) { RowEntity rowEntity = new RowEntity(); rowEntity.DisplayMember = "Model"; rowEntity.Name = step.Name; List <object> stepDevList = this.deviceList.Where(s => s.AgentType.Equals(step.AgentType)).ToList <object>(); UCRowComboBox row = new UCRowComboBox(rowEntity, stepDevList); row.IsHideThirdRow = true; if (this.testCase.StepList.Count == index) { row.ComBoxDockStyle = DockStyle.Top; } else { row.ComBoxDockStyle = DockStyle.Bottom; } index++; this.tableLayoutPanel2.Controls.Add(row, 0, j++); } }
private void SelectChanged(object sender, System.EventArgs e) { if (sender is ComboBox) { ComboBox cb = sender as ComboBox; string value = (string)cb.SelectedItem; foreach (Control c in this.uc.Controls[0].Controls) { if (c is UCRowComboBox) { UCRowComboBox box = c as UCRowComboBox; if (box.GetRow().Key == "Command") { if (value == AGENT_TYPE.AGENT_AP.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_AP); } else if (value == AGENT_TYPE.AGENT_CHARIOT.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_CHARIOT); } else if (value == AGENT_TYPE.AGENT_SNIFFER.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_SNIFFER); } else if (value == AGENT_TYPE.AGENT_STATION.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_STATION); } else if (value == AGENT_TYPE.AGENT_IPERF.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_IPERF); } else if (value == AGENT_TYPE.AGENT_MANUAL.ToString()) { assignmentCommand(box, AGENT_TYPE.AGENT_MANUAL); } break; } } } } }
private void SelectChanged(object sender, System.EventArgs e) { if (sender is ComboBox) { ComboBox cb = sender as ComboBox; string value = (string)cb.SelectedItem; foreach (Control c in this.uc.Controls[0].Controls) { if (c is UCRowComboBox) { UCRowComboBox box = c as UCRowComboBox; if (box.GetRow().Key == "Model") { if (value == AGENT_TYPE.AGENT_AP.ToString()) { box.ResetList(AgentModelAp.DataList); } else if (value == AGENT_TYPE.AGENT_CHARIOT.ToString()) { box.ResetList(AgentModelChariot.DataList); } else if (value == AGENT_TYPE.AGENT_SNIFFER.ToString()) { box.ResetList(AgentModelSniffer.DataList); } else if (value == AGENT_TYPE.AGENT_STATION.ToString()) { box.ResetList(AgentModelStation.DataList); } else if (value == AGENT_TYPE.AGENT_IPERF.ToString()) { box.ResetList(AgentModelIperf.DataList); } break; } } } } }
/// <summary> /// 根据agent_type 给UCRowComboBox动态赋值 /// </summary> /// <param name="box"></param> /// <param name="agentType"></param> private void assignmentCommand(UCRowComboBox box, AGENT_TYPE agentType) { List <object> commandList = commandBll.SelectAll().Where(p => p.AgentType.Equals(agentType)).ToList <object>(); box.ResetList(commandList); }