public async void ExportFile() { Console.WriteLine(_selectedIndex); string extension = FileProperties.GetExtension(GDAT.Files[_selectedIndex].Magic); SaveFileDialog dialog = new SaveFileDialog() { Title = "Where do you want to save this file !", DefaultExtension = extension, InitialFileName = _selectedIndex.ToString() + "." + extension }; IClassicDesktopStyleApplicationLifetime classicDesktopLifetime = (IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime; string results = await dialog.ShowAsync(classicDesktopLifetime.MainWindow); if (results == null) { return; } else { Console.WriteLine("Test"); GDATFile file = GDAT.Files[_selectedIndex]; using (FileStream s = File.Create(results)){ file.Export(s); } } }
void AddFormatProperties(GDATFile file) { string formattedMagic = FileProperties.GetExtension(file.Magic); FileProperties props = new FileProperties("Format", formattedMagic); Properties.Add(props); AddFormatDefinition(formattedMagic); }
void AddSizeProperty(GDATFile file) { FileProperties props = new FileProperties(); props.Property = "Size"; props.Value = GetSize(file); Properties.Add(props); }
public void UpdateProperties(GDATFile file) { Properties.Clear(); AddIDProperty(file); AddFormatProperties(file); AddOffsetProperty(file); AddSizeProperty(file); Console.WriteLine("Updated Properties"); }
public string GetSize(GDATFile file) { ulong size = file.Size; if (size > 100) { float kbSize = (float)file.Size * 0.001f; if (kbSize > 10) { float mbs = kbSize * 0.001f; return(mbs.ToString("0.00") + " MB"); } else { return(kbSize.ToString("0.00") + " KB"); } } else { return(size.ToString() + " B"); } }
void AddOffsetProperty(GDATFile file) { FileProperties props = new FileProperties("Offset", "0x" + file.Offset.ToString("X8")); Properties.Add(props); }
void AddIDProperty(GDATFile file) { FileProperties props = new FileProperties("ID", file.ID.ToString()); Properties.Add(props); }