/// <summary>
 /// Initializes a new instance of the CellMouseEventArgs class with
 /// the specified source Cell, table, row index, column index and
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 public I3CellMouseEventArgs(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect)
     : base(MouseButtons.None, 0, -1, -1, 0)
 {
     this.cell     = cell;
     this.table    = table;
     this.row      = cellPos.Row;
     this.column   = cellPos.Column;
     this.cellRect = cellRect;
 }
 /// <summary>
 /// Initializes a new instance of the CellMouseEventArgs class with
 /// the specified source Cell, table, row index, column index and
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 /// <param name="mea"></param>
 public I3CellMouseEventArgs(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, MouseEventArgs mea)
     : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta)
 {
     this.cell     = cell;
     this.table    = table;
     this.row      = cellPos.Row;
     this.column   = cellPos.Column;
     this.cellRect = cellRect;
 }
 /// <summary>
 /// Initializes a new instance of the CellKeyEventArgs class with
 /// the specified source Cell, table, row index, column index and
 /// cell bounds
 /// </summary>
 /// <param name="cell">The Cell that Raised the event</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="cellPos"></param>
 /// <param name="cellRect">The Cell's bounding rectangle</param>
 /// <param name="kea"></param>
 public I3CellKeyEventArgs(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, KeyEventArgs kea)
     : base(kea.KeyData)
 {
     this.cell     = cell;
     this.table    = table;
     this.row      = cellPos.Row;
     this.column   = cellPos.Column;
     this.cellRect = cellRect;
 }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the CellEditor class with default settings
        /// </summary>
        protected I3CellEditor()
        {
            this.control  = null;
            this.cell     = null;
            this.table    = null;
            this.cellPos  = I3CellPos.Empty;
            this.cellRect = Rectangle.Empty;

            this.mouseMessageFilter = new I3MouseMessageFilter(this);
            this.keyMessageFilter   = new I3KeyMessageFilter(this);
        }
示例#5
0
        /// <summary>
        /// 虚拟方法,从Table中移除编辑控件
        /// Conceals the editor from the user and removes it from the Table's
        /// Control collection
        /// </summary>
        protected virtual void RemoveEditControl()
        {
            this.control.Visible = false;
            this.control.Parent  = null;

            this.table.Focus();

            this.cell     = null;
            this.table    = null;
            this.cellPos  = I3CellPos.Empty;
            this.cellRect = Rectangle.Empty;
        }
        /// <summary>
        /// 准备编辑,继承父类的功能
        /// Prepares the CellEditor to edit the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to be edited</param>
        /// <param name="table">The Table that contains the Cell</param>
        /// <param name="cellPos">A CellPos representing the position of the Cell</param>
        /// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
        /// <param name="userSetEditorValues">Specifies whether the ICellEditors
        /// starting value has already been set by the user</param>
        /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
        public override bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            if (!(table.ColumnModel.Columns[cellPos.Column] is I3DropDownColumn))
            {
                throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn");
            }

            I3DropDownColumn dropDownColumn = table.ColumnModel.Columns[cellPos.Column] as I3DropDownColumn;

            this.DropDownStyle = dropDownColumn.DropDownStyle;

            return(base.PrepareForEditing(cell, table, cellPos, cellRect, userSetEditorValues));
        }
        /// <summary>
        /// Prepares the CellEditor to edit the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to be edited</param>
        /// <param name="table">The Table that contains the Cell</param>
        /// <param name="cellPos">A CellPos representing the position of the Cell</param>
        /// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
        /// <param name="userSetEditorValues">Specifies whether the ICellEditors
        /// starting value has already been set by the user</param>
        /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
        public override bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            //
            if (!(table.ColumnModel.Columns[cellPos.Column] is I3NumberColumn))
            {
                throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn");
            }

            if (!(table.ColumnModel.GetCellRenderer(cellPos.Column) is I3NumberCellRenderer))
            {
                throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn that uses a NumberCellRenderer");
            }

            this.NumberColumnType = ((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).NumberColumnType;
            this.Minimum          = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Minimum);
            this.Maximum          = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Maximum);
            this.Increment        = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Increment);

            return(base.PrepareForEditing(cell, table, cellPos, cellRect, userSetEditorValues));
        }
示例#8
0
        /// <summary>
        /// 虚拟方法,准备编辑,在ICellEditor中定义
        /// Prepares the CellEditor to edit the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to be edited</param>
        /// <param name="table">The Table that contains the Cell</param>
        /// <param name="cellPos">A CellPos representing the position of the Cell</param>
        /// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
        /// <param name="userSetEditorValues">Specifies whether the ICellEditors
        /// starting value has already been set by the user</param>
        /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
        public virtual bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            //初始化值
            this.cell     = cell;
            this.table    = table;
            this.cellPos  = cellPos;
            this.cellRect = cellRect;

            //检查用户是否已经自己设置了编辑控件的值,如果没有则调用 SetEditValue() 方法进行设置
            // check if the user has already set the editors value for us
            if (!userSetEditorValues)
            {
                this.SetEditValue();
            }

            //设置编辑控件的位置和大小
            this.SetEditLocation(cellRect);

            //引发开始编辑事件
            // raise the BeginEdit event
            I3CellEditEventArgs e = new I3CellEditEventArgs(cell, this, table, cellPos.Row, cellPos.Column, cellRect);

            e.Handled = userSetEditorValues;

            this.OnBeginEdit(e);

            //如果编辑被退出,移动编辑控件并返回false
            // if the edit has been canceled, remove the editor and return false
            if (e.Cancel)
            {
                this.RemoveEditControl();

                return(false);
            }

            return(true);
        }
示例#9
0
 /// <summary>
 /// Gets whether the specified Table is using a NumericCellEditor to edit the
 /// Cell at the specified CellPos
 /// </summary>
 /// <param name="table">The Table to check</param>
 /// <param name="cellPos">A CellPos that represents the Cell to check</param>
 /// <returns>true if the specified Table is using a NumericCellEditor to edit the
 /// Cell at the specified CellPos, false otherwise</returns>
 internal bool TableUsingNumericCellEditor(I3Table table, I3CellPos cellPos)
 {
     return(table.IsEditing && cellPos == table.EditingCell && table.EditingCellEditor is I3NumberCellEditor);
 }