Пример #1
0
        public Wizards_ViewModel()
        {
            btnOK = new ButtonModel { Visibility = System.Windows.Visibility.Collapsed};
            btnBack = new ButtonModel();
            btnNext = new ButtonModel();

            TabItemsCollection = new ObservableCollection<object>();

            SelectedIndex = 0;
        }
 private void PressWordButton_Cmd(ButtonModel button)
 {
     if (button.IsItTrue)
     {
         // Success
         Messenger.Default.Send(new PlayerEvent(PlyaerEventEnum.UnderstandingTestPassed, CurrentSub));
     }
     else
     {
         // False
         Messenger.Default.Send(new PlayerEvent(PlyaerEventEnum.UnderstandingTestFailed, CurrentSub));
     }
     NavigationService.NavigateBack();
 }
        private void PressWordButton_Cmd(ButtonModel btn)
        {

            if (btn.IsItTrue)
            {
                if(mode == Mode.Training)
                {
                    AppSetting.LearningWordStrategy.SetNextStep(CurrentWord);
                    EFDbContext.SaveChgs();
                }
                CommandDispatcher("Skip");
                return;
            }

            switch (mode)
            {
                case Mode.Training:
                    TranslatingVisibility = Visibility.Visible;
                    ImagePanelVisibility = Visibility.Visible;
                    btnTrainingNext.Visibility = Visibility.Visible;
                    WordsButtonPanelVisibility = Visibility.Collapsed;
                    break;

                case Mode.FoundNewWord:
                    TranslatingVisibility = Visibility.Visible;
                    ImagePanelVisibility = Visibility.Visible;
                    BottomButtonsPanelVisibility = Visibility.Visible;
                    WordsButtonPanelVisibility = Visibility.Collapsed;
                    btnSkip.Visibility = Visibility.Collapsed;
                    break;

                case Mode.WordTranslation:

                    break;

                default:
                    throw new NotImplementedException();
            }

        }
        public WordsTranslation_ViewModel(INavigationService NavigationService_,IDialogService DialogService_,AppSetting AppSetting_)
        {
            if (IsInDesignMode)
            {
                mode = Mode.Edit;
            }

            if (!IsInDesignMode)
            {
                NavigationService = NavigationService_;
                DialogService = DialogService_;
                AppSetting = AppSetting_;

                Statuses = WordOfDictionary.WordStatuses.Statuses;
            }

            ExecuteCommand = new RelayCommand<string>(CommandDispatcher);
            PressWordButton_Command = new RelayCommand<ButtonModel>(PressWordButton_Cmd);

            WordsForSelection_Buttons = new ObservableCollection<ButtonModel>(); 

            btnNextButton = new ButtonModel();
            btnPreviousButton = new ButtonModel();
            btnAddToDictionary = new ButtonModel();
            btnSkip = new ButtonModel();
            WordsCollection_ListModel = new List_Model();
            btnTrainingNext = new ButtonModel();
            btnOk = new ButtonModel();

            if (IsInDesignMode)
            {
                CurrentWord = new WordOfDictionary();
                CurrentWord.word = "White";
                CurrentWord.translation_as_string = "Белый";
                CurrentWord.transcription = "[wʌɪt]";
                //CurrentWord.commentary = "{Белый цвет, не черный, не зеленый, а именно белый. \nСовершенно белый.\nНу может с желтоватым отливом}";
                CurrentWord.pictures_url = "http://d144fqpiyasmrr.cloudfront.net/uploads/picture/295623.png";

                CurrentWord.translations.Add(new TranslationOfWord() {translation="белый",votes=150 });
                CurrentWord.translations.Add(new TranslationOfWord() {translation="беловатый",votes=50 });
                CurrentWord.translations.Add(new TranslationOfWord() {translation="беленький, беловатый, бледноватный, беловатенькая, серобуромалиновенькая, ярко белая в крапинку",votes=15 });

                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Зелёный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Белый"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Черный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Пурпурный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Фиолетовый"});

                WordsCollection = new ObservableCollection<WordOfDictionary>();
                WordsCollection.Add(new WordOfDictionary() {word = "everybody"});
                WordsCollection.Add(new WordOfDictionary() {word = "likes"});
                WordsCollection.Add(new WordOfDictionary() {word = "cakes"});

                Header_LabelModel.Text = "This is a Header";

                SetCurrentWord(CurrentWord);
            }

        }
        private async void PressCollectWordsButton_Cmd(ButtonModel btnModel)
        {
            if (CurrentPhrase.Words[CurrentPhrase.IndexOfCurrentWord].word.ToLower() == btnModel.WordOfButton.word.ToLower())
            {
                // Success
                btnModel.Visibility = Visibility.Hidden; 
                CollectedPhraseText = CurrentPhrase.Words[CurrentPhrase.IndexOfCurrentWord].phrase;
                CurrentPhrase.IndexOfCurrentWord++;

                foreach (var elm in CollectPhrases_Buttons) if (!elm.IsEnabled) elm.IsEnabled = true;

                StatList.Add(new StatisticsMessage() { Cmd = StatisticsCmd.WordCollected, phrase = CurrentPhrase, word = btnModel.WordOfButton });

                if (CurrentPhrase.IndexOfCurrentWord == CurrentPhrase.Words.Count)
                {
                    Controller(new PlayerEvent(PlyaerEventEnum.CollectingWordTestPassed,CurrentPhrase.SubtitleItem));
                }
                CurrentPhrase.Errors = 0;
            }
            else
            {
                // Fail, selected word is invalid

                StatList.Add(new StatisticsMessage() { Cmd = StatisticsCmd.WordFail, phrase = CurrentPhrase, word = btnModel.WordOfButton });

                btnModel.IsEnabled = false;
                CurrentPhrase.Errors++;

                if (CurrentPhrase.Errors > 1)
                {
                    VideoFrameVisibility = Visibility.Hidden;
                    bool res = await DialogService.Ask(Tx.T("Player.Message.CanRepeat"));
                    VideoFrameVisibility = Visibility.Visible;
                    if (res)
                    {
                        CmdDispatcher("Replay");
                    }
                }

            }
        }