Example #1
0
        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);
        }
Example #2
0
 private bool ConvertFlowConditionsSettingVariable()
 {
     try
     {
         DataGridView v = dataGridView;
         RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne;
         for (int i = 1; i < v.ColumnCount; ++i)
         {
             for (int j = 0; j < v.RowCount; ++j)
             {
                 o.Array2D()[i - 1, j] = Convert.ToDouble(v[i, j].Value);
             }
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Example #3
0
 private bool ConvertFlowConditionsSettingConstant()
 {
     try
     {
         DataGridView v = dataGridView;
         RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne;
         for (int i = 0; i < v.ColumnCount; ++i)
         {
             o.Array2D()[i, 0] = Convert.ToDouble(v[i, 0].Value);
         }
         if (singleValueTxt.Enabled)
         {
             o.ValueDouble()[0] = Convert.ToDouble(singleValueTxt.Text);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Example #4
0
 private bool ConvertTwoInOneDouble()
 {
     try
     {
         DataGridView v = dataGridView;
         RiverSimulationProfile.TwoInOne o = _data as RiverSimulationProfile.TwoInOne;
         for (int i = 0; i < colCount; ++i)
         {
             for (int j = 0; j < rowCount; ++j)
             {
                 o.Array2D()[i, j] = Convert.ToDouble(v[i, j].Value);
             }
         }
         if (singleValueTxt.Enabled)
         {
             o.ValueDouble()[0] = Convert.ToDouble(singleValueTxt.Text);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        private bool AlertBoundaryTimeChange(ref RiverSimulationProfile.TwoInOne o)
        {
            if (o == null)
            {
                return(false);
            }
            if (p.IsConstantFlowType())
            {   //定量流時不檢查
                return(true);
            }
            if (p.boundaryTime == null || p.boundaryTime.GetLength(0) != p.boundaryTimeNumber)
            {
                MessageBox.Show("邊界時間尚未輸入完成", "確認", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (!o.ArrayNull() && o.Array2D().GetLength(1) != p.boundaryTimeNumber)
            {   //邊界時間有輸入,但與邊界時間數目不符合
                if (DialogResult.OK == MessageBox.Show("改變過邊界時間數目需要重新輸入所有流況資料,請確認?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
                {
                    RiverSimulationProfile.TwoInOne.Type      tp = o.type;
                    RiverSimulationProfile.TwoInOne.ValueType vt = o.valueType;
                    RiverSimulationProfile.TwoInOne.ArrayType at = o.arrayType;
                    o = new RiverSimulationProfile.TwoInOne(vt, at, tp);
                    return(true);
                }
                else
                {
                    p.boundaryTimeNumber       = o.Array2D().GetLength(1);
                    boundaryTimeNumberTxt.Text = p.boundaryTimeNumber.ToString();
                    return(false);
                }
            }

            return(true);
        }
Example #6
0
        private void CreateData(object d)
        {
            RiverSimulationProfile.TwoInOne o  = d as RiverSimulationProfile.TwoInOne;
            RiverSimulationProfile.TwoInOne _d = null;
            switch (_inputFormType)
            {
            case InputFormType.TwoInOneDouble:
            case InputFormType.TwoInOneDoubleGreaterThanZero:
            case InputFormType.TwoInOneDoubleGreaterThanOrEqualZero:
                Debug.Assert(o != null);
                _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne);
                _d    = _data as RiverSimulationProfile.TwoInOne;
                Debug.Assert(_d != null);
                if (o.ValueNull() || o.ArrayNull())
                {
                    (_data as RiverSimulationProfile.TwoInOne).CreateDouble2D(colCount, rowCount);
                }
                if (_d.Array2D().GetLength(0) != colCount || _d.Array2D().GetLength(1) != rowCount)
                {
                    Debug.Assert(false);
                }
                break;

            case InputFormType.GenericDouble:
            case InputFormType.GenericDoubleGreaterThanZero:
            case InputFormType.GenericDoubleGreaterThanOrEqualZero:
            case InputFormType.BottomBedParticleSizeRatio:
                if (d == null)
                {
                    _data = new double[colCount, rowCount];
                }
                else
                {
                    _data = (double [, ])(d as double[, ]).Clone();
                }
                break;

            case InputFormType.SeabedThicknessForm:
                if (d == null)
                {
                    _data = new double[rowCount];
                }
                else
                {
                    _data = (double [])(d as double[]).Clone();
                }
                break;

            case InputFormType.SedimentCompositionRatioForm:
                if (d == null)
                {
                    _data = new double[colCount, rowCount];
                }
                else
                {
                    _data = (double [, ])(d as double[, ]).Clone();
                }
                break;

            case InputFormType.SeparateForm:
            case InputFormType.BoundaryTime:
                if (d == null)
                {
                    _data = new double[rowCount];
                }
                else
                {
                    _data = (double [])(d as double[]).Clone();
                }
                break;

            case InputFormType.VerticalVelocityDistributionForm:
                if (d == null)
                {
                    _data = new double[2, rowCount];
                }
                else
                {
                    _data = (double [, ])(d as double[, ]).Clone();
                }
                break;

            case InputFormType.BottomElevationForm:
                if (d == null)
                {
                    _data = new CoorPoint[colCount, rowCount];
                }
                else
                {
                    _data = (CoorPoint[, ])(d as CoorPoint[, ]).Clone();
                }
                break;

            case InputFormType.FlowConditionsSettingConstant:
            case InputFormType.FlowConditionsSettingVariable:
                Debug.Assert(o != null);
                _data = new RiverSimulationProfile.TwoInOne(d as RiverSimulationProfile.TwoInOne);
                _d    = _data as RiverSimulationProfile.TwoInOne;
                if (o.ValueNull() || o.ArrayNull())
                {       //rowCount : Q1 ~ Q5, colCount : J1 ~ J15
                    _d.CreateDouble2D(colCount, rowCount);
                    // (_data as RiverSimulationProfile.TwoInOne).dataValue = new double[colCount, rowCount];
                }
                break;
            }
        }
Example #7
0
        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();
        }