private bool ConvertType5() { try { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; o.Value2D()[0, 0] = Convert.ToDouble(dataGridView1[0, 0].Value); o.Value2D()[1, 0] = Convert.ToDouble(dataGridView1[1, 0].Value); o.Value2D()[2, 0] = Convert.ToDouble(dataGridView1[2, 0].Value); } catch { return(false); } return(true); }
private bool ConvertWaterLevelData() { try { DataGridView v = dataGridView; RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.None: case RiverSimulationProfile.TwoInOne.Type.UseValue: for (int jw = jStart; jw < jStart + rowCount; ++jw) { o.Value2D()[0, jw - jStart] = Convert.ToDouble(v[iStart, jw].Value); } break; case RiverSimulationProfile.TwoInOne.Type.UseArray: for (int jw = jStart; jw < jStart + rowCount; ++jw) { for (int iw = iStart; iw < iStart + colCount; ++iw) { o.Array2D()[iw - iStart, jw - jStart] = Convert.ToDouble(v[iw, jw].Value); } } break; } } catch { return(false); } return(true); }
private void FillDataGridView() { RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne; if (formType == FormType.FlowQuantity || formType == FormType.WaterLevel) { switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.None: case RiverSimulationProfile.TwoInOne.Type.UseValue: for (int jw = jStart; jw < jStart + rowCount; ++jw) { dataGridView[iStart, jw].Value = o.Value2D()[0, jw - jStart].ToString(); dataGridView[iStart, jw].ReadOnly = false; dataGridView[iStart, jw].Style.BackColor = tabPageItemColor; } dataGridView.CurrentCell = dataGridView[iStart, jStart]; //dataGridView[1, jStart]. = true; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: if (formType == FormType.FlowQuantity) { for (int jw = jStart; jw < jStart + rowCount; ++jw) { dataGridView[iStart, jw].Value = o.Value2D()[0, jw - jStart].ToString(); dataGridView[iStart, jw].ReadOnly = true; dataGridView[iStart, jw].Style.BackColor = tabPageItemColor2; } } for (int jw = jStart; jw < jStart + rowCount; ++jw) { for (int iw = iStart; iw < iStart + colCount; ++iw) { if (formType == FormType.FlowQuantity) { dataGridView[iw + 1, jw].Value = o.Array2D()[iw - iStart, jw - jStart].ToString(); dataGridView[iw + 1, jw].ReadOnly = false; dataGridView[iw + 1, jw].Style.BackColor = tabPageItemColor; } else { dataGridView[iw, jw].Value = o.Array2D()[iw - iStart, jw - jStart].ToString(); dataGridView[iw, jw].ReadOnly = false; dataGridView[iw, jw].Style.BackColor = tabPageItemColor; } } } if (formType == FormType.FlowQuantity) { AutoFinishConvertFlowQualityCell(); } dataGridView.CurrentCell = dataGridView[iStart, jStart]; break; } } else if (formType == FormType.BottomBedLoadFlux) { switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.None: case RiverSimulationProfile.TwoInOne.Type.UseValue: for (int tw = jStart; tw < jStart + (p.IsConstantFlowType() ? 1 : p.boundaryTimeNumber); ++tw) { for (int kw = iStart; kw < iStart + p.sedimentParticlesNumber; ++kw) { dataGridView[kw, tw].Value = o.Value3D()[kw - iStart, 0, tw - jStart].ToString(); dataGridView[kw, tw].ReadOnly = false; dataGridView[kw, tw].Style.BackColor = tabPageItemColor; } } dataGridView.CurrentCell = dataGridView[iStart, jStart]; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: for (int tw = jStart; tw < jStart + (p.IsConstantFlowType() ? 1 : p.boundaryTimeNumber); ++tw) { for (int jw = iStart; jw < iStart + p.inputGrid.GetJ; ++jw) { dataGridView[jw + 1, tw + 1].Value = o.Array3D()[tabIndex, jw - iStart, tw - jStart].ToString(); dataGridView[jw + 1, tw + 1].ReadOnly = false; dataGridView[jw + 1, tw + 1].Style.BackColor = tabPageItemColor; } dataGridView[iStart, tw + 1].Value = o.Value3D()[tabIndex, 0, tw - jStart].ToString(); dataGridView[iStart, tw + 1].ReadOnly = true; dataGridView[iStart, tw + 1].Style.BackColor = tabPageItemColor2; } dataGridView.CurrentCell = dataGridView[iStart, jStart]; break; } } else if (formType == FormType.DepthAverageConcentration) { switch (o.type) { case RiverSimulationProfile.TwoInOne.Type.None: case RiverSimulationProfile.TwoInOne.Type.UseValue: for (int jw = jStart; jw < jStart + 1; ++jw) { for (int iw = iStart; iw < iStart + p.sedimentParticlesNumber; ++iw) { dataGridView[iw, jw].Value = o.Value3D()[iw - iStart, 0, 0].ToString(); dataGridView[iw, jw].ReadOnly = false; dataGridView[iw, jw].Style.BackColor = tabPageItemColor; } } dataGridView.CurrentCell = dataGridView[iStart, jStart]; break; case RiverSimulationProfile.TwoInOne.Type.UseArray: for (int jw = jStart; jw < jStart + p.inputGrid.GetI; ++jw) { for (int iw = iStart; iw < iStart + p.inputGrid.GetJ; ++iw) { dataGridView[iw, jw].Value = o.Array3D()[tabIndex, iw - iStart, jw - jStart].ToString(); dataGridView[iw, jw].ReadOnly = false; dataGridView[iw, jw].Style.BackColor = tabPageItemColor; } } dataGridView.CurrentCell = dataGridView[iStart, jStart]; break; } } dataGridView.PerformLayout(); }
private void CreateData(object d) { RiverSimulationProfile.TwoInOne o = d as RiverSimulationProfile.TwoInOne; RiverSimulationProfile.TwoInOne _d = null; Debug.Assert(o != null); if (formType == FormType.FlowQuantity || formType == FormType.WaterLevel) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull() || (o.valueType == RiverSimulationProfile.TwoInOne.ValueType.TwoDim && (o.Value2D().GetLength(0) != colCount || o.Value2D().GetLength(1) != rowCount)) || (o.valueType == RiverSimulationProfile.TwoInOne.ValueType.ThreeDim && (o.Value3D().GetLength(0) != colCount || o.Value3D().GetLength(1) != rowCount))) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 //_data = new RiverSimulationProfile.TwoInOne(colCount, rowCount); _d.Create2D(colCount, rowCount); _d.type = RiverSimulationProfile.TwoInOne.Type.UseValue; } } else if (formType == FormType.BottomBedLoadFlux) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull()) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 // _data = new RiverSimulationProfile.TwoInOne(p.boundaryTimeNumber, p.sedimentParticlesNumber, p.inputGrid.GetJ); //[T, K, J] //_data = new RiverSimulationProfile.TwoInOne(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.boundaryTimeNumber); //[K, J, T] //_d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.boundaryTimeNumber); _d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, rowCount); _d.type = RiverSimulationProfile.TwoInOne.Type.UseValue; } } else if (formType == FormType.DepthAverageConcentration) { _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne); _d = _data as RiverSimulationProfile.TwoInOne; Debug.Assert(_d != null); if (o.ValueNull() || o.ArrayNull()) { //rowCount : Q1 ~ Q5, colCount : J1 ~ J15 _d.Create3D(p.sedimentParticlesNumber, p.inputGrid.GetJ, p.inputGrid.GetI); } } }