Skip to content

Commit f4d674d

Browse files
committed
优化支持ico
1 parent 28ef976 commit f4d674d

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ src/OneCode/wwwroot/
1111
/artifacts
1212
/src/OneCode/wwwroot
1313
node_modules
14+
/.vs/OneCode.slnx

src/OneCode.Win/FloatingBallForm.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public TrayAppContext()
2525
{
2626
var menu = new ContextMenuStrip();
2727
statusItem = new ToolStripMenuItem("Status: Stopped") { Enabled = false };
28-
startItem = new ToolStripMenuItem("Start OneCode", null, async (_, __) => await StartAppAsync());
29-
stopItem = new ToolStripMenuItem("Stop OneCode", null, async (_, __) => await StopAppAsync());
30-
openItem = new ToolStripMenuItem("Open OneCode", null, (_, __) => OpenUrl());
31-
exitItem = new ToolStripMenuItem("Exit", null, (_, __) => _ = ShutdownAsync());
28+
startItem = new ToolStripMenuItem("启动OneCode", null, async (_, __) => await StartAppAsync());
29+
stopItem = new ToolStripMenuItem("关闭OneCode", null, async (_, __) => await StopAppAsync());
30+
openItem = new ToolStripMenuItem("打开OneCode", null, (_, __) => OpenUrl());
31+
exitItem = new ToolStripMenuItem("退出", null, (_, __) => _ = ShutdownAsync());
3232

3333
menu.Items.Add(statusItem);
3434
menu.Items.Add(new ToolStripSeparator());
@@ -40,10 +40,11 @@ public TrayAppContext()
4040
menu.Items.Add(exitItem);
4141
menu.Opening += (_, __) => RefreshMenu();
4242

43+
var iconStream = typeof(TrayAppContext).Assembly.GetManifestResourceStream("OneCode.Win.favicon.ico");
4344
trayIcon = new NotifyIcon
4445
{
4546
Text = "OneCode",
46-
Icon = SystemIcons.Application,
47+
Icon = iconStream != null ? new Icon(iconStream) : SystemIcons.Application,
4748
ContextMenuStrip = menu,
4849
Visible = true
4950
};

src/OneCode.Win/OneCode.Win.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ImplicitUsings>enable</ImplicitUsings>
88
<UseWindowsForms>true</UseWindowsForms>
99
<EnableWindowsTargeting>true</EnableWindowsTargeting>
10+
<ApplicationIcon>favicon.ico</ApplicationIcon>
1011
</PropertyGroup>
1112

1213
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
@@ -16,6 +17,10 @@
1617
<DebugSymbols>false</DebugSymbols>
1718
</PropertyGroup>
1819

20+
<ItemGroup>
21+
<EmbeddedResource Include="favicon.ico" />
22+
</ItemGroup>
23+
1924
<ItemGroup>
2025
<ProjectReference Include="..\OneCode\OneCode.csproj" />
2126
</ItemGroup>
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup />
4-
<ItemGroup>
5-
<Compile Update="FloatingBallForm.cs">
6-
<SubType>Form</SubType>
7-
</Compile>
8-
</ItemGroup>
94
</Project>

0 commit comments

Comments
 (0)