GestureRecognizer在WP Direct3D App中抛出异常

时间:2015-09-03 16:06:08

标签: c++ c++11 windows-phone-8.1 windows-phone windows-10

我正在为WP10的图形应用程序工作。我需要使用GestureRecognizer移动并调整屏幕上的对象大小。看起来很酷,但在某些情况下有两个手指手势,GestureRecognizer会抛出此错误。

WinRT信息:帧中的数据包不一致。指针ID不是唯一的,或者时间戳,帧ID,指针类型或源设备存在差异。

用一根手指手势一切都好。这里奇怪的是这个逻辑在WP8.1上工作正常。

这是我的RecognizerHelper的源代码:

GestureHelper::GestureHelper(){
    this->recognizer = ref new GestureRecognizer();

    this->recognizer->GestureSettings = GestureSettings::ManipulationScale | GestureSettings::ManipulationTranslateX |
    GestureSettings::ManipulationTranslateY | GestureSettings::Tap | GestureSettings::ManipulationRotate | GestureSettings::DoubleTap;

    this->recognizer->Tapped += ref new TypedEventHandler<GestureRecognizer ^, TappedEventArgs ^>(this, &GestureHelper::OnTapped);
    this->recognizer->ManipulationStarted += ref new TypedEventHandler<GestureRecognizer ^, ManipulationStartedEventArgs ^>(this, &GestureHelper::OnManipulationStarted);
    this->recognizer->ManipulationCompleted += ref new TypedEventHandler<GestureRecognizer ^, ManipulationCompletedEventArgs ^>(this, &GestureHelper::OnManipulationCompleted);
    this->recognizer->ManipulationUpdated += ref new TypedEventHandler<GestureRecognizer ^, ManipulationUpdatedEventArgs ^>(this, &GestureHelper::OnManipulationUpdated);
}

void GestureHelper::ProcessPress(PointerPoint ^ppt){
    this->recognizer->ProcessDownEvent(ppt);
    if (this->Clicked) {
        this->Clicked(ppt->Position.X, ppt->Position.Y);
    }
}

void GestureHelper::ProcessMove(PointerPoint ^ppt){
    this->recognizer->ProcessMoveEvents(ppt->GetIntermediatePoints(ppt->PointerId));
}

void GestureHelper::ProcessRelease(PointerPoint ^ppt){
    this->recognizer->ProcessUpEvent(ppt);
}



void GestureHelper::OnManipulationStarted(GestureRecognizer^ sender, ManipulationStartedEventArgs^ e){
    if (this->Pressed){
        this->Pressed(e->Position.X, e->Position.Y);
    }
}

void GestureHelper::OnManipulationCompleted(GestureRecognizer ^sender, ManipulationCompletedEventArgs ^e) {
    if (this->Released) {
        this->Released(e->Position.X, e->Position.Y);
    }
}

void GestureHelper::OnManipulationUpdated(GestureRecognizer ^sender, ManipulationUpdatedEventArgs ^e){
    if (this->MoveUpdated){
        this->MoveUpdated(e->Position.X, e->Position.Y);
    }
    if (this->ZoomUpdated){
        this->ZoomUpdated(e->Delta.Scale);
    }
    if (this->RotateUpdated) {
        this->RotateUpdated(-e->Delta.Rotation);
    }
}

void GestureHelper::OnTapped(GestureRecognizer ^sender, TappedEventArgs ^e){
    if (this->Pressed) {
        this->Pressed(e->Position.X, e->Position.Y);
    }
    if (this->Released){
        this->Released(e->Position.X, e->Position.Y);
    }
}

感谢您的帮助!

UPD: Try-catch是有帮助的,但仍然想了解,为什么这个异常抛出

1 个答案:

答案 0 :(得分:1)

好的,我在微软论坛上得到了答案。这是微软的bug,将在下次更新中修复。所以现在我使用try catch来解决这个问题。

在那里回答: https://social.msdn.microsoft.com/Forums/ru-RU/2353edb7-8c1c-4a8d-9e57-ece72f863616/uwpgesturerecognizer-throws-exception-in-wp-direct3d-app?forum=wpdevelop