public async Task <DictionaryInfo> GetInfo() { bool isDemo = !IsPurchased; PBase dictBase = null; if (isDemo) { dictBase = _basesManager.DemoBase; } else { dictBase = _basesManager.DictBase; } string dictBasePath = await dictBase.GetPath(); if (string.IsNullOrEmpty(dictBasePath)) { throw new Exception("File of dictionary base is not found"); } DictionaryInfo dictionaryInfo = new DictionaryInfo(_model.Id, Name, isDemo); dictionaryInfo.DictBasePath = dictBasePath; dictionaryInfo.Colors = _model.Colors; foreach (PBase morphoBase in _basesManager.MorphoBases) { string morphoBasePath = await morphoBase.GetPath(); if (!string.IsNullOrEmpty(morphoBasePath)) { dictionaryInfo.MorphoBasesPaths.Add(morphoBasePath); } } foreach (PBase soundBase in _basesManager.SoundBases) { string soundBasePath = await soundBase.GetPath(); if (!string.IsNullOrEmpty(soundBasePath)) { dictionaryInfo.SoundBasesPaths.Add(soundBasePath); } } return(dictionaryInfo); }
private void InitializeBases() { _soundBases = new List <PBase>(); _morphoBases = new List <PBase>(); _downloadableBases = new ObservableCollection <PBase>(); foreach (Models.PBase baseModel in _bases) { PBase baseViewModel = new PBase(baseModel); switch (baseViewModel.Type) { case PBaseTypes.Dictionary: _downloadableBases.Add(baseViewModel); _dictBase = baseViewModel; _dictBase.StateChanged += DictBaseOnStateChanged; break; case PBaseTypes.Demo: _demoBase = baseViewModel; break; case PBaseTypes.Sound: _downloadableBases.Add(baseViewModel); _soundBases.Add(baseViewModel); break; case PBaseTypes.Morphology: _morphoBases.Add(baseViewModel); break; } } if (_dictBase == null) { throw new Exception("Dictionary base is not found"); } int dictBaseIndex = _downloadableBases.IndexOf(_dictBase); _downloadableBases.Move(dictBaseIndex, 0); _isInitialized = true; }