2025-11-20 14:23:05 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
2025-11-20 14:45:46 +08:00
|
|
|
|
namespace WinFormsAppTemplate
|
2025-11-20 11:10:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
|
{
|
|
|
|
|
|
public Form1()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2025-11-20 14:43:07 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置窗体图标
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Icon = new Icon("app.ico");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
// 如果图标文件不存在或格式错误,忽略
|
|
|
|
|
|
}
|
2025-11-20 11:10:53 +08:00
|
|
|
|
}
|
2025-11-20 12:10:18 +08:00
|
|
|
|
|
|
|
|
|
|
private void btnBrowseSource_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
|
|
|
|
|
|
{
|
2025-11-20 14:45:46 +08:00
|
|
|
|
dialog.Description = "选择文件夹";
|
2025-11-20 12:10:18 +08:00
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtSourcePath.Text = dialog.SelectedPath;
|
2025-11-20 14:45:46 +08:00
|
|
|
|
Log($"选择的文件夹: {dialog.SelectedPath}");
|
2025-11-20 12:10:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
{
|
2025-11-20 14:45:46 +08:00
|
|
|
|
MessageBox.Show("这是一个模板项目\n\n功能:\n• 单exe打包\n• 应用图标配置\n• UI按钮图标\n• 环境检测\n\n请在此基础上开发你的具体功能", "模板项目", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
Log("模板功能演示");
|
2025-11-20 12:10:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Log(string msg)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtLog.AppendText($"{msg}\r\n");
|
|
|
|
|
|
txtLog.ScrollToCaret();
|
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
|
}
|
2025-11-20 11:10:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|