<commit_before>using System;
using Microsoft.Xna.Framework;
using MonoGame.PortableUI.Common;

namespace MonoGame.PortableUI.Controls
{
    public class ToggleButton : Button
    {
        private Color _backgroundColor;
        public bool IsChecked { get; set; }

        public Color ToggleColor { get; set; }

        public event EventHandler<CheckedEventArgs> Checked;

        public ToggleButton()
        {
            Click += ToggleButton_Click;
            _backgroundColor = BackgroundColor;
        }                                     

        private void ToggleButton_Click(object sender, System.EventArgs e)
        {
            IsChecked = !IsChecked;
            OnChecked(IsChecked);
            BackgroundColor = IsChecked ? ToggleColor : _backgroundColor;
        }  

        protected virtual void OnChecked(bool e)
        {
            CheckedEventArgs args = new CheckedEventArgs { IsChecked = e };
            Checked?.Invoke(this, args);
        }
    }
}<commit_msg>ToggleButton color changes on OnChecked event not on Click<commit_after>using System;
using Microsoft.Xna.Framework;
using MonoGame.PortableUI.Common;

namespace MonoGame.PortableUI.Controls
{
    public class ToggleButton : Button
    {
        private Color _backgroundColor;
        public bool IsChecked { get; set; }

        public Color ToggleColor { get; set; }

        public event EventHandler<CheckedEventArgs> Checked;

        public ToggleButton()
        {
            Click += ToggleButton_Click;
            _backgroundColor = BackgroundColor;
        }                                     

        private void ToggleButton_Click(object sender, System.EventArgs e)
        {
            IsChecked = !IsChecked;
            OnChecked(IsChecked);
        }  

        protected virtual void OnChecked(bool e)
        {
            CheckedEventArgs args = new CheckedEventArgs { IsChecked = e };
            Checked?.Invoke(this, args);
            BackgroundColor = IsChecked ? ToggleColor : _backgroundColor;
        }
    }
}
{'fraction_non_alphanumeric': 0.06748166259168704, 'fraction_numerical': 0.0, 'mean_word_length': 1.986861313868613, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4729598', 'n_tokens_mistral': 511, 'n_tokens_neox': 493, 'n_words': 130}