如果我在 Windows 窗体Paint
中Panel
绘制一些水平线。然后我将Graphics
对象传递给一个函数以在水平线上绘制其他图形。
现在我必须在 WPF 中绘制相同的水平线并在水平线上绘制其他图形(使用 XBAP 在浏览器中显示 WPF)。我不知道在 WPF 中使用什么来动态绘制图形(我必须在浏览器中显示图形)。
private void pnlViewer_Paint(object sender, PaintEventArgs e)
{
int cellWidth = (int)((double)1024/ (double)50);
int cellHeight = (int)((double)768/ (double)50);
//Draw Horizontal lines.
int y;
for (int i = 0; i <= 50; i++)
{
y = (i * cellHeight) + cellHeight;
using (var pen = new Pen(Color.FromArgb(50, 50, 50)))
{
e.Graphics.DrawLine(pen, new Point(0, y), new Point(1024, y));
}
DrawGraph(e.Graphics);
}
}