コード例 #1
0
        public I3Cell Add()
        {
            I3Cell cell = new I3Cell();

            Add(cell);
            return(cell);
        }
コード例 #2
0
        /// <summary>
        /// Removes the specified Cell from the model
        /// </summary>
        /// <param name="cell">The Cell to remove</param>
        public void Remove(I3Cell cell)
        {
            int cellIndex = this.IndexOf(cell);

            if (cellIndex != -1)
            {
                this.RemoveAt(cellIndex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Removes the Cell at the specified index from the collection
        /// </summary>
        /// <param name="index">The index of the Cell to remove</param>
        public new void RemoveAt(int index)
        {
            if (index >= 0 && index < this.Count)
            {
                I3Cell cell = this[index];

                this.List.RemoveAt(index);

                this.OnCellRemoved(new I3RowEventArgs(this.owner, cell, index, index));
            }
        }
コード例 #4
0
        /// <summary>
        ///	Returns the index of the specified Cell in the model
        /// </summary>
        /// <param name="cell">The Cell to look for</param>
        /// <returns>The index of the specified Cell in the model</returns>
        public int IndexOf(I3Cell cell)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i] == cell)
                {
                    return(i);
                }
            }

            return(-1);
        }
コード例 #5
0
        /// <summary>
        /// Adds the specified Cell to the end of the collection
        /// </summary>
        /// <param name="cell">The Cell to add</param>
        public int Add(I3Cell cell)
        {
            if (cell == null)
            {
                throw new System.ArgumentNullException("Cell is null");
            }

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

            this.OnCellAdded(new I3RowEventArgs(this.owner, cell, index, index));

            return(index);
        }
コード例 #6
0
 /// <summary>
 /// 检查cell的数量,少了则添加,多了则删除
 /// </summary>
 /// <param name="count"></param>
 public void CheckCellsCount(int count)
 {
     while (this.List.Count > count)
     {
         this.List.RemoveAt(this.List.Count - 1);
     }
     while (this.List.Count < count)
     {
         I3Cell cell = new I3Cell();
         cell.Enabled = false;
         this.Add(cell);
     }
 }
コード例 #7
0
        /// <summary>
        /// 替换两个单元格的位置
        /// </summary>
        /// <param name="moveCellIndex"></param>
        /// <param name="newIndex"></param>
        public void MoveCell(int moveCellIndex, int newIndex)
        {
            if (moveCellIndex < 0 || moveCellIndex > this.Count - 1)
            {
                throw new Exception("无法移动单元格,moveCellIndex:" + moveCellIndex.ToString() + "错误");
            }
            if (newIndex < 0 /*|| newIndex > this.Count - 1*/)
            {
                throw new Exception("无法移动单元格,newIndex:" + newIndex.ToString() + "错误");
            }
            if (moveCellIndex == newIndex)
            {
                throw new Exception("无法移动单元格,newIndex:" + newIndex.ToString() + "与moveCellIndex相等");
            }

            I3Cell moveCell = this[moveCellIndex];

            this.Remove(moveCell);
            this.Insert(newIndex, moveCell);
        }
コード例 #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, I3Cell cell)
        {
            if (cell == null)
            {
                return;
            }

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

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

                this.OnCellAdded(new I3RowEventArgs(this.owner, cell, index, index));
            }
        }
コード例 #9
0
 /// <summary>
 /// 替换两个单元格的位置
 /// </summary>
 /// <param name="oldColumn"></param>
 /// <param name="newColumn"></param>
 public void MoveCell(I3Cell moveCell, I3Cell cellAfterAfterNewIndex)
 {
     MoveCell(this.IndexOf(moveCell), this.IndexOf(cellAfterAfterNewIndex));
 }