コード例 #1
0
        void InkingArea_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            // Make sure no pointer is already inking (we allow only one 'active' pointer at a time)
            if (pointerId == -1)
            {
                var pointerPoint = e.GetCurrentPoint(InkingArea);

                rootPage.NotifyUser(" ", SDKTemplate.NotifyType.StatusMessage);

                // Determine ink manipulation mode
                switch (Helpers.GetPointerEventType(e))
                {
                case Helpers.PointerEventType.Erase:
                    rootPage.NotifyUser("Erase mode: draw a line across the ink you want to erase.", SDKTemplate.NotifyType.StatusMessage);
                    inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Erasing;
                    break;

                case Helpers.PointerEventType.Ink:
                    inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Inking;
                    renderer.EnterLiveRendering(pointerPoint, drawingAttributes);
                    break;

                case Helpers.PointerEventType.Select:
                    rootPage.NotifyUser("Select mode: draw a contour around the ink you want to select.", SDKTemplate.NotifyType.StatusMessage);
                    inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Selecting;
                    renderer.EnterLiveRendering(pointerPoint, lassoAttributes);
                    break;

                default:
                    return;     // pointer is neither inking nor erasing nor selecting: do nothing
                }

                // Clear selection
                inkManager.ClearSelection();
                renderer.UpdateSelection();
                AnchorSelection();

                inkManager.ProcessPointerDown(pointerPoint);

                pointerId = (int)pointerPoint.PointerId; // save pointer id so that no other pointer can ink until this one is released
            }
        }