Beispiel #1
0
        bool DoOnePractice()
        {
            if (isToSayDetailNarrations)
            {
                SetCurrentMessage(Messages.View004_Message01000);
            }
            else
            {
                SetCurrentMessageWithoutVoice(Messages.View004_Message01000);
            }
            for (destinationAreaIndex = 1; destinationAreaIndex < 4; destinationAreaIndex++)
            {
                var hasSucceededDrag = false;
                while (hasSucceededDrag == false)
                {
                    TutorialLargeCircleAreaButtonList[destinationAreaIndex - 1].IsEnabled = true;
                    DisableAllCircleAreas();
                    InitializeDraggingThumbPosition();
                    DraggingThumbOpacity = 0.8;

                    // Hover is not completed.  So it notifies that users need to hover the gesture cursor.
                    while (IsDraggingThumbHovered == false)
                    {
                        if (IsStillSpeakingNarration == false && CurrentMessage.Equals(Messages.View004_Message01100) == false)
                        {
                            if (isToSayDetailNarrations)
                            {
                                SetCurrentMessage(Messages.View004_Message01100);
                            }
                            else
                            {
                                SetCurrentMessageWithoutVoice(Messages.View004_Message01100);
                            }
                        }
                        if (IsCancelling)
                        {
                            return(false);
                        }
                        if (stopwatch.ElapsedMilliseconds > 120000)
                        {
                            return(false);
                        }
                        Thread.Sleep(50);
                    }

                    // Hover is completed, so it notifies that users need to touch to the area.
                    while (IsDraggingThumbDragging == false)
                    {
                        if (IsStillSpeakingNarration == false && CurrentMessage.Equals(Messages.View004_Message01200) == false)
                        {
                            if (isToSayDetailNarrations)
                            {
                                SetCurrentMessage(Messages.View004_Message01200);
                            }
                            else
                            {
                                SetCurrentMessageWithoutVoice(Messages.View004_Message01200);
                            }
                        }
                        if (IsDraggingThumbHovered == false)
                        {
                            break;
                        }
                        if (IsCancelling)
                        {
                            return(false);
                        }
                        if (stopwatch.ElapsedMilliseconds > 120000)
                        {
                            return(false);
                        }
                        Thread.Sleep(50);
                    }
                    // When the other applications are activated, or users move their hands and so on, the hover is not locked-on, so users need to do this again.
                    if (IsDraggingThumbHovered == false)
                    {
                        continue;
                    }

                    StartEffectSuccess();
                    DisableAllCircleAreas();
                    TutorialLargeCircleAreaButtonList[destinationAreaIndex].IsEnabled = true;
                    DraggingThumbOpacity = 0.5;

                    // Touch is completed, so it notifies that users need to drag.
                    if (isToSayDetailNarrations)
                    {
                        switch (destinationAreaIndex)
                        {
                        case 1: SetCurrentMessage(Messages.View004_Message02102); break;

                        case 2: SetCurrentMessage(Messages.View004_Message02103); break;

                        case 3: SetCurrentMessage(Messages.View004_Message02104); break;

                        default: Debugger.Break(); break;
                        }
                    }
                    else
                    {
                        switch (destinationAreaIndex)
                        {
                        case 1: SetCurrentMessageWithoutVoice(Messages.View004_Message02102); break;

                        case 2: SetCurrentMessageWithoutVoice(Messages.View004_Message02103); break;

                        case 3: SetCurrentMessageWithoutVoice(Messages.View004_Message02104); break;

                        default: Debugger.Break(); break;
                        }
                    }

                    while (IsDraggingThumbDragging)
                    {
                        if (IsDraggingThumbHovered == false)
                        {
                            break;
                        }
                        if (IsCancelling)
                        {
                            return(false);
                        }
                        if (stopwatch.ElapsedMilliseconds > 120000)
                        {
                            return(false);
                        }
                        Thread.Sleep(50);
                    }
                    // When the other applications are activated, or users move their hands and so on, the hover is not locked-on, so users need to do this again.
                    if (IsDraggingThumbHovered == false)
                    {
                        continue;
                    }

                    // Drag is completed.  It judges it succeeded or not.
                    DraggingThumbOpacity = 0.8;
                    if (TutorialLargeCircleAreaButtonList[destinationAreaIndex].IsThumbDragged)
                    {
                        // Succeeded
                        StartEffectSuccess();
                        if (isToSayDetailNarrations)
                        {
                            SetCurrentMessage(Messages.View101_Message00100);
                            WaitNarrationComplete();
                        }
                        else
                        {
                            SetCurrentMessageWithoutVoiceAfterNarrationStop(Messages.View101_Message00100);
                        }
                        hasSucceededDrag = true;
                    }
                    else
                    {
                        // Failed.  Narration starts.
                        SetCurrentMessage(Messages.View004_Message01600);
                    }
                    if (IsCancelling)
                    {
                        return(false);
                    }
                    if (stopwatch.ElapsedMilliseconds > 120000)
                    {
                        return(false);
                    }
                    Thread.Sleep(50);
                }
            }
            WaitNarrationComplete(); if (IsCancelling)
            {
                return(false);
            }
            return(true);
        }
        void LetUserOnePractice()
        {
            var baseLengthVector = new Vector(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);
            var baseLength       = baseLengthVector.Length;

            // If it fails, it loops.
            while (true)
            {
                var stopwatchInWaitingDraggingStart = Stopwatch.StartNew();
                int narrationKind = 0;
                while (IsDragging == false)
                {
                    if (narrationKind == 0 && IsStillSpeakingNarration == false)
                    {
                        stopwatchInWaitingDraggingStart.Restart();
                        narrationKind++;
                    }
                    else if (narrationKind == 1 && stopwatchInWaitingDraggingStart.ElapsedMilliseconds > 2000)
                    {
                        switch (currentPracticeKind)
                        {
                        case PracticeKind.FirstPractice:
                            SetCurrentMessage(Messages.View005_Message00400);
                            break;

                        case PracticeKind.MultiplePractices:
                            SetCurrentMessageWithoutVoice(Messages.View005_Message00400);
                            break;

                        default:
                            if (ApplicationCommonSettings.IsDebugging)
                            {
                                Debugger.Break();
                            }
                            throw new NotImplementedException();
                        }
                        narrationKind++;
                    }
                    else if (narrationKind == 2 && stopwatchInWaitingDraggingStart.ElapsedMilliseconds > 20000)
                    {
                        SetCurrentMessage(Messages.View005_Message00200);
                        narrationKind = 0;
                    }

                    if (currentPracticeKind == PracticeKind.MultiplePractices &&
                        letUserOnePracticeStopwatch.Elapsed.TotalMilliseconds > 60000)
                    {
                        return;
                    }

                    if (IsCancelling)
                    {
                        return;
                    }
                    Thread.Sleep(50);
                }

                switch (currentPracticeKind)
                {
                case PracticeKind.FirstPractice:
                    SetCurrentMessage(Messages.View005_Message00500);
                    break;

                case PracticeKind.MultiplePractices:
                    SetCurrentMessageWithoutVoice(Messages.View005_Message00500);
                    break;

                default:
                    if (ApplicationCommonSettings.IsDebugging)
                    {
                        Debugger.Break();
                    }
                    throw new NotImplementedException();
                }

                bool isDistanceTooLarge = false;
                while (IsDragging)
                {
                    if (isDistanceTooLarge == false)
                    {
                        var distance = (DraggingPoint - DragStartedPoint).Length;
                        if (false)
                        {
                            Debug.WriteLine("distance: " + distance);
                        }
                        isDistanceTooLarge = distance > 0.5 * baseLength;

                        if (isDistanceTooLarge)
                        {
                            // When users moved their hands too large.
                            switch (currentPracticeKind)
                            {
                            case PracticeKind.FirstPractice:
                                DisableDetection();
                                SetCurrentMessage(Messages.View005_Message00600); WaitNarrationComplete(); if (IsCancelling)
                                {
                                    return;
                                }
                                SetCurrentMessage(Messages.View005_Message00900); WaitNarrationComplete(); if (IsCancelling)
                                {
                                    return;
                                }
                                break;

                            case PracticeKind.MultiplePractices:
                                if (IsStillSpeakingNarration == false && CurrentMessage.Equals(Messages.View005_Message00600) == false)
                                {
                                    SetCurrentMessage(Messages.View005_Message00600);
                                }
                                break;

                            default:
                                if (ApplicationCommonSettings.IsDebugging)
                                {
                                    Debugger.Break();
                                }
                                throw new NotImplementedException();
                            }
                            // It restarts from initial detection again.
                            EnableDetection();
                        }
                    }

                    if (currentPracticeKind == PracticeKind.MultiplePractices &&
                        letUserOnePracticeStopwatch.Elapsed.TotalMilliseconds > 60000)
                    {
                        return;
                    }

                    if (IsCancelling)
                    {
                        return;
                    }
                    Thread.Sleep(50);
                }
                // When the hand move distance was too large, it does not evaluate the hand speed in stopping drag gesture.
                if (isDistanceTooLarge)
                {
                    continue;
                }

                Debug.WriteLine("Math.Abs(FlickingCursorVelocityOnDragCompleteX): " + Math.Abs(FlickingCursorVelocityOnDragCompleteX));
                if (Math.Abs(FlickingCursorVelocityOnDragCompleteX) < 0.2 * baseLength)
                {
                    // If the hand speed in opening the hand was too slow.
                    switch (currentPracticeKind)
                    {
                    case PracticeKind.FirstPractice:
                        DisableDetection();
                        SetCurrentMessage(Messages.View005_Message00800); WaitNarrationComplete(); if (IsCancelling)
                        {
                            return;
                        }
                        SetCurrentMessage(Messages.View005_Message00700); WaitNarrationComplete(); if (IsCancelling)
                        {
                            return;
                        }
                        // It restarts from initial detection again.
                        EnableDetection();
                        break;

                    case PracticeKind.MultiplePractices:
                        SetCurrentMessage(Messages.View005_Message00700);
                        break;

                    default:
                        if (ApplicationCommonSettings.IsDebugging)
                        {
                            Debugger.Break();
                        }
                        throw new NotImplementedException();
                    }
                }
                else
                {
                    // Succeeded
                    StartEffectSuccess();
                    return;
                }
            }
        }
        protected override void RepeatPractice()
        {
            HideUpperSideMessageAreaAndReplayPracticeNextButtons();

            DisableDetection();
            SetCurrentMessage(Messages.View001_Message01500); WaitNarrationComplete(); if (IsCancelling)
            {
                return;
            }
            SetCurrentMessage(Messages.View001_Message01600); WaitNarrationComplete(); if (IsCancelling)
            {
                return;
            }
            SetCurrentMessage(Messages.View101_Message00600); if (IsCancelling)
            {
                return;
            }
            EnableDetection();
            PracticeSlideShow01VideoUserControlVisibility = Visibility.Collapsed;
            PracticeSlideShow02VideoUserControlVisibility = Visibility.Collapsed;

            var  stopwatch              = Stopwatch.StartNew();
            int  succeededCount         = 0;
            bool isHandTrackingPrevious = false;

            while (true)
            {
                if (IsStillSpeakingNarration == false && IsHandTracking == false && CurrentMessage.Equals(Messages.View100_Message00400) == false)
                {
                    // It notifies that users need to let the device recognize their hands again, because hand recognition is completed
                    SetCurrentMessageWithoutVoice(Messages.View100_Message00400); if (IsCancelling)
                    {
                        return;
                    }
                }
                if (IsStillSpeakingNarration == false && IsHandTracking == true && CurrentMessage.Equals(Messages.View001_Message01300) == false)
                {
                    // Hand is already recognized, so it notifies that users need to put their hands down.
                    SetCurrentMessageWithoutVoice(Messages.View001_Message01300); if (IsCancelling)
                    {
                        return;
                    }
                }
                if (isHandTrackingPrevious == false && IsHandTracking == true)
                {
                    isHandTrackingPrevious = true;
                }
                if (isHandTrackingPrevious == true && IsHandTracking == false)
                {
                    StartEffectSuccess();
                    succeededCount++;
                    if (succeededCount == 5)
                    {
                        break;
                    }
                    switch (succeededCount)
                    {
                    case 1: SetCurrentMessage(Messages.View101_Message00204); if (IsCancelling)
                        {
                            return;
                        }
                        break;

                    case 2: SetCurrentMessage(Messages.View101_Message00203); if (IsCancelling)
                        {
                            return;
                        }
                        break;

                    case 3: SetCurrentMessage(Messages.View101_Message00202); if (IsCancelling)
                        {
                            return;
                        }
                        break;

                    case 4: SetCurrentMessage(Messages.View101_Message00201); if (IsCancelling)
                        {
                            return;
                        }
                        break;
                    }
                    isHandTrackingPrevious = false;
                }
                if (stopwatch.ElapsedMilliseconds > 60000)
                {
                    DisableDetection();
                    SetCurrentMessage(Messages.View101_Message00300); WaitNarrationComplete(); if (IsCancelling)
                    {
                        return;
                    }
                    SetCurrentMessage(Messages.View001_Message01600); WaitNarrationComplete(); if (IsCancelling)
                    {
                        return;
                    }
                    SetCurrentMessage(Messages.View101_Message00600); if (IsCancelling)
                    {
                        return;
                    }
                    EnableDetection();
                    succeededCount = 0;
                    stopwatch.Restart();
                }
                if (IsCancelling)
                {
                    return;
                }
                Thread.Sleep(50);
            }

            WaitEffectSuccessComplete();
            SetCurrentMessage(Messages.View101_Message00500);
            EnableDetection();
            ShowWellDone();

            // It waits until some button is pushed.
            while (true)
            {
                if (IsCancelling)
                {
                    return;
                }
                Thread.Sleep(100);
            }
        }