示例#1
0
        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);
                        }
                        else
                        {
                            this.SlideQuestionModel = this.questionBeforeEdit;
                        }

                        // don't save presentation on cancel (no changes here)
                        this.ViewPresenter.CloseWithoutPrompt();
                    }
                },
                    (e, o) => o.CanExecute = true),
                new CommandBinding(
                    NavigationButtonCommands.Forward,
                    (e, o) =>
                {
                    var validationResult = this.Validate();

                    if (validationResult.Item1)
                    {
                        this.ViewPresenter.Show(
                            new AnswerOptionViewViewModel(this.GetViewModelRequirements(), this.questionId, this.isNew, this.questionBeforeEdit));
                    }
                    else
                    {
                        this.DisplayFailedValidationResults(validationResult.Item2);
                    }
                },
                    (e, o) => o.CanExecute = true)
            });
        }
        public void DeleteQuizFromSelectedSlide(Slide slide)
        {
            var slideSessionModel = this.GetSlideSessionModel();

            var slideQuestionModel = slideSessionModel.Questions.First(q => q.QuestionInfoSlideId == slide.SlideID ||
                                                                       q.QuestionTimerSlideId == slide.SlideID ||
                                                                       q.ResultsSlideId == slide.SlideID);

            if (slideQuestionModel == null)
            {
                throw new Exception("No existing arsnova question on slide.");
            }

            var questionText = $"{this.localizationService.Translate("Do you really want to delete this question?")}{Environment.NewLine}{Environment.NewLine}";

            questionText += slideQuestionModel.QuestionText;

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

            if (deleteQuestion)
            {
                SlideTracker.RemoveSlide(slideQuestionModel.QuestionInfoSlideId);
                if (this.IsARSnovaClickSession())
                {
                    SlideTracker.RemoveSlide(slideQuestionModel.QuestionTimerSlideId.Value);
                }
                SlideTracker.RemoveSlide(slideQuestionModel.ResultsSlideId.Value);

                if (!this.IsARSnovaClickSession())
                {
                    this.sessionManager.DeleteVotingQuestion(slideSessionModel, slideQuestionModel);
                }

                slideSessionModel.Questions.Remove(slideQuestionModel);
            }
        }
        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)
            });
        }