feat: 增强便携版支持与配置管理
- 更新 .gitignore 文件,添加便携版分发目录和 Fody 生成的配置文件。 - 修改 README.md,详细说明便携版的构建与分发流程,强调单文件分发的优势。 - 在 Config.cs 中实现便携配置管理,优先使用 exe 同目录的 config.json,提升用户体验。 - 更新 ExcelService.cs,优化默认模板的导出逻辑,支持现场替换模板文件。 - 在 MainForm.cs 中加载应用图标,提升界面一致性。 - 调整 Program.cs,确保在单文件分发时正确加载 native DLL。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TfsExcelImporter
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用图标。exe 的 Win32 图标资源由 csproj 的 ApplicationIcon 提供,
|
||||
/// 这里负责窗口标题栏/任务栏用的 Form.Icon:从内嵌的 app.ico(9 个尺寸帧)
|
||||
/// 直接构造,系统按 DPI 取 16/32/48;取不到再退回提取 exe 自身图标。
|
||||
/// </summary>
|
||||
internal static class AppIcon
|
||||
{
|
||||
private static Icon _cached;
|
||||
private static bool _tried;
|
||||
|
||||
public static Icon Load()
|
||||
{
|
||||
if (_tried) return _cached;
|
||||
_tried = true;
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream s = Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream("app.ico"))
|
||||
{
|
||||
if (s != null) _cached = new Icon(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 内嵌 ICO 解析失败(例如只认 BMP 帧的极端情况):忽略,走下面的兜底
|
||||
_cached = null;
|
||||
}
|
||||
|
||||
if (_cached == null)
|
||||
{
|
||||
try { _cached = Icon.ExtractAssociatedIcon(Application.ExecutablePath); }
|
||||
catch { }
|
||||
}
|
||||
return _cached;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user