GraphicsPath
을 구축하고 클릭 한 점이 IsVisible
방법으로 해당 부분에 있는지 확인할 수 있습니다.
또한이 코드는 포인트 목록을 작성하고 Paint 이벤트의 각 포인트에 이미지를 그립니다. GraphicsPath
도면을 수행하게하려면 DrawPath
행의 주석 처리를 제거하고 // ** 관련 목록을 삭제하십시오.
GraphicsPath GP = new GraphicsPath();
List<Point> PL = new List<Point>(); //**
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
int diameter = 22; // put in the size of your circle
Size s = new Size(diameter, diameter);
if (!GP.IsVisible(e.Location))
{
Point middle = new Point(e.X - diameter/2, e.Y - diameter/2);
GP.AddEllipse(new Rectangle(middle, s));
PL.Add(middle); //**
}
this.Invalidate();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
// e.Graphics.DrawPath(Pens.Firebrick, GP);
Image img = new Bitmap("D:\\circle22.png"); //**
foreach(Point pt in PL) e.Graphics.DrawImage(img, pt); //**
img.Dispose(); //**
}
출처
2014-06-15 09:20:48
TaW
문제가 해결 되었습니까? – TaW
예, 새로운 PictureBox를 인스턴스화하고 Controls.Add (new_box)를 사용했습니다. 내가 제대로 설명하지 못했고, 원 이미지가있는 PNG가 있습니다. 그리려는 것이 아닙니다. – nightshade
큰 차이는 없습니다. 당신은 여전히 수표에 대한 내 코드를 사용할 수 있습니다, 조금만 변경하십시오 : 전체 Paint 이벤트를 남겨두고 당신은'if 절'에 (new_box)를 추가합니다 ..! – TaW