private void FormMain_Load(object sender, EventArgs e) { _initializing = true; _config = Config.Load(); textBox_ip.Text = _config.Server.IP; textBox_port.Text = Convert.ToString(_config.Server.Port); lb_scenes.Items.AddRange(_config.Scenes.ToArray()); UpdateSceneCnt(); Console.SetOut(new TextBoxWriter(this.textBoxLog)); System.Drawing.Font f = dgv_doors.Font; System.Drawing.Font gf = new System.Drawing.Font(f.FontFamily, f.Size + 1, System.Drawing.FontStyle.Bold); int zIndex = 0; foreach (string zName in zones) { // Zone Row. int rowIndex = dgv_doors.Rows.Add();// dt.NewRow(); DataGridViewRow lvz = dgv_doors.Rows[rowIndex]; lvz.Cells[ViewColumns.STATE].Value = client.Properties.Resources.off_24; lvz.Cells[ViewColumns.INDEX].Value = zName; DataGridViewTextBoxCellEx cell = (DataGridViewTextBoxCellEx)lvz.Cells[ViewColumns.INDEX]; cell.ColumnSpan = 5; cell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft; cell.Style.Font = gf; _zoneIndex[zIndex] = lvz; // rowIndex=>row _zoneRows[zName] = lvz; // name=>row for (int di = 0; di < 12; di++) { DataGridViewRow lvi = dgv_doors.Rows[dgv_doors.Rows.Add()]; lvi.Cells[ViewColumns.STATE].Value = client.Properties.Resources.off_24; lvi.Cells[ViewColumns.INDEX].Value = di + 1; lvi.Cells[ViewColumns.NAME].Value = string.Format("门-{0}", di + 1); _doorRows[string.Format("{0}.{1}", zIndex, di)] = lvi; } zIndex++; } _initializing = false; if (lb_scenes.Items.Count > 0) { lb_scenes.SelectedIndex = 0; } }
static Config Default(int zoneCnt, int doorCnt) { Config cfg = new Config() { Server = new ServerConfig() { IP = "192.168.32.1", Port = 502 }, Scenes = new List<Scene>(), }; cfg.AddScene(Scene.Default()); return cfg; }