/// <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;
 }
        /// <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;
        }
        /// <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);

            this.OnRowAdded(new TableModelEventArgs(this.owner, row, index, index));

            return index;
        }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
            /// <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)
            {
                if (this.rows.Contains(row))
                {
                    int[] oldSelectedIndicies = this.SelectedIndicies;

                    this.rows.Remove(row);

                    this.owner.OnSelectionChanged(new SelectionEventArgs(this.owner, oldSelectedIndicies, this.SelectedIndicies));
                }
            }
예제 #6
0
        /// <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.tooltipText = null;

            this.state = (byte) (STATE_EDITABLE | STATE_ENABLED);
        }
예제 #7
0
        /// <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.tooltipText = null;

                this.state = (byte) 0;

                this.disposed = true;
            }
        }
        /// <summary>
        /// Adds an array of Row objects to the collection
        /// </summary>
        /// <param name="rows">An array of Row objects to add 
        /// to the collection</param>
        public void AddRange(Row[] rows)
        {
            if (rows == null)
            {
                throw new System.ArgumentNullException("Row[] is null");
            }

            for (int i=0; i<rows.Length; i++)
            {
                this.Add(rows[i]);
            }
        }
        /// <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>
        /// 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>
        /// 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);
            }
        }
        /// <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);

                this.owner.OnRowAdded(new TableModelEventArgs(this.owner, row, index, index));
            }
        }
        /// <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;
        }
예제 #14
0
 /// <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)
 {
 }
예제 #15
0
 /// <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)
 {
 }
예제 #16
0
 /// <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;
 }