all7 писал(а):Здравствуйте... бла-бла-бла... Прежде чем записать новую линию в bitmap, ее нужно динамически отобржать на экране (вобщем как в пейнте)... бла-бла... Может подскажите как решить проблему?
Public Class Form1
Private PointStart As Point = Point.Empty
Private PointEnd As Point = Point.Empty
Private bmp As Bitmap = New Bitmap(500, 500)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.DoubleBuffered = True
Me.Size = New Size(500, 500)
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
PointStart = e.Location
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If PointStart = Point.Empty Then Exit Sub
If PointEnd <> e.Location Then
PointEnd = e.Location
Me.Invalidate()
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Using g As Graphics = Graphics.FromImage(bmp)
g.DrawLine(Pens.Red, PointStart, PointEnd)
End Using
Me.BackgroundImage = bmp
PointStart = Point.Empty
PointEnd = Point.Empty
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If PointStart = Point.Empty Then Exit Sub
e.Graphics.DrawLine(Pens.Red, PointStart, PointEnd)
End Sub
End Class
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 89