Point position = new Point();
private void Background_MouseDown(object sender, MouseEventArgs e)
{
position.X = e.X;
position.Y = e.Y;
}
private void Background_MouseMove(object sender, MouseEventArgs e)
{
// Size의 크기가 -로 될 수 가 있다.
int width = e.X - position.X;
int height = e.Y - position.Y;
Size size = new Size(width, height);
}
width와 height는 -값이 나올 수 없으니
절대값으로 바꿔주어야 한다.
바꾸는 함수는 Math.Abs(); 다음과 같이 바꾸면 된다.
int width = Math.Abs(e.X - position.X);
int height = Math.Abs(e.Y - position.Y);
'Programming > C#' 카테고리의 다른 글
C# PictureBox Mouse Move (0) | 2012.07.18 |
---|---|
C# Save & OpenFileDialog (0) | 2012.07.12 |
C# MouseMove & MouseDown & MouseUp (0) | 2012.07.12 |