Esempio n. 1
0
        /// <summary>
        /// Raises the KeyDown event
        /// </summary>
        /// <param name="e">A CellKeyEventArgs that contains the event data</param>
        public override void OnKeyDown(I3CellKeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyData == Keys.Space && e.Table.IsCellEditable(e.CellPos))
            {
                // get the renderer data
                I3CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);

                //
                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);
            }
        }
Esempio n. 2
0
        /// <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);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the CheckBoxCellRenderer specific data used by the Renderer from
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the CheckBoxCellRenderer data for</param>
        /// <returns>The CheckBoxCellRenderer data for the specified Cell</returns>
        protected I3CheckBoxRendererData GetCheckBoxRendererData(I3Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is I3CheckBoxRendererData))
            {
                if (cell.CheckState == CheckState.Unchecked)
                {
                    rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.UncheckedNormal);
                }
                else if (cell.CheckState == CheckState.Indeterminate && cell.ThreeState)
                {
                    rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.MixedNormal);
                }
                else
                {
                    rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.CheckedNormal);
                }

                this.SetRendererData(cell, rendererData);
            }

            this.ValidateCheckState(cell, (I3CheckBoxRendererData)rendererData);

            return((I3CheckBoxRendererData)rendererData);
        }
Esempio n. 4
0
        /// <summary>
        /// Corrects any differences between the check state of the specified Cell
        /// and the check state in its rendererData
        /// </summary>
        /// <param name="cell">The Cell to chech</param>
        /// <param name="rendererData">The CheckBoxRendererData to check</param>
        private void ValidateCheckState(I3Cell cell, I3CheckBoxRendererData rendererData)
        {
            switch (cell.CheckState)
            {
            case CheckState.Checked:
            {
                if (rendererData.CheckState <= I3CheckBoxStates.UncheckedDisabled)
                {
                    rendererData.CheckState |= (I3CheckBoxStates)4;
                }
                else if (rendererData.CheckState >= I3CheckBoxStates.MixedNormal)
                {
                    rendererData.CheckState -= (I3CheckBoxStates)4;
                }

                break;
            }

            case CheckState.Indeterminate:
            {
                if (rendererData.CheckState <= I3CheckBoxStates.UncheckedDisabled)
                {
                    rendererData.CheckState |= (I3CheckBoxStates)8;
                }
                else if (rendererData.CheckState <= I3CheckBoxStates.CheckedDisabled)
                {
                    rendererData.CheckState |= (I3CheckBoxStates)4;
                }

                break;
            }

            default:
            {
                if (rendererData.CheckState >= I3CheckBoxStates.MixedNormal)
                {
                    rendererData.CheckState -= (I3CheckBoxStates)8;
                }
                else if (rendererData.CheckState >= I3CheckBoxStates.CheckedNormal)
                {
                    rendererData.CheckState -= (I3CheckBoxStates)4;
                }

                break;
            }
            }
        }
Esempio n. 5
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 6
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Raises the KeyUp event
        /// </summary>
        /// <param name="e">A CellKeyEventArgs that contains the event data</param>
        public override void OnKeyUp(I3CellKeyEventArgs e)
        {
            base.OnKeyUp(e);

            if (e.KeyData == Keys.Space && e.Table.IsCellEditable(e.CellPos))
            {
                // get the renderer data
                I3CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell);

                //
                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.UncheckedNormal;
                        e.Cell.CheckState       = CheckState.Unchecked;
                    }
                    else
                    {
                        rendererData.CheckState = I3CheckBoxStates.MixedNormal;
                        e.Cell.CheckState       = CheckState.Indeterminate;
                    }
                }
                else if (e.Cell.CheckState == CheckState.Indeterminate)
                {
                    rendererData.CheckState = I3CheckBoxStates.UncheckedNormal;
                    e.Cell.CheckState       = CheckState.Unchecked;
                }
                else                 //if (e.Cell.CheckState == CheckState.Unchecked)
                {
                    rendererData.CheckState = I3CheckBoxStates.CheckedNormal;
                    e.Cell.CheckState       = CheckState.Checked;
                }

                e.Table.Invalidate(e.CellRect);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Raises the MouseMove event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseMove(IE310.Table.Events.I3CellMouseEventArgs e)
        {
            base.OnMouseMove(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)
                    {
                        if (rendererData.CheckState == I3CheckBoxStates.CheckedNormal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                rendererData.CheckState = I3CheckBoxStates.CheckedPressed;
                            }
                            else
                            {
                                rendererData.CheckState = I3CheckBoxStates.CheckedHot;
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                    else if (e.Cell.CheckState == CheckState.Indeterminate)
                    {
                        if (rendererData.CheckState == I3CheckBoxStates.MixedNormal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                rendererData.CheckState = I3CheckBoxStates.MixedPressed;
                            }
                            else
                            {
                                rendererData.CheckState = I3CheckBoxStates.MixedHot;
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                    else                     //if (e.Cell.CheckState == CheckState.Unchecked)
                    {
                        if (rendererData.CheckState == I3CheckBoxStates.UncheckedNormal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                rendererData.CheckState = I3CheckBoxStates.UncheckedPressed;
                            }
                            else
                            {
                                rendererData.CheckState = I3CheckBoxStates.UncheckedHot;
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                }
                else
                {
                    if (e.Cell.CheckState == CheckState.Checked)
                    {
                        rendererData.CheckState = I3CheckBoxStates.CheckedNormal;
                    }
                    else if (e.Cell.CheckState == CheckState.Indeterminate)
                    {
                        rendererData.CheckState = I3CheckBoxStates.MixedNormal;
                    }
                    else                     //if (e.Cell.CheckState == CheckState.Unchecked)
                    {
                        rendererData.CheckState = I3CheckBoxStates.UncheckedNormal;
                    }

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