コード例 #1
0
        /// <summary>
        /// Raises the MouseLeave event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseLeave(CellMouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    NumberRendererData rendererData = this.GetNumberRendererData(e.Cell);

                    if (rendererData.UpButtonState != UpDownStates.Normal)
                    {
                        rendererData.UpButtonState = UpDownStates.Normal;

                        e.Table.Invalidate(e.CellRect);
                    }
                    else if (rendererData.DownButtonState != UpDownStates.Normal)
                    {
                        rendererData.DownButtonState = UpDownStates.Normal;

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the NumberRendererData specific data used by the Renderer from
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the NumberRendererData data for</param>
        /// <returns>The NumberRendererData data for the specified Cell</returns>
        protected NumberRendererData GetNumberRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is NumberRendererData))
            {
                rendererData = new NumberRendererData();

                this.SetRendererData(cell, rendererData);
            }

            return((NumberRendererData)rendererData);
        }
コード例 #3
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseDown(CellMouseEventArgs e)
        {
            base.OnMouseDown(e);

            //
            if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    NumberRendererData 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 NumberCellEditor))
                        {
                            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 = UpDownStates.Pressed;

                            ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e);

                            e.Table.Invalidate(e.CellRect);
                        }
                        else if (this.GetDownButtonBounds().Contains(e.X, e.Y))
                        {
                            rendererData.DownButtonState = UpDownStates.Pressed;

                            ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e);

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Raises the MouseUp event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseUp(CellMouseEventArgs e)
        {
            base.OnMouseUp(e);

            //
            if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the renderer data
                    NumberRendererData rendererData = this.GetNumberRendererData(e.Cell);

                    rendererData.ClickPoint = new Point(-1, -1);

                    if (this.GetUpButtonBounds().Contains(e.X, e.Y))
                    {
                        rendererData.UpButtonState = UpDownStates.Hot;

                        if (!e.Table.IsEditing)
                        {
                            e.Table.EditCell(e.CellPos);
                        }

                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e);

                        e.Table.Invalidate(e.CellRect);
                    }
                    else if (this.GetDownButtonBounds().Contains(e.X, e.Y))
                    {
                        rendererData.DownButtonState = UpDownStates.Hot;

                        if (!e.Table.IsEditing)
                        {
                            e.Table.EditCell(e.CellPos);
                        }

                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e);

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Raises the MouseMove event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseMove(KellControls.KellTable.Events.CellMouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (this.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    NumberRendererData rendererData = this.GetNumberRendererData(e.Cell);

                    if (this.GetUpButtonBounds().Contains(e.X, e.Y))
                    {
                        if (rendererData.UpButtonState == UpDownStates.Normal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                if (this.GetUpButtonBounds().Contains(rendererData.ClickPoint))
                                {
                                    rendererData.UpButtonState = UpDownStates.Pressed;

                                    if (this.TableUsingNumericCellEditor(e.Table, e.CellPos))
                                    {
                                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e);
                                    }
                                }
                                else if (this.GetDownButtonBounds().Contains(rendererData.ClickPoint))
                                {
                                    rendererData.DownButtonState = UpDownStates.Normal;

                                    if (this.TableUsingNumericCellEditor(e.Table, e.CellPos))
                                    {
                                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e);
                                    }
                                }
                            }
                            else
                            {
                                rendererData.UpButtonState = UpDownStates.Hot;

                                if (rendererData.DownButtonState == UpDownStates.Hot)
                                {
                                    rendererData.DownButtonState = UpDownStates.Normal;
                                }
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                    else if (this.GetDownButtonBounds().Contains(e.X, e.Y))
                    {
                        if (rendererData.DownButtonState == UpDownStates.Normal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                if (this.GetDownButtonBounds().Contains(rendererData.ClickPoint))
                                {
                                    rendererData.DownButtonState = UpDownStates.Pressed;

                                    if (this.TableUsingNumericCellEditor(e.Table, e.CellPos))
                                    {
                                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e);
                                    }
                                }
                                else if (this.GetUpButtonBounds().Contains(rendererData.ClickPoint))
                                {
                                    rendererData.UpButtonState = UpDownStates.Normal;

                                    if (this.TableUsingNumericCellEditor(e.Table, e.CellPos))
                                    {
                                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e);
                                    }
                                }
                            }
                            else
                            {
                                rendererData.DownButtonState = UpDownStates.Hot;

                                if (rendererData.UpButtonState == UpDownStates.Hot)
                                {
                                    rendererData.UpButtonState = UpDownStates.Normal;
                                }
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                    else
                    {
                        if (rendererData.UpButtonState != UpDownStates.Normal || rendererData.DownButtonState != UpDownStates.Normal)
                        {
                            rendererData.UpButtonState   = UpDownStates.Normal;
                            rendererData.DownButtonState = UpDownStates.Normal;

                            if (this.TableUsingNumericCellEditor(e.Table, e.CellPos))
                            {
                                ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e);
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                }
            }
        }