public void Save(object sender, RoutedEventArgs e) { #if DEMO MessageBox.Show("This free demo version can't save data.", "Cannot save", MessageBoxButton.OK, MessageBoxImage.Warning); #else if (rawData.Length > 0) { foreach (TabItem item in mainTabs.Items) { stopEdit((DataGrid)item.Content); //f*****g WPF } Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); string fileName = openFile.Split('\\').Last(); dlg.DefaultExt = ".sav"; // Default file extension dlg.Filter = "SOTS1 saved games|*.sav"; // Filter files by extension // Process save file dialog box results if (dlg.ShowDialog() == true) { parser.updateRawData(ref rawData); Gzip.Compress(dlg.FileName, rawData); load(dlg.FileName); } } else { MessageBox.Show("No data loaded.", "Cannot save", MessageBoxButton.OK, MessageBoxImage.Warning); } #endif }
public static void writeCompressedHex(string fileName) { byte[] unc = read(fileName); Gzip.Compress(fileName + ".temp", unc); byte[] compressed = Gzip.read(fileName + ".temp"); string res = "0x" + BitConverter.ToString(compressed).Replace("-", ",0x"); write(fileName + ".compressed", System.Text.Encoding.ASCII.GetBytes(res)); }