Esempio n. 1
0
        private void Card_SelectionChanged()
        {
            if (this.IsNewCard())
            {
                this.AddModifyButtonText        = "Add Card";
                this.CardTitle                  = null;
                this.QuestionType_SelectedIndex = 0;
                this.AnswerType_SelectedIndex   = 0;
                this.QuestionPanel              = this.QuestionPanelList[this.QuestionType_SelectedIndex];
                this.AnswerPanel                = this.AnswerPanelList[this.AnswerType_SelectedIndex];
            }
            else if (this.Card_SelectedIndex == -1)
            {
                return;
            }
            else
            {
                this.AddModifyButtonText = "Modify Card Title";
                this.CardTitle           = this.QnAModel.PackOfCards[this.Card_SelectedIndex].Title;
                // UserControl qView = null;
                // if (this.QnAModel.CardPack[this.Card_SelectedIndex].Question.GetType().Name == "QuestionTextModel")
                // {
                //     qView = new View.QuestionTextUserControl();
                //     ViewModel.QuestionTextViewModel dc = new ViewModel.QuestionTextViewModel(
                //         (Model.QuestionTextModel)this.QnAModel.CardPack[this.Card_SelectedIndex].Question);
                //     qView.DataContext = dc;
                // }
                // if (this.QnAModel.CardPack[this.Card_SelectedIndex].Question.GetType().Name == "QuestionPictureModel")
                // {
                //     qView = new View.QuestionPictureUserControl();
                //     ViewModel.QuestionPictureViewModel dc = new ViewModel.QuestionPictureViewModel(
                //         (Model.QuestionPictureModel)this.QnAModel.CardPack[this.Card_SelectedIndex].Question);
                //     qView.DataContext = dc;
                // }
                // this.QuestionPanel = qView;
                IQuestion selectedQuestion = this.QnAModel.PackOfCards[this.Card_SelectedIndex].Question;
                this.QuestionPanel = this.QuestionViewGenerator(selectedQuestion.GetQuestionType(), selectedQuestion);

                // UserControl aView = null;
                // if (this.QnAModel.CardPack[this.Card_SelectedIndex].Answer.GetType().Name == "AnswerTextModel")
                // {
                //     aView = new View.AnswerTextUserControl();
                //     ViewModel.AnswerLotofTextViewModel dc = new ViewModel.AnswerLotofTextViewModel(
                //         (Model.AnswerLotofTextModel)this.QnAModel.CardPack[this.Card_SelectedIndex].Answer);
                //     aView.DataContext = dc;
                // }
                // this.AnswerPanel = aView;
                IAnswer selectedAnswer = this.QnAModel.PackOfCards[this.Card_SelectedIndex].Answer;
                this.AnswerPanel = this.AnswerViewGenerator(selectedAnswer.GetAnswerType(), selectedAnswer);
                // this.OnPropertyChanged("AnswerPanel");
            }
        }
Esempio n. 2
0
        private IAnswer UserAnswerGenerator(IAnswer answer)
        {
            Type type = answer.GetAnswerType();

            if (type == typeof(AnswerExactTextModel))
            {
                return((IAnswer) new AnswerExactTextModel(GlobalLanguage.Instance.GetDict()["YourAnswerComesHere"]));
            }
            if (type == typeof(AnswerLotofTextModel))
            {
                return((IAnswer) new AnswerLotofTextModel(GlobalLanguage.Instance.GetDict()["YourAnswerComesHere"]));
            }
            if (type == typeof(AnswerTippMixModel))
            {
                AnswerTippMixModel oldAnswer = (AnswerTippMixModel)answer;
                AnswerTippMixModel newAnswer = new AnswerTippMixModel();
                foreach (TippMix item in oldAnswer.TippMixList)
                {
                    newAnswer.AddEmptyTipp(item);
                }
                return((IAnswer)newAnswer);
            }
            return(null);
        }