public DatViewer(string filename) { this.FileName = filename; data = new DatWrapper(filename); InitializeComponent(); DataContext = this; buttonSave.Content = Settings.Strings["DatViewer_Button_Save"]; buttonExportCSV.Content = Settings.Strings["DatViewer_Button_Export"]; }
public DatViewer(string filename) { FileName = filename; _showPointerDataValue = false; _showPointerPrefixValue = false; _wrapper = new DatWrapper(filename); InitializeComponent(); DataContext = this; buttonSave.Content = Settings.Strings["DatViewer_Button_Save"]; buttonExportCSV.Content = Settings.Strings["DatViewer_Button_Export"]; }
/// <summary> /// Attempts to display the specified record on the gui /// </summary> /// <param name="selectedRecord">Record to view</param> private void OpenFileRecord(FileRecord selectedRecord) { if (selectedRecord == null) { return; } string extractedFileName; try { extractedFileName = selectedRecord.ExtractTempFile(_ggpkPath); var extension = Path.GetExtension(selectedRecord.Name); // If we're dealing with .dat files then just create a human readable CSV and view that instead if (!String.IsNullOrEmpty(extension) && extension.ToLower().Equals(".dat")) { var extractedCsv = Path.GetTempFileName(); File.Move(extractedCsv, extractedCsv + ".csv"); extractedCsv = extractedCsv + ".csv"; using (var inStream = File.Open(extractedFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var tempWrapper = new DatWrapper(inStream, selectedRecord.Name); File.WriteAllText(extractedCsv, tempWrapper.GetCSV()); } File.Delete(extractedFileName); extractedFileName = extractedCsv; } } catch (Exception ex) { MessageBox.Show( string.Format(Settings.Strings["ViewSelectedItem_Failed"], ex.Message), Settings.Strings["Error_Caption"], MessageBoxButton.OK, MessageBoxImage.Error); return; } var fileViewerProcess = new Process { StartInfo = new ProcessStartInfo(extractedFileName), EnableRaisingEvents = true }; fileViewerProcess.Exited += fileViewerProcess_Exited; fileViewerProcess.Start(); }
public void Reset(string filename, Stream inStream) { this.FileName = filename; data = new DatWrapper(inStream, filename); DataContext = null; dataGridEntries.ItemsSource = null; dataGridEntries.Columns.Clear(); // if (data.Entries.Count <= 0) { return; } BuildGrid(data.Entries[0].GetType()); DataContext = this; }
public void Reset(string filename, byte[] data) { FileName = filename; _data = data; using (var ms = new MemoryStream(data)) { _wrapper = new DatWrapper(ms, filename); } DataContext = null; datName.Content = filename; datInfo.Content = "\tSingle record length (bytes) = " + _wrapper.RecordInfo.Length + "\n\tNumber of records = " + _wrapper.Records.Count + "\n\tData section start offset = " + _wrapper.DataSectionffset + "\n\tData section length = " + _wrapper.DataSectionDataLength; // Records DataGrid BuildGrid(); DataContext = this; }
/// <summary> /// Attempts to display the specified record on the gui /// </summary> /// <param name="selectedRecord">Record to view</param> private void ViewFileRecord(FileRecord selectedRecord) { string extractedFileName; try { extractedFileName = selectedRecord.ExtractTempFile(ggpkPath); // If we're dealing with .dat files then just create a human readable CSV and view that instead if (Path.GetExtension(selectedRecord.Name).ToLower() == ".dat") { string extractedCSV = Path.GetTempFileName(); File.Move(extractedCSV, extractedCSV + ".csv"); extractedCSV = extractedCSV + ".csv"; using (FileStream inStream = File.Open(extractedFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { DatWrapper tempWrapper = new DatWrapper(inStream, selectedRecord.Name); File.WriteAllText(extractedCSV, tempWrapper.Dat.GetCSV()); } File.Delete(extractedFileName); extractedFileName = extractedCSV; } } catch (Exception ex) { MessageBox.Show(string.Format(Settings.Strings["ViewSelectedItem_Failed"], ex.Message), Settings.Strings["Error_Caption"], MessageBoxButton.OK, MessageBoxImage.Error); return; } Process fileViewerProcess = new Process(); fileViewerProcess.StartInfo = new ProcessStartInfo(extractedFileName); fileViewerProcess.EnableRaisingEvents = true; fileViewerProcess.Exited += fileViewerProcess_Exited; fileViewerProcess.Start(); }