<commit_before>﻿using SharpCrop.Provider;
using SharpCrop.Provider.Utils;
using SharpCrop.Utils;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Threading;

namespace SharpCrop.Forms
{
    public partial class ClickForm : Form
    {
        private DrawForm drawForm;
        private IProvider provider;

        /// <summary>
        /// A clickable form which is totally transparent - so no drawing is possible here.
        /// </summary>
        public ClickForm(IProvider provider)
        {
            this.provider = provider;

            InitializeComponent();
            
            ClientSize = Screen.PrimaryScreen.Bounds.Size;
            Location = new Point(0, 0);
            Opacity = 0.005;

            drawForm = new DrawForm(this);
            drawForm.Show();
        }

        /// <summary>
        /// Grab bitmap and upload it to the saved Dropbox account.
        /// </summary>
        /// <param name="r">Bitmap position, size</param>
        public void Upload(Rectangle r)
        {
			Hide ();
			drawForm.Hide ();
			Application.DoEvents();

			#if __MonoCS__

			Thread.Sleep(500);

			#endif

			var name = DateTime.Now.ToString ("yyyy_MM_dd_HH_mm_ss") + "." + ConfigHelper.Memory.FormatExt;
			var bitmap = CaptureHelper.GetBitmap (r);

			using (var stream = new MemoryStream ()) 
			{
				bitmap.Save (stream, ConfigHelper.Memory.FormatType);

				var url = provider.Upload (name, stream);

				if (ConfigHelper.Memory.Copy)
                {
                    #if __MonoCS__

                    var form = new CopyForm(url);
                    form.FormClosed += (object sender, FormClosedEventArgs e) => Application.Exit();
                    form.Show();

                    #else

                    Clipboard.SetText(url);

                    #endif
                }
            }

            #if __MonoCS__

			ToastFactory.CreateToast("Uploaded successfully!", 3000, () => Application.Exit ());

            #endif
        }

        /// <summary>
        /// Listen for key presses.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
                case Keys.Escape:
                    Application.Exit();
                    break;
                case Keys.F1:
                    ConfigHelper.Reset();
                    Application.Exit();
                    break;
            }
        }

        /// <summary>
        /// Hide Form from the Alt + Tab application switcher menu.
        /// </summary>
        protected override CreateParams CreateParams
        {
            get
            {
                var Params = base.CreateParams;
                Params.ExStyle |= 0x80;
                return Params;
            }
        }

#region Mouse Events

        /* These mouse events are binded to DrawForm */

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            drawForm.CallOnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            drawForm.CallOnMouseUp(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            drawForm.CallOnMouseMove(e);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            drawForm.CallOnPaint(e);
        }

#endregion
    }
}<commit_msg>Missing toast fix - starting to get tired<commit_after>﻿using SharpCrop.Provider;
using SharpCrop.Provider.Utils;
using SharpCrop.Utils;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Threading;

namespace SharpCrop.Forms
{
    public partial class ClickForm : Form
    {
        private DrawForm drawForm;
        private IProvider provider;

        /// <summary>
        /// A clickable form which is totally transparent - so no drawing is possible here.
        /// </summary>
        public ClickForm(IProvider provider)
        {
            this.provider = provider;

            InitializeComponent();
            
            ClientSize = Screen.PrimaryScreen.Bounds.Size;
            Location = new Point(0, 0);
            Opacity = 0.005;

            drawForm = new DrawForm(this);
            drawForm.Show();
        }

        /// <summary>
        /// Grab bitmap and upload it to the saved Dropbox account.
        /// </summary>
        /// <param name="r">Bitmap position, size</param>
        public void Upload(Rectangle r)
        {
			Hide ();
			drawForm.Hide ();
			Application.DoEvents();

			#if __MonoCS__

			Thread.Sleep(500);

			#endif

			var name = DateTime.Now.ToString ("yyyy_MM_dd_HH_mm_ss") + "." + ConfigHelper.Memory.FormatExt;
			var bitmap = CaptureHelper.GetBitmap (r);

			using (var stream = new MemoryStream ()) 
			{
				bitmap.Save (stream, ConfigHelper.Memory.FormatType);

				var url = provider.Upload (name, stream);

				if (ConfigHelper.Memory.Copy)
                {
                    #if __MonoCS__

                    var form = new CopyForm(url);
                    form.FormClosed += (object sender, FormClosedEventArgs e) => Application.Exit();
                    form.Show();

                    #else

                    Clipboard.SetText(url);

                    #endif
                }
            }

            #if !__MonoCS__

			ToastFactory.CreateToast("Uploaded successfully!", 3000, () => Application.Exit ());

            #endif
        }

        /// <summary>
        /// Listen for key presses.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
                case Keys.Escape:
                    Application.Exit();
                    break;
                case Keys.F1:
                    ConfigHelper.Reset();
                    Application.Exit();
                    break;
            }
        }

        /// <summary>
        /// Hide Form from the Alt + Tab application switcher menu.
        /// </summary>
        protected override CreateParams CreateParams
        {
            get
            {
                var Params = base.CreateParams;
                Params.ExStyle |= 0x80;
                return Params;
            }
        }

#region Mouse Events

        /* These mouse events are binded to DrawForm */

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            drawForm.CallOnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            drawForm.CallOnMouseUp(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            drawForm.CallOnMouseMove(e);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            drawForm.CallOnPaint(e);
        }

#endregion
    }
}
{'fraction_non_alphanumeric': 0.09380322284815931, 'fraction_numerical': 0.004454342984409799, 'mean_word_length': 1.3352707249923523, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, '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': '6584584', 'n_tokens_mistral': 2149, 'n_tokens_neox': 1897, 'n_words': 456}