예제 #1
0
        public ZkooTutorialModel(EgsHostAppBaseComponents hostApp)
        {
            Trace.Assert(hostApp != null);

            RefToHostApp                   = hostApp;
            CurrentResources               = new ZkooTutorialResourcesModel();
            Launcher                       = new LauncherPageModel();
            TutorialAppHeaderMenu          = new TutorialAppHeaderMenuViewModel();
            Tutorial01StartGestureTraining = new Tutorial01StartGestureTrainingPageModel();
            Tutorial02MoveCursorTraining   = new Tutorial02MoveCursorTrainingPageModel();
            Tutorial03TapGestureTraining   = new Tutorial03TapGestureTrainingPageModel();
            Tutorial04DragGestureTraining  = new Tutorial04DragGestureTrainingPageModel();
            Tutorial05FlickGestureTraining = new Tutorial05FlickGestureTrainingPageModel();

            TutorialLargeCircleAreaButtonRightTop = new TutorialLargeCircleAreaButtonModel()
            {
                Index = 0,
                ImageSourceDisabledFileName = "tutorial_common_circle1_button_disabled.png",
                ImageSourcePressedFileName  = "tutorial_common_circle1_button_pressed.png",
                ImageSourceHoveredFileName  = "tutorial_common_circle1_button_hovered.png",
                ImageSourceSelectedFileName = "tutorial_common_circle1_button_pressed.png",
                ImageSourceEnabledFileName  = "tutorial_common_circle1_button_enabled.png",
            };
            TutorialLargeCircleAreaButtonRightBottom = new TutorialLargeCircleAreaButtonModel()
            {
                Index = 1,
                ImageSourceDisabledFileName = "tutorial_common_circle2_button_disabled.png",
                ImageSourcePressedFileName  = "tutorial_common_circle2_button_pressed.png",
                ImageSourceHoveredFileName  = "tutorial_common_circle2_button_hovered.png",
                ImageSourceSelectedFileName = "tutorial_common_circle2_button_pressed.png",
                ImageSourceEnabledFileName  = "tutorial_common_circle2_button_enabled.png",
            };
            TutorialLargeCircleAreaButtonLeftBottom = new TutorialLargeCircleAreaButtonModel()
            {
                Index = 2,
                ImageSourceDisabledFileName = "tutorial_common_circle3_button_disabled.png",
                ImageSourcePressedFileName  = "tutorial_common_circle3_button_pressed.png",
                ImageSourceHoveredFileName  = "tutorial_common_circle3_button_hovered.png",
                ImageSourceSelectedFileName = "tutorial_common_circle3_button_pressed.png",
                ImageSourceEnabledFileName  = "tutorial_common_circle3_button_enabled.png",
            };
            TutorialLargeCircleAreaButtonLeftTop = new TutorialLargeCircleAreaButtonModel()
            {
                Index = 3,
                ImageSourceDisabledFileName = "tutorial_common_circle4_button_disabled.png",
                ImageSourcePressedFileName  = "tutorial_common_circle4_button_pressed.png",
                ImageSourceHoveredFileName  = "tutorial_common_circle4_button_hovered.png",
                ImageSourceSelectedFileName = "tutorial_common_circle4_button_pressed.png",
                ImageSourceEnabledFileName  = "tutorial_common_circle4_button_enabled.png",
            };
        }
        public void InitializeOnceAtStartup(MainNavigationWindow navigator, Tutorial04DragGestureTrainingPageModel viewModel)
        {
            Trace.Assert(navigator != null);
            Trace.Assert(viewModel != null);


            // ---------- videos and state transition ----------
            PracticeSlideShow01VideoUserControl.SetMediaElementSourceUriByFilePath(System.IO.Path.Combine(viewModel.refToAppModel.CurrentResources.TutorialVideoFilesFolderPath, "tutorial_reference_video_4.mp4"), UriKind.Relative);
            PracticeSlideShow01VideoUserControl.IsVisibleChanged += (sender, e) =>
            {
                if (PracticeSlideShow01VideoUserControl.IsVisible)
                {
                    PracticeSlideShow01VideoUserControl.Replay();
                }
                else
                {
                    PracticeSlideShow01VideoUserControl.Pause();
                }
            };
            // ---------- videos and state transition ----------


            this.DataContext = viewModel;
            ReferenceToTutorialEachPageModelBase = viewModel;
            ReplayPracticeNextButtonsUserControl.InitializeOnceAtStartup(viewModel.TutorialAppHeaderMenu);
            TutorialAppHeaderMenuUserControl.InitializeOnceAtStartup(viewModel.TutorialAppHeaderMenu);

            LargeCircleAreaRightTop.InitializeOnceAtStartup(viewModel.TutorialLargeCircleAreaButtonRightTop);
            LargeCircleAreaRightBottom.InitializeOnceAtStartup(viewModel.TutorialLargeCircleAreaButtonRightBottom);
            LargeCircleAreaLeftBottom.InitializeOnceAtStartup(viewModel.TutorialLargeCircleAreaButtonLeftBottom);
            LargeCircleAreaLeftTop.InitializeOnceAtStartup(viewModel.TutorialLargeCircleAreaButtonLeftTop);

            var corners           = new FrameworkElement[] { LargeCircleAreaRightTop, LargeCircleAreaRightBottom, LargeCircleAreaLeftBottom, LargeCircleAreaLeftTop };
            var corner_Index_Dict = new Dictionary <object, int>();

            for (int i = 0; i < corners.Length; i++)
            {
                var corner = corners[i];
                corner_Index_Dict[corner] = i;
            }

            this.Loaded += (sender, e) =>
            {
                navigator.SetWindowFullScreen();
                navigator.Title = $"{ApplicationCommonSettings.HostApplicationName} Tutorial: Drag Gesture Practice";
                viewModel.OnLoaded();
                PracticeSlideShow01VideoUserControl.Replay();
            };
            this.Unloaded += (sender, e) =>
            {
                viewModel.IsCancelling = true;
            };

            DraggingThumb.MouseEnter    += (sender, e) => { viewModel.IsDraggingThumbHovered = true; };
            DraggingThumb.MouseLeave    += (sender, e) => { viewModel.IsDraggingThumbHovered = false; };
            DraggingThumb.DragStarted   += (sender, e) => { viewModel.IsDraggingThumbDragging = true; };
            DraggingThumb.DragCompleted += (sender, e) =>
            {
                var thumbRadius = DraggingThumb.ActualWidth / 2;
                var thumbCenterRelativePoint = new Point(thumbRadius, thumbRadius);
                viewModel.DraggingThumbCenterPoint = DraggingThumb.PointToScreen(thumbCenterRelativePoint);
                foreach (var corner in corners)
                {
                    var index        = corner_Index_Dict[corner];
                    var cornerRadius = corner.ActualWidth / 2;
                    var cornerCenterRelativePoint = new Point(cornerRadius, cornerRadius);
                    viewModel.LargeCircleAreaCenterPoint[index] = corner.PointToScreen(cornerCenterRelativePoint);

                    var diffVector = (viewModel.LargeCircleAreaCenterPoint[index] - viewModel.DraggingThumbCenterPoint);
                    var distance   = diffVector.Length;
                    viewModel.ThumbToLargeCircleAreaCenterDistanceList[index]         = distance;
                    viewModel.TutorialLargeCircleAreaButtonList[index].IsThumbDragged = (distance + thumbRadius < cornerRadius);
                }
                viewModel.IsDraggingThumbDragging = false;
            };
        }