/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(I3CellMouseEventArgs e) { base.OnMouseDown(e); if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data I3CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); if (this.CalcCheckBoxDisplayRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].CellAlignment, e.Table.ColumnModel.Columns[e.Column] as I3CheckBoxColumn).Contains(e.X, e.Y)) { // if (e.Cell.CheckState == CheckState.Checked) { rendererData.CheckState = I3CheckBoxStates.CheckedPressed; } else if (e.Cell.CheckState == CheckState.Indeterminate) { rendererData.CheckState = I3CheckBoxStates.MixedPressed; } else //if (e.Cell.CheckState == CheckState.Unchecked) { rendererData.CheckState = I3CheckBoxStates.UncheckedPressed; } e.Table.Invalidate(e.CellRect); } } }
/// <summary> /// Gets or sets the maximum value for the Cell /// </summary> //protected decimal Maximum //{ // get // { // return this.maximum; // } // set // { // this.maximum = value; // if (this.minimum > this.maximum) // { // this.minimum = this.maximum; // } // } //} /// <summary> /// Gets or sets the minimum value for the Cell /// </summary> //protected decimal Minimum //{ // get // { // return this.minimum; // } // set // { // this.minimum = value; // if (this.minimum > this.maximum) // { // this.maximum = value; // } // } //} #endregion #region Events #region Mouse #region MouseLeave /// <summary> /// Raises the MouseLeave event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseLeave(I3CellMouseEventArgs e) { base.OnMouseLeave(e); if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data I3NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); if (rendererData.UpButtonState != I3UpDownStates.Normal) { rendererData.UpButtonState = I3UpDownStates.Normal; e.Table.Invalidate(e.CellRect); } else if (rendererData.DownButtonState != I3UpDownStates.Normal) { rendererData.DownButtonState = I3UpDownStates.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseEnter event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseEnter(I3CellMouseEventArgs e) { base.OnMouseEnter(e); // get the button renderer data I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // if the mouse is inside the button, make sure it is "hot" if (this.CalcButtonBounds().Contains(e.X, e.Y)) { if (rendererData.ButtonState != I3PushButtonStates.Hot) { rendererData.ButtonState = I3PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } // the mouse isn't inside the button, so it is in its normal state else { if (rendererData.ButtonState != I3PushButtonStates.Normal) { rendererData.ButtonState = I3PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } } }
/// <summary> /// Raises the MouseEnter event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnMouseEnter(I3CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = I3CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } bool tooltipActive = e.Table.ToolTip.Active; if (tooltipActive) { e.Table.ToolTip.Active = false; } e.Table.ResetMouseEventArgs(); e.Table.ToolTip.SetToolTip(e.Table, e.Cell.ToolTipText); if (tooltipActive) { e.Table.ToolTip.Active = true; } }
/// <summary> /// Raises the MouseMove event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnMouseMove(I3CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = I3CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } }
/// <summary> /// Raises the MouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseUp(I3CellMouseEventArgs e) { base.OnMouseUp(e); // get the button renderer data I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // check for the left mouse button if (e.Button == MouseButtons.Left) { Rectangle buttonRect = this.CalcButtonBounds(); // if the mouse pointer is over the button, make sure // the button is "hot" if (buttonRect.Contains(e.X, e.Y)) { rendererData.ButtonState = I3PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); // check if the click started inside the button. if // it did, Raise the tables CellButtonClicked event if (buttonRect.Contains(rendererData.ClickPoint)) { I3Column column = e.Table.ColumnModel.Columns[e.Column]; if (column.GetType() == typeof(I3ButtonColumn)) { I3ButtonColumn buttonColumn = (I3ButtonColumn)column; buttonColumn.OnButtonClicked(new I3CellButtonEventArgs(e.Cell, e.Column, e.Row)); } //e.Table.OnCellButtonClicked(new CellButtonEventArgs(e.Cell, e.Column, e.Row)); } } else { // the mouse was released somewhere outside of the button, // so make set the button back to its normal state if (rendererData.ButtonState != I3PushButtonStates.Normal) { rendererData.ButtonState = I3PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } } } // reset the click point rendererData.ClickPoint = Point.Empty; }
/// <summary> /// Raises the MouseLeave event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseLeave(I3CellMouseEventArgs e) { base.OnMouseLeave(e); // get the button renderer data I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // make sure the button is in its normal state if (rendererData.ButtonState != I3PushButtonStates.Normal) { rendererData.ButtonState = I3PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(I3CellMouseEventArgs e) { base.OnMouseDown(e); // if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data I3NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); rendererData.ClickPoint = new Point(e.X, e.Y); if (this.CalcButtonBounds().Contains(e.X, e.Y)) { if (!(e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is I3NumberCellEditor)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellRenderer requires a NumberColumn that uses a NumberCellEditor"); } if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } if (this.GetUpButtonBounds().Contains(e.X, e.Y)) { rendererData.UpButtonState = I3UpDownStates.Pressed; ((II3EditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } else if (this.GetDownButtonBounds().Contains(e.X, e.Y)) { rendererData.DownButtonState = I3UpDownStates.Pressed; ((II3EditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } } } } }
/// <summary> /// Raises the MouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseUp(I3CellMouseEventArgs e) { base.OnMouseUp(e); if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data I3CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); Rectangle rect = this.CalcCheckBoxCheckRect(e.Table.TableModel.Rows[e.Row], e.Table.ColumnModel.Columns[e.Column] as I3CheckBoxColumn); if (rect.Contains(e.X, e.Y)) { if (e.Button == MouseButtons.Left && e.Table.LastMouseDownCell.Row == e.Row && e.Table.LastMouseDownCell.Column == e.Column) { // if (e.Cell.CheckState == CheckState.Checked) { if (!e.Cell.ThreeState || !(e.Table.ColumnModel.Columns[e.Column] is I3CheckBoxColumn) || ((I3CheckBoxColumn)e.Table.ColumnModel.Columns[e.Column]).CheckBoxColumnStyle == I3CheckBoxColumnStyle.RadioButton) { rendererData.CheckState = I3CheckBoxStates.UncheckedHot; e.Cell.CheckState = CheckState.Unchecked; } else { rendererData.CheckState = I3CheckBoxStates.MixedHot; e.Cell.CheckState = CheckState.Indeterminate; } } else if (e.Cell.CheckState == CheckState.Indeterminate) { rendererData.CheckState = I3CheckBoxStates.UncheckedHot; e.Cell.CheckState = CheckState.Unchecked; } else //if (e.Cell.CheckState == CheckState.Unchecked) { rendererData.CheckState = I3CheckBoxStates.CheckedHot; e.Cell.CheckState = CheckState.Checked; } e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseUp(I3CellMouseEventArgs e) { base.OnMouseUp(e); // if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data I3NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); rendererData.ClickPoint = new Point(-1, -1); if (this.GetUpButtonBounds().Contains(e.X, e.Y)) { rendererData.UpButtonState = I3UpDownStates.Hot; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } ((II3EditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e); e.Table.Invalidate(e.CellRect); } else if (this.GetDownButtonBounds().Contains(e.X, e.Y)) { rendererData.DownButtonState = I3UpDownStates.Hot; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } ((II3EditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e); e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the DoubleClick event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnDoubleClick(I3CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = I3CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } if ((e.Table.EditStartAction == I3EditStartAction.DoubleClick || e.Table.EditStartAction == I3EditStartAction.DoubleClick_DataInputKey || e.Table.EditStartAction == I3EditStartAction.DoubleClick_DataInputKey) && e.Table.IsCellEditable(e.CellPos)) { e.Table.EditCell(e.CellPos); } }
/// <summary> /// Handler for the editors buttons MouseDown event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public void OnEditorButtonMouseDown(object sender, I3CellMouseEventArgs e) { this.ParseEditText(); if (e.Y < this.buttonBounds.Top + (this.buttonBounds.Height / 2)) { this.buttonID = UpButtonID; this.UpButton(); } else { this.buttonID = DownButtonID; this.DownButton(); } this.StartTimer(); }
/// <summary> /// Raises the MouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseUp(I3CellMouseEventArgs e) { base.OnMouseUp(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data I3DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { rendererData.ButtonState = I3ComboBoxStates.Hot; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseLeave event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseLeave(I3CellMouseEventArgs e) { base.OnMouseLeave(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data I3DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (rendererData.ButtonState != I3ComboBoxStates.Normal) { rendererData.ButtonState = I3ComboBoxStates.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnMouseDown(I3CellMouseEventArgs e) { if (!e.Table.Focused) { if (!(e.Table.IsEditing && e.Table.EditingCell == e.CellPos && e.Table.EditingCellEditor is II3EditorUsesRendererButtons)) { e.Table.Focus(); } } this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = I3CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(I3CellMouseEventArgs e) { base.OnMouseDown(e); // get the button renderer data I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // check if the left mouse button is pressed if (e.Button == MouseButtons.Left) { // record where the click started rendererData.ClickPoint = new Point(e.X, e.Y); // if the click was inside the button, set the button state to pressed if (this.CalcButtonBounds().Contains(rendererData.ClickPoint)) { rendererData.ButtonState = I3PushButtonStates.Pressed; e.Table.Invalidate(e.CellRect); } } }
/// <summary> /// Raises the MouseLeave event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseLeave(I3CellMouseEventArgs e) { base.OnMouseLeave(e); if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data I3CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); if (e.Cell.CheckState == CheckState.Checked) { if (rendererData.CheckState != I3CheckBoxStates.CheckedNormal) { rendererData.CheckState = I3CheckBoxStates.CheckedNormal; e.Table.Invalidate(e.CellRect); } } else if (e.Cell.CheckState == CheckState.Indeterminate) { if (rendererData.CheckState != I3CheckBoxStates.MixedNormal) { rendererData.CheckState = I3CheckBoxStates.MixedNormal; e.Table.Invalidate(e.CellRect); } } else //if (e.Cell.CheckState == CheckState.Unchecked) { if (rendererData.CheckState != I3CheckBoxStates.UncheckedNormal) { rendererData.CheckState = I3CheckBoxStates.UncheckedNormal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(I3CellMouseEventArgs e) { base.OnMouseDown(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data I3DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { if (!(e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is I3DropDownCellEditor)) { throw new InvalidOperationException("Cannot edit Cell as DropDownCellRenderer requires a DropDownColumn that uses a DropDownCellEditor"); } rendererData.ButtonState = I3ComboBoxStates.Pressed; if (!e.Table.IsEditing) { if (!e.Table.EditCell(e.CellPos)) { e.Table.Invalidate(e.CellRect); return; } } ((II3EditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseMove event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseMove(I3CellMouseEventArgs e) { base.OnMouseMove(e); // get the button renderer data I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); Rectangle buttonRect = this.CalcButtonBounds(); // check if the left mouse button is pressed if (e.Button == MouseButtons.Left) { // check if the mouse press originated in the button area if (buttonRect.Contains(rendererData.ClickPoint)) { // check if the mouse is currently in the button if (buttonRect.Contains(e.X, e.Y)) { // make sure the button is pressed if (rendererData.ButtonState != I3PushButtonStates.Pressed) { rendererData.ButtonState = I3PushButtonStates.Pressed; e.Table.Invalidate(e.CellRect); } } else { // the mouse isn't inside the button so make sure it is "hot" if (rendererData.ButtonState != I3PushButtonStates.Hot) { rendererData.ButtonState = I3PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } } } else { // check if the mouse is currently in the button if (buttonRect.Contains(e.X, e.Y)) { // the mouse is inside the button so make sure it is "hot" if (rendererData.ButtonState != I3PushButtonStates.Hot) { rendererData.ButtonState = I3PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } else { // not inside the button so make sure it is in its normal state if (rendererData.ButtonState != I3PushButtonStates.Normal) { rendererData.ButtonState = I3PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// 下拉按钮弹起事件,不做任何处理 /// Handler for the editors drop down but /// Handler for the editors drop down button MouseUp event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnEditorButtonMouseUp(object sender, I3CellMouseEventArgs e) { }
/// <summary> /// 下拉按钮按下事件,隐藏或显示下拉容器 /// Handler for the editors drop down button MouseDown event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnEditorButtonMouseDown(object sender, I3CellMouseEventArgs e) { this.DroppedDown = !this.DroppedDown; }
/// <summary> /// Handler for the editors buttons MouseUp event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public void OnEditorButtonMouseUp(object sender, I3CellMouseEventArgs e) { this.StopTimer(); this.buttonID = 0; }