0

Hello I want to add some customized gesture (i made) functions on inkcanvas

But I don't know how to do that when the inputdevicetype is touch like this

inkcanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Touch;

when the input device type is touch, then i can't use any gestures

Because the all inputs are recognized the drawn

when using inkcanvas with touch input, can't i use gesture functions?

private void ink1_PointerPressed(object sender, PointerRoutedEventArgs e)
    {            
            PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;

            pointers = new Dictionary<uint, Windows.UI.Xaml.Input.Pointer>();

            e.Handled = true;

            PointerPoint ptrPt = e.GetCurrentPoint(ink1);
            m_pt.Add(ptrPt);

            if (!pointers.ContainsKey(ptrPt.PointerId))
            {
                // Add contact to dictionary.
                pointers[ptrPt.PointerId] = e.Pointer;
            }               

            switch (ptrPt.PointerDevice.PointerDeviceType)
            {
                case Windows.Devices.Input.PointerDeviceType.Mouse:                       
                    ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse;
                    ink1.RightTapped += ink1_RightTapped;

                    break;

                case PointerDeviceType.Touch:
                    if (m_pt.Count == 2)
                    {                            
                        ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.None;
                        ink1.RightTapped += ink1_RightTapped;                          


                    }
                    else if (m_pt.Count == 1 || m_pt.Count > 2)
                    {
                        ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Touch;
                        ink1.RightTapped += ink1_RightTapped;

                    }

                break;

            }         


    }

When i press my ink1(inkcanvas) with 2 fingers, then i want to use my gesture functions (draw letter L or tap the inkcanvas 3 times) what i made

such as uwp's doubletapped, righttapped etc.

Kay
  • 173
  • 14
  • " i can't use any gestures", could you please for example? – Sunteen Wu Apr 05 '18 at 06:40
  • Well For example, I can open an image file by drawing an alphabet "L" or when I double tap with two fingers ,then i can open a video file on the inkcanvas. – Kay Apr 05 '18 at 07:49
  • I'm still confused about your issue.You could upload some code snippet that can work well when the `inputdevicetype` is not touch. Why you open a video file with InkCanvas? – Sunteen Wu Apr 05 '18 at 08:19

1 Answers1

1

I saw you use the PointerPress event handle for InkCanvas.
The configuration of the InkPresenter determines the pointer event handling behavior of the InkCanvas. You must set InkPresenter.InputDeviceTypes to CoreInputDeviceTypes.None for the InkCanvas to process pointer events, otherwise they are passed to the InkPresenter object.

To handle pointer events with the InkPresenter object, you must set RightDragAction to LeaveUnprocessed to pass the input through as UnprocessedInput for custom processing by your app.

inkCanvas.InkPresenter.InputProcessingConfiguration.RightDragAction =  InkInputRightDragAction.LeaveUnprocessed;

Details please reference the remark section of InkCanvas.

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
  • Thanks, I'm happy to know about the pointer event. And it only for pen, mouse input right? not touch input – Kay Apr 12 '18 at 01:13
  • @Kay, this answer means if your input type is pen or touch , you should set as above mentioned. Which contains touch input. – Sunteen Wu May 02 '18 at 06:49