private static GuiWidget CreateToggleSwitch(ToggleSwitchConfig toggleSwitchConfig, ThemeConfig theme) { if (toggleSwitchConfig == null) { return(null); } var toggleSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Checked = toggleSwitchConfig.Checked, Name = toggleSwitchConfig.Name, Margin = new BorderDouble(left: 16), }; toggleSwitch.CheckedStateChanged += (sender, e) => { toggleSwitchConfig.ToggleAction?.Invoke(toggleSwitch.Checked); }; return(toggleSwitch); }
public SettingsItem(string text, ThemeConfig theme, ToggleSwitchConfig toggleSwitchConfig = null, GuiWidget optionalControls = null, ImageBuffer iconImage = null, bool enforceGutter = true) : this(text, CreateToggleSwitch(toggleSwitchConfig, theme), theme, optionalControls, iconImage, enforceGutter) { }