private void pictureBox1_Click(object sender, EventArgs e)
{
if (sender.GetType() == pictureBox1.GetType())
{
PictureBox pic = (PictureBox)sender;
int x = Control.MousePosition.X;
int y = Control.MousePosition.Y;
Point mousePos = new Point(x, y); //프로그램 내 좌표
Point mousePosPtoClient = pic.PointToClient(mousePos); //picbox 내 좌표
Point mousePosPtoScreen = pic.PointToScreen(mousePos); //스크린 내 좌표 (좌우 스크린 합친듯?)
this.Text = x.ToString() + ", " + y.ToString() +
", " + mousePosPtoClient.X.ToString() + ", " + mousePosPtoClient.Y.ToString() +
", " + mousePosPtoScreen.X.ToString() + ", " + mousePosPtoScreen.Y.ToString();
if (((MouseEventArgs)e).Button == MouseButtons.Left)
{
//do something
}
if (((MouseEventArgs)e).Button == MouseButtons.Right)
{
//do something
}
}
}
int GetInverseYval(int height, int inputY)
{
for (int i = 0, y = height - 1; i < height; i++, y--)
if (i == inputY)
return y;
return -1;
}
'컴퓨터 과학 & 영상처리 관련 > C# / .NET / JAVA' 카테고리의 다른 글
(퍼옴) C# textbox ctrl + a (0) | 2017.01.23 |
---|---|
C# OpenFileDialog Filter (0) | 2016.01.20 |
C# 변수명 없이 배열 파라메터 전달 (0) | 2016.01.12 |
C# 바탕화면 경로 등 특별한 경로를 알고 싶을 때 (0) | 2014.12.07 |
C# Resources 이미지 접근하기 (0) | 2014.11.28 |