ME3Explorer.Texplorer2.ExtractButton_Click C# (CSharp) Method

ExtractButton_Click() private method

private ExtractButton_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void ExtractButton_Click(object sender, EventArgs e)
        {
            if (MainListView.SelectedIndices.Count != 0 && MainListView.SelectedIndices[0] >= 0)
            {
                ProgBarUpdater.ChangeProgressBar(0, 1);

                // KFreon: Select mip to replace
                List<string> names = new List<string>();
                int index = GetSelectedTexInd();
                TreeTexInfo tex = Tree.GetTex(index);
                Textures.ITexture2D tex2D = tex.Textures[0];


                string savepath = "";
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Title = "Select destination for file. Hash will be appended to filename.";
                    sfd.FileName = tex.TexName + "_" + Textures.Methods.FormatTexmodHashAsString(tex.Hash) + ".dds";
                    sfd.Filter = "DDS Files|*.dds";
                    if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        savepath = sfd.FileName;
                    else
                        return;
                }

                // KFreon: Removed as per #313
                // KFreon: Make sure hash is there
                /*if (!savepath.Contains(Textures.Methods.FormatTexmodHashAsString(tex.Hash)))
                    savepath = Path.Combine(Path.GetDirectoryName(savepath), Path.GetFileNameWithoutExtension(savepath) + "_" + Textures.Methods.FormatTexmodHashAsString(tex.Hash) + Path.GetExtension(savepath));*/

                // KFreon: Save file
                File.WriteAllBytes(savepath, tex2D.extractMaxImage(true));

                StatusUpdater.UpdateText("Image extracted and saved!");
                ProgBarUpdater.ChangeProgressBar(1, 1);
            }
        }
Texplorer2