/// <summary> /// Initializes a new instance of the CellCollection class /// that belongs to the specified Row /// </summary> /// <param name="owner">A Row representing the row that owns /// the Cell collection</param> public CellCollection(Row owner) : base() { if (owner == null) { throw new ArgumentNullException("owner"); } this.owner = owner; }
private void FillGrid() { Table table = this.tablePlugIns; // The Table control on a form - already initialised MotionPlugIns ps = new MotionPlugIns(); foreach (AvailablePlugIn<IPlugIn> p in ps.AvailablePlugInCollection) { Row row = new Row(); row.Cells.Add(new Cell(ps.GetPlugInCategory(p.Instance))); row.Cells.Add(new Cell(p.Instance.Name)); row.Cells.Add(new Cell(p.Instance.Author)); row.Cells.Add(new Cell(p.Instance.Version)); row.Cells.Add(new Cell(p.Instance.Description)); row.Cells.Add(new Cell(p.AssemblyPath)); table.TableModel.Rows.Add(row); } table.ColumnModel.ResizeColumnWidth(); }
/// <summary> /// Initialise default values /// </summary> private void Init() { this.text = null; this.data = null; this.rendererData = null; this.tag = null; this.row = null; this.index = -1; this.cellStyle = null; this.checkStyle = null; this.imageStyle = null; this.tooltipText = null; this.colspan = 1; this.state = (byte)(STATE_EDITABLE | STATE_ENABLED); }
/// <summary> /// Initializes a new instance of the TableModel class with an array of Row objects /// </summary> /// <param name="rows">An array of Row objects that represent the Rows /// of the TableModel</param> public TableModel(Row[] rows) { if (rows == null) { throw new ArgumentNullException("rows", "Row[] cannot be null"); } this.Init(); if (rows.Length > 0) { this.Rows.AddRange(rows); } }
/// <summary> /// Initializes a new instance of the RowEventArgs class with /// the specified Row source, row index, start index, end index /// and affected Cell /// </summary> /// <param name="source">The Row that originated the event</param> /// <param name="rowIndex">The index of the Row</param> /// <param name="cell">The affected Cell</param> /// <param name="cellFromIndex">The start index of the affected Cell(s)</param> /// <param name="cellToIndex">The end index of the affected Cell(s)</param> /// <param name="eventType">The type of event</param> public RowEventArgs(Row source, int rowIndex, Cell cell, int cellFromIndex, int cellToIndex, RowEventType eventType) : base() { this.source = source; this.rowIndex = rowIndex; this.cell = cell; this.cellFromIndex = cellFromIndex; this.cellToIndex = cellToIndex; this.eventType = eventType; }
/// <summary> /// Returns the bounding rectangle of the specified row /// in client coordinates /// </summary> /// <param name="row">The row</param> /// <returns>The bounding rectangle of the specified /// row</returns> public Rectangle RowRect(Row row) { if (this.TableModel == null) { return Rectangle.Empty; } return this.RowRect(this.TableModel.Rows.IndexOf(row)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public void AddColumns(ColumnModel model) { this.model = model; CellStyle cellStyle = new CellStyle(); cellStyle.Padding = new CellPadding(6, 0, 0, 0); this.columnTable.BeginUpdate(); for (int i=0; i<model.Columns.Count; i++) { Row row = new Row(); Cell cell = new Cell(model.Columns[i].Text, model.Columns[i].Visible); cell.Tag = model.Columns[i].Width; cell.CellStyle = cellStyle; row.Cells.Add(cell); this.columnTable.TableModel.Rows.Add(row); } this.columnTable.SelectionChanged += new XPTable.Events.SelectionEventHandler(columnTable_SelectionChanged); this.columnTable.CellCheckChanged += new XPTable.Events.CellCheckBoxEventHandler(columnTable_CellCheckChanged); if (this.columnTable.VScroll) { this.columnTable.ColumnModel.Columns[0].Width -= SystemInformation.VerticalScrollBarWidth; } if (this.columnTable.TableModel.Rows.Count > 0) { this.columnTable.TableModel.Selections.SelectCell(0, 0); this.showButton.Enabled = !this.model.Columns[0].Visible; this.hideButton.Enabled = this.model.Columns[0].Visible; this.widthTextBox.Text = this.model.Columns[0].Width.ToString(); } this.columnTable.EndUpdate(); }
protected virtual Row ListAdd(UpdateSite us) { Table table = this.tableList; // The Table control on a form - already initialised Row row = new Row( new Cell[] { new Cell(us.Description), new Cell(us.URL) } ); row.Tag = us; table.TableModel.Rows.Add(row); this.AutosizeColumnWidth(); return row; }
/// <summary> /// Inserts an array of Rows into the collection at the specified /// index /// </summary> /// <param name="index">The zero-based index at which the rows /// should be inserted</param> /// <param name="rows">The array of Rows to be inserted into /// the collection</param> public void InsertRange(int index, Row[] rows) { if (rows == null) { throw new System.ArgumentNullException("Row[] is null"); } if (index < 0) { throw new IndexOutOfRangeException(); } if (index >= this.Count) { this.AddRange(rows); } else { for (int i=rows.Length-1; i>=0; i--) { this.Insert(index, rows[i]); } } }
/// <summary> /// Inserts a Row into the collection at the specified index /// </summary> /// <param name="index">The zero-based index at which the Row /// should be inserted</param> /// <param name="row">The Row to insert</param> public void Insert(int index, Row row) { if (row == null) { return; } if (index < 0) { throw new IndexOutOfRangeException(); } if (index >= this.Count) { this.Add(row); } else { base.List.Insert(index, row); if (owner != null) this.owner.OnRowAdded(new TableModelEventArgs(this.owner, row, index, index)); else if (rowowner != null) this.OnRowAdded(new RowEventArgs(row, RowEventType.Unknown)); } }
/// <summary> /// Returns the index of the specified Row in the model /// </summary> /// <param name="row">The Row to look for</param> /// <returns>The index of the specified Row in the model</returns> public int IndexOf(Row row) { for (int i=0; i<this.Count; i++) { if (this[i] == row) { return i; } } return -1; }
/// <summary> /// Adds the specified Row to the end of the collection /// </summary> /// <param name="row">The Row to add</param> public int Add(Row row) { if (row == null) { throw new System.ArgumentNullException("Row is null"); } int index = this.List.Add(row); if (owner != null) this.OnRowAdded(new TableModelEventArgs(this.owner, row, index, index)); else if (rowowner != null) { // this is a sub row, so it needs a parent row.Parent = rowowner; row.ChildIndex = this.List.Count; this.OnRowAdded(new RowEventArgs(row, RowEventType.Unknown)); } return index; }
/// <summary> /// Initializes a new instance of the TableModelEventArgs class with /// the specified TableModel source, start index, end index and affected Column /// </summary> /// <param name="source">The TableModel that originated the event</param> /// <param name="row">The affected Row</param> /// <param name="fromIndex">The start index of the affected Row(s)</param> /// <param name="toIndex">The end index of the affected Row(s)</param> public TableModelEventArgs(TableModel source, Row row, int fromIndex, int toIndex) { this.source = source; this.row = row; this.fromIndex = fromIndex; this.toIndex = toIndex; }
protected virtual Row ListAdd(LogItem log) { Table table = this.tableList; // The Table control on a form - already initialised Cell s = new Cell(log.Message); Cell c; switch (log.Level) { case LogLevel.LOG_ERROR: c = new Cell(Translator.Instance.T("����"), global::ZForge.Controls.Logs.Properties.Resources.scroll_error_16); s.ForeColor = Color.Red; c.ForeColor = s.ForeColor; this.CountError++; break; case LogLevel.LOG_WARNING: c = new Cell(Translator.Instance.T("����"), global::ZForge.Controls.Logs.Properties.Resources.scroll_warning_16); s.ForeColor = Color.SteelBlue; c.ForeColor = s.ForeColor; this.CountWarn++; break; default: c = new Cell(Translator.Instance.T("��Ϣ"), global::ZForge.Controls.Logs.Properties.Resources.scroll_information_16); s.ForeColor = Color.Green; c.ForeColor = s.ForeColor; this.CountInfo++; break; } Row row = new Row( new Cell[] { c, new Cell(log.Timestamp.ToString()), s } ); row.Tag = log; table.TableModel.Rows.Add(row); return row; }
/// <summary> /// Compares two rows and returns a value indicating whether one is less /// than, equal to or greater than the other. /// Compares the given rows without considering parent/sub-rows. /// </summary> /// <param name="row1"></param> /// <param name="row2"></param> /// <param name="column"></param> /// <param name="comparer"></param> /// <returns></returns> protected virtual int CompareRows(Row row1, Row row2, int column, IComparer comparer) { Cell cell1 = row1.Cells[column]; Cell cell2 = row2.Cells[column]; // check for null cells if (cell1 == null && cell2 == null) { return 0; } else if (cell1 == null) { return -1; } else if (cell2 == null) { return 1; } int result = comparer.Compare(cell1, cell2); return result; }
/// <summary> /// Replaces the Row in the TableModel located at index a with the specified Row /// </summary> /// <param name="a">The index of the Row that will be replaced</param> /// <param name="row">The Row that will be moved to index a</param> protected void Set(int a, Row row) { this.TableModel.Rows.SetRow(a, row); }
/// <summary> /// Removes the specified Row from the model /// </summary> /// <param name="row">The Row to remove</param> public void Remove(Row row) { int rowIndex = this.IndexOf(row); if (rowIndex != -1) { this.RemoveAt(rowIndex); } }
private void ListAdd(SALicense lic) { Table table = this.tableModules; // The Table control on a form - already initialised lic.Load(); Row row = new Row( new Cell[] { new Cell(lic.Product), new Cell(lic.Version), new Cell(lic.Username), new Cell(lic.Message) } ); row.Tag = lic; table.TableModel.Rows.Add(row); }
/// <summary> /// Removes an array of Row objects from the collection /// </summary> /// <param name="rows">An array of Row objects to remove /// from the collection</param> public void RemoveRange(Row[] rows) { if (rows == null) { throw new System.ArgumentNullException("Row[] is null"); } for (int i=0; i<rows.Length; i++) { this.Remove(rows[i]); } }
/// <summary> /// Invalidates the specified Row /// </summary> /// <param name="row">The Row to be invalidated</param> public void InvalidateRow(Row row) { this.InvalidateRow(row.Index); }
/// <summary> /// Replaces the Row at the specified index to the specified Row /// </summary> /// <param name="index">The index of the Row to be replaced</param> /// <param name="row">The Row to be placed at the specified index</param> internal void SetRow(int index, Row row) { if (index < 0 || index >= this.Count) { throw new ArgumentOutOfRangeException("value"); } if (row == null) { throw new ArgumentNullException("row cannot be null"); } this.List[index] = row; row.InternalIndex = index; }
/// <summary> /// Initializes a new instance of the Row class with default settings and a parent row. The new row /// is a sub row /// </summary> public Row(Row parent) { this.Init(); this.parentrow = parent; }
private void ListAdd(ChangeLogItem log) { Table table = this.tableList; // The Table control on a form - already initialised Cell c = new Cell(); switch (log.T) { case ChangeLogLevel.ADD: c = new Cell(Translator.Instance.T("新增"), global::ZForge.Controls.Logs.Properties.Resources.add_16); break; case ChangeLogLevel.BUGFIX: c = new Cell(Translator.Instance.T("BUGFIX"), global::ZForge.Controls.Logs.Properties.Resources.bug_yellow_16); break; case ChangeLogLevel.REMOVE: c = new Cell(Translator.Instance.T("移除"), global::ZForge.Controls.Logs.Properties.Resources.delete_16); break; default: c = new Cell(Translator.Instance.T("更改"), global::ZForge.Controls.Logs.Properties.Resources.document_into_16); break; } Row row = new Row( new Cell[] { new Cell(log.Version), c, new Cell(log.Message) } ); row.Tag = log; table.TableModel.Rows.Add(row); }
/// <summary> /// Initializes a new instance of the RowEventArgs class with /// the specified Row source, row index, start index, end index /// and affected Cell /// </summary> /// <param name="source">The Row that originated the event</param> /// <param name="cell">The affected Cell</param> /// <param name="cellFromIndex">The start index of the affected Cell(s)</param> /// <param name="cellToIndex">The end index of the affected Cell(s)</param> public RowEventArgs(Row source, Cell cell, int cellFromIndex, int cellToIndex) : this(source, -1, cell, cellFromIndex, cellToIndex, RowEventType.Unknown) { }
/// <summary> /// Compares two rows and returns a value indicating whether one is less /// than, equal to or greater than the other. Takes into account the sort order. /// </summary> /// <param name="row1">First row to compare</param> /// <param name="row2">Second row to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> protected int Compare(Row row1, Row row2) { int result = 0; if (this.SortOrder == SortOrder.None) { result = 0; } // check for null rows else if (row1 == null && row2 == null) { result = 0; } else if (row1 == null) { result = -1; } else if (row2 == null) { result = 1; } else { /* * 1. If both are subrows and from the same parent, then compare the rows * 2. If both are subrows, but from different parents, then compare parent rows * 3. If only one is a subrow, then compare the row against the parent row * 4. If both are not subrows, then just compare the rows * */ if (row1.Parent == null) { if (row2.Parent == null) { // 4. If both are not subrows, then just compare the rows result = CompareRows(row1, row2); } else { // 3. If only one is a subrow, then compare the row against the parent row result = CompareRows(row1, row2.Parent); } } else { if (row2.Parent == null) { // 3. If only one is a subrow, then compare the row against the parent row result = CompareRows(row1.Parent, row2); } else { // Both input rows are sub rows if (row1.Parent.Index == row2.Parent.Index) { // 1. From the same parent - compare subrows... // result = CompareRows(row1, row2); // ...or keep them in 'insert' order result = row1.ChildIndex.CompareTo(row2.ChildIndex); // If we are sorting in reverse order, then this would put the subrows in reverse // order too, bt we want to preserve the top-down order, so need to reverse the comparison //if (this.SortOrder == SortOrder.Descending) // result = -result; } else { // 2. From different parents - compare parents result = CompareRows(row1.Parent, row2.Parent); } } } } return result; }
/// <summary> /// Initializes a new instance of the RowEventArgs class with /// the specified Row source, row index, start index, end index /// and affected Cell /// </summary> /// <param name="source">The Row that originated the event</param> /// <param name="eventType">The type of event</param> public RowEventArgs(Row source, RowEventType eventType) : this(source, -1, null, -1, -1, eventType) { }
/// <summary> /// Compares two rows and returns a value indicating whether one is less /// than, equal to or greater than the other. /// Compares the given rows without considering parent/sub-rows. /// </summary> /// <param name="row1"></param> /// <param name="row2"></param> /// <returns></returns> protected virtual int CompareRows(Row row1, Row row2) { int result = CompareRows(row1, row2, this.SortColumn, this.Comparer); if (result == 0) { int i = 0; // used to get the right comparer out of the collection foreach (SortColumn col in this.SecondarySortOrders) { IComparer comparer = this.SecondaryComparers[i]; result = CompareRows(row1, row2, col.SortColumnIndex, comparer); if (result != 0) { if (col.SortOrder == SortOrder.Descending) result = -result; // Need to invert the result if a DESC sort order was used break; } i++; } } // If we do this then the direction of the secondary sorting is NOT reversed when // the main sort order is DESC else if (this.SortOrder == SortOrder.Descending) result = -result; // If we do this then the direction of the secondary sorting IS reversed when // the main sort order is DESC //if (this.SortOrder == SortOrder.Descending) // result = -result; return result; }
/// <summary> /// Removes the specified Row from the selection /// </summary> /// <param name="row">The Row to be removed from the selection</param> internal void RemoveRow(Row row) { // Mateusz [PEYN] Adamus ([email protected]) // old method didn't work well // it removed rows from selection but didn't refreshed table's view if (this.rows.Contains(row)) { // if Row has already been removed from the table then just remove it from selection if (this.owner.Rows.IndexOf(row) == -1) { int[] oldSelectedIndicies = this.SelectedIndicies; this.rows.Remove(row); this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies)); return; } // remove from selection every cell that is in the Row we want to remove // - remove Row this.RemoveCells(row.Index, 0, row.Index, row.Cells.Count - 1); } }
/// <summary> /// Releases all resources used by the Cell /// </summary> public void Dispose() { if (!this.disposed) { this.text = null; this.data = null; this.tag = null; this.rendererData = null; if (this.row != null) { this.row.Cells.Remove(this); } this.row = null; this.index = -1; this.cellStyle = null; this.checkStyle = null; this.imageStyle = null; this.tooltipText = null; this.state = (byte) 0; this.disposed = true; } }