我的程序只打印图表。 如果我在屏幕外移动表单,则不会打印图表。我该如何解决?我是一个初学者。 你能帮忙吗? 谢谢。
private void button1_Click(object sender, EventArgs e)
{
Graphics gr ;
int m11, m12, m21, m22, dx, dy, ax, ay;
gr = pictureBox1.CreateGraphics();
int xmin = -5;
int xmax = 10;
int ymin = 0;
int ymax = xmax * xmax;
ax = pictureBox1.Size.Width / (xmax - xmin);
ay = pictureBox1.Size.Height / (ymax - ymin);
m11 = ax;
m12 = 0;
m21 = 0;
m22 = -ay;
dx = -xmin * ax;
dy = pictureBox1.Size.Height - ay * (-ymin);
System.Drawing.Drawing2D.Matrix M = new
System.Drawing.Drawing2D.Matrix(m11, m12, m21, m22, dx, dy);
gr.Transform = M;
int x = 0;
for (x = xmin; x < xmax; x++)
{
System.Drawing.Point p1 = new System.Drawing.Point(x, x * x);
System.Drawing.Point p2 = new System.Drawing.Point(x + 1, (x + 1) * (x + 1));
float brushSize = 0.2F;
System.Drawing.Pen pen = new
System.Drawing.Pen(System.Drawing.Brushes.Black, brushSize);
gr.DrawLine(pen, p1, p2);
}