1

次の例を使用しています。http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.input.pointereventhandler?cs-save-lang=1&cs-lang=vb#code-snippet-1

私はそれをいくつかの異なる方法で変更しようとしましたが、タッチで画面上に描画することができません。

プログラムはこの関数で失敗します

Public Function InkCanvas_PointerPressed(sender As Object, e As PointerRoutedEventArgs)

    'Get information about the pointer location
    Dim pt As PointerPoint = e.GetCurrentPoint(panelcanvas)
    _previousContactPt = pt.Position

    'Accept input only from a pen or mouse with a left button pressed
    Dim pointerDevType As PointerDeviceType = e.Pointer.PointerDeviceType

    If ((pointerDevType = PointerDeviceType.Pen Or pointerDevType = PointerDeviceType.Mouse) And pt.Properties.IsLeftButtonPressed) Then
        'Pass the point information to the inkmanager

        _inkManager.ProcessPointerDown(pt)
        _penID = pt.PointerId
        e.Handled = True

    ElseIf (pointerDevType = PointerDeviceType.Touch) Then

        _touchID = pt.PointerId
        _inkManager.ProcessPointerDown(pt) '<-- error happens here



        e.Handled = True


    End If

    Return Nothing
End Function

次のエラー Message=TabletPC inking error code が表示されます。_inkManager.ProcessPointerDown(pt) 行での初期化エラー (HRESULT からの例外: 0x80040223)。

4

1 に答える 1

2

http://www.c-sharpcorner.com/uploadfile/269510/metro-style-paint-application/で解決策を見つけました 。この例では、彼は描き始めたところです。そこで、上記の手順を変更し、inkManager オプションを削除したところ、指で描画できるようになりました。

Public Function InkCanvas_PointerPressed(sender As Object, e As PointerRoutedEventArgs)

    'Get information about the pointer location
    Dim pt As PointerPoint = e.GetCurrentPoint(panelcanvas)
    _previousContactPt = pt.Position

    'Accept input only from a pen or mouse with a left button pressed
    Dim pointerDevType As PointerDeviceType = e.Pointer.PointerDeviceType

    If ((pointerDevType = PointerDeviceType.Pen Or pointerDevType = PointerDeviceType.Mouse) And pt.Properties.IsLeftButtonPressed) Then
        'Pass the point information to the inkmanager

        _inkManager.ProcessPointerDown(pt)
        _penID = pt.PointerId
        e.Handled = True

    ElseIf (pointerDevType = PointerDeviceType.Touch) Then
        '_inkManager.ProcessPointerDown(pt)


        Dim NewLine As Line = New Line
        NewLine.X1 = e.GetCurrentPoint(panelcanvas).Position.X
        NewLine.Y1 = e.GetCurrentPoint(panelcanvas).Position.Y
        NewLine.X2 = NewLine.X1 + 1
        NewLine.Y2 = NewLine.Y1 + 1
        NewLine.StrokeThickness = 4.0
        NewLine.Stroke = New SolidColorBrush(Colors.Red)
        panelcanvas.Children.Add(NewLine)
        _touchID = pt.PointerId
        e.Handled = True

    End If

    Return Nothing
End Function
于 2012-11-13T14:58:05.253 に答える