A:解决托盘图标问题
This commit is contained in:
1 parent
fbdf211e2f
commit
307df36d20
2 files changed
+18
-4
No files matched your search
@@ -48,7 +48,7 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Remove="Assets\Icons\app.ico"/>
|
<None Remove="Assets\Icons\app.ico"/>
|
||||||
<Resource Include="Assets\Icons\app.ico"/>
|
<EmbeddedResource Include="Assets\Icons\app.ico"/>
|
||||||
<Content Include="wwwroot\**\*">
|
<Content Include="wwwroot\**\*">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -250,8 +250,22 @@ public class TrayIconManager : IDisposable
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 尝试多种路径来加载图标
|
// 首先尝试从嵌入资源加载图标
|
||||||
string[] possiblePaths = {
|
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||||
|
var resourceName = "Shell.Assets.Icons.app.ico";
|
||||||
|
|
||||||
|
using (var stream = assembly.GetManifestResourceStream(resourceName))
|
||||||
|
{
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
Log.Info($"成功从资源加载托盘图标: {resourceName}");
|
||||||
|
return new Icon(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果资源加载失败,尝试从文件系统加载
|
||||||
|
string[] possiblePaths =
|
||||||
|
{
|
||||||
"Assets/Icons/app.ico",
|
"Assets/Icons/app.ico",
|
||||||
"./Assets/Icons/app.ico",
|
"./Assets/Icons/app.ico",
|
||||||
"Shell/Assets/Icons/app.ico",
|
"Shell/Assets/Icons/app.ico",
|
||||||
@@ -264,7 +278,7 @@ public class TrayIconManager : IDisposable
|
|||||||
{
|
{
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
Log.Info($"成功加载托盘图标: {path}");
|
Log.Info($"成功从文件系统加载托盘图标: {path}");
|
||||||
return new Icon(path);
|
return new Icon(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user