private void LoadFile(PffEntry entry) { if (entry == null) { Text = FormatWindowTitle(string.Empty); //TODO: Clear preview return; } Text = FormatWindowTitle(entry.FilePath); var fileContents = entry.GetContents(); if (fileContents == null) return; Bitmap img; var ext = Path.GetExtension(entry.FilePath)?.Substring(1); switch (ext) { case "PCX": img = PcxConvert.LoadPcx(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "TGA": img = TgaConvert.LoadTga(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "JPG": img = LoadBitmap(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "WAV": using (var stream = new MemoryStream(fileContents)) { var simpleSound = new SoundPlayer(stream); simpleSound.Play(); } break; case "3DI": var file = File3di.Open(fileContents); _renderer = new ModelRenderer(renderControl, file); renderControl.Visible = true; break; } }
public void OpenFilePreview(PffEntry fileContents) { if (fileContents == null) return; //TODO: Reuse window var mdiChild = new FormPreview { MdiParent = this, PreviewFile = fileContents }; mdiChild.Show(); }
private IEnumerable <PffEntry> EnumerateDirectory() { if (_cachedEntries != null) { return(_cachedEntries); } var entries = new List <PffEntry>(); _bReader.BaseStream.Position = _header.RecordOffset + _header.RecordSize; for (var i = 0; i < _header.RecordCount; i++) { PffEntry pffEntry; if (_header.Signature == PffVersion.PFF3) { if (_header.RecordSize == 32) { var entry = _bReader.ReadBytes(32).ToStruct <Entry_Pff3_32>(); pffEntry = new PffEntry(_bReader, entry, _header.Signature); } else { throw new NotImplementedException(); } } else if (_header.Signature == PffVersion.PFF2) { if (_header.RecordSize == 32) { var entry = _bReader.ReadBytes(32).ToStruct <Entry_Pff3_32>(); pffEntry = new PffEntry(_bReader, entry, _header.Signature); } else { throw new NotImplementedException(); } } else { throw new NotImplementedException(); } entries.Add(pffEntry); } _cachedEntries = entries; return(entries); }
private IEnumerable<PffEntry> EnumerateDirectory() { if (_cachedEntries != null) return _cachedEntries; var entries = new List<PffEntry>(); _bReader.BaseStream.Position = _header.RecordOffset + _header.RecordSize; for (var i = 0; i < _header.RecordCount; i++) { PffEntry pffEntry; if (_header.Signature == PffVersion.PFF3) { if (_header.RecordSize == 32) { var entry = _bReader.ReadBytes(32).ToStruct<Entry_Pff3_32>(); pffEntry = new PffEntry(_bReader, entry); } else throw new NotImplementedException(); } else throw new NotImplementedException(); entries.Add(pffEntry); } _cachedEntries = entries; return entries; }