mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-07 00:20:43 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b7048d570 | ||
|
|
bba99d800f | ||
|
|
4831af1f69 |
@@ -51,7 +51,7 @@ namespace AppStore
|
|||||||
|
|
||||||
// 初始化并添加应用信息
|
// 初始化并添加应用信息
|
||||||
infoLabel = new Label();
|
infoLabel = new Label();
|
||||||
infoLabel.Text = "kortapp-z\n版本: 1.3.8\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
infoLabel.Text = "kortapp-z\n版本: 1.3.9\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
||||||
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
||||||
infoLabel.AutoSize = false;
|
infoLabel.AutoSize = false;
|
||||||
infoLabel.Width = 300;
|
infoLabel.Width = 300;
|
||||||
|
|||||||
42
MainForm.cs
42
MainForm.cs
@@ -147,6 +147,8 @@ namespace AppStore
|
|||||||
|
|
||||||
// 软件下载按钮
|
// 软件下载按钮
|
||||||
private Button btnApps = null!;
|
private Button btnApps = null!;
|
||||||
|
// 网站推荐按钮
|
||||||
|
private Button btnWebsites = null!;
|
||||||
// 下载进度按钮
|
// 下载进度按钮
|
||||||
private Button btnDownloads = null!;
|
private Button btnDownloads = null!;
|
||||||
// 设置按钮
|
// 设置按钮
|
||||||
@@ -155,6 +157,8 @@ namespace AppStore
|
|||||||
private Button btnAbout = null!;
|
private Button btnAbout = null!;
|
||||||
// 内容显示面板
|
// 内容显示面板
|
||||||
private Panel contentPanel = null!;
|
private Panel contentPanel = null!;
|
||||||
|
// 网站卡片流式布局面板
|
||||||
|
private FlowLayoutPanel websitesFlowPanel = new FlowLayoutPanel();
|
||||||
// 系统托盘图标
|
// 系统托盘图标
|
||||||
private NotifyIcon trayIcon = null!;
|
private NotifyIcon trayIcon = null!;
|
||||||
// 托盘右键菜单
|
// 托盘右键菜单
|
||||||
@@ -372,10 +376,21 @@ namespace AppStore
|
|||||||
};
|
};
|
||||||
buttonPanel.Controls.Add(btnAbout);
|
buttonPanel.Controls.Add(btnAbout);
|
||||||
|
|
||||||
|
// 网站推荐按钮
|
||||||
|
btnWebsites = new Button();
|
||||||
|
btnWebsites.Text = "网站推荐";
|
||||||
|
btnWebsites.Location = new Point(590, 0);
|
||||||
|
styleButton(btnWebsites);
|
||||||
|
btnWebsites.Click += (s, e) => {
|
||||||
|
Logger.Log("用户点击了'网站推荐'按钮");
|
||||||
|
ShowWebsitesView();
|
||||||
|
};
|
||||||
|
buttonPanel.Controls.Add(btnWebsites);
|
||||||
|
|
||||||
// 内置工具按钮
|
// 内置工具按钮
|
||||||
var btnTools = new Button();
|
var btnTools = new Button();
|
||||||
btnTools.Text = "内置工具";
|
btnTools.Text = "内置工具";
|
||||||
btnTools.Location = new Point(590, 0);
|
btnTools.Location = new Point(730, 0);
|
||||||
styleButton(btnTools);
|
styleButton(btnTools);
|
||||||
btnTools.Click += (s, e) => {
|
btnTools.Click += (s, e) => {
|
||||||
Logger.Log("用户点击了'内置工具'按钮");
|
Logger.Log("用户点击了'内置工具'按钮");
|
||||||
@@ -830,6 +845,31 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowWebsitesView()
|
||||||
|
{
|
||||||
|
contentPanel.Controls.Clear();
|
||||||
|
websitesFlowPanel.Dock = DockStyle.Fill;
|
||||||
|
websitesFlowPanel.AutoScroll = true;
|
||||||
|
websitesFlowPanel.WrapContents = false;
|
||||||
|
websitesFlowPanel.Padding = new Padding(20);
|
||||||
|
contentPanel.Controls.Add(websitesFlowPanel);
|
||||||
|
|
||||||
|
// 添加示例网站卡片
|
||||||
|
var card1 = new WebSiteCards();
|
||||||
|
card1.WebSiteName = "GitHub";
|
||||||
|
card1.WebSiteIconPath = "img/jpg/github.jpg";
|
||||||
|
card1.Description = "全球最大的代码托管平台,支持Git版本控制";
|
||||||
|
card1.WebSiteUrl = "https://github.com";
|
||||||
|
websitesFlowPanel.Controls.Add(card1);
|
||||||
|
|
||||||
|
var card2 = new WebSiteCards();
|
||||||
|
card2.WebSiteName = "Stack Overflow";
|
||||||
|
card2.WebSiteIconPath = "img/png/StackOverflow.png";
|
||||||
|
card2.Description = "程序员问答社区,解决各种编程问题";
|
||||||
|
card2.WebSiteUrl = "https://stackoverflow.com";
|
||||||
|
websitesFlowPanel.Controls.Add(card2);
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowAboutView()
|
private void ShowAboutView()
|
||||||
{
|
{
|
||||||
contentPanel.Controls.Clear();
|
contentPanel.Controls.Clear();
|
||||||
|
|||||||
196
WebSiteCards.cs
Normal file
196
WebSiteCards.cs
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace AppStore
|
||||||
|
{
|
||||||
|
public class WebSiteCards : UserControl
|
||||||
|
{
|
||||||
|
private PictureBox iconBox;
|
||||||
|
private Label nameLabel;
|
||||||
|
private Label descriptionLabel;
|
||||||
|
private Button visitBtn;
|
||||||
|
private ToolTip toolTip;
|
||||||
|
private Color borderColor = SystemColors.ControlDark;
|
||||||
|
|
||||||
|
public string WebSiteName { get; set; } = string.Empty;
|
||||||
|
private Image _webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
public Image WebSiteIcon
|
||||||
|
{
|
||||||
|
get { return _webSiteIcon; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
_webSiteIcon = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string WebSiteIconPath
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = value;
|
||||||
|
if (!Path.IsPathRooted(path))
|
||||||
|
{
|
||||||
|
path = Path.Combine(Application.StartupPath, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
_webSiteIcon = Image.FromFile(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string WebSiteUrl { get; set; } = string.Empty;
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public WebSiteCards()
|
||||||
|
{
|
||||||
|
iconBox = new PictureBox() { SizeMode = PictureBoxSizeMode.StretchImage };
|
||||||
|
nameLabel = new Label() { Text = string.Empty };
|
||||||
|
descriptionLabel = new Label() { Text = string.Empty };
|
||||||
|
visitBtn = new Button() { Text = "访问" };
|
||||||
|
toolTip = new ToolTip();
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.Size = new Size(400, 150); // 更宽的卡片以适应横向布局
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Padding = new Padding(10);
|
||||||
|
|
||||||
|
// 网站名称标签 - 顶部
|
||||||
|
nameLabel.Font = new Font("Microsoft YaHei", 10, FontStyle.Bold);
|
||||||
|
nameLabel.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
nameLabel.Location = new Point(10, 10);
|
||||||
|
nameLabel.Size = new Size(Width - 20, 20);
|
||||||
|
this.Controls.Add(nameLabel);
|
||||||
|
|
||||||
|
// 网站图标 - 左侧
|
||||||
|
iconBox.Size = new Size(80, 80);
|
||||||
|
iconBox.Location = new Point(10, 40);
|
||||||
|
this.Controls.Add(iconBox);
|
||||||
|
|
||||||
|
// 网站描述 - 右侧
|
||||||
|
descriptionLabel.Font = new Font("Microsoft YaHei", 9);
|
||||||
|
descriptionLabel.TextAlign = ContentAlignment.TopLeft;
|
||||||
|
descriptionLabel.AutoSize = false;
|
||||||
|
descriptionLabel.Size = new Size(Width - 110, 80);
|
||||||
|
descriptionLabel.Location = new Point(100, 40);
|
||||||
|
descriptionLabel.MaximumSize = new Size(Width - 110, 0); // 允许自动换行
|
||||||
|
this.Controls.Add(descriptionLabel);
|
||||||
|
|
||||||
|
// 访问按钮 - 右下角
|
||||||
|
visitBtn.Size = new Size(80, 30);
|
||||||
|
visitBtn.Location = new Point(Width - 90, Height - 40);
|
||||||
|
visitBtn.Click += VisitBtn_Click;
|
||||||
|
this.Controls.Add(visitBtn);
|
||||||
|
|
||||||
|
// 工具提示
|
||||||
|
toolTip.AutoPopDelay = 5000;
|
||||||
|
toolTip.InitialDelay = 500;
|
||||||
|
toolTip.ReshowDelay = 500;
|
||||||
|
toolTip.ShowAlways = true;
|
||||||
|
toolTip.SetToolTip(visitBtn, "在浏览器中打开网站");
|
||||||
|
|
||||||
|
UpdateDisplay();
|
||||||
|
UpdateLabelTheme();
|
||||||
|
ThemeManager.ThemeChanged += (theme) => UpdateLabelTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLabelTheme()
|
||||||
|
{
|
||||||
|
if (ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Dark)
|
||||||
|
{
|
||||||
|
this.BackColor = Color.FromArgb(45, 45, 48);
|
||||||
|
nameLabel.ForeColor = Color.White;
|
||||||
|
descriptionLabel.ForeColor = Color.White;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
nameLabel.ForeColor = Color.Black;
|
||||||
|
descriptionLabel.ForeColor = Color.Black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateDisplay()
|
||||||
|
{
|
||||||
|
nameLabel.Text = WebSiteName;
|
||||||
|
iconBox.Image = WebSiteIcon;
|
||||||
|
descriptionLabel.Text = Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VisitBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(WebSiteUrl))
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = WebSiteUrl,
|
||||||
|
UseShellExecute = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"打开网站失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
|
||||||
|
// 绘制圆角边框
|
||||||
|
using (var pen = new Pen(borderColor, 1))
|
||||||
|
{
|
||||||
|
int radius = 10;
|
||||||
|
var rect = new Rectangle(0, 0, Width - 1, Height - 1);
|
||||||
|
e.Graphics.DrawPath(pen, GetRoundedRectPath(rect, radius));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.Drawing.Drawing2D.GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
|
||||||
|
{
|
||||||
|
var path = new System.Drawing.Drawing2D.GraphicsPath();
|
||||||
|
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y, radius, radius, 270, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y + rect.Height - radius, radius, radius, 0, 90);
|
||||||
|
path.AddArc(rect.X, rect.Y + rect.Height - radius, radius, radius, 90, 90);
|
||||||
|
path.CloseFigure();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
img/png/StackOverflow.png
Normal file
BIN
img/png/StackOverflow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 690 B |
@@ -2,7 +2,7 @@
|
|||||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||||
|
|
||||||
#define MyAppName "kortapp-z"
|
#define MyAppName "kortapp-z"
|
||||||
#define MyAppVersion "1.3.8"
|
#define MyAppVersion "1.3.9"
|
||||||
#define MyAppPublisher "zsyg"
|
#define MyAppPublisher "zsyg"
|
||||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||||
#define MyAppExeName "kortapp-z.exe"
|
#define MyAppExeName "kortapp-z.exe"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||||
|
|
||||||
#define MyAppName "kortapp-z"
|
#define MyAppName "kortapp-z"
|
||||||
#define MyAppVersion "1.3.8"
|
#define MyAppVersion "1.3.9"
|
||||||
#define MyAppPublisher "zsyg"
|
#define MyAppPublisher "zsyg"
|
||||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||||
#define MyAppExeName "kortapp-z.exe"
|
#define MyAppExeName "kortapp-z.exe"
|
||||||
|
|||||||
Reference in New Issue
Block a user