Ejemplo n.º 1
0
        private void OnSelectSimpleCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (!_ignoreEvents)
            {
                if (e.NewValue == CheckState.Checked)
                {
                    // if any other box is checked except 'Select All (Entity Value)', clear 'Select All (Entity Value)'
                    if (e.Index != 0)
                    {
                        _selectSimpleCheckedListBox.SetItemChecked(0, false);
                        _dataSelection.SelectEnableInsert(false);
                        _dataSelection.SelectEnableUpdate(false);
                        _dataSelection.SelectEnableDelete(false);
                    }
                    // if 'Select All (Entity Value)' is checked, uncheck all others
                    else
                    {
                        // disable events while we bulk clear the selected items
                        _ignoreEvents = true;
                        // this event occurs before the check state is changed on the current selection, so it won't
                        // uncheck the box that triggered this event
                        foreach (int checkedIndex in _selectSimpleCheckedListBox.CheckedIndices)
                        {
                            _selectSimpleCheckedListBox.SetItemChecked(checkedIndex, false);
                        }
                        _ignoreEvents = false;
                        _dataSelection.ClearAllSelectedProperties();
                    }

                    // Add the current index to the list of selected properties in temporary state storage
                    _dataSelection.SelectEntityProperty(e.Index);
                }
                else
                {
                    // Remove the current index from the list of selected properties in temporary state storage.
                    _dataSelection.DeselectEntityProperty(e.Index);
                }

                _dataSelection.UpdateInsertUpdateDeleteState();

                // If there are no longer any properties checked at this point, the Finish button will be disabled
                _dataSelection.UpdateWizardState();
            }
        }