Esempio n. 1
0
        private void BtnImportDDS_Click(object sender, EventArgs e)
        {
            if (LstTextures.SelectedIndex > -1)
            {
                using (OpenFileDialog OpenDlg = new OpenFileDialog())
                {
                    OpenDlg.Filter = "DDS texture|*.dds";

                    if (OpenDlg.ShowDialog() == DialogResult.OK && File.Exists(OpenDlg.FileName))
                    {
                        DDSContent DDSTexture = DDS.Import(OpenDlg.FileName);
                        IDDTexture Texture    = CurrentFile.Textures[LstTextures.SelectedIndex];

                        if (DDSTexture.Resolution != Texture.Resolution)
                        {
                            MessageBox.Show(
                                "The texture can't be imported because the size is different!",
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);

                            return;
                        }

                        if (DDSTexture.Format != Texture.Format)
                        {
                            MessageBox.Show(
                                string.Format("The texture can't be imported because the format is different! (Expected {0})", Texture.Format),
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);

                            return;
                        }

                        Texture.TextureData = DDSTexture.TextureData;
                        CurrentFile.Textures.RemoveAt(LstTextures.SelectedIndex);
                        CurrentFile.Textures.Insert(LstTextures.SelectedIndex, Texture);
                        DisplayTexture(Texture);
                    }
                }
            }
        }