using System; using System.Drawing; using System.Windows.Forms; namespace WinFormsAppTemplate { public partial class Form1 : Form { public Form1() { InitializeComponent(); // 设置窗体图标 - 使用嵌入资源 try { var stream = GetType().Assembly.GetManifestResourceStream("WinFormsAppTemplate.app.ico"); if (stream != null) { this.Icon = new Icon(stream); } } catch { // 如果图标加载失败,使用默认图标 // this.Icon = SystemIcons.Application; } } private void btnBrowseSource_Click(object sender, EventArgs e) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "选择文件夹"; if (dialog.ShowDialog() == DialogResult.OK) { txtSourcePath.Text = dialog.SelectedPath; Log($"选择的文件夹: {dialog.SelectedPath}"); } } } private void btnBrowseOutput_Click(object sender, EventArgs e) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "选择输出文件夹"; if (dialog.ShowDialog() == DialogResult.OK) { txtOutputPath.Text = dialog.SelectedPath; Log($"输出文件夹: {dialog.SelectedPath}"); } } } private void btnClear_Click(object sender, EventArgs e) { txtSourcePath.Clear(); txtOutputPath.Clear(); txtLog.Clear(); progressBar.Value = 0; } private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void btnMerge_Click(object sender, EventArgs e) { MessageBox.Show("HelloWorld", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Log("HelloWorld"); } private void Log(string msg) { txtLog.AppendText($"{msg}\r\n"); txtLog.ScrollToCaret(); Application.DoEvents(); } } }