diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..6be42b3 --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,174 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace SlideCombine +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + + // 主窗体设置 + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(600, 400); + Text = "WinForms应用模板"; + StartPosition = FormStartPosition.CenterScreen; + + // 创建控件 + grpSourceFolder = new GroupBox(); + lblSourcePath = new Label(); + txtSourcePath = new TextBox(); + btnBrowseSource = new Button(); + + grpOutputFolder = new GroupBox(); + lblOutputPath = new Label(); + txtOutputPath = new TextBox(); + btnBrowseOutput = new Button(); + + pnlButtons = new Panel(); + btnMerge = new Button(); + btnClear = new Button(); + btnExit = new Button(); + + grpProgress = new GroupBox(); + progressBar = new ProgressBar(); + txtLog = new TextBox(); + + // 设置源文件夹组 + grpSourceFolder.Text = "输入文件夹"; + grpSourceFolder.Location = new Point(10, 10); + grpSourceFolder.Size = new Size(580, 60); + grpSourceFolder.TabStop = false; + + lblSourcePath.Text = "路径:"; + lblSourcePath.Location = new Point(10, 25); + lblSourcePath.Size = new Size(30, 23); + + txtSourcePath.Location = new Point(45, 22); + txtSourcePath.Size = new Size(470, 23); + + btnBrowseSource.Text = "浏览"; + btnBrowseSource.Location = new Point(520, 20); + btnBrowseSource.Size = new Size(50, 25); + btnBrowseSource.Click += new EventHandler(btnBrowseSource_Click); + + grpSourceFolder.Controls.Add(lblSourcePath); + grpSourceFolder.Controls.Add(txtSourcePath); + grpSourceFolder.Controls.Add(btnBrowseSource); + + // 设置输出文件夹组 + grpOutputFolder.Text = "输出文件夹"; + grpOutputFolder.Location = new Point(10, 80); + grpOutputFolder.Size = new Size(580, 60); + grpOutputFolder.TabStop = false; + + lblOutputPath.Text = "路径:"; + lblOutputPath.Location = new Point(10, 25); + lblOutputPath.Size = new Size(30, 23); + + txtOutputPath.Location = new Point(45, 22); + txtOutputPath.Size = new Size(470, 23); + + btnBrowseOutput.Text = "浏览"; + btnBrowseOutput.Location = new Point(520, 20); + btnBrowseOutput.Size = new Size(50, 25); + btnBrowseOutput.Click += new EventHandler(btnBrowseOutput_Click); + + grpOutputFolder.Controls.Add(lblOutputPath); + grpOutputFolder.Controls.Add(txtOutputPath); + grpOutputFolder.Controls.Add(btnBrowseOutput); + + // 设置按钮面板 + pnlButtons.Location = new Point(10, 150); + pnlButtons.Size = new Size(580, 40); + + btnMerge.Text = "执行"; + btnMerge.Location = new Point(10, 8); + btnMerge.Size = new Size(75, 25); + btnMerge.Click += new EventHandler(btnMerge_Click); + + btnClear.Text = "清空"; + btnClear.Location = new Point(100, 8); + btnClear.Size = new Size(75, 25); + btnClear.Click += new EventHandler(btnClear_Click); + + btnExit.Text = "退出"; + btnExit.Location = new Point(190, 8); + btnExit.Size = new Size(75, 25); + btnExit.Click += new EventHandler(btnExit_Click); + + pnlButtons.Controls.Add(btnMerge); + pnlButtons.Controls.Add(btnClear); + pnlButtons.Controls.Add(btnExit); + + // 设置进度组 + grpProgress.Text = "进度"; + grpProgress.Location = new Point(10, 200); + grpProgress.Size = new Size(580, 180); + grpProgress.TabStop = false; + + progressBar.Location = new Point(10, 25); + progressBar.Size = new Size(560, 23); + progressBar.Style = ProgressBarStyle.Continuous; + + txtLog.Location = new Point(10, 55); + txtLog.Size = new Size(560, 115); + txtLog.Multiline = true; + txtLog.ScrollBars = ScrollBars.Vertical; + txtLog.ReadOnly = true; + + grpProgress.Controls.Add(progressBar); + grpProgress.Controls.Add(txtLog); + + // 添加所有控件到窗体 + Controls.Add(grpSourceFolder); + Controls.Add(grpOutputFolder); + Controls.Add(pnlButtons); + Controls.Add(grpProgress); + } + + #endregion + + private GroupBox grpSourceFolder; + private Label lblSourcePath; + private TextBox txtSourcePath; + private Button btnBrowseSource; + private GroupBox grpOutputFolder; + private Label lblOutputPath; + private TextBox txtOutputPath; + private Button btnBrowseOutput; + private Panel pnlButtons; + private Button btnMerge; + private Button btnClear; + private Button btnExit; + private GroupBox grpProgress; + private ProgressBar progressBar; + private TextBox txtLog; + } +} diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..dc6a8ba --- /dev/null +++ b/Form1.cs @@ -0,0 +1,81 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace SlideCombine +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + + // 设置窗体图标 - 使用嵌入资源 + try + { + var stream = GetType().Assembly.GetManifestResourceStream("SlideCombine.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(); + } + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..915ed6c --- /dev/null +++ b/Program.cs @@ -0,0 +1,60 @@ +using System; +using System.Windows.Forms; +using Microsoft.Win32; + +namespace SlideCombine +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // 检查.NET Framework 4.8是否已安装 + if (!CheckDotNetFramework48()) + { + MessageBox.Show( + "检测到您的系统未安装 .NET Framework 4.8\n\n" + + "Excel合并工具需要此环境才能运行。\n\n" + + "请前往以下链接下载并安装:\n" + + "https://dotnet.microsoft.com/download/dotnet-framework/net48\n\n" + + "安装完成后请重新运行本程序。", + "缺少运行环境", + MessageBoxButtons.OK, + MessageBoxIcon.Error + ); + return; + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + + private static bool CheckDotNetFramework48() + { + try + { + using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\")) + { + if (key != null) + { + object release = key.GetValue("Release"); + if (release != null && int.TryParse(release.ToString(), out int releaseValue)) + { + // .NET Framework 4.8 的 Release 值为 528040 或更高 + return releaseValue >= 528040; + } + } + } + } + catch + { + // 如果无法访问注册表,假设未安装 + } + return false; + } + } +} \ No newline at end of file diff --git a/SlideCombine.csproj b/SlideCombine.csproj new file mode 100644 index 0000000..a9716a1 --- /dev/null +++ b/SlideCombine.csproj @@ -0,0 +1,44 @@ + + + + WinExe + net48 + true + SlideCombine + SlideCombine + app.ico + + + + + + + + + + false + false + true + + true + + + + + + + \ No newline at end of file diff --git a/SlideCombine.slnx b/SlideCombine.slnx new file mode 100644 index 0000000..09655da --- /dev/null +++ b/SlideCombine.slnx @@ -0,0 +1,3 @@ + + + diff --git a/app.ico b/app.ico new file mode 100644 index 0000000..b95e081 Binary files /dev/null and b/app.ico differ