diff --git a/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/Form1.Designer.cs index 921e331..0ddc6d7 100644 --- a/WinFormsApp1/Form1.Designer.cs +++ b/WinFormsApp1/Form1.Designer.cs @@ -73,10 +73,21 @@ namespace WinFormsApp1 txtSourcePath.Location = new Point(45, 22); txtSourcePath.Size = new Size(470, 23); - btnBrowseSource.Text = "浏览"; + btnBrowseSource.Text = ""; btnBrowseSource.Location = new Point(520, 20); btnBrowseSource.Size = new Size(50, 25); btnBrowseSource.Click += new EventHandler(btnBrowseSource_Click); + // 设置浏览按钮图标 + try + { + btnBrowseSource.Image = Image.FromFile("app.ico"); + btnBrowseSource.ImageAlign = ContentAlignment.MiddleCenter; + } + catch + { + // 如果图标加载失败,显示文字 + btnBrowseSource.Text = "浏览"; + } grpSourceFolder.Controls.Add(lblSourcePath); grpSourceFolder.Controls.Add(txtSourcePath); @@ -95,10 +106,21 @@ namespace WinFormsApp1 txtOutputPath.Location = new Point(45, 22); txtOutputPath.Size = new Size(470, 23); - btnBrowseOutput.Text = "浏览"; + btnBrowseOutput.Text = ""; btnBrowseOutput.Location = new Point(520, 20); btnBrowseOutput.Size = new Size(50, 25); btnBrowseOutput.Click += new EventHandler(btnBrowseOutput_Click); + // 设置浏览按钮图标 + try + { + btnBrowseOutput.Image = Image.FromFile("app.ico"); + btnBrowseOutput.ImageAlign = ContentAlignment.MiddleCenter; + } + catch + { + // 如果图标加载失败,显示文字 + btnBrowseOutput.Text = "浏览"; + } grpOutputFolder.Controls.Add(lblOutputPath); grpOutputFolder.Controls.Add(txtOutputPath); diff --git a/WinFormsApp1/Form1.cs b/WinFormsApp1/Form1.cs index 7a5a74f..dfe0291 100644 --- a/WinFormsApp1/Form1.cs +++ b/WinFormsApp1/Form1.cs @@ -12,6 +12,16 @@ namespace WinFormsApp1 public Form1() { InitializeComponent(); + + // 设置窗体图标 + try + { + this.Icon = new Icon("app.ico"); + } + catch + { + // 如果图标文件不存在或格式错误,忽略 + } } private void btnBrowseSource_Click(object sender, EventArgs e) diff --git a/WinFormsApp1/WinFormsApp1.csproj b/WinFormsApp1/WinFormsApp1.csproj index c762826..4e4bbbb 100644 --- a/WinFormsApp1/WinFormsApp1.csproj +++ b/WinFormsApp1/WinFormsApp1.csproj @@ -32,4 +32,8 @@ + + + + \ No newline at end of file