<commit_before>using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace VulkanCore.Samples
{
    public class Win32Window : IVulkanAppHost
    {
        private readonly string _title;
        private readonly Timer _timer = new Timer();
        private readonly VulkanApp _app;
        private Form _form;

        private bool _appPaused; // Is the application paused?
        private bool _minimized; // Is the application minimized?
        private bool _maximized; // Is the application maximized?
        private bool _resizing;  // Are the resize bars being dragged?
        private bool _running;   // Is the application running?
        private FormWindowState _lastWindowState = FormWindowState.Normal;

        private int _frameCount;
        private float _timeElapsed;

        public Win32Window(string title, VulkanApp app)
        {
            _title = title;
            _app = app;
        }

        public IntPtr WindowHandle => _form.Handle;
        public IntPtr InstanceHandle => Process.GetCurrentProcess().Handle;
        public int Width { get; private set; } = 1280;
        public int Height { get; private set; } = 720;
        public Platform Platform => Platform.Win32;

        public Stream Open(string path) => new FileStream(path, FileMode.Open, FileAccess.Read);

        public void Initialize()
        {
            _form = new Form
            {
                Text = _title,
                FormBorderStyle = FormBorderStyle.Sizable,
                ClientSize = new System.Drawing.Size(Width, Height),
                StartPosition = FormStartPosition.CenterScreen,
                MinimumSize = new System.Drawing.Size(200, 200),
                Visible = false
            };
            _form.ResizeBegin += (sender, e) =>
            {
                _appPaused = true;
                _resizing = true;
                _timer.Stop();
            };
            _form.ResizeEnd += (sender, e) =>
            {
                _appPaused = false;
                _resizing = false;
                _timer.Start();
                _app.Resize();
            };
            _form.Activated += (sender, e) =>
            {
                _appPaused = false;
                _timer.Start();
            };
            _form.Deactivate += (sender, e) =>
            {
                _appPaused = true;
                _timer.Stop();
            };
            _form.HandleDestroyed += (sender, e) => _running = false;
            _form.Resize += (sender, e) =>
            {
                Width = _form.ClientSize.Width;
                Height = _form.ClientSize.Height;
                // When window state changes.
                if (_form.WindowState != _lastWindowState)<commit_msg>Fix for _form.Activated callback setting '_appPaused' to false even though the window was minimised.<commit_after>using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace VulkanCore.Samples
{
    public class Win32Window : IVulkanAppHost
    {
        private readonly string _title;
        private readonly Timer _timer = new Timer();
        private readonly VulkanApp _app;
        private Form _form;

        private bool _appPaused; // Is the application paused?
        private bool _minimized; // Is the application minimized?
        private bool _maximized; // Is the application maximized?
        private bool _resizing;  // Are the resize bars being dragged?
        private bool _running;   // Is the application running?
        private FormWindowState _lastWindowState = FormWindowState.Normal;

        private int _frameCount;
        private float _timeElapsed;

        public Win32Window(string title, VulkanApp app)
        {
            _title = title;
            _app = app;
        }

        public IntPtr WindowHandle => _form.Handle;
        public IntPtr InstanceHandle => Process.GetCurrentProcess().Handle;
        public int Width { get; private set; } = 1280;
        public int Height { get; private set; } = 720;
        public Platform Platform => Platform.Win32;

        public Stream Open(string path) => new FileStream(path, FileMode.Open, FileAccess.Read);

        public void Initialize()
        {
            _form = new Form
            {
                Text = _title,
                FormBorderStyle = FormBorderStyle.Sizable,
                ClientSize = new System.Drawing.Size(Width, Height),
                StartPosition = FormStartPosition.CenterScreen,
                MinimumSize = new System.Drawing.Size(200, 200),
                Visible = false
            };
            _form.ResizeBegin += (sender, e) =>
            {
                _appPaused = true;
                _resizing = true;
                _timer.Stop();
            };
            _form.ResizeEnd += (sender, e) =>
            {
                _appPaused = false;
                _resizing = false;
                _timer.Start();
                _app.Resize();
            };
            _form.Activated += (sender, e) =>
            {
                _appPaused = _form.WindowState != FormWindowState.Normal;
                _timer.Start();
            };
            _form.Deactivate += (sender, e) =>
            {
                _appPaused = true;
                _timer.Stop();
            };
            _form.HandleDestroyed += (sender, e) => _running = false;
            _form.Resize += (sender, e) =>
            {
                Width = _form.ClientSize.Width;
                Height = _form.ClientSize.Height;
                // When window state changes.
                if (_form.WindowState != _lastWindowState)
{'fraction_non_alphanumeric': 0.08425100506904387, 'fraction_numerical': 0.006642195420381052, 'mean_word_length': 1.6151736745886653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '4368259', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1409, 'n_words': 399}