public OverviewDetails(ManagedGameVersion versionItem, Overview parent) { GameDetails = versionItem; _parent = parent; InitializeComponent(); DataContext = this; }
public void DeleteGameDirectory(ManagedGameVersion game, IProgress <int> progress) { progress.Report(10); if (Directory.Exists(game.Path)) { Directory.Delete(game.Path, true); } RootDirectoryEntity root = new RootDirectoryEntityIO().Deserialize(game.GameXML); List <RootDirectoryEntity> otherVersions = new List <RootDirectoryEntity>(); foreach (var mgv in _mvs.GetManagedVersions()) { RootDirectoryEntity data = new RootDirectoryEntityIO().Deserialize(mgv.GameXML); otherVersions.Add(data); } Progress <int> partialProgress = new Progress <int>(prog => { int percent = (int)(prog * 0.9); progress.Report(10 + percent); }); string container = Settings.Default.ContainerDirectory; GameFilesRemover.RemoveFiles(root, otherVersions, Helpers.EntityToPath(container), _dirCache, partialProgress); SaveDirCache(); System.Windows.Application.Current.Dispatcher.BeginInvoke((Action) delegate() { _mvs.Remove(game); }); progress.Report(100); }
public async void RebuildDirectory(ManagedGameVersion version) { ProgressWindow pw = new ProgressWindow("Verify integrity", "Rebuilding World of Tanks directory. Do not close the application."); pw.CloseOnComplete = true; var winTask = pw.ShowDialogAsync(); int previous = 0; Progress <int> progress = new Progress <int>(prog => { if (prog != previous) { pw.SetProgress(prog); } previous = prog; }); try { await Task.Run(() => _gameDirService.RebuildGameDirectory(version, progress)); } catch (FileNotFoundException ex) { new MessageWindow("Error", "Corrupted files detected. Please delete this version and re-import it.", MessageWindowButtons.OK).ShowDialog(); (progress as IProgress <int>).Report(100); } await winTask; }
public void Remove(ManagedGameVersion game) { if (_items.Contains(game)) { _items.Remove(game); Save(); } }
public void UpdateGameDirectory(RootDirectoryEntity updated, string outputDir, IProgress <int> progress) { ManagedGameVersion oldMGV = _mvs.GetManagedVersions().First(mvg => mvg.Version == updated.Version); RootDirectoryEntity oldBuild = new RootDirectoryEntityIO().Deserialize(oldMGV.GameXML); HashSet <FileEntity> oldFiles = oldBuild.GetAllFileEntities(true).OfType <FileEntity>().ToHashSet(); HashSet <FileEntity> newFiles = updated.GetAllFileEntities(true).OfType <FileEntity>().ToHashSet(); HashSet <FileEntity> changedFiles = newFiles.Except(oldFiles).ToHashSet(); HashSet <FileEntity> filesToRemove = oldFiles.Except(newFiles).ToHashSet(); // Do not remove files that only changed location HashSet <string> newFilesHashes = newFiles.Select(x => x.Hash).ToHashSet(); HashSet <FileEntity> movedFileHashes = filesToRemove.Where(f => newFilesHashes.Contains(f.Hash)).ToHashSet(); filesToRemove.ExceptWith(movedFileHashes); string container = Settings.Default.ContainerDirectory; List <RootDirectoryEntity> otherVersions = new List <RootDirectoryEntity>(); foreach (var mgv in _mvs.GetManagedVersions().Except(new List <ManagedGameVersion>() { oldMGV })) { RootDirectoryEntity data = new RootDirectoryEntityIO().Deserialize(mgv.GameXML); otherVersions.Add(data); } int basePercent = 0; Progress <int> partialProgress = new Progress <int>(percent => { progress.Report(basePercent + percent / 2); }); // Remove old unused files from cache GameFilesRemover.RemoveFiles(filesToRemove, otherVersions, Helpers.EntityToPath(container), _dirCache, partialProgress ); SaveDirCache(); basePercent = 50; // Remove old unused files from game directory foreach (FileEntity unusedFile in filesToRemove) { string path = Path.Combine(oldMGV.Path, unusedFile.RelativePath); try { File.Delete(path); } catch (Exception ex) { } } // Update files in directory CreateGameDirectory(updated, oldMGV.Path, partialProgress); progress.Report(100); }
private void btnRemove_Click(object sender, RoutedEventArgs e) { ManagedGameVersion version = lbVersions.SelectedItem as ManagedGameVersion; if (version != null) { ManagedVersions.Remove(version); } }
private async void RemoveGameFiles() { string btnContent = btnRemove.Content as string; ManagedGameVersion selected = lbVersions.SelectedItem as ManagedGameVersion; if (selected == null) { return; } _containerPath = txtContainer.Text; if (_containerPath == null || !Directory.Exists(_containerPath)) { MessageBox.Show("Please select container directory.", "Error"); return; } if (!LoadDirCache()) { return; } MessageBoxResult result = MessageBox.Show("This process will remove ALL files from the selected version and delete the game directory. Proceed?", "Warning", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { return; } btnRemove.IsEnabled = false; btnRemove.Content = "Removing..."; if (Directory.Exists(selected.Path)) { await Task.Run(() => Directory.Delete(selected.Path, true)); } RootDirectoryEntity root = new RootDirectoryEntityIO().Deserialize(selected.GameXML); List <RootDirectoryEntity> otherVersions = new List <RootDirectoryEntity>(); foreach (var mgv in ManagedVersions) { RootDirectoryEntity data = new RootDirectoryEntityIO().Deserialize(mgv.GameXML); otherVersions.Add(data); } await Task.Run(() => GameFilesRemover.RemoveFiles(root, otherVersions, _containerPath, Helpers.EntityToPath(_containerPath), _dirCache, null)); ManagedVersions.Remove(selected); SaveManagedVersions(); SaveDirCache(); btnRemove.IsEnabled = true; btnRemove.Content = btnContent; }
public void RebuildGameDirectory(ManagedGameVersion game, IProgress <int> progress) { progress.Report(10); if (Directory.Exists(game.Path)) { Directory.Delete(game.Path, true); } Progress <int> partialProgress = new Progress <int>(percent => { progress.Report((int)(10 + 0.9 * percent)); }); CreateGameDirectory(game.GameXML, game.Path, partialProgress); progress.Report(100); }
public async void DeleteVersion(ManagedGameVersion version) { ProgressWindow pw = new ProgressWindow("Deleting version", "Deleting selected World of Tanks version. Do not close the application."); pw.CloseOnComplete = true; var winTask = pw.ShowDialogAsync(); int previous = 0; Progress <int> progress = new Progress <int>(prog => { if (prog != previous) { pw.SetProgress(prog); } previous = prog; }); await Task.Run(() => _gameDirService.DeleteGameDirectory(version, progress)); await winTask; }
public void Add(ManagedGameVersion mgv) { _items.Add(mgv); Save(); }
public bool Contains(ManagedGameVersion version) { return(_items.Contains(version)); }