/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="editor">The CellEditor used to edit the Cell</param> /// <param name="table">The Table that the Cell belongs to</param> /// <param name="row">The Column index of the Cell</param> /// <param name="column">The Row index of the Cell</param> /// <param name="cellRect"></param> public CellEditEventArgs(Cell source, ICellEditor editor, Table table, int row, int column, Rectangle cellRect) : base(source, column, row) { this.editor = editor; this.table = table; this.cellRect = cellRect; this.cancel = false; }
/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="editor">The CellEditor used to edit the Cell</param> /// <param name="table">The Table that the Cell belongs to</param> /// <param name="row">The Column index of the Cell</param> /// <param name="column">The Row index of the Cell</param> /// <param name="cellRect"></param> public CellEditEventArgs(Cell source, ICellEditor editor, HTable table, int row, int column, Gdk.Rectangle cellRect) : base(source, column, row) { this.editor = editor; this.table = table; this.cellRect = cellRect; this.cancel = false; }
/// <summary> /// Associates the specified ICellRenderer with the specified name /// </summary> /// <param name="name">The name to be associated with the specified ICellEditor</param> /// <param name="editor">The ICellEditor to be added to the ColumnModel</param> public void SetCellEditor(string name, ICellEditor editor) { if (name == null || name.Length == 0 || editor == null) { return; } name = name.ToUpper(); if (this.cellEditors.ContainsKey(name)) { this.cellEditors.Remove(name); } this.cellEditors.Add(name, editor); }
/// <summary> /// Initialise default values /// </summary> private void Init() { this.text = null; this.width = Column.DefaultWidth; this.columnState = ColumnState.Normal; this.alignment = ColumnAlignment.Left; this.image = null; this.imageOnRight = false; this.columnModel = null; this.x = 0; this.tooltipText = null; this.format = ""; this.sortOrder = SortOrder.None; this.renderer = null; this.editor = null; this.comparer = null; this.state = (byte)(STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE); }
/// <summary> /// Initialise default values /// </summary> private void Init() { this.text = null; this.width = Column.DefaultWidth; this.columnState = ColumnState.Normal; this.alignment = ColumnAlignment.Left; this.image = null; this.imageOnRight = false; this.columnModel = null; this.x = 0; this.tooltipText = null; this.format = ""; this.sortOrder = SortOrder.None; this.renderer = null; this.editor = null; this.comparer = null; // Mateusz [PEYN] Adamus ([email protected]) // Added STATE_RESIZABLE to column's initialization this.state = (byte)(STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE | STATE_RESIZABLE); }
/// <summary> /// Cancels editing the current Cell and ignores any changes /// </summary> public void CancelEditing() { // don't bother if we're not editing if (this.EditingCell == CellPos.Empty) { return; } this.EditingCellEditor.CancelEditing(); this.editingCell = CellPos.Empty; this.curentCellEditor = null; }
/*/// <summary> /// Stops editing the current Cell and starts editing the next editable Cell /// </summary> /// <param name="forwards">Specifies whether the editor should traverse /// forward when looking for the next editable Cell</param> protected internal void EditNextCell(bool forwards) { if (this.EditingCell == CellPos.Empty) { return; } CellPos nextCell = this.FindNextEditableCell(this.FocusedCell, true, forwards, false); if (nextCell != CellPos.Empty && nextCell != this.EditingCell) { this.StopEditing(); this.EditCell(nextCell); } }*/ /// <summary> /// Stops editing the current Cell and commits any changes /// </summary> public void StopEditing() { // don't bother if we're not editing if (this.EditingCell == CellPos.Empty) { return; } this.EditingCellEditor.StopEditing(); this.Invalidate(this.RowRect(this.editingCell.Row)); this.editingCell = CellPos.Empty; this.curentCellEditor = null; }
/// <summary> /// Starts editing the Cell at the specified CellPos /// </summary> /// <param name="cellPos">A CellPos that specifies the Cell to be edited</param> public void EditCell(CellPos cellPos) { // don't bother if the cell doesn't exists or the cell's // column is not visible or the cell is not editable if (!this.IsValidCell(cellPos) || !this.ColumnModel.Columns[cellPos.Column].Visible || !this.IsCellEditable(cellPos)) { return; } // check if we're currently editing a cell if (this.EditingCell != CellPos.Empty) { // don't bother if we're already editing the cell. // if we're editing a different cell stop editing if (this.EditingCell == cellPos) { return; } else { this.EditingCellEditor.StopEditing(); } } Cell cell = this.TableModel[cellPos]; ICellEditor editor = this.ColumnModel.GetCellEditor(cellPos.Column); // make sure we have an editor and that the cell // and the cell's column are editable if (editor == null || !cell.Editable || !this.ColumnModel.Columns[cellPos.Column].Editable) { return; } if (this.EnsureVisible(cellPos)) { this.Refresh(); } Rectangle cellRect = this.CellRect(cellPos); // give anyone subscribed to the table's BeginEditing // event the first chance to cancel editing CellEditEventArgs e = new CellEditEventArgs(cell, editor, this, cellPos.Row, cellPos.Column, cellRect); this.OnBeginEditing(e); // if (!e.Cancel) { // get the editor ready for editing. if PrepareForEditing // returns false, someone who subscribed to the editors // BeginEdit event has cancelled editing if (!editor.PrepareForEditing(cell, this, cellPos, cellRect, e.Handled)) { return; } // keep track of the editing cell and editor // and start editing this.editingCell = cellPos; this.curentCellEditor = editor; editor.StartEditing(); } }
/// <summary> /// Records the Cell that is currently being edited and the /// ICellEditor used to edit the Cell /// </summary> /// <param name="cellPos">The Cell that is currently being edited</param> /// <param name="editor">The ICellEditor used to edit the Cell</param> private void SetEditingCell(CellPos cellPos, ICellEditor editor) { this.editingCell = cellPos; this.curentCellEditor = editor; }
public void SetCellEditor(ICellEditor editor) { this.editor = editor; }
/// <summary> /// Initializes a new instance of the NumericCellEditEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source"></param> /// <param name="editor"></param> /// <param name="table"></param> /// <param name="row"></param> /// <param name="column"></param> /// <param name="cellRect"></param> /// <param name="oldValue"></param> public NumericCellEditEventArgs(Cell source, ICellEditor editor, Table table, int row, int column, Rectangle cellRect, decimal oldValue) : base(source, editor, table, row, column, cellRect) { this.oldValue = oldValue; this.newValue = oldValue; }
/// <summary> /// Associates the specified ICellRenderer with the specified name /// </summary> /// <param name="name">The name to be associated with the specified ICellEditor</param> /// <param name="editor">The ICellEditor to be added to the ColumnModel</param> public void SetCellEditor(string name, ICellEditor editor) { if (name == null || name.Length == 0 || editor == null) { return; } name = name.ToUpper(); if (this.cellEditors.ContainsKey(name)) { this.cellEditors.Remove(name); this.cellEditors[name] = editor; } else { this.cellEditors.Add(name, editor); } }
/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="editor">The CellEditor used to edit the Cell</param> /// <param name="table">The Table that the Cell belongs to</param> public CellEditEventArgs(Cell source, ICellEditor editor, HTable table) : this(source, editor, table, -1, -1, Gdk.Rectangle.Zero) { }
/*/// <summary> /// Specifies whether pressing the Tab key while editing moves the /// editor to the next available cell /// </summary> private bool tabMovesEditor;*/ #endregion #endregion #region Constructor /// <summary> /// Initializes a new instance of the Table class with default settings /// </summary> public Table() { // starting setup this.init = true; // This call is required by the Windows.Forms Form Designer. components = new System.ComponentModel.Container(); // this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Selectable, true); this.TabStop = true; this.Size = new Size(150, 150); this.BackColor = Color.White; // this.columnModel = null; this.tableModel = null; // header this.headerStyle = ColumnHeaderStyle.Clickable; this.headerFont = this.Font; this.headerRenderer = new XPHeaderRenderer(); //this.headerRenderer = new GradientHeaderRenderer(); //this.headerRenderer = new FlatHeaderRenderer(); this.headerRenderer.Font = this.headerFont; this.headerContextMenu = new HeaderContextMenu(); this.columnResizing = true; this.resizingColumnIndex = -1; this.resizingColumnWidth = -1; this.hotColumn = -1; this.pressedColumn = -1; this.lastSortedColumn = -1; this.sortedColumnBackColor = Color.WhiteSmoke; // borders this.borderStyle = BorderStyle.Fixed3D; // scrolling this.scrollable = true; this.hScrollBar = new HScrollBar(); this.hScrollBar.Visible = false; this.hScrollBar.Location = new Point(this.BorderWidth, this.Height - this.BorderWidth - SystemInformation.HorizontalScrollBarHeight); this.hScrollBar.Width = this.Width - (this.BorderWidth * 2) - SystemInformation.VerticalScrollBarWidth; this.hScrollBar.Scroll += new ScrollEventHandler(this.OnHorizontalScroll); this.Controls.Add(this.hScrollBar); this.vScrollBar = new VScrollBar(); this.vScrollBar.Visible = false; this.vScrollBar.Location = new Point(this.Width - this.BorderWidth - SystemInformation.VerticalScrollBarWidth, this.BorderWidth); this.vScrollBar.Height = this.Height - (this.BorderWidth * 2) - SystemInformation.HorizontalScrollBarHeight; this.vScrollBar.Scroll += new ScrollEventHandler(this.OnVerticalScroll); this.Controls.Add(this.vScrollBar); // this.gridLines = GridLines.None;; this.gridColor = SystemColors.Control; this.gridLineStyle = GridLineStyle.Solid; this.allowSelection = true; this.multiSelect = false; this.fullRowSelect = false; this.hideSelection = false; this.selectionBackColor = SystemColors.Highlight; this.selectionForeColor = SystemColors.HighlightText; this.unfocusedSelectionBackColor = SystemColors.Control; this.unfocusedSelectionForeColor = SystemColors.ControlText; this.selectionStyle = SelectionStyle.ListView; this.alternatingRowColor = Color.Transparent; // current table state this.tableState = TableState.Normal; this.lastMouseCell = new CellPos(-1, -1); this.lastMouseDownCell = new CellPos(-1, -1); this.focusedCell = new CellPos(-1, -1); this.hoverTime = 1000; this.trackMouseEvent = null; this.ResetMouseEventArgs(); this.toolTip = new ToolTip(this.components); this.toolTip.Active = false; this.toolTip.InitialDelay = 1000; this.noItemsText = "There are no items in this view"; this.editingCell = new CellPos(-1, -1); this.curentCellEditor = null; this.editStartAction = EditStartAction.DoubleClick; this.customEditKey = Keys.F5; //this.tabMovesEditor = true; // finished setting up this.beginUpdateCount = 0; this.init = false; this.preview = false; }
/// <summary> /// Initialise default values /// </summary> private void Init() { this.text = null; this.width = Column.DefaultWidth; this.columnState = ColumnState.Normal; this.alignment = ColumnAlignment.Left; this.image = null; this.imageOnRight = false; this.columnModel = null; this.x = 0; this.tooltipText = null; this.format = ""; this.sortOrder = SortOrder.None; this.renderer = null; this.editor = null; this.comparer = null; // Mateusz [PEYN] Adamus ([email protected]) // Added STATE_RESIZABLE to column's initialization this.state = (byte) (STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE | STATE_RESIZABLE ); }
/// <summary> /// Initialise default values /// </summary> private void Init() { this.text = null; this.width = Column.DefaultWidth; this.columnState = ColumnState.Normal; this.alignment = ColumnAlignment.Left; this.image = null; this.imageOnRight = false; this.columnModel = null; this.x = 0; this.tooltipText = null; this.format = ""; this.sortOrder = SortOrder.None; this.renderer = null; this.editor = null; this.comparer = null; this.state = (byte) (STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE); }
/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="editor">The CellEditor used to edit the Cell</param> /// <param name="table">The Table that the Cell belongs to</param> public CellEditEventArgs(Cell source, ICellEditor editor, Table table) : this(source, editor, table, -1, -1, Rectangle.Empty) { }
/// <summary> /// Initializes a new instance of the NumericCellEditEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source"></param> /// <param name="editor"></param> /// <param name="table"></param> /// <param name="row"></param> /// <param name="column"></param> /// <param name="cellRect"></param> /// <param name="oldValue"></param> public DoubleCellEditEventArgs(Cell source, ICellEditor editor, Table table, int row, int column, Rectangle cellRect, double oldValue) : base(source, editor, table, row, column, cellRect) { this.OldValue = oldValue; this.NewValue = oldValue; }
/// <summary> /// Records the Cell that is currently being edited and the /// ICellEditor used to edit the Cell /// </summary> /// <param name="cell">The Cell that is currently being edited</param> /// <param name="editor">The ICellEditor used to edit the Cell</param> private void SetEditingCell(Cell cell, ICellEditor editor) { this.SetEditingCell(new CellPos(cell.Row.InternalIndex, cell.InternalIndex), editor); }