//<Snippet11> void selectionTester_SelectionChanged(object sender, LassoSelectionChangedEventArgs args) { // Change the color of all selected strokes to red. foreach (Stroke selectedStroke in args.SelectedStrokes) { selectedStroke.DrawingAttributes.Color = Colors.Red; selectedStrokes.Add(selectedStroke); } // Change the color of all unselected strokes to // their original color. foreach (Stroke unselectedStroke in args.DeselectedStrokes) { unselectedStroke.DrawingAttributes.Color = inkDA.Color; selectedStrokes.Remove(unselectedStroke); } }
// When the stylus encircles a stroke, // erase that stroke. void myIHT_StrokeHitChanged(object sender, LassoSelectionChangedEventArgs e) { foreach (MyStroke stroke in e.SelectedStrokes) { stroke.Selected = true; //stroke.DrawingAttributes.Color = Colors.Red; } foreach (MyStroke stroke in e.DeselectedStrokes) { stroke.Selected = false; //stroke.DrawingAttributes.Color = Colors.Green; } // Remove the encircled stroke. //if (eraseResult.Count > 0) //{ // myInkPresenter.Strokes.Remove(eraseResult); //} }
//------------------------------------------------------------------------------- // // Private Methods // //------------------------------------------------------------------------------- #region Private Methods /// <summary> /// Private event handler that updates which strokes are actually selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSelectionChanged(object sender, LassoSelectionChangedEventArgs e) { this.InkCanvas.UpdateDynamicSelection(e.SelectedStrokes, e.DeselectedStrokes); }