private void singleValueRdo_CheckedChanged(object sender, EventArgs e) { bool chk = (sender as RadioButton).Checked; if (!chk) { singleValueTxt.Enabled = false; return; } RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; if (o != null) { o.type = RiverSimulationProfile.TwoInOne.Type.UseValue; } if (inputFormType == InputFormType.FlowConditionsSettingVariable) { dataGridView.Enabled = true; dataGridView.Rows.Clear(); DataGridViewUtility.InitializeDataGridView(dataGridView, 2, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, true, noRowNum); dataGridView.Columns[0].Name = "邊界時間"; dataGridView.Columns[1].Name = colName; FillDataGridView(); } else { singleValueTxt.Enabled = true; dataGridView.Enabled = false; } }
private void InitTableBottomBedParticleSizeRatio() { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum); if (p.IsVariableFlowType()) { //變量流需顯示邊界時間欄位 for (int jw = 0; jw < p.boundaryTimeNumber; ++jw) { dataGridView.Rows[jw].HeaderCell.Value = p.boundaryTime[jw].ToString(); } } }
private void InitializeDataGridView() { dataGridView.Rows.Clear(); DataGridViewUtility.InitializeDataGridView(dataGridView, colCount + extraCol, rowCount + extraRow, 120, 60, "", "", "", false, false); //if(formType == FormType.FlowQuantity) //{ // dataGridView[0, 0].Value = p.IsVariableFlowType() ? "變量流(輸入百分比)" : "定量流(輸入百分比)"; //} //else //{ // dataGridView[0, 0].Value = p.IsVariableFlowType() ? "變量流" : "定量流"; //} flowTypeLbl.Text = p.IsVariableFlowType() ? "變量流" : "定量流"; for (int jw = 0; jw < rowCount + extraRow; ++jw) { //全畫面設為唯讀 for (int iw = 0; iw < colCount + extraCol; ++iw) { dataGridView[iw, jw].ReadOnly = true; } } if (formType == FormType.FlowQuantity) { InitTableFlowQuantity(); } else if (formType == FormType.WaterLevel) { InitTableWaterLevel(); } else if (formType == FormType.BottomBedLoadFlux) { InitTableBottomBedLoadFlux(); } else if (formType == FormType.DepthAverageConcentration) { InitTableDepthAverageConcentration(); } FillDataGridView(); }
private void generateGridBtn_Click(object sender, EventArgs e) { int xNum = 0, yNum = 0; try { xNum = Convert.ToInt32(xGridNum.Text); yNum = Convert.ToInt32(yGridNum.Text); } catch { } if (xNum <= 0 && yNum <= 0) { MessageBox.Show("請輸入正確的數字", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } tabControl.Enabled = true; DataGridViewUtility.InitializeDataGridView(dataGridViewX, xNum, yNum, 96); DataGridViewUtility.InitializeDataGridView(dataGridViewY, xNum, yNum, 96); DataGridViewUtility.InitializeDataGridView(dataGridViewZ, xNum, yNum, 96); foreach (DataGridViewColumn column in dataGridViewX.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridViewY.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridViewZ.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } }
private void ImportTableForm_Load(object sender, EventArgs e) { if (hideGenerate) { yGridNum.Text = gridData.GetI.ToString(); xGridNum.Text = gridData.GetJ.ToString(); yGridNum.Enabled = false; xGridNum.Enabled = false; generateGridBtn.Enabled = false; tabControl.Enabled = true; DataGridViewUtility.InitializeDataGridView(dataGridViewX, colCount, rowCount, 96); DataGridViewUtility.InitializeDataGridView(dataGridViewY, colCount, rowCount, 96); DataGridViewUtility.InitializeDataGridView(dataGridViewZ, colCount, rowCount, 96); foreach (DataGridViewColumn column in dataGridViewX.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridViewY.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridViewZ.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } FillDataGridView(); RiverSimulationProfile p = RiverSimulationProfile.profile; if (null != p.tBarSets) { foreach (List <Point> pl in p.tBarSets) { if (pl == null) { continue; } foreach (Point pt in pl) { dataGridViewZ[pt.Y, pt.X].ReadOnly = true; dataGridViewZ[pt.Y, pt.X].Value = "99999999"; dataGridViewZ[pt.Y, pt.X].Style.BackColor = Color.LightGray; } } } if (null != p.bridgePierSets) { foreach (List <Point> pl in p.bridgePierSets) { if (pl == null) { continue; } foreach (Point pt in pl) { dataGridViewZ[pt.Y, pt.X].ReadOnly = true; dataGridViewZ[pt.Y, pt.X].Value = "99999999"; dataGridViewZ[pt.Y, pt.X].Style.BackColor = Color.LightGray; } } } if (null != p.groundsillWorkSets) { foreach (List <Point> pl in p.groundsillWorkSets) { if (pl == null) { continue; } foreach (Point pt in pl) { dataGridViewZ[pt.Y, pt.X].ReadOnly = true; dataGridViewZ[pt.Y, pt.X].Style.BackColor = Color.LightGray; } } } if (null != p.sedimentationWeirSets) { foreach (List <Point> pl in p.sedimentationWeirSets) { foreach (Point pt in pl) { dataGridViewZ[pt.Y, pt.X].ReadOnly = true; dataGridViewZ[pt.Y, pt.X].Style.BackColor = Color.LightGray; } } } //p.tBarSets, p.bridgePierSets, p.groundsillWorkSets, p.sedimentationWeirSets } }
private void InitializeDataGridView() { if (inputFormType == InputFormType.SeparateForm) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum, false, true); } else if (inputFormType == InputFormType.VerticalVelocityDistributionForm) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum, false, true); dataGridView.Columns[0].Name = "垂向分層位置"; dataGridView.Columns[1].Name = "比例係數"; } else if (inputFormType == InputFormType.BoundaryTime) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum, false, false); } else if (inputFormType == InputFormType.TwoInOneDouble || inputFormType == InputFormType.TwoInOneDoubleGreaterThanZero || inputFormType == InputFormType.TwoInOneDoubleGreaterThanOrEqualZero) { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(o != null); singleValueTxt.Text = o.ValueDouble()[0].ToString(); DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum); selInputBtn.Visible = true; switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.UseValue: singleValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: tableValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.None: singleValueRdo.Checked = false; tableValueRdo.Checked = false; singleValueTxt.Enabled = false; dataGridView.Enabled = false; break; } } else if (inputFormType == InputFormType.GenericDouble || inputFormType == InputFormType.GenericDoubleGreaterThanZero || inputFormType == InputFormType.GenericDoubleGreaterThanOrEqualZero) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum); } else if (inputFormType == InputFormType.FlowConditionsSettingConstant) { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(o != null); singleValueTxt.Text = o.ValueDouble()[0].ToString(); DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, "", colName, rowName, nocolNum, true); dataGridView.Rows[0].HeaderCell.Value = tableName; switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.UseValue: singleValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: tableValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.None: singleValueRdo.Checked = false; tableValueRdo.Checked = false; singleValueTxt.Enabled = false; dataGridView.Enabled = false; break; } } else if (inputFormType == InputFormType.FlowConditionsSettingVariable) { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(o != null); switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.UseValue: singleValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: tableValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.None: singleValueRdo.Checked = false; tableValueRdo.Checked = false; singleValueTxt.Enabled = false; dataGridView.Enabled = false; break; } singleValueTxt.Visible = (inputFormType == InputFormType.FlowConditionsSettingConstant) ? true :false; } else if (inputFormType == InputFormType.SeabedThicknessForm) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum, false, true); dataGridView.Rows[0].HeaderCell.Value = "作用層"; } else if (inputFormType == InputFormType.SedimentCompositionRatioForm) { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum, false, true); dataGridView.Rows[0].HeaderCell.Value = "作用層"; } else if (inputFormType == InputFormType.BottomBedParticleSizeRatio) { InitTableBottomBedParticleSizeRatio(); } else { DataGridViewUtility.InitializeDataGridView(dataGridView, colCount, rowCount, colWidth, rowHeadersWidth, tableName, colName, rowName, nocolNum, noRowNum); } FillDataGridView(); }
private void InitializeDataGridView() { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.UseValue: singleValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: tableValueRdo.Checked = true; break; case RiverSimulationProfile.TwoInOne.Type.None: Debug.Assert(false); break; } if (inputFormType == InputFormType.Type1) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, colWidth, rowHeadersWidth, tableName, "", "", false, false, false, false); dataGridView1.Columns[0].Name = "主流方向流量(cms)"; dataGridView1.Columns[1].Name = "側方向流量(cms)"; } else if (inputFormType == InputFormType.Type2) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, colWidth, rowHeadersWidth, "時間 T (sec)", "主流方向流量(cms)", "", true, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, colWidth, rowHeadersWidth, "時間 T (sec)", "側方向流量(cms)", "", true, true, false, false); for (int i = 0; i < p.boundaryTime.Length; ++i) { dataGridView1.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView2.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); } dataGridView1.Columns[0].Name = "主流方向流量(cms)"; dataGridView2.Columns[0].Name = "側方向流量(cms)"; } else if (inputFormType == InputFormType.Type3) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, 72, 140, "", "", "主流方向流量(cms)", false, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, 72, 140, "", "", "側方向流量(cms)", false, true, false, false); for (int i = 0; i < colCount; ++i) { int start = inputData.sideFlowPoints.OrderBy(p => p.X).ToArray()[0].X; dataGridView1.Columns[i].Name = (i + start + 1).ToString(); dataGridView2.Columns[i].Name = (i + start + 1).ToString(); } } else if (inputFormType == InputFormType.Type4) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, 72, 140, "時間 T (sec)", "", "", false, false, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, 72, 140, "時間 T (sec)", "", "", false, false, false, false); for (int i = 0; i < p.boundaryTime.Length; ++i) { dataGridView1.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView2.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); } for (int i = 0; i < colCount; ++i) { int start = inputData.sideFlowPoints.OrderBy(p => p.X).ToArray()[0].X; dataGridView1.Columns[i].Name = (i + start + 1).ToString(); dataGridView2.Columns[i].Name = (i + start + 1).ToString(); } } else if (inputFormType == InputFormType.Type5) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, colWidth, rowHeadersWidth, tableName, "", "", true, true, false, false); dataGridView1.Columns[0].Name = "主流方向流量(cms)"; dataGridView1.Columns[1].Name = "側方向流量(cms)"; dataGridView1.Columns[2].Name = "水位(m)"; } else if (inputFormType == InputFormType.Type7) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, 72, 140, "", "", "主流方向流量(cms)", false, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, 72, 140, "", "", "側方向流量(cms)", false, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView3, colCount, rowCount, 72, 140, "", "", "水位(m)", false, true, false, false); for (int i = 0; i < colCount; ++i) { int start = inputData.sideFlowPoints.OrderBy(p => p.X).ToArray()[0].X; dataGridView1.Columns[i].Name = (i + start + 1).ToString(); dataGridView2.Columns[i].Name = (i + start + 1).ToString(); dataGridView3.Columns[i].Name = (i + start + 1).ToString(); } } else if (inputFormType == InputFormType.Type6) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, colWidth, rowHeadersWidth, "時間 T (sec)", "主流方向流量(cms)", "", true, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, colWidth, rowHeadersWidth, "時間 T (sec)", "側方向流量(cms)", "", true, true, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView3, colCount, rowCount, colWidth, rowHeadersWidth, "時間 T (sec)", "水位(m)", "", true, true, false, false); for (int i = 0; i < p.boundaryTime.Length; ++i) { dataGridView1.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView2.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView3.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); } dataGridView1.Columns[0].Name = "主流方向流量(cms)"; dataGridView2.Columns[0].Name = "側方向流量(cms)"; dataGridView3.Columns[0].Name = "水位(m)"; } else if (inputFormType == InputFormType.Type8) { DataGridViewUtility.InitializeDataGridView(dataGridView1, colCount, rowCount, 72, 140, "時間 T (sec)", "", "", false, false, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView2, colCount, rowCount, 72, 140, "時間 T (sec)", "", "", false, false, false, false); DataGridViewUtility.InitializeDataGridView(dataGridView3, colCount, rowCount, 72, 140, "時間 T (sec)", "", "", false, false, false, false); for (int i = 0; i < p.boundaryTime.Length; ++i) { dataGridView1.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView2.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); dataGridView3.Rows[i].HeaderCell.Value = p.boundaryTime[i].ToString(); } for (int i = 0; i < colCount; ++i) { int start = inputData.sideFlowPoints.OrderBy(p => p.X).ToArray()[0].X; dataGridView1.Columns[i].Name = (i + start + 1).ToString(); dataGridView2.Columns[i].Name = (i + start + 1).ToString(); dataGridView3.Columns[i].Name = (i + start + 1).ToString(); } } foreach (DataGridViewColumn column in dataGridView1.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridView2.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewColumn column in dataGridView3.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } FillDataGridView(); }