using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EX3
{
    public partial class Form1 : Form
    {
        int Cx, Cy;
        bool flag = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            flag = true;
            Cx = e.Location.X;
            Cy = e.Location.Y;

        }
         private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            flag = false;
           //این خط برای این است که ماوس بعد از انتقال به مکان قیلی خود برگردد
             Cursor.Position = new Point(Cx + this.Left, Cy + this.Top);
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (flag)
            {
                this.Left =this.Left + e.X;
                this.Top = this.Top+e.Y;
            }
        }
    }
}
