wpf - How to get just the resulting strokes when erasing by point on InkCanvas? -
i don't understand. lets draw "s" on inkcanvas.
the onstrokecollected event fire. inside onstrokecollected event, send stroke inkanalyzer:
analyzer.addstroke(e.stroke)
now erase-by-point center point of "s".
the onstrokeerasing event fires. can remove original "s" inkanalzyer:
analyzer.removestroke(e.stroke)
but, have 2 strokes. top , bottom of original "s". since have 2 strokes, how each of these "new" strokes add inkanalyzer (having removed original composite stroke "s") without removing entire previous stroke collection , adding anew new strokecollection ?
i sincerely appreciate ideas.
the idea come posted below. surely appreciate better solution.
xaml
<ink:custominkcanvas x:name="inkcanvas" strokes="{binding strokes}" />
viewmodel
strokes = new strokecollection(); (strokes inotifycollectionchanged).collectionchanged += (sender, e) => { if (iserasingbypoint == true) { if (e.olditems != null && e.olditems.count > 0) { foreach (stroke s in e.olditems) { } } if (e.newitems != null && e.newitems.count > 0) { foreach (stroke s in e.newitems) { } } } iserasingbypoint = false; }; public void onstrokecollected(object sender, inkcanvasstrokecollectedeventargs e) { // onstrokecollected event occurs after strokecollection.collectionchanged event. analyzer.addstroke(e.stroke); } public void onstrokeerasing(object sender, inkcanvasstrokeerasingeventargs e) { // when erasingbypoint, onstrokeerasing event occurs before strokecollection.collectionchanged event. // if erasing stroke, strokecollection.collectionchanged event not called. if (editingmode == inkcanvaseditingmode.erasebypoint) iserasingbypoint = true; else analyzer.removestroke(e.stroke); }
hope of use somebody.
Comments
Post a Comment