<commit_before>﻿using System.Drawing;
using System.Windows.Forms;

namespace TweetDck.Core.Controls{
    public partial class FlatProgressBar : ProgressBar{
        private SolidBrush brush;

        public FlatProgressBar(){
            SetStyle(ControlStyles.UserPaint,true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer,true);
        }

        public void SetValueInstant(int value){
            ControlExtensions.SetValueInstant(this,value);
        }

        protected override void OnPaint(PaintEventArgs e){
            if (brush == null || brush.Color != ForeColor){
                brush = new SolidBrush(ForeColor);
            }

            Rectangle rect = e.ClipRectangle;
            rect.Width = (int)(rect.Width*((double)Value/Maximum));
            e.Graphics.FillRectangle(brush,rect);
        }

        protected override void Dispose(bool disposing){
            if (brush != null)brush.Dispose();

            base.Dispose(disposing);
        }
    }
}<commit_msg>Fix potential memory leaks with FlatProgressBar color brush<commit_after>﻿using System.Drawing;
using System.Windows.Forms;

namespace TweetDck.Core.Controls{
    public partial class FlatProgressBar : ProgressBar{
        private readonly SolidBrush brush;

        public FlatProgressBar(){
            brush = new SolidBrush(Color.White);

            SetStyle(ControlStyles.UserPaint,true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer,true);
        }

        public void SetValueInstant(int value){
            ControlExtensions.SetValueInstant(this,value);
        }

        protected override void OnPaint(PaintEventArgs e){
            if (brush.Color != ForeColor){
                brush.Color = ForeColor;
            }

            Rectangle rect = e.ClipRectangle;
            rect.Width = (int)(rect.Width*((double)Value/Maximum));
            e.Graphics.FillRectangle(brush,rect);
        }

        protected override void Dispose(bool disposing){
            base.Dispose(disposing);

            if (disposing){
                brush.Dispose();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09289099526066351, 'fraction_numerical': 0.0, 'mean_word_length': 2.1936459909228443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '223269', 'n_tokens_mistral': 567, 'n_tokens_neox': 529, 'n_words': 110}