【发布时间】:2012-12-18 01:19:51
【问题描述】:
我知道我的问题听起来很基本,但是我到处搜索却一无所获。 这是我的代码:
public MainWindow()
{
InitializeComponent();
Map newMap = new Map();
newMap.setMapStrategy(new SmallMapStrategy());
newMap.createMap();
System.Windows.Forms.PictureBox pictureBox1 = new System.Windows.Forms.PictureBox();
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(newMap.grid[3].afficher);
}
这是附加函数:
public override void afficher(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(squareImage, pos_x, pos_y, 50, 50);
}
squareImage 是一个与Drawing.Image 对应的属性。 pos_x 和 pos_y 是自定义 int32 属性。
我想在运行我的应用程序时查看图像...
【问题讨论】:
-
newMap.grid 是什么类型?
-
这也是 winforms 或 wpf,您已将其标记为 Wpf,但使用的是 Winforms 控件并使用 Winforms System.Drawing Methods
-
newMap.grid 是一个自定义类,在这里并不真正相关。但它包含如上所示的“afficher”方法
-
可能是这样,但我的第二个问题是相关的。
-
哦,抱歉,没看到。该项目以 WPF 为重点,但我打算使用实际使用图片框和 winforms 的 DrawImage(我猜?)
标签: c# wpf picturebox system.drawing drawimage