diff --git a/UnamBinder/Forms/Builder.cs b/UnamBinder/Forms/Builder.cs index f9921c1..7295e7f 100644 --- a/UnamBinder/Forms/Builder.cs +++ b/UnamBinder/Forms/Builder.cs @@ -494,6 +494,10 @@ private void btnBuild_Click(object sender, EventArgs e) ManagedCompiler(save); } } + if (Directory.Exists(Environment.CurrentDirectory + @"\TempIcon\")) + { + Directory.Delete(Environment.CurrentDirectory + @"\TempIcon\", true); + } } private void btnVanity_Click(object sender, EventArgs e) diff --git a/UnamBinder/Forms/Vanity.Designer.cs b/UnamBinder/Forms/Vanity.Designer.cs index 8a5075b..43a5722 100644 --- a/UnamBinder/Forms/Vanity.Designer.cs +++ b/UnamBinder/Forms/Vanity.Designer.cs @@ -47,6 +47,7 @@ private void InitializeComponent() this.txtAssemblyCompany = new MephTextBox(); this.txtAssemblyDescription = new MephTextBox(); this.txtAssemblyTitle = new MephTextBox(); + this.btnIconClone = new MephButton(); this.mephTheme1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.imageIcon)).BeginInit(); this.SuspendLayout(); @@ -56,6 +57,7 @@ private void InitializeComponent() this.mephTheme1.AccentColor = System.Drawing.Color.Indigo; this.mephTheme1.Anchor = System.Windows.Forms.AnchorStyles.None; this.mephTheme1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28))))); + this.mephTheme1.Controls.Add(this.btnIconClone); this.mephTheme1.Controls.Add(this.chkAssembly); this.mephTheme1.Controls.Add(this.chkIcon); this.mephTheme1.Controls.Add(this.imageIcon); @@ -331,6 +333,18 @@ private void InitializeComponent() this.txtAssemblyTitle.UseSystemPasswordChar = false; this.txtAssemblyTitle.WordWrap = false; // + // btnIconClone + // + this.btnIconClone.BackColor = System.Drawing.Color.Transparent; + this.btnIconClone.Enabled = false; + this.btnIconClone.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); + this.btnIconClone.Location = new System.Drawing.Point(392, 71); + this.btnIconClone.Name = "btnIconClone"; + this.btnIconClone.Size = new System.Drawing.Size(135, 23); + this.btnIconClone.TabIndex = 22; + this.btnIconClone.Text = "Clone File"; + this.btnIconClone.Click += new System.EventHandler(this.btnIconClone_Click); + // // Vanity // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -375,5 +389,6 @@ private void InitializeComponent() public MephTextBox txtAssemblyDescription; public MephTextBox txtAssemblyTitle; public System.Windows.Forms.PictureBox imageIcon; + private MephButton btnIconClone; } } \ No newline at end of file diff --git a/UnamBinder/Forms/Vanity.cs b/UnamBinder/Forms/Vanity.cs index 9982b48..fe779e4 100644 --- a/UnamBinder/Forms/Vanity.cs +++ b/UnamBinder/Forms/Vanity.cs @@ -2,6 +2,8 @@ using System.Diagnostics; using System.IO; using System.Windows.Forms; +using TsudaKageyu; +using System.Drawing; namespace UnamBinder { @@ -36,6 +38,7 @@ private void checkAssembly_CheckedChanged(object sender) private void checkIcon_CheckedChanged(object sender) { btnIconBrowse.Enabled = chkIcon.Checked; + btnIconClone.Enabled = chkIcon.Checked; txtIconPath.Enabled = chkIcon.Checked; } @@ -77,5 +80,30 @@ private void btnIconBrowse_Click(object sender, EventArgs e) imageIcon.ImageLocation = dialog.FileName; } } + private void btnIconClone_Click(object sender, EventArgs e) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Filter = "Executable Files (*.exe) |*.exe|Dynamic Link Library Files (*.dll)|*.dll"; + if (dialog.ShowDialog() == DialogResult.OK) + { + IconExtractor ie = new IconExtractor(dialog.FileName); + string savePath = Environment.CurrentDirectory + @"\TempIcon\icon.ico"; + Directory.CreateDirectory(Environment.CurrentDirectory + @"\TempIcon\"); + try + { + Icon icon1 = ie.GetIcon(0); + using (FileStream stream = new FileStream(savePath, FileMode.Create)) + { + icon1.Save(stream); + txtIconPath.Text = savePath; + imageIcon.ImageLocation = savePath; + } + } + catch + { + MessageBox.Show("The icon is invalid. Try a different one!", "Invalid icon"); + } + } + } } } diff --git a/UnamBinder/Resources/IconExtractor/IconExtractor.dll b/UnamBinder/Resources/IconExtractor/IconExtractor.dll new file mode 100644 index 0000000..9c0d7d9 Binary files /dev/null and b/UnamBinder/Resources/IconExtractor/IconExtractor.dll differ diff --git a/UnamBinder/UnamBinder.csproj b/UnamBinder/UnamBinder.csproj index dab7084..c8a2c93 100644 --- a/UnamBinder/UnamBinder.csproj +++ b/UnamBinder/UnamBinder.csproj @@ -54,6 +54,10 @@ unam.ico + + False + Resources\IconExtractor\IconExtractor.dll +