Esempio n. 1
0
        private void removeBtn_Click(object sender, EventArgs e)
        {
            var selectedCellCount = dataGv.GetCellCount(DataGridViewElementStates.Selected);

            if (selectedCellCount <= 0)
            {
                return;
            }

            int index = selCombo.SelectedIndex;
            int type = 0, count = 0;

            GetTypeAndCount(index, ref type, ref count);

            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        = (type == 0) ? sideOutObjects[count].sideFlowPoints : sideInObjects[count].sideFlowPoints;
            List <Point> plSelected = (pts == null) ? null : new List <Point>(pts);

            SideFlowtUtility.RemovePoints(ref plSelected, pl);

            if (!SideFlowtUtility.IsContinuous(plSelected))
            {
                FillDataGrid(plSelected, true);
                MessageBox.Show("刪減後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                FillDataGrid();
                return;
            }

            if (type == 0)
            {
                sideOutObjects[count].sideFlowPoints = plSelected;
            }
            else
            {
                sideInObjects[count].sideFlowPoints = plSelected;
            }

            FillDataGrid();
            dataGv.ClearSelection();
        }