daveofgv
Well-known member
Would it be possible if someone can help with my paint application?
I need an eraser tool for the user and some other cool effects.
What I have now is:
I have tried several methods of an eraser, but nothing really works good. Also, I am needing help with adding a picture (which I can) and being able to draw on the picture (which I can not).
Also, If I should be using a panel instead of using a picturebox can someone show me how? I tried and it says panel1.image is not a memeber of the system.panel......
If anyone can help I would sure appreciate it.
Thanks in advanced.
daveofgv
I need an eraser tool for the user and some other cool effects.
What I have now is:
VB.NET:
Public Class doodletime
Dim xStart, yStart, xEnd, yEnd As Integer
Dim Drawbitmap As Bitmap
Dim Drawgraphics As Graphics
Dim myPen As New Pen(Color.BlueViolet, 3)
Dim myColor As Color = Color.Blue
Dim myBrush As New Drawing.SolidBrush(Color.Red)
Dim myBrushWidth As Integer
Dim ContinuousFlag As Boolean
Private Sub drawMyline()
PictureBox1.Image = Drawbitmap
Drawgraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Drawgraphics.DrawLine(myPen, xStart, yStart, xEnd, yEnd)
End Sub
Private Sub doodletime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Drawgraphics = Graphics.FromImage(Drawbitmap)
PictureBox1.Image = Drawbitmap
Drawgraphics.Clear(Color.White)
myBrushWidth = 4
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
xStart = Control.MousePosition.X - (Me.Left + PictureBox1.Left + 4)
yStart = Control.MousePosition.Y - (Me.Top + PictureBox1.Top + 31)
'to do continuous drawing, enable this line
'drawMyline()
If RadioButton1.Checked = True Then
ContinuousFlag = True
End If
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If ContinuousFlag Then
Drawgraphics.SmoothingMode = Drawing2D.SmoothingMode.None
Drawgraphics.FillEllipse(myBrush, e.X, e.Y, myBrushWidth, myBrushWidth)
PictureBox1.Image = Drawbitmap
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
xEnd = Control.MousePosition.X - (Me.Left + PictureBox1.Left + 4)
yEnd = Control.MousePosition.Y - (Me.Top + PictureBox1.Top + 31)
If RadioButton1.Checked Then
ContinuousFlag = False
Else
drawMyline()
End If
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
ColorDialog1.ShowDialog()
myPen.Color = ColorDialog1.Color
myBrush.Color = ColorDialog1.Color
End Sub
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
Dim Savefiledialog1 As New SaveFileDialog()
Savefiledialog1.Filter = "Bitmap Image (*.bmp)|*.bmp |All Files |*.*"
If Savefiledialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(Savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
End Sub
Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Drawgraphics = Graphics.FromImage(Drawbitmap)
PictureBox1.Image = Drawbitmap
Drawgraphics.Clear(Color.White)
End Sub
Private Sub ButtonX3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX3.Click
Me.Close()
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
With OpenFileDialog1
'.InitialDirectory = "C:\"
.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
End With
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.BorderStyle = BorderStyle.Fixed3D
lblFilePath.Text = OpenFileDialog1.FileName()
End If
End Sub
Private Sub PanelEx1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PanelEx1.Click
End Sub
End Class
I have tried several methods of an eraser, but nothing really works good. Also, I am needing help with adding a picture (which I can) and being able to draw on the picture (which I can not).
Also, If I should be using a panel instead of using a picturebox can someone show me how? I tried and it says panel1.image is not a memeber of the system.panel......
If anyone can help I would sure appreciate it.
Thanks in advanced.
daveofgv
Last edited: