From 954e5643186eebcdc76b793d90e634ed2d0bb521 Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 20 Nov 2025 14:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A8=8B=E5=BA=8F=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E5=92=8CUI=E5=9B=BE=E6=A0=87=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 程序窗体显示app.ico图标 2. 两个浏览按钮使用app.ico图标显示 3. 添加错误处理,图标加载失败时回退到文字显示 4. 优化编译输出,减少终端窗口显示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- WinFormsApp1/Form1.Designer.cs | 26 ++++++++++++++++++++++++-- WinFormsApp1/Form1.cs | 10 ++++++++++ WinFormsApp1/WinFormsApp1.csproj | 4 ++++ 3 files changed, 38 insertions(+), 2 deletions(-) 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