Пример #1
0
        /// <summary>
        /// Removes the specified Column from the model
        /// </summary>
        /// <param name="column">The Column to remove</param>
        public void Remove(I3Column column)
        {
            int columnIndex = this.IndexOf(column);

            if (columnIndex != -1)
            {
                this.RemoveAt(columnIndex);
            }
        }
Пример #2
0
        /// <summary>
        ///	Returns the index of the specified Column in the model
        /// </summary>
        /// <param name="column">The Column to look for</param>
        /// <returns>The index of the specified Column in the model</returns>
        public int IndexOf(I3Column column)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i] == column)
                {
                    return(i);
                }
            }

            return(-1);
        }
Пример #3
0
        /// <summary>
        /// Returns a rectangle that countains the header of the specified column
        /// </summary>
        /// <param name="column">The column</param>
        /// <returns>A rectangle that countains the header of the specified column</returns>
        public Rectangle ColumnHeaderDisplayRect(I3Column column)
        {
            // check if we actually own the column
            int index = this.Columns.IndexOf(column);

            if (index == -1)
            {
                return(Rectangle.Empty);
            }

            return(this.ColumnHeaderDisplayRect(index));
        }
Пример #4
0
        /// <summary>
        /// Removes the Column at the specified index from the collection
        /// </summary>
        /// <param name="index">The index of the Column to remove</param>
        public new void RemoveAt(int index)
        {
            if (index >= 0 && index < this.Count)
            {
                I3Column column = this[index];

                this.List.RemoveAt(index);

                this.RecalcWidthCache();

                this.OnColumnRemoved(new I3ColumnModelEventArgs(this.owner, column, index, index));
            }
        }
Пример #5
0
        /// <summary>
        /// Adds the specified Column to the end of the collection
        /// </summary>
        /// <param name="column">The Column to add</param>
        public int Add(I3Column column)
        {
            if (column == null)
            {
                throw new System.ArgumentNullException("Column is null");
            }

            int index = this.List.Add(column);

            this.RecalcWidthCache();

            this.OnColumnAdded(new I3ColumnModelEventArgs(this.owner, column, index, index));

            return(index);
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the ColumnModel class with an array of strings
        /// representing TextColumns
        /// </summary>
        /// <param name="columns">An array of strings that represent the Columns of
        /// the ColumnModel</param>
        public I3ColumnModel(string[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns", "string[] cannot be null");
            }

            this.Init();

            if (columns.Length > 0)
            {
                I3Column[] cols = new I3Column[columns.Length];

                for (int i = 0; i < columns.Length; i++)
                {
                    cols[i] = new I3TextColumn(columns[i]);
                }

                this.Columns.AddRange(cols);
            }
        }
Пример #7
0
        /// <summary>
        /// 替换两个列的位置
        /// </summary>
        /// <param name="moveColumnIndex"></param>
        /// <param name="newIndex"></param>
        public void MoveColumn(int moveColumnIndex, int newIndex)
        {
            if (moveColumnIndex < 0 || moveColumnIndex > this._columns.Count - 1)
            {
                throw new Exception("无法移动列,moveColumnIndex:" + moveColumnIndex.ToString() + "错误");
            }
            if (newIndex < 0 /*|| newIndex > this._columns.Count - 1*/)
            {
                throw new Exception("无法移动列,newIndex:" + newIndex.ToString() + "错误");
            }
            if (moveColumnIndex == newIndex)
            {
                throw new Exception("无法移动列,moveColumnIndex:" + newIndex.ToString() + "与columnIndexAfterNewIndex相等");
            }

            I3Column moveColumn = this._columns[moveColumnIndex];

            this._columns.Remove(moveColumn);
            this._columns.Insert(newIndex, moveColumn);

            this.OnColumnPositionChanged(moveColumnIndex, newIndex);
        }
Пример #8
0
        /// <summary>
        /// Inserts a Cell into the collection at the specified index
        /// </summary>
        /// <param name="index">The zero-based index at which the Cell
        /// should be inserted</param>
        /// <param name="cell">The Cell to insert</param>
        public void Insert(int index, I3Column column)
        {
            if (column == null)
            {
                return;
            }

            if (index < 0)
            {
                throw new IndexOutOfRangeException();
            }

            if (index >= this.Count)
            {
                this.Add(column);
            }
            else
            {
                base.List.Insert(index, column);
                this.RecalcWidthCache();

                this.OnColumnAdded(new I3ColumnModelEventArgs(this.owner, column, index, index));
            }
        }
Пример #9
0
 /// <summary>
 /// 替换两个列的位置
 /// </summary>
 /// <param name="moveColumn"></param>
 /// <param name="columnAfterNewIndex"></param>
 public void MoveColumn(I3Column moveColumn, I3Column columnAfterNewIndex)
 {
     MoveColumn(this._columns.IndexOf(moveColumn), this._columns.IndexOf(columnAfterNewIndex));
 }