添加项目文件。
This commit is contained in:
parent
1590ad8da6
commit
3f38a8c323
174
Form1.Designer.cs
generated
Normal file
174
Form1.Designer.cs
generated
Normal file
@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SlideCombine
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
81
Form1.cs
Normal file
81
Form1.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Form1.resx
Normal file
120
Form1.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
60
Program.cs
Normal file
60
Program.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace SlideCombine
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
SlideCombine.csproj
Normal file
44
SlideCombine.csproj
Normal file
@ -0,0 +1,44 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AssemblyName>SlideCombine</AssemblyName>
|
||||
<RootNamespace>SlideCombine</RootNamespace>
|
||||
<ApplicationIcon>app.ico</ApplicationIcon>
|
||||
<Win32Resource />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="app.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- 用于单文件发布的配置 -->
|
||||
<PropertyGroup>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<SelfContained>false</SelfContained>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
<!-- 强制将所有依赖项合并到输出目录 -->
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- 模板项目不需要外部依赖 -->
|
||||
<!-- 如需合并第三方DLL,可在此添加PackageReference -->
|
||||
<!-- 示例:
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ILRepack" Version="2.0.18" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="ILRepack" AfterTargets="Build">
|
||||
<ItemGroup>
|
||||
<InputAssemblies Include="$(OutputPath)$(AssemblyName).exe" />
|
||||
<InputAssemblies Include="$(OutputPath)YourLibrary.dll" />
|
||||
</ItemGroup>
|
||||
<Message Text="ILRepack merging..." Importance="high" />
|
||||
<Exec Command="$(PkgILRepack)\tools\ILRepack.exe /target:exe /out:$(OutputPath)$(AssemblyName)_merged.exe @(InputAssemblies->'%(FullPath)', ' ')" />
|
||||
<Message Text="ILRepack merge complete: $(OutputPath)$(AssemblyName)_merged.exe" Importance="high" />
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
||||
3
SlideCombine.slnx
Normal file
3
SlideCombine.slnx
Normal file
@ -0,0 +1,3 @@
|
||||
<Solution>
|
||||
<Project Path="SlideCombine.csproj" />
|
||||
</Solution>
|
||||
Loading…
x
Reference in New Issue
Block a user