Пример #1
0
        private void InjectImageButton_Click(object sender, EventArgs e)
        {
            IMaterial material = (IMaterial)AssetListBox.SelectedItem;

            if (material == null)
            {
                return;
            }

            var file = new OpenFileDialog {
                Filter = "DDS|*.bin;*.dds"
            };

            if (file.ShowDialog() == DialogResult.OK)
            {
                string fileName = file.FileName;
                try {
                    byte[] image = File.ReadAllBytes(file.FileName);

                    DialogResult dialogResult = DialogResult.Yes;
                    if (image.Length > material.Size)
                    {
                        dialogResult = MessageBox.Show("The file you are trying to inject is larger than the buffer.\n\nWould you like to inject anyways?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    }

                    if (dialogResult == DialogResult.Yes)
                    {
                        material.InjectImage(image);
                    }
                }
                catch (Exception) {
                    this.Close();

                    MessageBox.Show("Unable to inject your image", "Injection Error!");
                }
            }
        }