0

我正在尝试做并且真正努力做的事情是让我的应用程序将几张图片一张一张地绘制到面板上。这目前被编码为通过向函数发送请求以绘制图像来工作。它发送与所述图像相对应的值,但在那之后,我被卡住了。我不能让它在我的面板上画任何东西。这是功能:

Function ImageUpdater(ByVal CellNum As Short, ByVal NewImage As Short)
    Dim NewImgLoc As String = CurDirShrt & "\Data\Img\" & NewImage & ".png"
    DrawPic = NewImgLoc
    Try
        InitializeComponent()
        Cell(CellNum) = NewImage
        DrawCell = Cell(CellNum)
        UpdateForm = True
        'PaintMe(panGame, Nothing)
        'e.Graphics.DrawImage(Image.FromFile(NewImgLoc), PicCell(CellNum).X, PicCell(CellNum).Y, CellSize, CellSize)
        'PicCell(CellNum).BackgroundImage = Image.FromFile(NewImgLoc)
        'PicCell(CellNum).Refresh()
    Catch ex As Exception
        InitializeComponent()
        Cell(CellNum) = 0
        DrawCell = Cell(CellNum)
        UpdateForm = True
        'PaintMe(panGame, Nothing)
        'e.Graphics.DrawImage(MisImg, PicCell(CellNum).X, PicCell(CellNum).Y, CellSize, CellSize)
        'PicCell(CellNum).BackgroundImage = MisImg
        'PicCell(CellNum).Refresh()
    End Try
    Return 0
End Function

对我不起作用的与油漆相关的项目包括注释行。他们被评论是为了让我尝试不同的方式让面板上色。

我需要在这个函数中添加什么,让它将图像及其各自的位置发送到面板的 PaintEventArgs 子,我在那个子中需要什么?或者,如果我不把它发送到那个潜艇,我应该怎么做?

这是 PaintEventArgs 子:

Private Sub PaintMe(sender As Object, e As PaintEventArgs) Handles panGame.Paint
    While ChangeInProgress
        Application.DoEvents()
        If UpdateForm = True Then
            e.Graphics.DrawImage(Image.FromFile(DrawPic), PicCell(DrawCell).X, PicCell(DrawCell).Y, CellSize, CellSize)
            UpdateForm = False
        End If
    End While
    Return
End Sub
4

0 回答 0