944,123 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9948
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 26th, 2007
0

simple paint similar to MS Paint.. I have qustions!

Expand Post »
Hi,

I work with Microsoft Visual Studio 2005.


I'm about to build a simple paint editor similar to MS Paint program.


of course, it has Edit menu, with Undo, Redo, Cut, Copy, Paste, Delete... etc.


I have a problem with Undo and Redo!

How to do them with drawing?

have I use Stack or something like this?

I'm just a beginner and I have no idea


Another question..

For Cut, Paste, Copy and Delete, I need a selection tool same as the one in MS Paint.
Where can I find it? or how to Cut and Paste with out it?

Please, I really need your help

thanx a lot.
Last edited by Nana.vb; Apr 26th, 2007 at 9:05 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nana.vb is offline Offline
4 posts
since Apr 2007
Apr 27th, 2007
1

Re: simple paint similar to MS Paint.. I have qustions!

Here is how I did a undo:
VB.NET Syntax (Toggle Plain Text)
  1. Dim UndoStack As New Stack(Of Bitmap)() 'holds the backup images
  2.  
  3. '==========================================================================
  4. ' Saves the picture passed
  5. '==========================================================================
  6. Private Sub PushUndo(ByVal b As Bitmap)
  7. UndoStack.Push(b)
  8. btnUnDo.Visible = True
  9. End Sub
  10.  
  11. '==========================================================================
  12. ' Returns the last picture saved
  13. '==========================================================================
  14. Private Function PopUndo() As Bitmap
  15. If UndoStack.Count = 0 Then
  16. Return Nothing
  17. btnUnDo.Visible = False
  18. Exit Function
  19. End If
  20. If UndoStack.Count = 1 Then btnUnDo.Visible = False
  21. Return UndoStack.Pop
  22. End Function
To save a bitmap:
VB.NET Syntax (Toggle Plain Text)
  1. 'save the current picture for undo
  2. PushUndo(Display.Image.Clone)
To undo:
VB.NET Syntax (Toggle Plain Text)
  1. '==========================================================================
  2. ' pops the last bitmat off the stack and places it in the display
  3. '==========================================================================
  4. Private Sub btnUnDo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnDo.Click
  5. Dim bmp As Bitmap
  6. bmp = PopUndo()
  7. If bmp IsNot Nothing Then
  8. Display.Image = bmp
  9. End If
  10. End Sub
The second part I am going to have to find. I'll get back at you.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Apr 27th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

waynespangler

thank u soooo mutch ..


I have a good idea now : )


thanks again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nana.vb is offline Offline
4 posts
since Apr 2007
Apr 27th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

After all this time I finally found my bug in this routine. The undo button would never go off and I couldn't figure out why. Can you see it?
VB.NET Syntax (Toggle Plain Text)
  1. If UndoStack.Count = 0 Then
  2. Return Nothing
  3. btnUnDo.Visible = False
  4. Exit Function
  5. End If
In vb net a return exits the routine immediatlly so in the above btnUnDo.visible=False never got executed and neither did Exit Function. Because it was exiting I figured it was working right. Now I know why not.
It should be:
VB.NET Syntax (Toggle Plain Text)
  1. If UndoStack.Count = 0 Then
  2. btnUnDo.Visible = False
  3. Return Nothing
  4. End If
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Apr 27th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

What are you using for the drawing, GDI+ ?
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is offline Offline
16,534 posts
since Apr 2005
Apr 27th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

waynespangler..

ohhh .. yes that's right : )


thanx alooot





jbennet..

The drawing tool bar contains:
  • Lines (in different styles : regular, dashed and thick)
  • curves
  • Shapes: rectangle, circle and oval.
  • Pen.
  • Brush ( in different styles- HatchBrush, LinearGradientBrush, PathGradientBrush and TextureBrush)
  • Text.
  • Fill (with color or pattern)
and I drow on picture box


thank u : )
Last edited by Nana.vb; Apr 27th, 2007 at 12:06 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nana.vb is offline Offline
4 posts
since Apr 2007
Apr 27th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

Here is some samples of cut, copy and paste. They are not as effecient as they should be, so that is up to you. Post if you have any more questions.
Attached Files
File Type: zip Rubberband.zip (642.9 KB, 411 views)
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
May 15th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

waynespangler..

thnx alooot : )

I did my project, and it's perfect now

thnx again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nana.vb is offline Offline
4 posts
since Apr 2007
May 18th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

Hi

please i want to ask about this statment

PushUndo(Display.Image.Clone)

Display is't the surface i draw on it??

i use a picture box for drawing and i don't want just the back ground image to be save

what about the drawings like lines,curves...etc??

please i need your healp

see ya
Reputation Points: 10
Solved Threads: 0
Newbie Poster
WoW7787 is offline Offline
3 posts
since May 2007
May 18th, 2007
0

Re: simple paint similar to MS Paint.. I have qustions!

plz Nana can you help me ??

i've similar assignment and i need a little help

I'm just a beginner
Reputation Points: 10
Solved Threads: 0
Newbie Poster
WoW7787 is offline Offline
3 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Uploading and Image to SQL with TableAdapter.Insert
Next Thread in VB.NET Forum Timeline: update database related to checklistbox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC