[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • Basic Paint App using VB2010
Page 1 of 1

Basic Paint App using VB2010

Posted: Tue Jan 25, 2011 9:48 pm
by bitfogav
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 15536 times
basicpainter2.jpg
basicpainter2.jpg (32.33 KiB) Viewed 15536 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

Re: Basic Paint App using VB2010

Posted: Tue Jan 25, 2011 10:32 pm
by brad
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?

Re: Basic Paint App using VB2010

Posted: Tue Jan 25, 2011 10:43 pm
by bitfogav
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 :)

Re: Basic Paint App using VB2010

Posted: Wed Jan 26, 2011 7:11 am
by brad
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!