From 6d2711da081cf10a82e57c440ad04ef0e7efc723 Mon Sep 17 00:00:00 2001 From: zsyg <3872006562@qq.com> Date: Mon, 7 Jul 2025 17:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=89=BA=E6=9C=AF=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AboutForm.cs | 6 - AppCard.cs | 6 - AppSearch.cs | 6 - DownloadItem.cs | 268 +++++++++++++++++++++-------------------- DownloadManager.cs | 6 - ImageCompressorForm.cs | 6 - MainForm.cs | 6 - Program.cs | 6 - SettingsForm.cs | 6 - ThemeManager.cs | 6 - ToolCard.cs | 6 - border_renderer.cpp | 6 - card_calculator.cpp | 6 - log_cleaner.cpp | 6 - logger.cs | 6 - 15 files changed, 137 insertions(+), 215 deletions(-) diff --git a/AboutForm.cs b/AboutForm.cs index 2da3aad..c161ceb 100644 --- a/AboutForm.cs +++ b/AboutForm.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Drawing; using System.Windows.Forms; diff --git a/AppCard.cs b/AppCard.cs index 17c5c55..12c96a2 100644 --- a/AppCard.cs +++ b/AppCard.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Drawing; using System.Windows.Forms; diff --git a/AppSearch.cs b/AppSearch.cs index 900d84c..ac88f75 100644 --- a/AppSearch.cs +++ b/AppSearch.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Collections.Generic; using System.Linq; diff --git a/DownloadItem.cs b/DownloadItem.cs index a15169d..fe44764 100644 --- a/DownloadItem.cs +++ b/DownloadItem.cs @@ -1,131 +1,137 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace AppStore -{ - public class DownloadItem : UserControl - { - private Label nameLabel; - private ProgressBar progressBar; - private Label statusLabel; - private Button cancelBtn; - - public string FileName { get; set; } = string.Empty; - public int Progress { get; set; } - public string Status { get; set; } = string.Empty; - - public DownloadItem() - { - nameLabel = new Label(); - progressBar = new ProgressBar(); - statusLabel = new Label(); - cancelBtn = new Button(); - - InitializeComponent(); - - // 监听主题变化 - ThemeManager.ThemeChanged += (theme) => { - this.Invoke((MethodInvoker)delegate { - ApplyTheme(); - }); - }; - } - - private void ApplyTheme() - { - this.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? Color.White - : Color.Black; - this.ForeColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? Color.Black - : Color.White; - - cancelBtn.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? SystemColors.Control - : Color.FromArgb(70, 70, 70); - cancelBtn.ForeColor = ThemeManager.TextColor; - } - - private void InitializeComponent() - { - this.Size = new Size(400, 60); - this.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? Color.White - : Color.Black; - this.BorderStyle = BorderStyle.FixedSingle; - this.ForeColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? Color.Black - : Color.White; - - // 文件名标签 - nameLabel = new Label(); - nameLabel.AutoSize = true; - nameLabel.Location = new Point(10, 10); - nameLabel.Font = new Font("Microsoft YaHei", 9, FontStyle.Bold); - this.Controls.Add(nameLabel); - - // 进度条 - progressBar = new ProgressBar(); - progressBar.Size = new Size(200, 20); - progressBar.Location = new Point(10, 30); - this.Controls.Add(progressBar); - - // 状态标签 - statusLabel = new Label(); - statusLabel.AutoSize = true; - statusLabel.Location = new Point(220, 30); - statusLabel.Font = new Font("Microsoft YaHei", 8); - this.Controls.Add(statusLabel); - - // 取消按钮 - cancelBtn = new Button(); - cancelBtn.Text = "取消"; - cancelBtn.Size = new Size(60, 25); - cancelBtn.Location = new Point(320, 30); - cancelBtn.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light - ? SystemColors.Control - : Color.FromArgb(70, 70, 70); - cancelBtn.ForeColor = ThemeManager.TextColor; - cancelBtn.FlatStyle = FlatStyle.Flat; - cancelBtn.FlatAppearance.BorderSize = 0; - cancelBtn.Click += CancelBtn_Click; - this.Controls.Add(cancelBtn); - } - - public void UpdateDisplay() - { - nameLabel.Text = FileName; - progressBar.Value = Progress; - statusLabel.Text = Status; - } - - private void CancelBtn_Click(object sender, EventArgs e) - { - if (sender == null || e == null) return; - if (InvokeRequired) - { - Invoke(new EventHandler(CancelBtn_Click), sender, e); - return; - } - - try - { - DownloadManager.Instance.CancelDownload(this); - Status = "已取消"; - UpdateDisplay(); - } - catch (Exception ex) - { - Status = $"取消失败: {ex.Message}"; - UpdateDisplay(); - } - } - } -} +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace AppStore +{ + public class DownloadItem : UserControl + { + private Label nameLabel; + private ProgressBar progressBar; + private Label statusLabel; + private Button cancelBtn; + + public string FileName { get; set; } = string.Empty; + public int Progress { get; set; } + public string Status { get; set; } = string.Empty; + + public DownloadItem() + { + nameLabel = new Label(); + progressBar = new ProgressBar(); + statusLabel = new Label(); + cancelBtn = new Button(); + + InitializeComponent(); + + // 监听主题变化 + ThemeManager.ThemeChanged += (theme) => { + this.Invoke((MethodInvoker)delegate { + ApplyTheme(); + }); + }; + } + + private void ApplyTheme() + { + this.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? Color.White + : Color.Black; + this.ForeColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? Color.Black + : Color.White; + + cancelBtn.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? SystemColors.Control + : Color.FromArgb(70, 70, 70); + cancelBtn.ForeColor = ThemeManager.TextColor; + } + + private void InitializeComponent() + { + this.Size = new Size(400, 60); + this.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? Color.White + : Color.Black; + this.BorderStyle = BorderStyle.None; // 禁用默认边框 + this.ForeColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? Color.Black + : Color.White; + this.Paint += DownloadItem_Paint; // 添加自定义绘制 + + // 文件名标签 + nameLabel = new Label(); + nameLabel.AutoSize = true; + nameLabel.Location = new Point(10, 10); + nameLabel.Font = new Font("Microsoft YaHei", 9, FontStyle.Bold); + this.Controls.Add(nameLabel); + + // 进度条 + progressBar = new ProgressBar(); + progressBar.Size = new Size(200, 20); + progressBar.Location = new Point(10, 30); + this.Controls.Add(progressBar); + + // 状态标签 + statusLabel = new Label(); + statusLabel.AutoSize = true; + statusLabel.Location = new Point(220, 30); + statusLabel.Font = new Font("Microsoft YaHei", 8); + this.Controls.Add(statusLabel); + + // 取消按钮 + cancelBtn = new Button(); + cancelBtn.Text = "取消"; + cancelBtn.Size = new Size(60, 25); + cancelBtn.Location = new Point(320, 30); + cancelBtn.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light + ? SystemColors.Control + : Color.FromArgb(70, 70, 70); + cancelBtn.ForeColor = ThemeManager.TextColor; + cancelBtn.FlatStyle = FlatStyle.Flat; + cancelBtn.FlatAppearance.BorderSize = 0; + cancelBtn.Click += CancelBtn_Click; + this.Controls.Add(cancelBtn); + } + + public void UpdateDisplay() + { + nameLabel.Text = FileName; + progressBar.Value = Progress; + statusLabel.Text = Status; + this.Invalidate(); // 触发重绘 + } + + private void DownloadItem_Paint(object sender, PaintEventArgs e) + { + // 自定义边框绘制 + using (var pen = new Pen(ThemeManager.BorderColor, 1)) + { + e.Graphics.DrawRectangle(pen, + new Rectangle(0, 0, this.Width - 1, this.Height - 1)); + } + } + + private void CancelBtn_Click(object sender, EventArgs e) + { + if (sender == null || e == null) return; + if (InvokeRequired) + { + Invoke(new EventHandler(CancelBtn_Click), sender, e); + return; + } + + try + { + DownloadManager.Instance.CancelDownload(this); + Status = "已取消"; + UpdateDisplay(); + } + catch (Exception ex) + { + Status = $"取消失败: {ex.Message}"; + UpdateDisplay(); + } + } + } +} diff --git a/DownloadManager.cs b/DownloadManager.cs index e863c01..0c39fa4 100644 --- a/DownloadManager.cs +++ b/DownloadManager.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/ImageCompressorForm.cs b/ImageCompressorForm.cs index 01348b7..82aac9a 100644 --- a/ImageCompressorForm.cs +++ b/ImageCompressorForm.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Diagnostics; using System.Drawing; diff --git a/MainForm.cs b/MainForm.cs index 2ec56c4..f70e7d6 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| #nullable enable using System; using System.Drawing; diff --git a/Program.cs b/Program.cs index 00320df..77f322d 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Windows.Forms; diff --git a/SettingsForm.cs b/SettingsForm.cs index 15cbe23..afa8bd5 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Diagnostics; using System.IO; diff --git a/ThemeManager.cs b/ThemeManager.cs index cc322fd..17095f9 100644 --- a/ThemeManager.cs +++ b/ThemeManager.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Drawing; using System.Windows.Forms; diff --git a/ToolCard.cs b/ToolCard.cs index 3769816..7ab4690 100644 --- a/ToolCard.cs +++ b/ToolCard.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.Drawing; using System.Windows.Forms; diff --git a/border_renderer.cpp b/border_renderer.cpp index d1206df..6b61884 100644 --- a/border_renderer.cpp +++ b/border_renderer.cpp @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| #include #include #include diff --git a/card_calculator.cpp b/card_calculator.cpp index 610eacb..1835223 100644 --- a/card_calculator.cpp +++ b/card_calculator.cpp @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| #include #include #include diff --git a/log_cleaner.cpp b/log_cleaner.cpp index da71655..1e36ebd 100644 --- a/log_cleaner.cpp +++ b/log_cleaner.cpp @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| #include #include #include diff --git a/logger.cs b/logger.cs index 177dce2..538a2bb 100644 --- a/logger.cs +++ b/logger.cs @@ -1,9 +1,3 @@ - // _ _ - //| | _____ _ __| |_ __ _ _ __ _ __ ____ - //| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ / - //| | (_) | | | || (_| | |_) | |_) |_____/ / - //|_|\_\___/|_| \__\__,_| .__/| .__/ /___| - // |_| |_| using System; using System.IO; using System.Text;