Picturebox qoplamasi vb.net

Men quyidagi kodni yozdim, lekin bir muammo bor, uni tushunishga harakat qilmayapman. ammo, bo'yoq usuli deyiladi, lekin chizmaydi, o'rniga rasmni rasm maydoniga aylantirganimda o'sha nuqtadagi chiziq chiziladi.. Iltimos, yordam bering.

Private Sub picCurrentimage_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picCurrentimage.MouseDown
     px = e.X
     py = e.Y
     highlightPic(px, py)
End Sub

Private Sub highlightPic(ByVal x1 As Integer, ByVal y1 As Integer)
        haspoint = True
        picCurrentimage.Invalidate()
        picCurrentimage.Update()
End Sub


Private Sub picCurrentimage_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picCurrentimage.Paint
        If haspoint Then
            Dim g As Graphics = picCurrentimage.CreateGraphics
            Dim r As Rectangle = New Rectangle(px, py, 600, 10) 
            Dim pen As Pen = New Pen(Color.FromArgb(128, 32, 100, 200), 1) 
            Dim b As Brush = New SolidBrush(pen.Color)
            g.FillRectangle(b, r)
        End If
End Sub

person user1874442    schedule 04.12.2012    source manba


Javoblar (1)


Kodingizni quyidagi o'zgartirishlar bilan almashtirishga harakat qiling:

Private Sub highlightPic(ByVal x1 As Integer, ByVal y1 As Integer)
    haspoint = True
    picCurrentimage.Refresh()  'this do both of your lines in one
End Sub

Private Sub picCurrentimage_Paint(ByVal sender As Object, _
                                  ByVal e As PaintEventArgs) _
                                  Handles picCurrentimage.Paint
    If haspoint Then

        Dim g As Graphics = e.Graphics
        Dim r As Rectangle = picCurrentimage.ClientRectangle

        Dim b As Brush = New SolidBrush(Color.FromArgb(128, 32, 100, 200))
        g.FillRectangle(b, r)
        b.Dispose

    End If

End Sub
person Community    schedule 04.12.2012