Exemple #1
0
        private void openFileFor(string context, string filename)
        {
            Texture texture = SceneManager.Current.Content.Load(Path.GetFileName(filename), Path.GetDirectoryName(filename));

            Controls.Find($"lbl{context}Path", true)[0].Text = Path.GetFileName(filename);
            (Controls.Find($"pb{context}Preview", true)[0] as PictureBox).Image = texture.GetThumbnail(1024, false);
        }
        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);
                }
            }
        }
Exemple #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))
            {
                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);
                }
            }
        }
Exemple #4
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);
                }
            }
        }
Exemple #5
0
 private void SetTexture(Texture t)
 {
     txtTexture.Text = t.Name;
     pbPreview.Image = t.GetThumbnail();
     mi.SetThumbnail((Bitmap)pbPreview.Image);
 }
 private void SetTexture(Texture t)
 {
     txtTexture.Text = t.Name;
     pbPreview.Image = t.GetThumbnail();
     mi.SetThumbnail((Bitmap)pbPreview.Image);
 }