protected virtual void PrepareVisualElementCheckBox(CellContext context)
        {
            ElementCheckBox.AnchorArea = new DevAge.Drawing.AnchorArea(CheckBoxAlignment, false);

            Models.ICheckBox      checkBoxModel  = (Models.ICheckBox)context.Cell.Model.FindModel(typeof(Models.ICheckBox));
            Models.CheckBoxStatus checkBoxStatus = checkBoxModel.GetCheckBoxStatus(context);

            if (context.CellRange.Contains(context.Grid.MouseCellPosition))
            {
                if (checkBoxStatus.CheckEnable)
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Hot;
                }
                else
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled;
                }
            }
            else
            {
                if (checkBoxStatus.CheckEnable)
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Normal;
                }
                else
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled;
                }
            }

            ElementCheckBox.CheckBoxState = checkBoxStatus.CheckState;


            ElementText.Value = checkBoxStatus.Caption;
        }
Exemple #2
0
        /// <summary>
        /// Toggle the value of the current cell and if AutoChangeValueOfSelectedCells is true of all the selected cells.
        /// Simulate an edit operation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIChangeChecked(CellContext sender, EventArgs e)
        {
            Models.ICheckBox checkModel = (Models.ICheckBox)sender.Cell.Model.FindModel(typeof(Models.ICheckBox));;
            if (checkModel == null)
            {
                throw new SourceGrid.SourceGridException("Models.ICheckBox not found");
            }

            Models.CheckBoxStatus checkStatus = checkModel.GetCheckBoxStatus(sender);
            if (checkStatus.CheckEnable)
            {
                bool newVal = true;
                if (checkStatus.Checked != null)
                {
                    newVal = !checkStatus.Checked.Value;
                }

                sender.StartEdit();
                try
                {
                    checkModel.SetCheckedValue(sender, newVal);
                    sender.EndEdit(false);
                }
                catch (Exception)
                {
                    sender.EndEdit(true);
                    throw;
                }

                //change the status of all selected control
                if (AutoChangeValueOfSelectedCells)
                {
                    foreach (Position pos in sender.Grid.Selection.GetSelectionRegion().GetCellsPositions())
                    {
                        Cells.ICellVirtual c = sender.Grid.GetCell(pos);
                        Models.ICheckBox   check;
                        if (c != this && c != null &&
                            (check = (Models.ICheckBox)c.Model.FindModel(typeof(Models.ICheckBox))) != null)
                        {
                            CellContext context = new CellContext(sender.Grid, pos, c);
                            context.StartEdit();
                            try
                            {
                                check.SetCheckedValue(context, newVal);
                                context.EndEdit(false);
                            }
                            catch (Exception)
                            {
                                context.EndEdit(true);
                                throw;
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Toggle the value of the current cell and if AutoChangeValueOfSelectedCells is true of all the selected cells.
        /// Simulate an edit operation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIChangeChecked(CellContext sender, EventArgs e)
        {
            Models.ICheckBox checkModel = (Models.ICheckBox)sender.Cell.Model.FindModel(typeof(Models.ICheckBox));;
            if (checkModel == null)
            {
                throw new SourceGrid.SourceGridException("Models.ICheckBox not found");
            }

            Models.CheckBoxStatus checkStatus = checkModel.GetCheckBoxStatus(sender);
            if (checkStatus.CheckEnable)
            {
                bool newVal = true;
                if (checkStatus.Checked != null)
                {
                    newVal = !checkStatus.Checked.Value;
                }

                if (sender.StartEdit())
                {
                    try
                    {
                        checkModel.SetCheckedValue(sender, newVal);
                        sender.EndEdit(false);
                        OnCheckedChanged(EventArgs.Empty);
                    }
                    catch (Exception ex)
                    {
                        sender.EndEdit(true);
                        throw new Exception(string.Empty, ex);
                    }

                    //change the status of all selected control
                    if (AutoChangeValueOfSelectedCells)
                    {
                        AutoChangeValues(sender, newVal);
                    }
                }
            }
        }
Exemple #4
0
        protected virtual void PrepareVisualElementCheckBox(CellContext context)
        {
            ElementCheckBox.AnchorArea = new DevAge.Drawing.AnchorArea(CheckBoxAlignment, false);

            Models.ICheckBox      checkBoxModel  = (Models.ICheckBox)context.Cell.Model.FindModel(typeof(Models.ICheckBox));
            Models.CheckBoxStatus checkBoxStatus = checkBoxModel.GetCheckBoxStatus(context);

            if (context.CellRange.Contains(context.Grid.MouseCellPosition))
            {
                //[email protected]:Readonly state is taken into acct and disabled style is displayed
                if (!checkBoxStatus.CheckEnable || checkBoxStatus.ReadOnly)
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled;
                }
                else
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Hot;
                }
            }
            else
            {
                if (!checkBoxStatus.CheckEnable || checkBoxStatus.ReadOnly)
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Disabled;
                }
                else
                {
                    ElementCheckBox.Style = DevAge.Drawing.ControlDrawStyle.Normal;
                }
            }

            ElementCheckBox.CheckBoxState = checkBoxStatus.CheckState;


            ElementText.Value = checkBoxStatus.Caption;
        }