From 43027d7953020e855c5d97735b514052828cb309 Mon Sep 17 00:00:00 2001 From: zsyg <3872006562@qq.com> Date: Mon, 7 Jul 2025 18:07:29 +0800 Subject: [PATCH] Add files via upload --- AboutForm.cs | 2 +- MainForm.cs | 39 +++++++++++++++++++++++++++++++++++++++ inno/innosetup_x64.iss | 2 +- inno/innosetup_x86.iss | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/AboutForm.cs b/AboutForm.cs index c161ceb..bb9b17e 100644 --- a/AboutForm.cs +++ b/AboutForm.cs @@ -51,7 +51,7 @@ namespace AppStore // 初始化并添加应用信息 infoLabel = new Label(); - infoLabel.Text = "kortapp-z\n版本: 1.2.6\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件"; + infoLabel.Text = "kortapp-z\n版本: 1.2.7\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件"; infoLabel.Font = new Font("Microsoft YaHei", 12); infoLabel.AutoSize = false; infoLabel.Width = 300; diff --git a/MainForm.cs b/MainForm.cs index f70e7d6..52d9eb5 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -126,6 +126,10 @@ namespace AppStore private Button btnAbout = null!; // 内容显示面板 private Panel contentPanel = null!; + // 系统托盘图标 + private NotifyIcon trayIcon = null!; + // 托盘右键菜单 + private ContextMenuStrip trayMenu = null!; /// /// 初始化窗体组件 @@ -140,6 +144,41 @@ namespace AppStore this.StartPosition = FormStartPosition.CenterScreen; this.Icon = new Icon("img/ico/icon.ico"); // 设置窗体图标 + // 初始化系统托盘 + trayMenu = new ContextMenuStrip(); + trayMenu.Items.Add("打开", null, (s, e) => { + this.Show(); + this.WindowState = FormWindowState.Normal; + }); + trayMenu.Items.Add("退出", null, (s, e) => Application.Exit()); + + trayIcon = new NotifyIcon(); + trayIcon.Text = "kortapp-z"; + trayIcon.Icon = new Icon("img/ico/icon.ico"); + trayIcon.ContextMenuStrip = trayMenu; + trayIcon.Visible = true; + trayIcon.DoubleClick += (s, e) => { + this.Show(); + this.WindowState = FormWindowState.Normal; + }; + + // 窗体最小化到托盘处理 + this.Resize += (s, e) => { + if (this.WindowState == FormWindowState.Minimized) + { + this.Hide(); + } + }; + + // 窗体关闭按钮处理 - 隐藏到托盘而不是退出 + this.FormClosing += (s, e) => { + if (e.CloseReason == CloseReason.UserClosing) + { + e.Cancel = true; + this.Hide(); + } + }; + // 注册主题变更事件 ThemeManager.ThemeChanged += (theme) => { diff --git a/inno/innosetup_x64.iss b/inno/innosetup_x64.iss index a29b720..1feb4b1 100644 --- a/inno/innosetup_x64.iss +++ b/inno/innosetup_x64.iss @@ -2,7 +2,7 @@ ; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档! #define MyAppName "kortapp-z" -#define MyAppVersion "1.2.6" +#define MyAppVersion "1.2.7" #define MyAppPublisher "zsyg" #define MyAppURL "https://github.com/zs-yg/kortapp-z" #define MyAppExeName "kortapp-z.exe" diff --git a/inno/innosetup_x86.iss b/inno/innosetup_x86.iss index c2c2a8a..5ac1825 100644 --- a/inno/innosetup_x86.iss +++ b/inno/innosetup_x86.iss @@ -2,7 +2,7 @@ ; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档! #define MyAppName "kortapp-z" -#define MyAppVersion "1.2.6" +#define MyAppVersion "1.2.7" #define MyAppPublisher "zsyg" #define MyAppURL "https://github.com/zs-yg/kortapp-z" #define MyAppExeName "kortapp-z.exe"