diff --git a/.gitignore b/.gitignore
index 9491a2f..34c856c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -360,4 +360,6 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+Output
diff --git a/MainWindow.xaml b/MainWindow.xaml
index b5f7b8d..74d4d66 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Topuino_Client_Windows"
mc:Ignorable="d"
+ Closing="Window_Closing"
Title="Topuino 客户端" Height="150" Width="400">
@@ -26,7 +27,7 @@
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 67ab850..83cd4f7 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -6,6 +6,8 @@ using System.IO;
using System.Net.NetworkInformation;
using System.Collections.Generic;
using System.Windows.Input;
+using System.Drawing;
+using System.Windows.Forms;
using Newtonsoft.Json;
namespace Topuino_Client_Windows
@@ -36,6 +38,8 @@ namespace Topuino_Client_Windows
if (File.Exists("Config.json"))
{
+ ShowInTaskbar = true;
+ Visibility = Visibility.Hidden;
LoadConfig();
}
else
@@ -43,8 +47,15 @@ namespace Topuino_Client_Windows
ComboBox_Disk0.SelectedIndex = 0;
ComboBox_Disk1.SelectedIndex = 0;
}
+
+ trayIon.Icon = new Icon(@"Topuino.ico");
+ trayIon.Visible = true;
+ trayIon.Text = "Topuino";
+ trayIon.DoubleClick += TrayIcon_DoubleClick;
}
+ private NotifyIcon trayIon = new NotifyIcon();
+
private string sn = "";
private List allDrives;
private DriveInfo? drive0 = null;
@@ -159,8 +170,8 @@ namespace Topuino_Client_Windows
public void ShowErrorBox(string msg)
{
- MessageBox.Show(
- Application.Current.MainWindow,
+ System.Windows.MessageBox.Show(
+ System.Windows.Application.Current.MainWindow,
msg,
"错误",
MessageBoxButton.OK,
@@ -177,7 +188,7 @@ namespace Topuino_Client_Windows
private void StartRun()
{
- Mouse.OverrideCursor = Cursors.Wait;
+ Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
if (refreshThread != null)
{
requestStop.Set();
@@ -218,5 +229,24 @@ namespace Topuino_Client_Windows
SaveConfig();
StartRun();
}
+
+ private void TrayIcon_DoubleClick(object? sender, EventArgs e)
+ {
+ Visibility = Visibility.Visible;
+ }
+
+ private void Button_Hide_Click(object sender, RoutedEventArgs e)
+ {
+ Visibility = Visibility.Hidden;
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if (refreshThread != null)
+ {
+ requestStop.Set();
+ stopDone.WaitOne();
+ }
+ }
}
}
diff --git a/Topuino.ico b/Topuino.ico
new file mode 100644
index 0000000..00f9060
Binary files /dev/null and b/Topuino.ico differ
diff --git a/Topuino_Client_Windows.csproj b/Topuino_Client_Windows.csproj
index f41d130..d10e8fa 100644
--- a/Topuino_Client_Windows.csproj
+++ b/Topuino_Client_Windows.csproj
@@ -5,10 +5,15 @@
net6.0-windows
enable
true
+ true
+
+
+
+
diff --git a/pack.iss b/pack.iss
new file mode 100644
index 0000000..f3f1771
--- /dev/null
+++ b/pack.iss
@@ -0,0 +1,49 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "TopuinoClient"
+#define MyAppVersion "0.1"
+#define MyAppPublisher "VVZERO"
+#define MyAppURL "https://iot.vvzero.com"
+#define MyAppExeName "Topuino_Client_Windows.exe"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{775354B5-2CB5-4689-B28C-534A1848B810}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+DefaultDirName={autopf}\{#MyAppName}
+DisableDirPage=yes
+DisableProgramGroupPage=yes
+; Remove the following line to run in administrative install mode (install for all users.)
+PrivilegesRequired=lowest
+OutputDir=Output
+OutputBaseFilename=Topuino_Client
+SetupIconFile=Topuino.ico
+Compression=lzma
+SolidCompression=yes
+WizardStyle=modern
+
+[Languages]
+Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "bin\Release\net6.0-windows\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Icons]
+Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+