Exemplo n.º 1
0
 public void SetSelectionItems(ListBox lb, string[] structureName, int[] structureNum, RiverSimulationProfile.StructureType[] typeIndex)
 {
     for(int i=0; i<lb.Items.Count; ++i)
     {
         selCombo.Items.Add(lb.Items[i].ToString());
     }
     this.structureName = structureName;
     this.structureNum = structureNum;
     this.typeIndex = typeIndex;
     selIndex = lb.SelectedIndex;
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 public void SetForm(RiverSimulationProfile profile)
 {
     p = profile;
 }
Exemplo n.º 4
0
        //檢查一群組是否與都位於空白處(不屬於任何群組)
        public static bool IsAllInEmpty(RiverSimulationProfile profile, List<Point> pl, int passType, int passIndex)
        {
            foreach (Point p in pl)
            {
                for (int n = 0; n < (int)RiverSimulationProfile.StructureType.StructureTypeSize; ++n)
                {
                    List<Point>[] pts = null;
                    switch (n)
                    {
                        case 0:
                            pts = profile.tBarSets;
                            break;
                        case 1:
                            pts = profile.bridgePierSets;
                            break;
                        case 2:
                            pts = profile.groundsillWorkSets;
                            break;
                        case 3:
                            pts = profile.sedimentationWeirSets;
                            break;
                        default:
                            break;
                    }

                    if (null == pts)
                    {
                        continue;
                    }

                    for (int i = 0; i < pts.Length; ++i)
                    {
                        List<Point> ppl = pts[i];

                        if (i == passIndex || ppl == null)
                            continue;

                        if (ppl.Contains(p))
                        {
                            return false;
                        }
                    }
                }
            }
            return true;
        }
Exemplo n.º 5
0
 //查詢一格網點位於哪個結構物群組?
 //public static int WhichGroup(List<Point>[] pts, Point pt, List<Point> addional = null, int passIndex = -1)
 //{
 //    for (int i = 0; i < pts.Length; ++i)
 //    {
 //        List<Point> pl = pts[i];
 //        if (pl == null || (passIndex != -1 && i == passIndex))
 //            continue;
 //        if(pl.Contains(pt))
 //        {
 //            return i;
 //        }
 //    }
 //    if (addional != null)
 //    {
 //        if (addional.Contains(pt))
 //        {
 //            return passIndex;
 //        }
 //    }
 //    return -1;
 //}
 public static List<Point>[] GetStructureSets(RiverSimulationProfile profile, int type)
 {
     List<Point>[] pts = null;
     switch (type)
     {
         case 0:
             pts = profile.tBarSets;
             break;
         case 1:
             pts = profile.bridgePierSets;
             break;
         case 2:
             pts = profile.groundsillWorkSets;
             break;
         case 3:
             pts = profile.sedimentationWeirSets;
             break;
         default:
             break;
     }
     return pts;
 }
Exemplo n.º 6
0
 public static List<Point> GetStructureSet(RiverSimulationProfile profile, int type, int index)
 {
     List<Point>[] pts = GetStructureSets(profile, type);
     if (pts == null)
     {
         return null;
     }
     else
     {
         return pts[index];
     }
 }
Exemplo n.º 7
0
        public static void EditBottomElevation(RiverSimulationProfile profile, string title, int type, int index)
        {
            TableInputForm form = new TableInputForm();
            form.SetFormMode(title, profile.inputGrid.GetJ, profile.inputGrid.GetI, "", "", "",
                TableInputForm.InputFormType.BottomElevationForm, 90, 120, true, false, false, profile.inputGrid.inputCoor);
            form.SetFormModeExtraData(GetStructureSet(profile, type, index));

            DialogResult r = form.ShowDialog();
            if (DialogResult.OK == r)
            {
                //p.levelProportion = (double[])form.SeparateData().Clone();
                //ShowGridMap(PicBoxType.Sprate);
                //DrawPreview();
            }
        }
Exemplo n.º 8
0
        //檢查結構物清單,得知是哪種結構物的第幾個?
        public static void CalcTypeCount(int index, ref int type, ref int count, RiverSimulationProfile.StructureType[] typeIndex)
        {
            if (index >= typeIndex.Length)
                return;

            RiverSimulationProfile.StructureType lastType = RiverSimulationProfile.StructureType.StructureTypeSize;
            int c = 0;

            for (int i = 0; i <= index; ++i)
            {
                if (typeIndex[i] != lastType)
                {
                    c = 0;
                    lastType = typeIndex[i];
                }
                else
                {
                    ++c;
                }

            }
            type = (lastType == RiverSimulationProfile.StructureType.StructureTypeSize) ? -1 : (int)lastType;
            count = c;
        }
Exemplo n.º 9
0
        public static bool SaveProject(RiverSimulationProfile p)
        {
            if (p == null)
            {
                return false;
            }

            RiverSimulationProfile.SerializeBinary(p, Program.GetProjectFileFullPath());
            return true;
        }
Exemplo n.º 10
0
 public static void InitialGridPictureBoxByProfile(ref PictureBoxCtrl.GridPictureBox gp, RiverSimulationProfile p)
 {
     RiverSimulationProfile.BackgroundMapType t = p.GetBackgroundMapType();
     if (RiverSimulationProfile.profile.inputGrid != null)
     {
         gp.Grid = p.inputGrid;
     }
     if(RiverSimulationProfile.BackgroundMapType.ImportImage == t)
     {
         gp.SetMapBackground(p.imagePath, p.sourceE, p.sourceN, p.sourceW, p.sourceH);
     }
     else if(RiverSimulationProfile.BackgroundMapType.GoogleStaticMap == t)
     {
         gp.SetMapBackground(p.tl, p.tr, p.bl, p.br);
     }
     else //if (RiverSimulationProfile.BackgroundMapType.None == t)
     {
         gp.ClearMapBackground();
     }
 }
Exemplo n.º 11
0
        //查詢一格網點位於哪個結構物群組?
        public static Point WhichGroup(RiverSimulationProfile profile, Point pt, List<Point> addional = null, int passType = -1, int passIndex = -1)
        {
            for (int n = 0; n < (int)RiverSimulationProfile.StructureType.StructureTypeSize; ++n)
            {
                List<Point>[] pts = GetStructureSets(profile, n);
                if (null == pts)
                {
                    continue;
                }

                for (int i = 0; i < pts.Length; ++i)
                {
                    List<Point> pl = pts[i];
                    if (pl == null || (passIndex != -1 && i == passIndex))
                        continue;
                    if (pl.Contains(pt))
                    {
                        return new Point(n, i);
                    }
                }
            }

            if (addional != null)
            {
                if (addional.Contains(pt))
                {
                    return new Point(passType, passIndex);
                }
            }
            return new Point(-1, -1);
        }
Exemplo n.º 12
0
 public static void SerializeBinary(RiverSimulationProfile p, string file)
 {
     FileStream oFileStream = new FileStream(file, FileMode.Create);
     BinaryFormatter myBinaryFormatter = new BinaryFormatter();
     myBinaryFormatter.Serialize(oFileStream, p);
     oFileStream.Flush();
     oFileStream.Close();
     oFileStream.Dispose();
 }
Exemplo n.º 13
0
        public void SetFormMode(FormType t, string title, string colName, int colCount, int rowCount,  RiverSimulationProfile profile, object initData = null)
        {
            this.formType = t;
            this.p = profile;

            this.title = title;
            this.colCount = colCount;
            this.iTitle = colName;
            //this.rowCount = rowCount;

            if (formType == FormType.FlowQuantity || formType == FormType.WaterLevel)
            {
                if (p.IsVariableFlowType())
                {
                    this.iStart = 1;
                    this.jStart = 1;
                    this.rowCount = rowCount;
                    this.extraCol = (formType == FormType.FlowQuantity) ? 2 : 1;
                }
                else
                {
                    this.iStart = 0;
                    this.jStart = 1;
                    this.rowCount = 1;
                    this.extraCol = 1;
                }
                if (formType == FormType.FlowQuantity)
                {
                    type1Btn.Text = "均勻入流";
                    type2Btn.Text = "非均勻入流";
                }
                else
                {
                    type1Btn.Text = "均一值";
                    type2Btn.Text = "逐點給";
                }

            }
            else if (formType == FormType.BottomBedLoadFlux)
            {
                if (p.IsVariableFlowType())
                {
                    this.iStart = 1;
                    this.jStart = 1;
                    this.rowCount = rowCount;
                    this.extraCol = 2;
                    this.extraRow = 2;
                }
                else
                {
                    this.iStart = 0;
                    this.jStart = 1;
                    this.rowCount = 1;
                    this.extraCol = 2;
                    this.extraRow = 2;
                }
                this.colCount = (p.sedimentParticlesNumber > p.inputGrid.GetJ) ? p.sedimentParticlesNumber : p.inputGrid.GetJ;
            }
            else if (formType == FormType.DepthAverageConcentration)
            {
                this.iStart = 1;
                this.jStart = 2;
                this.rowCount = rowCount;
                this.extraCol = 2;
                this.extraRow = 4;

                this.colCount = (p.sedimentParticlesNumber > p.inputGrid.GetJ) ? p.sedimentParticlesNumber : p.inputGrid.GetJ;
            }
            CreateData(initData);
        }