CameraPlay.cs 1.8 KB
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 TSA_V
{
    public partial class CameraPlay : UserControl
    {
        public CameraPlay()
        {
            InitializeComponent();
        }

        private void FrmCameraPlay_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (blnDraw)
            {
                this.Invoke(new Action(() =>
                {
                    currPoint = Cursor.Position;
                    currPoint.X = currPoint.X - (this.Size.Width / 2);
                    currPoint.Y = currPoint.Y - (this.Size.Height / 2);
                    this.Location = currPoint;
                }));
            }
        }
        Point currPoint;
        Point start;
        Point end;
        bool blnDraw;
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                start = e.Location;
                blnDraw = true;
            }
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            //if (blnDraw)
            //{
            //    if (e.Button != MouseButtons.Left)
            //    {
            //        return;
            //    }
            //    end = e.Location;
            //    pictureBox1.Invalidate();
            //}
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if(e.Button==MouseButtons.Left)
            {
                blnDraw = false;
            }
        }
    }
}