private void ToggleSwitch_Toggled()

in UWP-Advanced-Inking/UnprocessedInput/UnprocessedInput/MainPage.xaml.cs [71:98]


		private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
		{
			ToggleSwitch toggleSwitch = sender as ToggleSwitch;

			var p = inkCanvas.InkPresenter;
			if (toggleSwitch.IsOn == true)
			{
				// We are not in the inking or erasing mode 
				// ==> Inputs are redirected to UnprocessedInput
				// i.e. Our code will take care of the inking inputs
				p.InputProcessingConfiguration.Mode = InkInputProcessingMode.None;

				p.UnprocessedInput.PointerPressed += UnprocessedInput_PointerPressed;
				p.UnprocessedInput.PointerMoved += UnprocessedInput_PointerMoved;
				p.UnprocessedInput.PointerReleased += UnprocessedInput_PointerReleased;
			}
			else
			{
				// Go back to normal which is the inking mode
				// ==> We can draw lines on the InkCanvas
				inkCanvas.InkPresenter.InputProcessingConfiguration.Mode = InkInputProcessingMode.Inking;

				// Remove the handlers for UnprocessedInput
				p.UnprocessedInput.PointerPressed -= UnprocessedInput_PointerPressed;
				p.UnprocessedInput.PointerMoved -= UnprocessedInput_PointerMoved;
				p.UnprocessedInput.PointerReleased -= UnprocessedInput_PointerReleased;
			}
		}