Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing
- Imports System.Drawing.Drawing2D
- Public Class form1
- Dim mousePath As New System.Drawing.Drawing2D.GraphicsPath()
- Dim myAlpha As Integer = 100
- Dim myUserColor As New Color()
- Dim myPenWidth As Single = 5
- Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
- If e.Button = MouseButtons.Left Then
- mousePath.StartFigure()
- End If
- End Sub
- Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
- If e.Button = MouseButtons.Left Then
- Try
- mousePath.AddLine(e.X, e.Y, e.X, e.Y)
- Catch
- MsgBox("No way, Hose!")
- End Try
- End If
- PictureBox1.Invalidate()
- End Sub
- Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
- Try
- If btnColours.Text = "Red" Then
- myUserColor = (System.Drawing.Color.Red)
- myAlpha = 100
- ElseIf btnColours.Text = "Green" Then
- myUserColor = (System.Drawing.Color.Green)
- myAlpha = 255
- ElseIf btnColours.Text = "Black" Then
- myUserColor = (System.Drawing.Color.Black)
- myAlpha = 150
- ElseIf btnColours.Text = "Blue" Then
- myUserColor = (System.Drawing.Color.Blue)
- myAlpha = 175
- ElseIf btnColours.Text = "Bisque" Then
- myUserColor = (System.Drawing.Color.Bisque)
- myAlpha = 255
- End If
- Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor), myPenWidth) 'Set up the pen
- e.Graphics.DrawPath(CurrentPen, mousePath)
- Catch
- ' MsgBox("Not happening!")
- End Try
- End Sub
- Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
- mousePath.Reset()
- PictureBox1.Invalidate()
- End Sub
- End Class
Add Comment
Please, Sign In to add comment