示例#1
0
        public HomeViewModel()
        {
            this.Phrases = new List<PhraseReference.Phrase>() { };
            this.Phrases2 = new ObservableCollection<CompletePhrase>();
            this.Translations = new ObservableCollection<TranslationReference.Translation>();
            this.TranslationsComplete = new ObservableCollection<CompleteTranslation>();

            this.CreatePhraseCommand = new DelegateCommand(AddPhrase_Execute, AddPhrase_CanExecute);
            this.EditPhraseCommand = new DelegateCommand(EditPhrase_Execute, EditPhrase_CanExecute);
            this.DeletePhraseCommand = new DelegateCommand(DeletePhrase_Execute, DeletePhrase_CanExecute);

            this.CreateTranslationCommand = new DelegateCommand(AddTranslation_Execute, AddTranslation_CanExecute);
            this.EditTranslationCommand = new DelegateCommand(EditTranslation_Execute, EditTranslation_CanExecute);
            this.DeleteTranslationCommand = new DelegateCommand(DeleteTranslation_Execute, DeleteTranslation_CanExecute);

            _phraseClient = new PhraseReference.PhraseServiceClient();
            _phraseClient.CreatePhraseCompleted += CreatePhraseComplete;
            _phraseClient.DisplayPhrasesCompleted += DisplayListPhrasesComplete;
            _phraseClient.EditPhraseCompleted += EditPhraseComplete;
            _phraseClient.DeletePhraseCompleted += DeletePhraseComplete;

            _translationClient = new TranslationReference.TranslationServiceClient();
            _translationClient.CreateTranslationCompleted += CreateTranslationComplete;
            _translationClient.DisplayTranslationsCompleted += DisplayListTranslationComplete;
            _translationClient.DisplayTranslationsByPhraseIdCompleted += DisplayTranslationsByPhraseIdCompleted;
            _translationClient.EditTranslationCompleted += EditTranslationComplete;
            _translationClient.DeleteTranslationCompleted += DeleteTranslationComplete;

            _languageClient = new LanguageReference.LanguageServiceClient();
            _languageClient.DisplayLanguagesCompleted += DisplayListLanguageComplete;

            _phraseClient.DisplayPhrasesAsync();

            _messageBoxService = new MessageBoxService();
            _modalDialogService = new ModalDialogService();
            _informationDialogService = new ModalDialogService();
            _translationModalDialogService = new ModalDialogService();

            _temporalPhraseTranslation = new TranslationReference.Translation();
        }
示例#2
0
 void EditTranslation_Execute(object parameters)
 {
     if (parameters == null)
         return;
     CompleteTranslation temporalTranslation = (parameters as CompleteTranslation);
     foreach (var item in this.Phrases2)
     {
         if (item.Phrase.phraseId == temporalTranslation.Translation.PhraseId)
         {
             TranslationEditorViewModel editorViewModel = new TranslationEditorViewModel(item.Phrase, temporalTranslation.Translation);
             TranslationEditorWindow dialog = new TranslationEditorWindow(editorViewModel);
             _translationModalDialogService.ShowDialog<TranslationEditorViewModel>(dialog,
                 editorViewModel,
                 returnedViewModelInstance =>
                 {
                     if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                     {
                         TranslationReference.Translation result = editorViewModel.TranslationResult;
                         _temporalPhraseTranslation = editorViewModel.TranslationResult;
                         _translationClient.EditTranslationAsync(result);
                     }
                 });
             break;
         }
     }
 }
示例#3
0
 void EditPhrase_Execute(object parameters)
 {
     if (parameters == null)
         return;
     CompletePhrase temporalPhrase = (parameters as CompletePhrase);
     EditorViewModel editorViewModel = new EditorViewModel(temporalPhrase);
     EditorWindow dialog = new EditorWindow(editorViewModel);
     _modalDialogService.ShowDialog<EditorViewModel>(dialog,
         editorViewModel,
         returnedViewModelInstance =>
         {
             if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
             {
                 PhraseReference.Phrase result = editorViewModel.PhraseResult;
                 _temporalPhraseTranslation = editorViewModel.TranslationResult;
                 _phraseClient.EditPhraseAsync(result);
             }
         });
 }
示例#4
0
 void AddTranslation_Execute(object parameters)
 {
     if (parameters == null)
         return;
     CompletePhrase temporalPhrase = (parameters as CompletePhrase);
     TranslationEditorViewModel editorViewModel = new TranslationEditorViewModel(temporalPhrase.Phrase, new TranslationReference.Translation());
     TranslationEditorWindow dialog = new TranslationEditorWindow(editorViewModel);
     _translationModalDialogService.ShowDialog<TranslationEditorViewModel>(dialog,
         editorViewModel,
         returnedViewModelInstance =>
         {
             if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
             {
                 TranslationReference.Translation result = editorViewModel.TranslationResult;
                 _temporalPhraseTranslation = editorViewModel.TranslationResult;
                 _translationClient.CreateTranslationAsync(result);
             }
         });
 }
示例#5
0
 void AddPhrase_Execute(object parameters)
 {
     CompletePhrase temporalPhrase = new CompletePhrase(new PhraseReference.Phrase(), new TranslationReference.Translation());
     temporalPhrase.Translation.PhraseByDefault = true;
     EditorViewModel editorViewModel = new EditorViewModel(temporalPhrase);
     EditorWindow dialog = new EditorWindow(editorViewModel);
     _modalDialogService.ShowDialog<EditorViewModel>(dialog,
         editorViewModel,
         returnedViewModelInstance =>
         {
             if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
             {
                 PhraseReference.Phrase result = editorViewModel.PhraseResult;
                 _temporalPhraseTranslation = editorViewModel.TranslationResult;
                 _phraseClient.CreatePhraseAsync(result);
             }
         });
 }
示例#6
0
 public TranslationReference.Translation CreateATranslation()
 {
     TranslationReference.Translation temporalTranslation = new TranslationReference.Translation();
     temporalTranslation.TranslationId = this.TranslationResult.TranslationId;
     temporalTranslation.TranslationContent = this.Content;
     temporalTranslation.TranslationFirstLetter = this.Content[0].ToString();
     temporalTranslation.TranslationDescription = this.Description;
     temporalTranslation.Lexicon = this.Lexicon.ToLower();
     temporalTranslation.LanguageId = Convert.ToInt32(Language);
     temporalTranslation.PhraseId = this.TranslationResult.PhraseId;
     temporalTranslation.PhraseByDefault = this.TranslationResult.PhraseByDefault;
     return temporalTranslation;
 }