private void OnSaveImage(object sender, RoutedEventArgs e) { Application.Current.Dispatcher.Invoke(delegate { if (ImagePreview.Source == null) { return; } var saveFileDialog = new SaveFileDialog { Title = "Save Image", FileName = "Preview.png", InitialDirectory = UserSettings.Default.OutputDirectory, Filter = "Png Files (*.png)|*.png|All Files (*.*)|*.*" }; if (!(bool)saveFileDialog.ShowDialog()) { return; } using var fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImagePreview.Source)); encoder.Save(fileStream); if (!File.Exists(saveFileDialog.FileName)) { return; } Log.Information("{FileName} successfully saved", saveFileDialog.FileName.SubstringAfterLast('\\')); FLogger.AppendInformation(); FLogger.AppendText($"Successfully saved '{saveFileDialog.FileName.SubstringAfterLast('\\')}'", Constants.WHITE, true); });
private static void SaveCheck(string path, string fileName) { if (File.Exists(path)) { Log.Information("{FileName} successfully saved", fileName); FLogger.AppendInformation(); FLogger.AppendText($"Successfully saved '{fileName}'", Constants.WHITE, true); } else { Log.Error("{FileName} could not be saved", fileName); FLogger.AppendError(); FLogger.AppendText($"Could not save '{fileName}'", Constants.WHITE, true); } }
private async Task FilterNewOrModifiedFilesToDisplay(CancellationToken cancellationToken) { var openFileDialog = new OpenFileDialog { Title = "Select a backup file older than your current game version", InitialDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Backups"), Filter = "FBKP Files (*.fbkp)|*.fbkp|All Files (*.*)|*.*", Multiselect = false }; if (!(bool)openFileDialog.ShowDialog()) { return; } FLogger.AppendInformation(); FLogger.AppendText($"Backup file older than current game version is '{openFileDialog.FileName.SubstringAfterLast("\\")}'", Constants.WHITE, true); await using var fileStream = new FileStream(openFileDialog.FileName, FileMode.Open); await using var memoryStream = new MemoryStream(); if (fileStream.ReadUInt32() == _IS_LZ4) { fileStream.Position -= 4; await using var compressionStream = LZ4Stream.Decode(fileStream); await compressionStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false); } else { await fileStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false); } memoryStream.Position = 0; await using var archive = new FStreamArchive(fileStream.Name, memoryStream); var entries = new List <VfsEntry>(); switch (UserSettings.Default.LoadingMode) { case ELoadingMode.AllButNew: { var paths = new Dictionary <string, int>(); while (archive.Position < archive.Length) { cancellationToken.ThrowIfCancellationRequested(); archive.Position += 29; paths[archive.ReadString().ToLower()[1..]] = 0;
private void OnClick(object sender, RoutedEventArgs e) { if (_applicationView.MapViewer.MapImage == null) { return; } var path = Path.Combine(UserSettings.Default.OutputDirectory, "Textures", "MiniMap.png"); var saveFileDialog = new SaveFileDialog { Title = "Save MiniMap", FileName = "MiniMap.png", InitialDirectory = path.SubstringBeforeLast('\\'), Filter = "PNG Files (*.png)|*.png|All Files (*.*)|*.*" }; if (!(bool)saveFileDialog.ShowDialog()) { return; } path = saveFileDialog.FileName; using var fileStream = new FileStream(path, FileMode.Create); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(_applicationView.MapViewer.GetImageToSave())); encoder.Save(fileStream); if (File.Exists(path)) { Log.Information("MiniMap.png successfully saved"); FLogger.AppendInformation(); FLogger.AppendText("Successfully saved 'MiniMap.png'", Constants.WHITE, true); } else { Log.Error("MiniMap.png could not be saved"); FLogger.AppendError(); FLogger.AppendText("Could not save 'MiniMap.png'", Constants.WHITE, true); } }