<commit_before>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ManagedWinapi
{
    /// <summary>
    /// This component displays a crosshair icon that can be dragged to any point
    /// on screen. This is useful to select other programs by dragging the crosshair
    /// to a program window.
    /// </summary>
    public partial class Crosshair : UserControl
    {
        Image myImage;
        Cursor myCursor;

        /// <summary>
        /// Occurs when the user finished dragging the crosshair. Use 
        /// <see cref="Cursor.Position"/> to detect the cursor position.
        /// </summary>
        public event EventHandler CrosshairDragged;

        /// <summary>
        /// Occurs while the user drags the crosshair. Use 
        /// <see cref="Cursor.Position"/> to detect the cursor position.
        /// </summary>
        public event EventHandler CrosshairDragging;

        /// <summary>
        /// Creates a new crosshair control.
        /// </summary>
        public Crosshair()
        {
            InitializeComponent();
            myImage = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
            myCursor = new Cursor(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
            dragger.Image = myImage;
        }

        private void dragger_MouseDown(object sender, MouseEventArgs e)
        {
            dragger.Image = null;
            dragger.Cursor = myCursor;
        }

        private void dragger_MouseUp(object sender, MouseEventArgs e)
        {
            dragger.Image = myImage;
            dragger.Cursor = Cursors.Cross;
            if (CrosshairDragged != null)
            {
                CrosshairDragged(this, new EventArgs());
            }
        }

        private void dragger_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragger.Cursor == myCursor)
            {
                if (CrosshairDragging != null)
                {
                    CrosshairDragging(this, new EventArgs());
                }
            }
        }

        /// <summary>
        /// When a window is hidden, the .NET framework releases mouse capture.
        /// If you hide your window while the crosshair is dragged, invoke
        /// this method afterwards to restore mouse capture.
        /// </summary>
        public void RestoreMouseCapture()
        {
            SetCapture(dragger.Handle);
        }

        #region PInvoke Declarations
        [DllImport("user32")]
        private static extern int SetCapture(IntPtr hwnd);
        #endregion
    }
}<commit_msg>Use the managed Control#Capture property instead of calling the SetCapture PInvoke method.<commit_after>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ManagedWinapi
{
    /// <summary>
    /// This component displays a crosshair icon that can be dragged to any point
    /// on screen. This is useful to select other programs by dragging the crosshair
    /// to a program window.
    /// </summary>
    public partial class Crosshair : UserControl
    {
        Image myImage;
        Cursor myCursor;

        /// <summary>
        /// Occurs when the user finished dragging the crosshair. Use 
        /// <see cref="Cursor.Position"/> to detect the cursor position.
        /// </summary>
        public event EventHandler CrosshairDragged;

        /// <summary>
        /// Occurs while the user drags the crosshair. Use 
        /// <see cref="Cursor.Position"/> to detect the cursor position.
        /// </summary>
        public event EventHandler CrosshairDragging;

        /// <summary>
        /// Creates a new crosshair control.
        /// </summary>
        public Crosshair()
        {
            InitializeComponent();
            myImage = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
            myCursor = new Cursor(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
            dragger.Image = myImage;
        }

        private void dragger_MouseDown(object sender, MouseEventArgs e)
        {
            dragger.Image = null;
            dragger.Cursor = myCursor;
        }

        private void dragger_MouseUp(object sender, MouseEventArgs e)
        {
            dragger.Image = myImage;
            dragger.Cursor = Cursors.Cross;
            if (CrosshairDragged != null)
            {
                CrosshairDragged(this, new EventArgs());
            }
        }

        private void dragger_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragger.Cursor == myCursor)
            {
                if (CrosshairDragging != null)
                {
                    CrosshairDragging(this, new EventArgs());
                }
            }
        }

        /// <summary>
        /// When a window is hidden, the .NET framework releases mouse capture.
        /// If you hide your window while the crosshair is dragged, invoke
        /// this method afterwards to restore mouse capture.
        /// </summary>
        public void RestoreMouseCapture()
        {
            dragger.Capture = true;
        }
    }
}
{'fraction_non_alphanumeric': 0.09192546583850932, 'fraction_numerical': 0.000354924578527063, 'mean_word_length': 1.891739353514623, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '4301489', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1362, 'n_words': 415}