using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using IEditableObject = DelftTools.Utils.Editing.IEditableObject; namespace DelftTools.Controls { /// /// Graphical representation of tabular data /// public interface ITableView : IView, ISynchronizeInvoke { event EventHandler SelectionChanged; event EventHandler FocusedRowChanged; /// /// Specifies whether it is possible to remove rows /// bool AllowDeleteRow { get; set; } /// /// Specifies whether it is possible to add new rows /// bool AllowAddNewRow { get; set; } /// /// Specifies whether it is possible to sort the columns /// bool AllowColumnSorting { get; set; } bool ColumnAutoWidth { get; set; } /// /// Determines whether the table view generates columns when /// setting data /// bool AutoGenerateColumns { get; set; } /// /// Grid will be read only: just for displaying the data /// bool ReadOnly { get; set; } /// /// Gets a Boolean value indicating that the view is being edited or not /// bool IsEditing { get; } /// /// Allows the user to edit multiple cells simultaneously using CTRL-ENTER like Excel. /// bool MultipleCellEdit { get; set; } /// /// TODO: If RowSelect is true, gridView.GetSelectedCells etc will give an empty array.... SelectedRows will still work. /// bool RowSelect { get; set; } /// /// Gets or sets whether multiple rows can be selected /// bool MultiSelect { get; set; } /// /// Gets or sets whether column captions are copied to the clipboard, when CTRL+C is pressed /// bool IncludeHeadersOnCopy { get; set; } /// /// Number of rows in the grid excluding the newrow and filtered rows. /// int RowCount { get; } /// /// Sets and gets the zero-based index of the focused row in the visualized table. /// ///A value of 1 corresponds to the 2nd entry as shown in the table (sorted, filtered, etc). int FocusedRowIndex { get; set; } /// /// Retrieve selected row indexes (when using multi-select). /// TODO: Turn this into a method! /// int[] SelectedRowsIndices { get; } /// /// Returns the focused row (also works if the focused row is new or deleted) /// object CurrentFocusedRowObject { get; } /// /// Gets or sets the disabled cell fore color /// Color ReadOnlyCellForeColor { get; set; } /// /// Gets or sets the disabled cell fore color /// Color ReadOnlyCellBackColor { get; set; } /// /// Gets or sets the background color of the invalid cell (value) /// Color InvalidCellBackgroundColor { get; set; } ITableViewPasteController PasteController { get; set; } /// /// Return the for the given index. /// IList Columns { get; } /// /// Contains collection of selected cells. Allows to add, remove selected cells. /// IList SelectedCells { get; } Func> InputValidator { get; set; } /// /// Gets or sets the row values validator. The validator should return a RowValidationResult /// Func RowValidator { get; set; } /// /// Allow the pinning of columns (default is true) /// bool AllowColumnPinning { get; set; } /// /// Commit row at enter. /// bool IsEndEditOnEnterKey { get; set; } /// /// If data is not editable object it's owner is, this should be set to it. /// IEditableObject EditableObject { get; set; } /// /// Allows to fit all columns to their contents. /// void BestFitColumns(bool useOnlyFirstWordOfHeader = true); /// /// Select row on index /// /// index /// void SelectRow(int index, bool clearPreviousSelection = true); /// /// Select multiple rows on index /// void SelectRows(int[] indices, bool clearPreviousSelection = true); /// /// Updates the SelectedCells to a rectangle top,left,bottom,right /// void SelectCells(int top, int left, int bottom, int right, bool clearOldSelection = true); /// /// Clears the current selection /// void ClearSelection(); /// /// Deletes the content of the current selection /// void DeleteCurrentSelection(); /// /// Set the value of a certain cell /// bool SetCellValue(int rowIndex, int columnIndex, object value); /// /// Sets a number of values in a certain row. Can be faster than SetCellValue because validation and end edit is done after /// all values are set. /// bool SetRowCellValues(int rowIndex, int columnDisplayStartIndex, object[] cellValues); /// /// Updates grid cells using current data source. /// void RefreshData(); /// /// Sets render required to true. Updates are done by timer /// void ScheduleRefresh(); /// /// Converts the displayRowIndex (used in events) to the dataSourceRowIndex /// ///The zero-based index of row in the table ///The matching zero-based index in the data source int GetDataSourceIndexByRowIndex(int rowIndex); /// /// Converts the zero-based data source index to the zero-based index of the row in the table /// ///The zero based index in the data source ///The zero-based index as visualized in the table int GetRowIndexByDataSourceIndex(int dataSourceIndex); /// /// Gets value of a certain cell. /// /// Row index of the cell /// Absolute index of the column object GetCellValue(int rowIndex, int absoluteColumnIndex); /// /// Gets value of a certain cell. /// object GetCellValue(TableViewCell cell); ITableViewColumn GetColumnByName(string columnName); } }