Пример #1
0
        private void InitializeWindowCommandBindings()
        {
            this.WindowCommandBindings.AddRange(
                new List <CommandBinding>
            {
                new CommandBinding(
                    NavigationButtonCommands.Finish,
                    (e, o) =>
                {
                    var validationResult = this.Validate();

                    if (validationResult.Item1)
                    {
                        // TODO  maybe get and set user information from office
                        // Globals.ThisAddIn.Application.

                        this.SessionManager.CreateSession(this.SlideSessionModel);
                        this.SlideSessionModel.SessionTypeSet = true;
                        PresentationInformationStore.StoreSlideSessionModel(this.SlideSessionModel);
                        this.OnSelectArsnovaTypeViewClose?.Invoke();
                        this.ViewPresenter.CloseWithoutPrompt();
                    }
                    else
                    {
                        this.DisplayFailedValidationResults(validationResult.Item2);
                    }
                },
                    (e, o) => o.CanExecute = true)
            });
        }
        protected void AddSessionToSlides(SlideQuestionModel slideQuestionModel)
        {
            var hasIntroSlide = this.HasIntroSlide();

            if (!hasIntroSlide)
            {
                var introSlide = this.RibbonHelper.CreateNewSlide(1);

                this.SlideManipulator.AddIntroSlide(this.SlideSessionModel, introSlide);

                this.SlideSessionModel.IntroSlideId = introSlide.SlideID;

                PresentationInformationStore.SetArsnovaIntroSlideAdded();
            }

            var questionInfoSlide = SlideTracker.GetSlideById(slideQuestionModel.QuestionInfoSlideId);

            if (this.SessionInformationProvider.IsClickQuestion(slideQuestionModel.QuestionType))
            {
                // arsnova.click
                var questionTimerSlide = slideQuestionModel.QuestionTimerSlideId.HasValue
                    ? SlideTracker.GetSlideById(slideQuestionModel.QuestionTimerSlideId.Value)
                    : this.RibbonHelper.CreateNewSlide(questionInfoSlide.SlideIndex + 1);
                slideQuestionModel.QuestionTimerSlideId = questionTimerSlide.SlideID;

                var resultsSlide = slideQuestionModel.ResultsSlideId.HasValue
                                        ? SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value)
                                        : this.RibbonHelper.CreateNewSlide(questionInfoSlide.SlideIndex + 2);
                slideQuestionModel.ResultsSlideId = resultsSlide.SlideID;

                this.SlideManipulator.AddQuizToStyledSlides(slideQuestionModel, questionInfoSlide, questionTimerSlide, resultsSlide);
            }
            else
            {
                // arsnova.voting
                slideQuestionModel.QuestionTimerSlideId = slideQuestionModel.QuestionInfoSlideId;

                var resultsSlide = slideQuestionModel.ResultsSlideId.HasValue
                                        ? SlideTracker.GetSlideById(slideQuestionModel.ResultsSlideId.Value)
                                        : this.RibbonHelper.CreateNewSlide(questionInfoSlide.SlideIndex + 1);
                slideQuestionModel.ResultsSlideId = resultsSlide.SlideID;

                this.SlideManipulator.AddQuizToStyledSlides(slideQuestionModel, questionInfoSlide, resultsSlide);
            }

            PresentationInformationStore.StoreSlideSessionModel(this.SlideSessionModel);
            this.ViewPresenter.CloseWithoutPrompt();
        }
        private void InitializeWindowCommandBindings()
        {
            this.WindowCommandBindings.AddRange(
                new List <CommandBinding>
            {
                new CommandBinding(
                    NavigationButtonCommands.Cancel,
                    (e, o) =>
                {
                    var delete = PopUpWindow.ConfirmationWindow(
                        this.LocalizationService.Translate("Cancel"),
                        this.LocalizationService.Translate("Do you really want to cancel and rewind all current changes?"));

                    if (delete)
                    {
                        if (this.isNew)
                        {
                            this.SlideSessionModel.Questions.Remove(this.SlideQuestionModel);
                            this.OnPropertyChanged(nameof(this.SlideSessionModel.Questions));
                        }
                        else
                        {
                            this.SlideQuestionModel = this.questionBeforeEdit;
                            this.OnPropertyChanged(nameof(this.SlideSessionModel.Questions));
                        }

                        // don't save presentation on cancel (no changes here)
                        this.ViewPresenter.CloseWithoutPrompt();
                    }
                },
                    (e, o) => o.CanExecute = true),
                new CommandBinding(
                    NavigationButtonCommands.Back,
                    (e, o) =>
                {
                    this.ViewPresenter.Show(
                        new QuestionViewViewModel(
                            this.GetViewModelRequirements(), this.questionId, this.isNew,
                            this.questionBeforeEdit));
                },
                    (e, o) => o.CanExecute = true),
                new CommandBinding(
                    NavigationButtonCommands.Finish,
                    (e, o) =>
                {
                    var validationResult = this.Validate();

                    if (validationResult.Item1)
                    {
                        this.SlideQuestionModel.QuestionTypeText = this.QuestionTypeTranslator.TranslateQuestionType(this.SlideQuestionModel.QuestionType);

                        var questionInfoSlide = SlideTracker.GetSlideById(this.SlideQuestionModel.QuestionInfoSlideId);
                        if (questionInfoSlide != null)
                        {
                            var questionInfoSlideNumber          = questionInfoSlide.SlideNumber;
                            this.SlideQuestionModel.SlideNumbers = $"{questionInfoSlideNumber} - {questionInfoSlideNumber + 2}";
                        }

                        if (this.SlideSessionModel.SessionType == SessionType.ArsnovaVoting)
                        {
                            // arsnova.click session will be posted to server on presentation startup
                            this.SessionManager.CreateOrUpdateArsnovaVotingQuestion(this.SlideSessionModel,
                                                                                    this.SlideQuestionModel.Index);
                        }

                        this.AddSessionToSlides(this.SlideQuestionModel);
                        PresentationInformationStore.StoreSlideSessionModel(this.SlideSessionModel);
                    }
                    else
                    {
                        this.DisplayFailedValidationResults(validationResult.Item2);
                    }
                },
                    (e, o) => o.CanExecute = true)
            });
        }
Пример #4
0
        private void InitializeWindowCommandBindings()
        {
            this.WindowCommandBindings.AddRange(
                new List <CommandBinding>
            {
                new CommandBinding(
                    NavigationButtonCommands.Finish,
                    (e, o) =>
                {
                    PresentationInformationStore.StoreSlideSessionModel(this.SlideSessionModel);

                    this.ViewPresenter.CloseWithoutPrompt();
                },
                    (e, o) => o.CanExecute = true),

                /*new CommandBinding(
                 *  NavigationButtonCommands.Back,
                 *  (e, o) =>
                 *  {
                 *      this.ViewPresenter.Show(
                 *          new SelectArsnovaTypeViewViewModel(this.GetViewModelRequirements()));
                 *  },
                 *  (e, o) => o.CanExecute = true),
                 * new CommandBinding(
                 *  NavigationButtonCommands.New,
                 *  (e, o) =>
                 *  {
                 *      var newQuestion = new SlideQuestionModel(this.QuestionTypeTranslator)
                 *                        {
                 *                            QuestionType = this.SlideSessionModel.SessionType
                 *                                           == SessionType.ArsnovaClick
                 *                                               ? QuestionTypeEnum.SingleChoiceClick
                 *                                               : QuestionTypeEnum.SingleChoiceVoting,
                 *                            Index = this.SlideSessionModel.Questions.Count
                 *                            // no new question without selected slide!
                 *                        };
                 *
                 *
                 *      this.SlideSessionModel.Questions.Add(newQuestion);
                 *
                 *      this.OpenQuestionEditDialog(newQuestion.Id, true);
                 *  },
                 *  (e, o) => o.CanExecute = true),*/
                new CommandBinding(
                    NavigationButtonCommands.Edit,
                    (e, o) =>
                {
                    this.OpenQuestionEditDialog(this.SelectedSlideQuestionModel.Id, false);
                },
                    (e, o) => o.CanExecute = this.SelectedSlideQuestionModel != null),
                new CommandBinding(
                    NavigationButtonCommands.Delete,
                    (e, o) =>
                {
                    var questionText =
                        $"{this.LocalizationService.Translate("Do you really want to delete this question?")}{Environment.NewLine}{Environment.NewLine}";
                    questionText += this.SelectedSlideQuestionModel.QuestionText;

                    var deleteQuestion = PopUpWindow.ConfirmationWindow(
                        this.LocalizationService.Translate("Delete"),
                        questionText);

                    if (deleteQuestion)
                    {
                        var questionModel = this.SelectedSlideQuestionModel;
                        SlideTracker.RemoveSlide(questionModel.QuestionInfoSlideId);
                        SlideTracker.RemoveSlide(questionModel.QuestionTimerSlideId.Value);
                        SlideTracker.RemoveSlide(questionModel.ResultsSlideId.Value);
                        this.SelectedSlideQuestionModel = null;
                        this.SlideSessionModel.Questions.Remove(questionModel);
                    }
                },
                    (e, o) => o.CanExecute = this.SelectedSlideQuestionModel != null)
            });
        }
        private void KeepAliveEvent(object source, ElapsedEventArgs e)
        {
            var slideSessionModel = PresentationInformationStore.GetStoredSlideSessionModel();

            this.ribbonHelper.SendKeepAlive(slideSessionModel);
        }
 private bool HasIntroSlide()
 {
     // TODO set to false if the user deletes the slide
     return(PresentationInformationStore.IsArsnovaIntroSlideAlreadyAdded());
 }