/// <summary> /// Replaces the currently selected Cells with the Cell at the specified CellPos /// </summary> /// <param name="cellPos">A CellPos thst specifies the row and column indicies of /// the Cell to be selected</param> public void SelectCell(CellPos cellPos) { this.SelectCell(cellPos.Row, cellPos.Column); }
/// <summary> /// Replaces the currently selected Cells with the Cells located between the specified /// start and end CellPos /// </summary> /// <param name="start">A CellPos that specifies the start Cell</param> /// <param name="end">A CellPos that specifies the end Cell</param> public void SelectCells(CellPos start, CellPos end) { this.SelectCells(start.Row, start.Column, end.Row, end.Column); }
/// <summary> /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public virtual bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { // this.cell = cell; this.table = table; this.cellPos = cellPos; this.cellRect = cellRect; // check if the user has already set the editors value for us if (!userSetEditorValues) { this.SetEditValue(); } this.SetEditLocation(cellRect); // raise the BeginEdit event CellEditEventArgs e = new CellEditEventArgs(cell, this, table, cellPos.Row, cellPos.Column, cellRect); e.Handled = userSetEditorValues; this.OnBeginEdit(e); // if the edit has been canceled, remove the editor and return false if (e.Cancel) { this.RemoveEditControl(); return false; } return true; }
/// <summary> /// Initializes a new instance of the TableModel.Selection class /// that belongs to the specified TableModel /// </summary> /// <param name="owner">A TableModel representing the tableModel that owns /// the Selection</param> public Selection(TableModel owner) { if (owner == null) { throw new ArgumentNullException("owner", "owner cannot be null"); } this.owner = owner; this.rows = new ArrayList(); this.shiftSelectStart = CellPos.Empty; this.shiftSelectEnd = CellPos.Empty; }
/// <summary> /// Adds the Cells between the last selection start Cell and the Cell at the /// specified row/column indicies to the current selection. Any Cells that are /// between the last start and end Cells that are not in the new area are /// removed from the current selection /// </summary> /// <param name="row">The row index of the shift selected Cell</param> /// <param name="column">The column index of the shift selected Cell</param> public void AddShiftSelectedCell(int row, int column) { int[] oldSelectedIndicies = this.SelectedIndicies; if (this.shiftSelectStart == CellPos.Empty) { this.shiftSelectStart = new CellPos(0, 0); } bool changed = false; if (this.shiftSelectEnd != CellPos.Empty) { changed = this.InternalRemoveCells(this.shiftSelectStart, this.shiftSelectEnd); changed |= this.InternalAddCells(this.shiftSelectStart, new CellPos(row, column)); } else { changed = this.InternalAddCells(0, 0, row, column); } if (changed) { this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies)); } this.shiftSelectEnd = new CellPos(row, column); }
/// <summary> /// Removes all selected Rows and Cells from the selection /// </summary> public void Clear() { if (this.rows.Count > 0) { int[] oldSelectedIndicies = this.SelectedIndicies; this.InternalClear(); this.shiftSelectStart = CellPos.Empty; this.shiftSelectEnd = CellPos.Empty; this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies)); } }
/// <summary> /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { // if (!(table.ColumnModel.Columns[cellPos.Column] is NumberColumn)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn"); } if (!(table.ColumnModel.GetCellRenderer(cellPos.Column) is NumberCellRenderer)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn that uses a NumberCellRenderer"); } this.Minimum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Minimum; this.Maximum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Maximum; this.Increment = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Increment; return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues); }
/// <summary> /// Adds the Cells located between the specified start and end CellPos to the /// current selection /// </summary> /// <param name="start">A CellPos that specifies the start Cell</param> /// <param name="end">A CellPos that specifies the end Cell</param> public void AddCells(CellPos start, CellPos end) { this.AddCells(start.Row, start.Column, end.Row, end.Column); }
/// <summary> /// Initializes a new instance of the CellKeyEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="kea"></param> public CellKeyEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Gets whether the specified Table is using a NumericCellEditor to edit the /// Cell at the specified CellPos /// </summary> /// <param name="table">The Table to check</param> /// <param name="cellPos">A CellPos that represents the Cell to check</param> /// <returns>true if the specified Table is using a NumericCellEditor to edit the /// Cell at the specified CellPos, false otherwise</returns> internal bool TableUsingNumericCellEditor(Table table, CellPos cellPos) { return (table.IsEditing && cellPos == table.EditingCell && table.EditingCellEditor is NumberCellEditor); }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="mea"></param> public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, MouseEventArgs mea) : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Conceals the editor from the user and removes it from the Table's /// Control collection /// </summary> protected virtual void RemoveEditControl() { this.control.Visible = false; this.control.Parent = null; this.table.Focus(); this.cell = null; this.table = null; this.cellPos = CellPos.Empty; this.cellRect = Rectangle.Empty; }
/// <summary> /// Adds the Cell at the specified row and column indicies to the current selection /// </summary> /// <param name="cellPos">A CellPos that specifies the Cell to add to the selection</param> public void AddCell(CellPos cellPos) { this.AddCell(cellPos.Row, cellPos.Column); }
/// <summary> /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { if (!(table.ColumnModel.Columns[cellPos.Column] is DropDownColumn)) { throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn"); } return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues); }
/// <summary> /// Adds the Cells located between the specified start and end row/column indicies /// to the current selection /// </summary> /// <param name="startRow">The row index of the start Cell</param> /// <param name="startColumn">The column index of the start Cell</param> /// <param name="endRow">The row index of the end Cell</param> /// <param name="endColumn">The column index of the end Cell</param> public void AddCells(int startRow, int startColumn, int endRow, int endColumn) { int[] oldSelectedIndicies = this.SelectedIndicies; if (InternalAddCells(startRow, startColumn, endRow, endColumn)) { this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies)); } this.shiftSelectStart = new CellPos(startRow, startColumn); this.shiftSelectEnd = new CellPos(endRow, endColumn); }
/// <summary> /// Removes the Cells located between the specified start and end CellPos from the /// current selection /// </summary> /// <param name="start">A CellPos that specifies the start Cell</param> /// <param name="end">A CellPos that specifies the end Cell</param> public void RemoveCells(CellPos start, CellPos end) { this.RemoveCells(start.Row, start.Column, end.Row, end.Column); }
/// <summary> /// Adds the Cells located between the specified start and end CellPos to the /// current selection without raising an event /// </summary> /// <param name="start">A CellPos that specifies the start Cell</param> /// <param name="end">A CellPos that specifies the end Cell</param> /// <returns>true if any Cells were added, false otherwise</returns> private bool InternalAddCells(CellPos start, CellPos end) { return this.InternalAddCells(start.Row, start.Column, end.Row, end.Column); }
/// <summary> /// Returns whether the Cell at the specified CellPos is currently selected /// </summary> /// <param name="cellPos">A CellPos the represents the row and column indicies /// of the Cell to check</param> /// <returns>true if the Cell at the specified CellPos is currently selected, /// false otherwise</returns> public bool IsCellSelected(CellPos cellPos) { return this.IsCellSelected(cellPos.Row, cellPos.Column); }
/// <summary> /// Adds the Cells between the last selection start Cell and the Cell at the /// specified CellPas to the current selection. Any Cells that are /// between the last start and end Cells that are not in the new area are /// removed from the current selection /// </summary> /// <param name="cellPos">A CellPos that specifies the shift selected Cell</param> public void AddShiftSelectedCell(CellPos cellPos) { this.AddShiftSelectedCell(cellPos.Row, cellPos.Column); }
public Cell this[CellPos cellPos] { get { return this[cellPos.Row, cellPos.Column]; } }
/// <summary> /// Removes the Cell at the specified row and column indicies from the current selection /// </summary> /// <param name="cellPos">A CellPos that specifies the Cell to remove from the selection</param> public void RemoveCell(CellPos cellPos) { this.RemoveCell(cellPos.Row, cellPos.Column); }
/// <summary> /// Initializes a new instance of the CellEditor class with default settings /// </summary> protected CellEditor() { this.control = null; this.cell = null; this.table = null; this.cellPos = CellPos.Empty; this.cellRect = Rectangle.Empty; this.mouseMessageFilter = new MouseMessageFilter(this); this.keyMessageFilter = new KeyMessageFilter(this); }