Skip to content

Commit

Permalink
Add new icon for active status
Browse files Browse the repository at this point in the history
  • Loading branch information
ailelix committed Nov 22, 2024
1 parent 190387e commit 6bb622c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
3 changes: 2 additions & 1 deletion MainPage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Diagnostics;
using System.Security.Principal;
using System.Collections;

namespace SingSelector
{
Expand Down Expand Up @@ -150,6 +149,7 @@ private void TurnOn_SingBox()
// 所有需要变化文字的按钮
this.Button_Switch.Text = "停止";
this.TrayMenu_Switch.Text = "停止";
this.TrayIcon.Icon = Properties.Resources.Icon_SingBox_Active;

this.RichTextBox_Log.Clear();
this.RichTextBox_Log.AppendText("启动: " + this.ComboBox_Selector.SelectedItem + "\n");
Expand All @@ -166,6 +166,7 @@ private void TurnOff_SingBox()

this.Button_Switch.Text = "启动";
this.TrayMenu_Switch.Text = "启动";
this.TrayIcon.Icon = Properties.Resources.Icon_SingBox;
}

// 刷新配置文件列表
Expand Down
8 changes: 6 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ internal static class Program
[STAThread]
static void Main()
{
// 这么做并不严谨,但Good Enough To Me
using Mutex mutex = new(true, Process.GetCurrentProcess().ProcessName, out bool createdNew);
if (createdNew)
if (createdNew) // 成功创建了互斥体,即没有已经运行的进程
{
// 成功创建了互斥体,即没有已经运行的进程
Application.EnableVisualStyles();
ApplicationConfiguration.Initialize();
Application.Run(new MainPage());
}
else
{
MessageBox.Show("请勿重复运行");
}
}
}
}
20 changes: 20 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@
<data name="Icon_UpdateProfiles" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon-UpdateProfiles.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Icon-SingBox-Active" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon-SingBox-Active.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Icon-SingBox" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon-SingBox.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added Resources/Icon-SingBox-Active.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion SingSelector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>True</UseWPF>
<ApplicationIcon>Resources\Icon-SingBox.ico</ApplicationIcon>
<Platforms>AnyCPU;x64;x86;ARM64</Platforms>
<PlatformTarget>AnyCPU</PlatformTarget>
<ApplicationIcon>Resources\Icon-SingBox.ico</ApplicationIcon>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions SingSelector.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12074087-8FEC-4BFA-A7C2-057E4BC8B1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12074087-8FEC-4BFA-A7C2-057E4BC8B1D4}.Release|Any CPU.Build.0 = Release|Any CPU
{12074087-8FEC-4BFA-A7C2-057E4BC8B1D4}.Release|Any CPU.ActiveCfg = Release|x64
{12074087-8FEC-4BFA-A7C2-057E4BC8B1D4}.Release|Any CPU.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 6bb622c

Please sign in to comment.