Esempio n. 1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            ofdBrowse.Filter = "All supported files|*.jpg;*.png;*.tif;*.tga;*.bmp;*.tdx|JPG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIF (*.tif)|*.tif|TGA (*.tga)|*.tga|BMP (*.bmp)|*.bmp|TDX (*.tdx)|*.tdx";

            if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName))
            {
                var fi = new FileInfo(ofdBrowse.FileName);

                switch (fi.Extension.ToLower())
                {
                    case ".bmp":
                        t = SceneManager.Current.Content.Load<Texture, BMPImporter>(fi.Name, fi.DirectoryName);
                        break;

                    case ".jpg":
                        t = SceneManager.Current.Content.Load<Texture, JPGImporter>(fi.Name, fi.DirectoryName);
                        break;

                    case ".png":
                        t = SceneManager.Current.Content.Load<Texture, PNGImporter>(fi.Name, fi.DirectoryName);
                        break;

                    case ".tif":
                        t = SceneManager.Current.Content.Load<Texture, TIFImporter>(fi.Name, fi.DirectoryName);
                        break;

                    case ".tga":
                        t = SceneManager.Current.Content.Load<Texture, TGAImporter>(fi.Name, fi.DirectoryName);
                        break;

                    case ".tdx":
                        t = SceneManager.Current.Content.Load<Texture, TDXImporter>(fi.Name, fi.DirectoryName);
                        break;
                }

                if (t != null)
                {
                    var b = t.GetBitmap();

                    pbPreview.Image = t.GetThumbnail(1024, false);
                    lblFile.Text = string.Format(lblFile.Tag.ToString(), fi.Name);
                    lblWidth.Text = string.Format(lblWidth.Tag.ToString(), b.Width);
                    lblHeight.Text = string.Format(lblHeight.Tag.ToString(), b.Height);
                    lblFileSize.Text = string.Format(lblFileSize.Tag.ToString(), fi.Length);
                }
            }
        }
Esempio n. 2
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            ofdBrowse.Filter = "All supported files|*.jpg;*.png;*.tif;*.tga;*.bmp;*.tdx|JPG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIF (*.tif)|*.tif|TGA (*.tga)|*.tga|BMP (*.bmp)|*.bmp|TDX (*.tdx)|*.tdx";

            if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName))
            {
                var fi = new FileInfo(ofdBrowse.FileName);

                switch (fi.Extension.ToLower())
                {
                case ".bmp":
                    t = SceneManager.Current.Content.Load <Texture, BMPImporter>(fi.Name, fi.DirectoryName);
                    break;

                case ".jpg":
                    t = SceneManager.Current.Content.Load <Texture, JPGImporter>(fi.Name, fi.DirectoryName);
                    break;

                case ".png":
                    t = SceneManager.Current.Content.Load <Texture, PNGImporter>(fi.Name, fi.DirectoryName);
                    break;

                case ".tif":
                    t = SceneManager.Current.Content.Load <Texture, TIFImporter>(fi.Name, fi.DirectoryName);
                    break;

                case ".tga":
                    t = SceneManager.Current.Content.Load <Texture, TGAImporter>(fi.Name, fi.DirectoryName);
                    break;

                case ".tdx":
                    t = SceneManager.Current.Content.Load <Texture, TDXImporter>(fi.Name, fi.DirectoryName);
                    break;
                }

                if (t != null)
                {
                    var b = t.GetBitmap();

                    pbPreview.Image  = t.GetThumbnail(1024, false);
                    lblFile.Text     = string.Format(lblFile.Tag.ToString(), fi.Name);
                    lblWidth.Text    = string.Format(lblWidth.Tag.ToString(), b.Width);
                    lblHeight.Text   = string.Format(lblHeight.Tag.ToString(), b.Height);
                    lblFileSize.Text = string.Format(lblFileSize.Tag.ToString(), fi.Length);
                }
            }
        }
Esempio n. 3
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            ofdBrowse.Filter = "All supported files|*.jpg;*.png;*.tif;*.tga;*.bmp;*.tdx|JPG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIF (*.tif)|*.tif|TGA (*.tga)|*.tga|BMP (*.bmp)|*.bmp|TDX (*.tdx)|*.tdx";

            if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName))
            {
                FileInfo fi = new FileInfo(ofdBrowse.FileName);

                if ((t = SceneManager.Current.Content.Load(fi.Name, fi.DirectoryName)) != null)
                {
                    System.Drawing.Bitmap b = t.GetBitmap();

                    pbPreview.Image  = t.GetThumbnail(1024, false);
                    lblFile.Text     = string.Format(lblFile.Tag.ToString(), fi.Name);
                    lblWidth.Text    = string.Format(lblWidth.Tag.ToString(), b.Width);
                    lblHeight.Text   = string.Format(lblHeight.Tag.ToString(), b.Height);
                    lblFileSize.Text = string.Format(lblFileSize.Tag.ToString(), fi.Length);
                }
            }
        }