刷新PictureBox ImageLocation

时间:2015-07-08 06:21:55

标签: vb.net winforms

我正在尝试刷新PictureBox ImageLocation。现在这是有效的,但我希望图像在" landscape"模式以我的形式显示风景。我可以通过使用image.RotateFlip()并预先使用加载来实现这一点。

但是当我尝试刷新图片时(使用计时器控件和另一个使用adb抓取屏幕截图的功能),它并不想刷新。使用断点显示它继续刷新。即使我添加其他项目,如刷新,更新,图像=没有..它仍然不刷新或清除图像。

定时器或负载是罪魁祸首吗?

Delegate Sub SetPicCallback([text] As String, ByVal [X] As Integer, ByVal [Y] As Integer, [label] As PictureBox)
Public Sub SetPic(ByVal [text] As String, ByVal [X] As Integer, ByVal [Y] As Integer, ByVal [label] As PictureBox)

    ' InvokeRequired required compares the thread ID of the 
    ' calling thread to the thread ID of the creating thread. 
    ' If these threads are different, it returns true. 
    If [label] IsNot Nothing Then
        For Each ctrl As PictureBox In myPics
            If ctrl.Name = [label].Name Then
                If ctrl.InvokeRequired Then
                    Dim d As New SetPicCallback(AddressOf SetPic)
                    Me.Invoke(d, New Object() {[text], [X], [Y], [label]})
                Else
                    With ctrl

                        .Width = [X] / 4
                        .Height = [Y] / 4
                        .Image = Nothing
                        .ImageLocation = [text]
                        '.Load([text])
                        'If [X] > [Y] Then
                        '    .Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
                        'End If
                    End With
                End If
            End If
        Next
    End If
End Sub

0 个答案:

没有答案