private void dataGv_SelectionChanged(object sender, EventArgs e)
        {
            var selectedCellCount = dataGv.GetCellCount(DataGridViewElementStates.Selected);

            if (selectedCellCount <= 0)
            {
                return;
            }

            int type = 0, count = 0;

            StructureSetUtility.CalcTypeCount(selIndex, ref type, ref count, typeIndex);

            List <Point> pl = new List <Point>();

            for (int i = 0; i < selectedCellCount; ++i)
            {   //pl 所有被選取的點集合
                pl.Add(new Point(dataGv.SelectedCells[i].RowIndex, dataGv.SelectedCells[i].ColumnIndex));
            }
            addBtn.Enabled = StructureSetUtility.IsAllInEmpty(p, pl, type, count);

            List <Point> pts = StructureSetUtility.GetStructureSet(p, type, count);

            removeBtn.Enabled = CheclRemoveBtnEnabled(pts, pl);

            editBtn.Enabled = CheclEditBtnEnabled(type, count);
        }
示例#2
0
        //private List<Point> GetSelectedGroup()
        //{
        //    RiverSimulationProfile p = RiverSimulationProfile.profile;
        //    int index = listBox.SelectedIndex;

        //    if (st == SelectType.StructureSet)
        //    {
        //        return p.DryBedPts[index];
        //    }
        //    return null;
        //}
        private bool CheckOverlapping(List <Point> pl, List <Point>[] rg, int count)
        {
            if (rg == null)
            {
                return(true);
            }

            if (StructureSetUtility.IsOverlapping(rg, pl, count))
            {
                UpdateSelectedGroup(pl, true);
                if (DialogResult.Yes == MessageBox.Show("圈選到重覆區域,是否刪減重複範圍(選「否」將放棄此次圈選)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
                {
                    StructureSetUtility.RemoveOverlapping(ref pl, rg, count);
                    if (!StructureSetUtility.IsContinuous(pl))
                    {
                        UpdateSelectedGroup(pl, true);
                        MessageBox.Show("刪減後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        UpdateSelectedGroup(null);
                        return(false);
                    }
                }
                else
                {
                    UpdateSelectedGroup(null);
                    return(false);
                }
            }
            return(true);
        }
        private void dryBedCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //groupColors = StructureSetUtility.ColoringGrid(pts, selCombo.SelectedIndex);
            selIndex = selCombo.SelectedIndex;
            int type = 0, count = 0;

            StructureSetUtility.CalcTypeCount(selIndex, ref type, ref count, typeIndex);
            editBtn.Enabled = CheclEditBtnEnabled(type, count);
            FillDataGrid();
        }
示例#4
0
        private void UpdateSelectedGroup(List <Point> pts, bool alert = false)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;
            int index = listBox.SelectedIndex;

            int type = -1, count = 0;

            StructureSetUtility.CalcTypeCount(index, ref type, ref count, typeIndex);

            p.UpdateStructureSet(pts, type, count);
            mapPicBox.SetSelectedGrid(p.tBarSets, p.bridgePierSets, p.groundsillWorkSets, p.sedimentationWeirSets, type, count, alert);
        }
        private void edit_Click(object sender, EventArgs e)
        {
            int type = 0, count = 0;

            StructureSetUtility.CalcTypeCount(selIndex, ref type, ref count, typeIndex);
            if (type == (int)RiverSimulationProfile.StructureType.GroundSillWork || type == (int)RiverSimulationProfile.StructureType.SedimentationWeir)
            {
                StructureSetUtility.EditBottomElevation(p, "編輯" + structureName[type] + (1 + count).ToString() + "高程", type, count);
            }
            else
            {
                MessageBox.Show("此結構物不可編輯高程!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#6
0
        private void SetPicBoxGrid(int index, bool alert)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;

            mapPicBox.SelectGroup = true;

            if (onlySelectMode)
            {
                return;
            }

            int type = -1, count = 0;

            StructureSetUtility.CalcTypeCount(index, ref type, ref count, typeIndex);
            mapPicBox.SetSelectedGrid(p.tBarSets, p.bridgePierSets, p.groundsillWorkSets, p.sedimentationWeirSets, type, count, alert);
        }
        private void addBtn_Click(object sender, EventArgs e)
        {
            var selectedCellCount = dataGv.GetCellCount(DataGridViewElementStates.Selected);

            if (selectedCellCount <= 0)
            {
                return;
            }

            int type = 0, count = 0;

            StructureSetUtility.CalcTypeCount(selIndex, ref type, ref count, typeIndex);

            List <Point> pl = new List <Point>();     //表格內被選取的格網點

            for (int i = 0; i < selectedCellCount; ++i)
            {
                pl.Add(new Point(dataGv.SelectedCells[i].RowIndex, dataGv.SelectedCells[i].ColumnIndex));
            }

            List <Point> pts        = StructureSetUtility.GetStructureSet(p, type, count);
            List <Point> plSelected = (pts == null) ? null : new List <Point>(pts);

            if (null != plSelected)
            {   //正在編輯的結構物不為空則合併被選取的格網點到正在編輯的結構物中
                StructureSetUtility.MergePoints(ref plSelected, pl);
            }
            else
            {   //正在編輯的結構物還沒有任何格網點
                plSelected = new List <Point>(pl);
            }

            if (!StructureSetUtility.IsContinuous(plSelected))
            {   //檢查是否連續
                FillDataGrid(plSelected, true);
                MessageBox.Show("新增後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                FillDataGrid();
                return;
            }

            p.UpdateStructureSet(plSelected, type, count);

            FillDataGrid();
            dataGv.ClearSelection();
        }
示例#8
0
        private void mapPicBox_SelectedGroupChangedEvent(List <Point> pl)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;
            int index = listBox.SelectedIndex;

            if (onlySelectMode)
            {
                InputForm dlg = new InputForm();
                dlg.Text          = "填入數值";
                dlg.desc.Text     = "請輸入數值";
                dlg.inputTxt.Text = "";
                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return;
                }
                selectedPl        = new List <Point>(pl);
                selectedValue     = dlg.inputTxt.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
                return;
            }


            int type = -1, count = 0;

            StructureSetUtility.CalcTypeCount(index, ref type, ref count, typeIndex);

            //檢查連續
            if (!StructureSetUtility.IsContinuous(pl))
            {
                UpdateSelectedGroup(pl, true);
                MessageBox.Show("請圈選連續區域!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                UpdateSelectedGroup(null);
                return;
            }

            //檢查重疊
            for (int n = 0; n < StructureTypeNumber; ++n)
            {
                bool overlapping = false;
                switch (n)
                {
                case 0:
                    overlapping = CheckOverlapping(pl, p.tBarSets, (n == type) ? count : -1);
                    break;

                case 1:
                    overlapping = CheckOverlapping(pl, p.bridgePierSets, (n == type) ? count : -1);
                    break;

                case 2:
                    overlapping = CheckOverlapping(pl, p.groundsillWorkSets, (n == type) ? count : -1);
                    break;

                case 3:
                    overlapping = CheckOverlapping(pl, p.sedimentationWeirSets, (n == type) ? count : -1);
                    break;

                default:
                    break;
                }
                if (!overlapping)
                {
                    return;
                }
            }

            //最後確認 [20141121]更新客製化需求 回報問題 新增規格
            if (DialogResult.OK == MessageBox.Show("請確認以此次圈選範圍取代原先資料。", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.None))
            {
                UpdateSelectedGroup(pl);
            }
            //StructureSetUtility.EditBottomElevation(p, "編輯" + structureName[type] + (1 + count).ToString() + "高程", type, count);
            //if (StructureSetUtility.IsOverlapping(rg, pl, index))
            //{
            //    UpdateSelectedGroup(pl, true);
            //    if (DialogResult.Yes == MessageBox.Show("圈選到重覆區域,是否刪減重複範圍(選「否」將放棄此次圈選)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
            //    {
            //        StructureSetUtility.RemoveOverlapping(ref pl, rg, index);
            //        if (!StructureSetUtility.IsContinuous(pl))
            //        {
            //            UpdateSelectedGroup(pl, true);
            //            MessageBox.Show("刪減後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //            UpdateSelectedGroup(null);
            //            return;
            //        }
            //    }
            //    else
            //    {
            //        UpdateSelectedGroup(null);
            //        return;
            //    }
            //}

            //UpdateSelectedGroup(pl);
        }
 private bool CheclRemoveBtnEnabled(List <Point> pts, List <Point> pl)
 {
     return((pts == null) ? false : StructureSetUtility.IsAllInclude(pts, pl));
 }
示例#10
0
 private bool CheclEditBtnEnabled(int type, int count)
 {
     return((null != StructureSetUtility.GetStructureSet(p, type, count)) &&
            (type == (int)RiverSimulationProfile.StructureType.GroundSillWork || type == (int)RiverSimulationProfile.StructureType.SedimentationWeir));
 }
示例#11
0
        private void FillDataGrid(List <Point> newPl = null, bool alert = false, bool fillZ = false)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;
            var rg = p.inputGrid;

            int type = 0, count = 0;

            StructureSetUtility.CalcTypeCount(selIndex, ref type, ref count, typeIndex);

            Point pt = new Point();

            for (int i = 0; i < rg.GetI; ++i)
            {
                for (int j = 0; j < rg.GetJ; ++j)
                {
                    pt.X = i;
                    pt.Y = j;
                    Point grpId = StructureSetUtility.WhichGroup(p, pt, newPl, (newPl == null) ? -1 : type, (newPl == null) ? -1 : count);


                    Color cr;
                    if (grpId.X == -1 && grpId.Y == -1)
                    {   //空白處
                        cr = Color.White;
                        if (fillZ)
                        {
                            dataGv[j, i].Value    = p.inputGrid.inputCoor[i, j].z.ToString();
                            dataGv[j, i].ReadOnly = true;
                        }
                        else
                        {
                            dataGv[j, i].Value    = "";
                            dataGv[j, i].ReadOnly = true;
                        }
                    }
                    else if (grpId.X == type && grpId.Y == count)
                    {   //被選取的結構物
                        cr = (alert) ? alertColor : selectedColor;
                        if (fillZ)
                        {
                            dataGv[j, i].Value    = p.inputGrid.inputCoor[i, j].z.ToString();
                            dataGv[j, i].ReadOnly = false;
                        }
                        else
                        {
                            dataGv[j, i].Value    = structureName[grpId.X] + (grpId.Y + 1).ToString();
                            dataGv[j, i].ReadOnly = true;
                        }
                    }
                    else
                    {   //其他結構物
                        cr = colorTable[grpId.X % colorTable.Length];
                        if (fillZ)
                        {
                            dataGv[j, i].Value    = p.inputGrid.inputCoor[i, j].z.ToString();
                            dataGv[j, i].ReadOnly = false;
                        }
                        else
                        {
                            dataGv[j, i].Value    = structureName[grpId.X] + (grpId.Y + 1).ToString();
                            dataGv[j, i].ReadOnly = true;
                        }
                    }

                    dataGv[j, i].Style.BackColor = cr;
                }
            }
        }