예제 #1
0
        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 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();
        }
예제 #3
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));
 }