private int MutuallyExclusiveChoiceWithMaster( object _Sender, CheckBox[] _Choices, int _MasterChoice )
{
m_ModifyingCheckboxes = true;
CheckBox C = _Sender as CheckBox;
if ( C == _Choices[0] )
{ // Master choice
if ( !C.Checked )
{ // Unchecking the master just clears all other choices
for ( int ChoiceIndex=1; ChoiceIndex < _Choices.Length; ChoiceIndex++ )
_Choices[ChoiceIndex].Checked = false;
m_ModifyingCheckboxes = false;
return 0;
}
m_ModifyingCheckboxes = false;
return _MasterChoice;
}
// Always check the master
_Choices[0].Checked = true;
if ( !C.Checked )
{ // Unchecking a non master tick means we're left with the master choice anyway
m_ModifyingCheckboxes = false;
return _MasterChoice;
}
// Uncheck all others and keep the only one that's checked
int SelectedChoice = 0;
for ( int ChoiceIndex=1; ChoiceIndex < _Choices.Length; ChoiceIndex++ )
if ( _Choices[ChoiceIndex] == C )
SelectedChoice = ChoiceIndex;
else
_Choices[ChoiceIndex].Checked = false;
m_ModifyingCheckboxes = false;
return SelectedChoice | _MasterChoice;
}