// https://www.youtube.com/watch?v=SAf7M_igdNg&t=1s
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Systehttp://m.Threading.Tasks;
using Systehttp://m.Windows.Forms;
namespace LabelMoveSize
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Point mousePoint ;
Size labelSize ;
private void label1_MouseDown(object sender, MouseEventArgs e)
{
mousePoint = new Point(e.X, e.Y);
labelSize = label1.Size ;
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
int xDiff = label1.Size.Width - e.X ;
int yDiff = label1.Size.Height - e.Y ;
if(xDiff<20 && yDiff<20) // mouse cursor change
{
Cursor.Current = Cursors.SizeNWSE ;
}
if( (e.Button & MouseButtons.Left) != MouseButtons.Left) return ;
if(xDiff<20 && yDiff<20)
{
label1.Size = new Size(labelSize.Width - (mousePoint.X-e.X),
labelSize.Height - (mousePoint.Y-e.Y)) ;
return ;
}
label1.Location = new Point(label1.Left - (mousePoint.X-e.X),
label1.Top - (mousePoint.Y-e.Y));
}
}
}