private void CmdDispatcher(string cmd)
        {
            switch (cmd)
            {
                case "AddDictionary":
                    if (CurrentLanguage == null) return;
                    Dictionary dict = new Dictionary();
                    dict.name = "default name "+CurrentLanguage.DictionariesCollection.Count;
                    CurrentLanguage.DictionariesCollection.Add(dict);
                    EFDbContext.SaveChgs();
                    break;

                case "DeleteDictionary":
                    throw new NotImplementedException();

                case "Ok":
                    EFDbContext.SaveChgs();
                    NavigationService.NavigateBack();
                    break;


                default:
                    throw new NotImplementedException();
            }
        }
        public Dictionary_ViewModel(ILogger Logger_, INavigationService NavigationService_, IDialogService DialogService_, ITranslate TranslateService_)
        {
            if (!IsInDesignMode)
            {
                Logger = Logger_;
                NavigationService = NavigationService_;
                DialogService = DialogService_;
                TranslateService = TranslateService_;
                Languages = ViewModelLocator.Instance.Languages;

                SpeechItem_Command = new RelayCommand<WordOfDictionary>(SpeechItem_Cmd);
            }


            if (IsInDesignMode)
            {
                Dictionary = new Dictionary();
                Dictionary.Words.Add(new WordOfDictionary { word="Hello",transcription="hello"});
                Dictionary.Words.Add(new WordOfDictionary { word="day",transcription="day"});

            }

        }
        public void CmdDispatcher(string cmd)
        {

            switch (cmd)
            {
                case "Close":

                    if (NativeLanguage == null)
                    {
                        DialogService.Message(Tx.T("InitialWizard.Messages.DontSelectedNativeLanguage"));
                        return;
                    }

                    if(TargetLanguage == null)
                    {
                        DialogService.Message(Tx.T("InitialWizard.Messages.DontSelectedTargetLanguageLanguage"));
                        return;
                    }

                    if(AppSetting.LearningWordStrategy == null)
                    {
                        DialogService.Message(Tx.T("InitialWizard.Messages.DontSelectedLearningWordStrategy"));
                        return;
                    }

                    Dictionary dict = new Dictionary();
                    dict.name = Tx.T("Common.Phrases.PersonalDictionary");
                    dict.Language = TargetLanguage;
                    dict.SecondaryLanguage = NativeLanguage;

                    AppSetting.DictionariesCollection.Add(dict);
                    AppSetting.PersonalDictionary = dict;

                    EFDbContext.SaveChgs();

                    NavigationService.NavigateBack();
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
 private void Dispatcher_DictionaryGrid(Dictionary dict,string cmd)
 {
     switch (cmd)
     {
         case "Open":
             NavigationService.NavigateForward(Form.Dictionary, new Dictionary_parameters { Dictionary = dict });
             break;
         default:
             throw new NotImplementedException();
     }
 }
        private void CmdDispatcher(string cmd)
        {
            switch (cmd)
            {
                case "AddNewDictionary":
                    if(Subtitles.SecondaryLanguage == null)
                    {
                        DialogService.Message(Tx.T("SubtitleEditor.Messages.SelectNativeLanguageForThisSubtitles"));
                        return;
                    }
                    Dictionary newdict = new Dictionary();
                    newdict.name = "default name" + (Subtitles.PrimaryLanguage.DictionariesCollection.Count + 1);
                    newdict.SecondaryLanguage = Subtitles.SecondaryLanguage;
                    Subtitles.PrimaryLanguage.DictionariesCollection.Add(newdict);
                    EFDbContext.SaveChgs();
                    break;

                case "EditDictionary":
                    NavigationService.NavigateForward(Form.AppSettingEdit, new AppSettingEdit_parameters() { language = Subtitles.PrimaryLanguage });
                    break;
                case "AddSubAsTranslating":
                    AddSubtitleAsTranslate();
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 6
0
        private void InitializeFrequencyDictionary()
        {

            return;

            string url = "http://dict.ruslang.ru/";
            FrequencyDictionary fd =  DataBase.FrequencyDictionary.Where(x=>x.Url == url).FirstOrDefault();
            if(fd == null)
            {

                List<FrequencyDictionary.Item> items = new List<FrequencyDictionary.Item>();

                using (TextReader reader = File.OpenText("Resources/russian_freq_dict.txt"))
                {
                    // header
                    string line = reader.ReadLine();

                    Dictionary<string, SpeechParts> dict = new Dictionary<string, SpeechParts>();
                    dict.Add("s",SpeechParts.Noun);
                    dict.Add("spro",SpeechParts.Pronoun);
                    dict.Add("v",SpeechParts.Verb);
                    dict.Add("a",SpeechParts.Adjective);

                    dict.Add("pr",null);// SpeechParts.Preposition
                    dict.Add("adv",null);// SpeechParts.Adverb
                    dict.Add("conj",null);// SpeechParts.Conjuction
                    dict.Add("intj",null);// SpeechParts.Interjection
                    dict.Add("num",null);//SpeechParts.Numeral
                    dict.Add("part",null);//SpeechParts.Part
                    dict.Add("s.prop",null);// SpeechParts.NounProp
                    dict.Add("advpro", null);
                    dict.Add("anum", null);
                    dict.Add("apro", null);

                    while (true)
                    {
                        line = reader.ReadLine();
                        if (line == null) break;

                        string[] res = line.Split('\t');

                        FrequencyDictionary.Item item = new FrequencyDictionary.Item();
                        item.Lemma = res[0];

                        item.freq = float.Parse(res[2]);
                        if (item.freq < 40) continue;

                        item.speechpart = dict[res[1].ToLower()];
                        if (item.speechpart == null) continue;
                        

                        items.Add(item);
                        //fd.Items.Add(item);
                    }
                    //DataBase.SaveChanges();                    

                }


                fd = new FrequencyDictionary();
                fd.Url = url;
                fd.Count = items.Count();
                DataBase.FrequencyDictionary.Add(fd);

                // блок нужно переработать кривое использование id
                /*
                foreach(var grp in items.GroupBy(x => x.speechpart))
                {
                    FrequencyDictionary.RangeOfSpeechParts range = new FrequencyDictionary.RangeOfSpeechParts();
                    range.speechpart = grp.Key;
                    range.Count = grp.Count();
                    fd.Range.Add(range);

                    FrequencyDictionary.Item first = null;

                    var list2 = grp.OrderByDescending(x => x.freq);
                    foreach(var elm in list2)
                    {
                        fd.Items.Add(elm);
                        if (first == null) first = elm;
                    }
                    DataBase.SaveChanges();
                    range.StartId = first.id;
                    if (fd.StartId == 0) fd.StartId = first.id;
                }
                */

                DataBase.SaveChanges();
                //var lst = items.OrderBy(x => x.speechpart).Select(x=>x.speechpart);
                /*
                int id_ = 1;
                SpeechParts CurSpeechPart = null;
                foreach(var elm in lst)
                {
                    if()
                }
                */
            }
        }
Exemplo n.º 7
0
 public ResultOfParsingMKV() {
     dicSub = new Dictionary<int, Subtitles>();
     AudioTracks = new SynchronizedObservableCollection<AudioTrack>();
 }
Exemplo n.º 8
0
 public void Translating(Dictionary dictionary)
 {
     word_of_dictionary  =  dictionary.GetWord(word.ToLower(),true);
         
     /*
         if (word_of_dictionary.status__ == WordOfDictionary.WordStatuses.enStatus.ManualEditing)
         {
             Status = enWordStatus.Translated;
         }
         else
         {
             Status = enWordStatus.AutoTranslated;    
         }
         */
     RaisePropertyChanged(()=>presentation);
 }