0
Reply

Retrieve strokes from InkCanvas

abhas mangal

abhas mangal

Feb 7 2007 12:04 AM
6.6k
hi friends, I want to implement undo and redo functionality such that when an graphical object is moved from one place to a different place and if undo option is selected then the object strokes are removed from the new place and added to the original place. For this,I need to retrieve strokes when the object is particularly selected by the user in the SelectionChanged Event of InkCanvas. I have written the following code : void inkcanvas1_SelectionChanged(object sender, EventArgs e) { StrokeCollection tempcol = inkcanvas1.GetSelectedStrokes(); removecl.Add(tempcol.Clone()); aftmovundo = 1; } In the function which implements the undo functionality I have written the following code : inkcanvas1.Strokes.Remove(redolist.scol[redolist.scol.Count - 1]); inkcanvas1.Strokes.Add(removecl.Clone()); Here strokes stored in removecl are not properly added into inkcanvas for e.g. if 80 strokes are saved in removecl then only 75 from them are added to inkcanvas. I don't know why this problem is taking place. The redolist contains the strokes of the object moved to the new position. Please guide me I am really caught up in an unpredictable error.