Exemple #1
0
        public void Change_WholeRow(SelectionChangeOperation op, int row)
        {
            if ((cells_by_col != null) || (whole_columns != null))
            {
                mode_mismatch();
            }

            bool prev_state = contains_row(row);

            if (no_effect(op, prev_state))
            {
                return;
            }

            if (whole_rows == null)
            {
                whole_rows = new HashSet <int> ();
            }

            if (prev_state)
            {
                whole_rows.Remove(row);
            }
            else
            {
                whole_rows.Add(row);
            }

            notify_selection_changed(new SelectionChangedEventArgs(SelectionMode.WHOLE_ROW, -1, row, !prev_state));
        }
Exemple #2
0
        public void Change_Cell(SelectionChangeOperation op, int col, int row)
        {
            if ((whole_rows != null) || (whole_columns != null))
            {
                mode_mismatch();
            }

            bool prev_state = contains_cell(col, row);

            if (no_effect(op, prev_state))
            {
                return;
            }

            if (cells_by_col == null)
            {
                cells_by_col = new Dictionary <int, HashSet <int> > ();
            }

            if (!cells_by_col.ContainsKey(col))
            {
                cells_by_col [col] = new HashSet <int> ();
            }

            if (prev_state)
            {
                cells_by_col [col].Remove(row);
            }
            else
            {
                cells_by_col [col].Add(row);
            }

            notify_selection_changed(new SelectionChangedEventArgs(SelectionMode.CELLS, col, row, !prev_state));
        }
Exemple #3
0
        public void Change_WholeColumn(SelectionChangeOperation op, int col)
        {
            if ((whole_rows != null) || (cells_by_col != null))
            {
                mode_mismatch();
            }

            bool prev_state = contains_col(col);

            if (no_effect(op, prev_state))
            {
                return;
            }

            if (whole_columns == null)
            {
                whole_columns = new HashSet <int> ();
            }

            if (prev_state)
            {
                whole_columns.Remove(col);
            }
            else
            {
                whole_columns.Add(col);
            }

            notify_selection_changed(new SelectionChangedEventArgs(SelectionMode.WHOLE_COLUMN, col, -1, !prev_state));
        }
Exemple #4
0
        private bool no_effect(SelectionChangeOperation op, bool prev_state)
        {
            if (SelectionChangeOperation.TOGGLE == op)
            {
                return(false);
            }

            if ((SelectionChangeOperation.SELECT == op) && prev_state)
            {
                return(true);
            }

            if ((SelectionChangeOperation.UNSELECT == op) && !prev_state)
            {
                return(true);
            }

            return(false);
        }