/// <summary> /// Updates the states of all radio buttons within the radio button group based on the state of the /// radio button specified by the supplied <see cref="RadioButtonViewModel"/>. /// </summary> /// <param name="activeButtonViewModel"></param> public void UpdateRadioButtons(RadioButtonViewModel activeButtonViewModel) { foreach (RadioButtonViewModel radioButtonViewModel in _radioButtonViewModels) { if (radioButtonViewModel.Id != activeButtonViewModel.Id) { radioButtonViewModel.UiValue = false; } } }
/// <summary> /// Factory method for creating new ControlViewModel instances. /// </summary> /// <param name="underlyingStrategy"><see cref="Strategy_t"/> that this ControlViewModel's <see cref="Control_t"/> is a member of.</param> /// <param name="control">Underlying Control_t for this ControlViewModel.</param> /// <returns>New ControlViewModel instance.</returns> public static ControlViewModel Create(Strategy_t underlyingStrategy, Control_t control, IInitialFixValueProvider initialValueProvider) { IParameter referencedParameter = null; if (control.ParameterRef != null) { referencedParameter = underlyingStrategy.Parameters[control.ParameterRef]; if (referencedParameter == null) { throw ThrowHelper.New <ReferencedObjectNotFoundException>(ErrorMessages.UnresolvedParameterRefError, control.ParameterRef); } } ControlViewModel controlViewModel; #if !NET_40 // This is to workaround a bug in .NET Framework 3.5 where it is possible for more than one radio button in a // group to be checked at a time. if (control is RadioButton_t) { controlViewModel = new RadioButtonViewModel(control as RadioButton_t, referencedParameter); } else #endif if (control is ListControlBase) { controlViewModel = ListControlViewModel.Create(control as ListControlBase, referencedParameter); } else if (InvalidatableControlViewModel.IsInvalidatable(control)) { controlViewModel = InvalidatableControlViewModel.Create(control, referencedParameter); } else { controlViewModel = new ControlViewModel(control, referencedParameter); } controlViewModel._stateRules = new ViewModelStateRuleCollection(controlViewModel, control.StateRules); controlViewModel._fixFieldValues = new FixFieldValueProvider(initialValueProvider, underlyingStrategy.Parameters); return(controlViewModel); }
private void RegisterRadioButton(RadioButton_t radioButton, RadioButtonViewModel controlViewModel) { string groupName = radioButton.RadioGroup; if (!string.IsNullOrEmpty(groupName)) { RadioButtonGroupManager groupManager; if (_radioButtonGroups.Contains(groupName)) { groupManager = _radioButtonGroups[groupName]; } else { groupManager = _radioButtonGroups.AddGroup(groupName); } groupManager.RegisterRadioButton(controlViewModel); controlViewModel.RadioButtonGroupManager = groupManager; } }
/// <summary> /// Registers a radio button via its <see cref="RadioButtonViewModel"/> with this RadionButtonGroupManager. /// </summary> /// <param name="radioButtonViewModel">Reference to the RadioButtonViewModel to register.</param> public void RegisterRadioButton(RadioButtonViewModel radioButtonViewModel) { _radioButtonViewModels.Add(radioButtonViewModel); }