예제 #1
0
        public SettingsRequirementViewModel GetSettingsRequirement()
        {
            if (this.EnableDisablePatreonBenefitToggleSwitch.IsChecked.GetValueOrDefault() && this.PatreonBenefitComboBox.SelectedIndex < 0)
            {
                return(null);
            }

            SettingsRequirementViewModel settings = new SettingsRequirementViewModel();

            if (ChannelSession.Settings.DeleteChatCommandsWhenRun)
            {
                settings.DontDeleteChatCommandWhenRun = this.DeleteChatCommandWhenRunToggleSwitch.IsChecked.GetValueOrDefault();
            }
            else
            {
                settings.DeleteChatCommandWhenRun = this.DeleteChatCommandWhenRunToggleSwitch.IsChecked.GetValueOrDefault();
            }

            if (this.EnableDisablePatreonBenefitToggleSwitch.IsChecked.GetValueOrDefault())
            {
                PatreonBenefit benefit = (PatreonBenefit)this.PatreonBenefitComboBox.SelectedItem;
                settings.PatreonBenefitIDRequirement = benefit.ID;
            }

            settings.ShowOnChatMenu = this.ShowOnChatMenuToggleSwitch.IsChecked.GetValueOrDefault();

            return(settings);
        }
        public void SetSettingsRequirement(SettingsRequirementViewModel settings)
        {
            if (ChannelSession.Settings.DeleteChatCommandsWhenRun)
            {
                this.DeleteChatCommandWhenRunToggleSwitch.IsChecked = settings.DontDeleteChatCommandWhenRun;
            }
            else
            {
                this.DeleteChatCommandWhenRunToggleSwitch.IsChecked = settings.DeleteChatCommandWhenRun;
            }

            if (!string.IsNullOrEmpty(settings.PatreonBenefitIDRequirement) && ChannelSession.Services.Patreon != null)
            {
                if (ChannelSession.Services.Patreon.Campaign.Benefits.ContainsKey(settings.PatreonBenefitIDRequirement))
                {
                    this.EnableDisablePatreonBenefitToggleSwitch.IsChecked = true;
                    this.PatreonBenefitComboBox.SelectedItem = ChannelSession.Services.Patreon.Campaign.Benefits[settings.PatreonBenefitIDRequirement];
                }
            }
        }