private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEdit1.SelectedIndex >= 0) { HHDeviceGrp devType = comboBoxEdit1.SelectedItem as HHDeviceGrp; IList <HHDevice> listDev = devType.Devices; comboBoxEdit2.Properties.Items.Clear(); comboBoxEdit2.Text = ""; for (int i = 0; i < listDev.Count; i++) { comboBoxEdit2.Properties.Items.Add(listDev[i]); } if (listDev.Count > 0) { comboBoxEdit2.SelectedIndex = 0; } gridControl1.DataSource = devType.AnalogProperties; } }
private void comboBoxEdit3_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEdit3.Visible && comboBoxEdit3.SelectedItem != null) { HHDeviceGrp devGrp = comboBoxEdit3.SelectedItem as HHDeviceGrp; if (devGrp != null) { InitDevList(devGrp); } } }
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.FieldName == "Selected") { HHDeviceGrp devType = comboBoxEdit1.SelectedItem as HHDeviceGrp; devType.SelectProperty(e.RowHandle, (bool)e.Value); int num = devType.AnalogProperties.Count; for (int i = 0; i < num; i++) { gridView1.RefreshRow(i); } DrawCurve(); } }
private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) { HHDeviceGrp devGrp = comboBoxEdit1.SelectedItem as HHDeviceGrp; if (devGrp == null) { return; } if (devGrp.Level == 2) { IList <HHDeviceGrp> childGrp = devGrp.ChildGrp; comboBoxEdit3.Properties.Items.Clear(); for (int i = 0; i < childGrp.Count; i++) { comboBoxEdit3.Properties.Items.Add(childGrp[i]); } comboBoxEdit1.Width = 200; labelControl5.Visible = true; comboBoxEdit3.Visible = true; if (childGrp.Count > 0) { comboBoxEdit3.SelectedIndex = 0; } } else { labelControl5.Visible = false; comboBoxEdit3.Visible = false; comboBoxEdit3.SelectedIndex = -1; comboBoxEdit1.Width = comboBoxEdit2.Width; InitDevList(devGrp); } }
private void Load(string fileName) { if (File.Exists(fileName) == false) { if (File.Exists(fileName) == false) { Assembly assembly = this.GetType().Assembly; System.IO.Stream smEmbeded = assembly.GetManifestResourceStream("ConfigManager.Config.设备.rhhcfg"); byte[] data = new byte[smEmbeded.Length]; smEmbeded.Read(data, 0, data.Length); //建立目录 string dir = Path.GetDirectoryName(fileName); if (Directory.Exists(dir) == false) { Directory.CreateDirectory(dir); } File.WriteAllBytes(fileName, data); smEmbeded.Close(); } } IniDocument ini = new IniDocument(); ini.Load(fileName); int num = ini.GetInt("设备", "数目", 0); for (int i = 0; i < num; i++) { HHDeviceGrp devGrp = new HHDeviceGrp(ini, i); if (devGrp.IsValid) { listGrp.Add(devGrp); } } //区间轨道电路 List <HHDeviceGrp> grpsQJ = new List <HHDeviceGrp>(); HHDeviceGrp grpQJ = null; List <HHDeviceGrp> grpsZN = new List <HHDeviceGrp>(); HHDeviceGrp grpZN = null; for (int i = 0; i < listGrp.Count; i++) { int devType = listGrp[i].DevType; switch (devType) { case 8: //区间轨道电路 grpQJ = listGrp[i]; listGrpSort.Add(grpQJ); break; case 10: //无绝缘移频 grpsQJ.Add(listGrp[i]); break; case 30: //有绝缘移频 grpsQJ.Add(listGrp[i]); break; case 208: //ZPW2000 grpsQJ.Add(listGrp[i]); break; case 4: //站内轨道电路 grpZN = listGrp[i]; listGrpSort.Add(grpZN); break; case 11: //25HZ轨道电路 grpsZN.Add(listGrp[i]); break; case 16: //480轨道电路 grpsZN.Add(listGrp[i]); break; case 17: //高压不对称 grpsZN.Add(listGrp[i]); break; case 25: //驼峰 grpsZN.Add(listGrp[i]); break; default: listGrpSort.Add(listGrp[i]); break; } if (devType != 4 && devType != 8) { listGrpUnsort.Add(listGrp[i]); } } if (grpQJ != null) { grpQJ.AddGrp(grpsQJ); } else { listGrpSort.AddRange(grpsQJ); } if (grpZN != null) { grpZN.AddGrp(grpsZN); } else { listGrpSort.AddRange(grpsZN); } }
private void InitDevList(HHDeviceGrp devGrp) { comboBoxEdit2.Properties.Items.Clear(); for (int i = 0; i < MaxSrcs; i++) { selectChannels[i] = null; txtBoxes[i] = null; buttons[i] = null; } comboBoxEdit2.Text = ""; IList <HHDevice> devices = devGrp.Devices; for (int i = 0; i < devices.Count; i++) { comboBoxEdit2.Properties.Items.Add(devices[i]); } List <HHSourceGroup> grps = devGrp.SourceGroups; xtraTabControl1.TabPages.Clear(); for (int i = 0; i < grps.Count; i++) { XtraTabPage tabPage = new XtraTabPage(); tabPage.Name = "Signal" + i; tabPage.Text = "信号源" + (i + 1); int height = 15; int grpCnt = 1; for (int j = 0; j < grps[i].Properties.Count; j++) { string propName = grps[i].Properties[j].Name; Label label = new Label(); label.AutoSize = true; label.Font = new Font("宋体", 11, FontStyle.Bold); label.Text = (j + 1) + ":" + propName; label.Location = new Point(15, height); height += 30; tabPage.Controls.Add(label); grpCnt = grps[i].Properties[j].GroupCount; } string[][] txtList = new string[][] { new string[] { "选取" }, new string[] { "参考", "选取" }, new string[] { "A相(或单相)", "B相", "C相" }, }; for (int j = 0; j < grpCnt; j++) { TextBox textBox = new TextBox(); txtBoxes[i * PropChannelNum + j] = textBox; textBox.Location = new Point(15, height); textBox.Size = new Size(150, 25); textBox.ReadOnly = true; textBox.BackColor = Color.Pink; tabPage.Controls.Add(textBox); Button bt = new Button(); bt.Tag = i * PropChannelNum + j; bt.Location = new Point(textBox.Left + textBox.Width, height); bt.Size = new Size(80, 25); bt.Text = txtList[grpCnt - 1][j]; tabPage.Controls.Add(bt); bt.Click += new EventHandler(bt_Click); height += 30; } xtraTabControl1.TabPages.Add(tabPage); } }