Example #1
0
        public void OpenFilePreview(PffEntry fileContents)
        {
            if (fileContents == null)
            {
                return;
            }


            //TODO: Reuse window
            var mdiChild = new FormPreview
            {
                MdiParent   = this,
                PreviewFile = fileContents
            };

            mdiChild.Show();
        }
        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;
            }
        }