<commit_before>﻿using System;
using System.Windows.Forms;
using osu_StreamCompanion.Code.Core;
using osu_StreamCompanion.Code.Helpers;

namespace osu_StreamCompanion.Code.Modules.ModParser
{
    public partial class ModParserSettings : UserControl
    {
        private Settings _settings;
        private bool init = true;
        public ModParserSettings(Settings settings)
        {
            _settings = settings;
            _settings.SettingUpdated+= SettingUpdated;
            this.Enabled = _settings.Get("EnableMemoryScanner", true);
            InitializeComponent();
            textBox_Mods.Text = _settings.Get("NoModsDisplayText", "None");
            radioButton_longMods.Checked = _settings.Get("UseLongMods", false);
            radioButton_shortMods.Checked = !radioButton_longMods.Checked;
            init = false;
        }

        private void SettingUpdated(object sender, SettingUpdated settingUpdated)
        {
            this.BeginInvoke((MethodInvoker) (() =>
            {
                if (settingUpdated.Name == "EnableMemoryScanner")
                    this.Enabled = _settings.Get("EnableMemoryScanner", true);
            }));
        }

        private void textBox_Mods_TextChanged(object sender, EventArgs e)
        {
            if (init) return;
            _settings.Add("NoModsDisplayText", textBox_Mods.Text);
        }

        private void radioButton_longMods_CheckedChanged(object sender, EventArgs e)
        {
            if (init) return;
            if (((RadioButton)sender).Checked)
            {
                _settings.Add("UseLongMods", radioButton_longMods.Checked);<commit_msg>Make sure that beginInvoke target exists<commit_after>﻿using System;
using System.Windows.Forms;
using osu_StreamCompanion.Code.Core;
using osu_StreamCompanion.Code.Helpers;

namespace osu_StreamCompanion.Code.Modules.ModParser
{
    public partial class ModParserSettings : UserControl
    {
        private Settings _settings;
        private bool init = true;
        public ModParserSettings(Settings settings)
        {
            _settings = settings;
            _settings.SettingUpdated += SettingUpdated;
            this.Enabled = _settings.Get("EnableMemoryScanner", true);
            InitializeComponent();
            textBox_Mods.Text = _settings.Get("NoModsDisplayText", "None");
            radioButton_longMods.Checked = _settings.Get("UseLongMods", false);
            radioButton_shortMods.Checked = !radioButton_longMods.Checked;
            init = false;
        }

        private void SettingUpdated(object sender, SettingUpdated settingUpdated)
        {
            if (this.IsHandleCreated)
                this.BeginInvoke((MethodInvoker)(() =>
           {
               if (settingUpdated.Name == "EnableMemoryScanner")
                   this.Enabled = _settings.Get("EnableMemoryScanner", true);
           }));
        }

        private void textBox_Mods_TextChanged(object sender, EventArgs e)
        {
            if (init) return;
            _settings.Add("NoModsDisplayText", textBox_Mods.Text);
        }

        private void radioButton_longMods_CheckedChanged(object sender, EventArgs e)
        {
            if (init) return;
            if (((RadioButton)sender).Checked)
            {
                _settings.Add("UseLongMods", radioButton_longMods.Checked);
{'fraction_non_alphanumeric': 0.08792846497764531, 'fraction_numerical': 0.0, 'mean_word_length': 2.352647352647353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4440686', 'n_tokens_mistral': 874, 'n_tokens_neox': 863, 'n_words': 166}