Esempio n. 1
0
        private bool OnQuestionPointerStrokeReceived(Event ev)
        {
            if (!(IsStudent && LessonExists))
            {
                return(true);
            }

            var sharedPointer = ev.get <SharedPointer>();

            Application.Current.Dispatcher.Invoke(() =>
            {
                // If we're not sync or on Question mode, we don't care
                if (Catalog.CurrentPageName != "QuestionsPage")
                {
                    return;
                }

                int position;
                try
                {
                    position = Data.Lesson.Exercises.GetPositionOfUID(sharedPointer.Offset);
                    // We select the good slide
                    (QuestionsPage.LessonPage as Exercises).GoingToPage(position);
                    // We tell the PointerManager that we want to show a new stroke
                    PointerManager.Instance.DrawStroke(StrokeConverter.ToWindowsStroke(sharedPointer.Stroke));
                }
                catch (Exception)
                {
                    Console.WriteLine("UID (Exercise Pointer) not found.");
                }
            });

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        ///     A Stroke has been received (inner event) and we trigger the Deletion event.
        /// </summary>
        /// <param name="stroke">The stroke.</param>
        public void StrokeAdded(Stroke stroke)
        {
            var currentPageName = Catalog.Instance.CurrentPageName;

            if (currentPageName == "MainPage" || currentPageName == "QuestionsPage")
            {
                var currentLesson = currentPageName == "MainPage"
                    ? (Catalog.Instance.GetPage(currentPageName) as MainPage).LessonPage.DataContext as Lesson
                    : (Catalog.Instance.GetPage(currentPageName) as QuestionsPage).LayerStackDC.LessonViewModel;
                // We don't send very small strokes
                if (stroke.StylusPoints.Count > 2 &&
                    Data.Instance.Role == Role.TEACHER &&
                    currentPageName != "FreeNotesPage" &&
                    currentLesson.IsSync == true)
                {
                    // Packing and sending our stroke and context to share with students
                    LinkIOImp.Instance.send(
                        currentPageName == "MainPage" ? "slide-pointer" : "question-pointer",
                        new SharedPointer(
                            LS.LessonViewModel.CurrentPageIndex,
                            StrokeConverter.ToNineStroke(stroke)));
                }

                // Creation of a new timer, execution every quantum
                var timer = new Timer(_quantum);

                var nbPtsPerTick = HowManyPointPerTick(stroke.StylusPoints.Count);

                // Setup with the timer collection, StrokeCollection and the right Stroke
                timer.Elapsed += (src, args) => TimedDeletion(
                    src,
                    new Tuple <StrokeCollection, Stroke, int>(
                        LS.PointerStrokes,
                        stroke,
                        nbPtsPerTick));
                timer.Start();
            }
        }
Esempio n. 3
0
        private bool OnSlidePointerStrokeReceived(Event ev)
        {
            if (!(IsStudent && LessonExists))
            {
                return(true);
            }

            var sharedPointer = ev.get <SharedPointer>();

            Application.Current.Dispatcher.BeginInvoke(
                new Action(
                    () =>
            {
                var lesson = (MainPage.LessonPage.DataContext as Lesson);

                // If we're not sync or on Question mode, we don't care
                if (!lesson.IsSync.Value || Catalog.CurrentPageName != "MainPage")
                {
                    return;
                }

                // We redirect to the correct view (beacause, if we are on FreeNotesPage in Sync mode, we want to follow
                Catalog.NavigateTo("MainPage");

                // We select the good slide
                lesson.ChangeCurrentPage(sharedPointer.Offset);

                // We tell the PointerManager that we want to show a new stroke
                PointerManager.Instance.DrawStroke(StrokeConverter.ToWindowsStroke(sharedPointer.Stroke));
            }
                    ),
                DispatcherPriority.Normal
                );

            return(true);
        }