private OptionsRowButtonWrapper(SimpleDescriptor optionName, Action <bool?> SetState, Func <bool?> GetState, Func <bool?, string> GetText, Func <bool?, string> GetHint, SimpleDescriptor warningText, EnabledOrDisabledWithToolTipNullBtn disabledWithTooltipGetter, bool allowsNull) : base(optionName) { getter = GetState ?? throw new ArgumentNullException(nameof(GetState)); setter = SetState ?? throw new ArgumentNullException(nameof(SetState)); if (GetText is null) { throw new ArgumentNullException(nameof(GetText)); } GetDescriptionText = GetHint ?? throw new ArgumentNullException(nameof(GetHint)); warningTextFn = warningText; enabledFnGetter = disabledWithTooltipGetter ?? throw new ArgumentNullException(nameof(disabledWithTooltipGetter)); string getData(bool?target, bool enabled) { //if enabled FnGetter returns true, we ignore the output. return(enabledFnGetter(target, out string data) ? null : data); } nullable = allowsNull; enabledButton = new AutomaticButtonWrapper(() => GetText(true), () => SetStatus(true), (x) => getData(true, x), null, GetState() != true, false); if (allowsNull) { clearedButton = new AutomaticButtonWrapper(() => GetText(null), () => SetStatus(null), (x) => getData(null, x), null, GetState() != null, false); } else { clearedButton = new AutomaticButtonWrapper(() => "N/A", () => { }, tipCallback: null, null, false, false); clearedButton.SetVisibility(Visibility.Collapsed); } disabledButton = new AutomaticButtonWrapper(() => GetText(false), () => SetStatus(false), (x) => getData(false, x), null, GetState() != false, false); }
public MainMenuModelView(ModelViewRunner runner) : base(runner) { runner.PropertyChanged += Runner_PropertyChanged; ContinueButton = new AutomaticButtonWrapper(ContinueBtnText, resumeCallbackWrapper, ContinueButtonTip, null, resumeCallback != null, false); NewGameButton = new AutomaticButtonWrapper(newGameBtnText, newGameCallbackWrapper, NewGameBtnTip, null); DataButton = new AutomaticButtonWrapper(DataButtonText, dataCallbackWrapper, DataButtonTip, null); OptionsButton = new AutomaticButtonWrapper(OptionsButtonText, optionsCallbackWrapper, OptionsButtonTip, null); AchievementsButton = new AutomaticButtonWrapper(AchievementsButtonText, handleAchievements, AchievementsButtonTip, null); InstructionsButton = new AutomaticButtonWrapper(InstructionsButtonText, handleInstructions, InstructionsButtonTip, null); CreditsButton = new AutomaticButtonWrapper(CreditsButtonText, handleCredits, CreditsButtonTip, null); ModThreadButton = new AutomaticButtonWrapper(ModThreadButtonText, handleModUrl, ModThreadButtonTip, null); LastLanguageIndex = LanguageEngine.currentLanguageIndex; }