Basic Paint App using VB2010

Post here to discuss programming in VB.net

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Basic Paint App using VB2010

Post by bitfogav » Tue Jan 25, 2011 9:48 pm

This is my first VB 2010 app I made, it is a basic painter based on the Windows operating system app Paint.

Version 1.
basicpainter1.jpg
basicpainter1.jpg (22.67 KiB) Viewed 16300 times
basicpainter2.jpg
basicpainter2.jpg (32.33 KiB) Viewed 16300 times
Source Code:

Code: Select all

Public Class PaintForm

    Private shouldPaint As Boolean = False ' determines whether to paint
   Dim PaintColor As Color

    '***************************************************
   '   Load all our Radiobuttons and Set Radiobutton1.
   '***************************************************
   Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.RadioButton1.Tag = Color.Black
        Me.RadioButton2.Tag = Color.Yellow
        Me.RadioButton3.Tag = Color.Green
        Me.RadioButton4.Tag = Color.Purple
        Me.RadioButton5.Tag = Color.Pink
        Me.RadioButton6.Tag = Color.Brown
        Me.RadioButton7.Tag = Color.Cyan
        Me.RadioButton8.Tag = Color.Red
        Me.RadioButton9.Tag = Color.Blue
        Me.RadioButton10.Tag = Color.Orange
        Me.RadioButton11.Tag = Color.White
        Me.RadioButton1.Checked = True
    End Sub
    '***************************************************
   '   Check our Mouse button to paint on screen = True
   '***************************************************
   Private Sub Panel1_MouseDown(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Panel3.MouseDown
        shouldPaint = True
    End Sub
    '***************************************************
   '   Check our Mouse button to paint on screen = False
   '***************************************************
   Private Sub Panel1_MouseUp(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Panel3.MouseUp
        shouldPaint = False
    End Sub
    '***************************************************
   '   Draws on Panel3 with mouse clicked.
   '***************************************************
   Private Sub Panel1_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Panel3.MouseMove, RadioButton1.MouseMove, RadioButton1.MouseClick
        If (shouldPaint) Then
            Using g As Graphics = Panel3.CreateGraphics()
                g.FillEllipse(New SolidBrush(PaintColor), e.X, e.Y, 4, 4)
                g.Dispose()
            End Using
        End If
    End Sub ' 
   '***************************************************
   '   Selects which colour by check/change of Radiobuttons.
   '***************************************************
   Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, RadioButton2.CheckedChanged, RadioButton3.CheckedChanged, RadioButton4.CheckedChanged, RadioButton5.CheckedChanged, RadioButton6.CheckedChanged, RadioButton7.CheckedChanged, RadioButton8.CheckedChanged, RadioButton9.CheckedChanged, RadioButton10.CheckedChanged, RadioButton11.CheckedChanged
        If CType(sender, RadioButton).Checked = True Then
            PaintColor = CType(CType(sender, RadioButton).Tag, Color)
        End If
    End Sub
    '***************************************************
   '   Clears Panel3 when the Clear button is pressed.
   '***************************************************
   Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        Dim a As Graphics = Panel3.CreateGraphics()
        a.Clear(Color.White)     
     End Sub
End Class

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Basic Paint App using VB2010

Post by brad » Tue Jan 25, 2011 10:32 pm

I have to say - I love this app!

I have used a bit of your code to implement an inbuilt drawing option to the 8x85 POV converter program.

i don't suppose you have figured out how to save a panel to an image file?

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Basic Paint App using VB2010

Post by bitfogav » Tue Jan 25, 2011 10:43 pm

brad wrote:i don't suppose you have figured out how to save a panel to an image file?
I haven't done anymore to it since to be honest Brad, but that would be a great function for version2, looks like you have been more busy than me with visual basic though, you've made some great apps already :)

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Basic Paint App using VB2010

Post by brad » Wed Jan 26, 2011 7:11 am

It's a great program and fun to use.

I have been getting alot of help and sample code from searching google.

A great site is dreamingincode - loads of info on there :D

Still so much to learn - but that's half the fun!

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 3 guests