﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TP5
{
    internal class ZoneDessin2 : Control
    {
        private int x_deb;
        private int y_deb;
        private int x_fin;
        private int y_fin;

        public ZoneDessin2() : base()
        {
            this.Location = new System.Drawing.Point(50, 50);
            this.Size = new System.Drawing.Size(400, 400);
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Pen myPen = new Pen(Color.DarkBlue);
            e.Graphics.DrawLine(myPen, this.x_deb, this.y_deb, 
                    this.x_fin, this.y_fin);
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.x_deb = e.Location.X;
            this.y_deb = e.Location.Y;
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            this.x_fin = e.Location.X;
            this.y_fin = e.Location.Y;
            this.Invalidate();
        }

    }
}
