Thursday, December 18, 2003

I had some difficulty figuring this out. ALthough the ink can interact with the clipboard, I wanted to have an explicit place to tuck away my strokes and retrieve them again. A few hints in the Tablet Newsgroup pointed me in to some interesting methods and I was able to come up with the following solution. Take a look at the functionality of ink.CreateStrokes, ink.ExtractStrokes and ink.AddStrokestoRectangle to better understand this code.

(DeletedStrokes is just a ListArray created elsewhere in the class)

Case "undo"

With (InkPicture1.Ink)
Dim id As
Int32 = .Strokes(.Strokes.Count - 1).Id
Dim ids() As
Int32 = {id}
Dim delStrokes As
Strokes = .CreateStrokes(ids)
Dim storeInk As
Ink = .ExtractStrokes(delStrokes, ExtractFlags.RemoveFromOriginal)
DeletedStrokes.Add(storeInk)
.Strokes.Remove(.Strokes(.Strokes.Count - 1))
End
With
InkPicture1.Refresh()

Case "redo"
If DeletedStrokes.Count > 0
Then
Dim storeInk As
Ink = DeletedStrokes(DeletedStrokes.Count - 1)
InkPicture1.Ink.AddStrokesAtRectangle(storeInk.Strokes, thisink.GetBoundingBox)
DeletedStrokes.Remove(thisink)
InkPicture1.Refresh()
End If

Thursday, December 18, 2003 5:17:01 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview