/// <summary> /// Create a new project /// </summary> public ProjectViewModel(IAppService appService) { this._AppService = appService; Project = new Model.TranslationProject(); Groups = new ObservableCollection<GroupViewModel>(); Editors = new ObservableCollection<TranslationEditorViewModel>(); OpenTranslationCommand = new RelayCommand<TranslationFileViewModel>( async file => { Exception error = null; try { await OpenTranslationAsync(file); } catch (Exception ex) { error = ex; } if (error != null) await _AppService.ShowError(error); }, file => file != null ); CloseEditorCommand = new RelayCommand<TranslationEditorViewModel>( async editor => await CloseEditorAsync(editor), editor => editor != null ); }
/// <summary> /// Import the files to the project folder from an another folder /// </summary> public async Task<bool> ImportFolderAsync(String folder, bool overrideFiles) { if (String.IsNullOrWhiteSpace(ProjectFolder)) return false; if (Loading) return false; try { Loading = true; DirectoryInfo iDir = new DirectoryInfo(folder); var iProject = new Model.TranslationProject(); iProject.ScanFolder(folder); foreach (var iFile in iProject.Groups.SelectMany(g => g.Files)) { // If neutral XML find the DLL if (iFile.IsNeutral && String.Equals(iFile.FileType, "xml", StringComparison.OrdinalIgnoreCase)) { var dllFile = new Model.TranslationFile(iFile.Folder, iFile.FileName, "dll"); if (!iProject.Groups.Any(g => g.FindFile(dllFile.File) != null)) await CopyFileAsync(overrideFiles, iDir, dllFile); } await CopyFileAsync(overrideFiles, iDir, iFile); } Project.Groups.Clear(); await InternalLoadProjectASync(ProjectFolder); return true; } finally { Loading = false; } }