Ejemplo n.º 1
0
        void LoadLanguagePacks()
        {
            var fileEntries = Directory.GetFiles("vocabulary");

            foreach (var fileName in fileEntries)
            {
                // do something with fileName
                var info      = new FileInfo(fileName);
                var _fileName = fileName;
                var name      = info.Name;
                if (name.Contains(".xml"))
                {
                    name = name.Replace(".xml", "");

                    var languagePack = new Models.LanguagePack();
                    languagePack.Name = name;
                    languagePack.Info = info;

                    //Get words
                    var sr           = new  StreamReader(_fileName);
                    var deserializer = new XmlSerializer(typeof(List <Word>));
                    languagePack.Words = (List <Word>)deserializer.Deserialize(sr);

                    languagePack.NativeLanguage = Client.NativeLanguage;
                    languagePack.TargetLanguage = Client.TargetLanguage;

                    if (LanguagePacks == null)
                    {
                        LanguagePacks = new ObservableCollection <LanguagePack>();
                    }
                    LanguagePacks.Add(languagePack);
                }
            }
        }
        void LoadLanguagePacks()
        {
            var fileEntries = Directory.GetFiles("vocabulary");
            foreach (var fileName in fileEntries)
            {
                // do something with fileName
                var info = new FileInfo(fileName);
                var _fileName = fileName;
                var name = info.Name;
                if (name.Contains(".xml"))
                {
                    name = name.Replace(".xml", "");

                    var languagePack = new Models.LanguagePack();
                    languagePack.Name = name;
                    languagePack.Info = info;

                    //Get words
                    var sr = new  StreamReader(_fileName);
                    var deserializer = new XmlSerializer(typeof(List<Word>));
                    languagePack.Words = (List<Word>)deserializer.Deserialize(sr);

                    languagePack.NativeLanguage = Client.NativeLanguage;
                    languagePack.TargetLanguage = Client.TargetLanguage;

                    if (LanguagePacks == null)
                        LanguagePacks = new ObservableCollection<LanguagePack>();
                    LanguagePacks.Add(languagePack);
                }
            }
        }
        void RefreshWordViews(LanguagePack languagePack)
        {
            _currentWord = languagePack.SelectedWord;
            //Native probably being english
            if (_nativeWord == null)
            {
                if (languagePack.NativeLanguage == null)
                    languagePack.NativeLanguage = Client.NativeLanguage;
                _nativeWord = new WordView(new CGRect(0, 0, View.Bounds.Width, 30), languagePack.NativeLanguage,
                    languagePack.SelectedWord.Native);
                View.Add(_nativeWord);
            }

            //Target being Dutch, French etc..
            if (_targetWord == null)
            {
                if (languagePack.TargetLanguage == null)
                    languagePack.TargetLanguage = Client.TargetLanguage;

                _targetWord = new WordView(new CGRect(0, 160, View.Frame.Width, 30), languagePack.TargetLanguage,
                    languagePack.SelectedWord.Target);
                View.Add(_targetWord);
            }

            _targetWord.Update(languagePack.SelectedWord.Target);
            _nativeWord.Update(languagePack.SelectedWord.Native);

            _countDownValue = 5;
            _countdownTimer.Start();
        }