이 문제에 대한 몇 가지 질문을 보았지만 모든 솔루션을 시도했지만 그 중 아무 것도 내 경우에는 효과가 없었습니다. 내 코드가 작동 중입니다. 이 image은 그리기 버튼을 클릭하면 어떻게되는지 보여줍니다. 해당 도면을 확대해야합니다. AutoCAD 기능 "확대/축소"와 같은 코드를 작성할 수 있습니까?페인트 이벤트의 드로잉 크기 조정
Pen myPen = new Pen(Color.Black);
int centerpointx, centerpointy;
private void pictureBoxDraw_Paint(object sender, PaintEventArgs e)
{
centerpointx = pictureBoxDraw.Size.Width/2;
centerpointy = pictureBoxDraw.Size.Height/2;
myPen.Width = 2;
if (binary > 0)
{
var sizecrestgeo = 40;
var distancearraycrestgeo = new float[sizecrestgeo];
var elevationarraycrestgeo = new float[sizecrestgeo];
for (int i = 0; i < sizecrestgeo; i++)
{
distancearraycrestgeo[i] = float.Parse(dataGridViewCrestGeo.Rows[i].Cells[0].Value.ToString());
elevationarraycrestgeo[i] = float.Parse(dataGridViewCrestGeo.Rows[i].Cells[1].Value.ToString())*-1;
}
for (int i=0; i < sizecrestgeo-1; i++)
{
e.Graphics.DrawLine(myPen, distancearraycrestgeo[i]+centerpointx, elevationarraycrestgeo[i]+centerpointy, distancearraycrestgeo[i + 1]+centerpointx, elevationarraycrestgeo[i + 1]+centerpointy);
}
}
else
{
}
}
private void buttonDraw_Click_1(object sender, EventArgs e)
{
if (Hd > 0.0001)
{
binary = 1;
pictureBoxDraw.Invalidate();
}
else
{
MessageBox.Show("No data to draw, perform analysis first.");
}
}
private void buttoncleardraw_Click(object sender, EventArgs e)
{
binary = 0;
pictureBoxDraw.Invalidate();
}
}
Graphics 객체의 크기를 조절할 수 있습니다. [여기] (http://stackoverflow.com/questions/32204274/panel-drawing-zoom-in-c-sharp/32204516#32204516) 및 [여기] (http://stackoverflow.com/questions/32204274/)를 참조하십시오. 패널 드로잉 - 줌 - 인 - 샤프/32204516? s = 4 | 0.8505 # 32204516). – TaW
펜의 너비도 조정되므로 그림판에서 1px보다 작은 크기를 사용하는 것이 좋습니다. 그들은 여전히 최소 1px로 그려 질 것입니다. – TaW
@TaW 유용한 예와 경고, 감사합니다. [img1] (https://i.hizliresim.com/V0q6oV.png) [img2] (https://i.hizliresim.com/1LQDmp.png) 사실 이것은 내가 정확히 원하는 것이 아닙니다. 나는 사용자가 이것을 제어하기를 원하지 않는다. 나는 어떻게 든 그림을 중심에 놓아야한다. –