From 6dd8819f224b89fd1afed623066b9974144f2a18 Mon Sep 17 00:00:00 2001 From: zsyg <3872006562@qq.com> Date: Wed, 2 Jul 2025 17:59:18 +0800 Subject: [PATCH] Add files via upload --- AboutForm.cs | 2 +- MainForm.cs | 2899 ++++++++++++++++++++-------------------- inno/innosetup_x64.iss | 2 +- inno/innosetup_x86.iss | 2 +- 4 files changed, 1461 insertions(+), 1444 deletions(-) diff --git a/AboutForm.cs b/AboutForm.cs index f694430..c7674f3 100644 --- a/AboutForm.cs +++ b/AboutForm.cs @@ -57,7 +57,7 @@ namespace AppStore // 初始化并添加应用信息 infoLabel = new Label(); - infoLabel.Text = "kortapp-z\n版本: 1.1.3\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件"; + infoLabel.Text = "kortapp-z\n版本: 1.1.4\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 010257f..0d97587 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1,1441 +1,1458 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| -#nullable enable -using System; -using System.Drawing; -using System.Windows.Forms; -using System.IO; -using System.Security.Cryptography; -using System.Text; -using System.Text.Json; -using System.Diagnostics; -using AppStore; - -namespace AppStore -{ - /// - /// 主窗体类,负责应用程序的主界面显示和交互 - /// - public class MainForm : Form - { - private static readonly string CacheDir = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "zsyg", "kortapp-z", ".cache"); - - private class AppPositionCache - { - public string AppName { get; set; } = string.Empty; - public int X { get; set; } - public int Y { get; set; } - public DateTime LastUpdated { get; set; } = DateTime.Now; - } - - private static string GetPositionCacheFilePath(string appName) - { - using var md5 = MD5.Create(); - var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(appName)); - var fileName = BitConverter.ToString(hash).Replace("-", "").ToLower() + ".json"; - return Path.Combine(CacheDir, fileName); - } - - private static void EnsureCacheDirectory() - { - try - { - if (!Directory.Exists(CacheDir)) - { - Directory.CreateDirectory(CacheDir); - Logger.Log($"已创建缓存目录: {CacheDir}"); - } - } - catch (Exception ex) - { - Logger.LogError($"创建缓存目录失败: {CacheDir}", ex); - throw; - } - } - - private static bool TryReadPositionCache(string appName, out AppPositionCache? cacheData) - { - cacheData = null; - var cacheFile = GetPositionCacheFilePath(appName); - - if (!File.Exists(cacheFile)) - return false; - - try - { - var json = File.ReadAllText(cacheFile); - cacheData = JsonSerializer.Deserialize(json); - return cacheData != null; - } - catch - { - return false; - } - } - - private static void WritePositionCache(string appName, Point position) - { - try - { - EnsureCacheDirectory(); - var cacheFile = GetPositionCacheFilePath(appName); - - var cacheData = new AppPositionCache - { - AppName = appName, - X = position.X, - Y = position.Y, - LastUpdated = DateTime.Now - }; - - var json = JsonSerializer.Serialize(cacheData); - File.WriteAllText(cacheFile, json); - Logger.Log($"已保存位置缓存: {appName} ({position.X}, {position.Y})"); - } - catch (Exception ex) - { - Logger.LogError($"保存位置缓存失败: {appName}", ex); - throw; - } - } - - private static bool IsPositionCacheValid(AppPositionCache cacheData) - { - // 缓存有效期设为7天 - return (DateTime.Now - cacheData.LastUpdated).TotalDays <= 7; - } - - private static void SaveAllCardPositions(FlowLayoutPanel flowPanel) - { - foreach (Control control in flowPanel.Controls) - { - if (control is AppCard card) - { - WritePositionCache(card.AppName, control.Location); - } - } - } - - // 软件下载按钮 - private Button btnApps = null!; - // 下载进度按钮 - private Button btnDownloads = null!; - // 设置按钮 - private Button btnSettings = null!; - // 关于按钮 - private Button btnAbout = null!; - // 内容显示面板 - private Panel contentPanel = null!; - - /// - /// 初始化窗体组件 - /// - private void InitializeComponent() - { - // 设置窗体基本属性 - // 窗体基本设置 - this.Text = "kortapp-z"; - this.Size = new Size(1430, 1050); // 增加窗体高度 - this.MinimumSize = new Size(600, 600); // 设置最小尺寸 - this.StartPosition = FormStartPosition.CenterScreen; - this.Icon = new Icon("img/ico/icon.ico"); // 设置窗体图标 - - // 注册主题变更事件 - ThemeManager.ThemeChanged += (theme) => - { - this.Invoke((MethodInvoker)delegate { - AnimateThemeChange(); - }); - }; - - // 现代化顶部导航栏 - Panel buttonPanel = new Panel(); - buttonPanel.Dock = DockStyle.Top; - buttonPanel.Height = 70; - buttonPanel.BackColor = ThemeManager.ControlBackgroundColor; - buttonPanel.Padding = new Padding(10, 15, 10, 0); - buttonPanel.AutoScroll = true; - buttonPanel.AutoSize = true; - buttonPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; - - // 导航按钮样式 - Action