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 | |
|---|---|---|---|
|
|
481fc24735 | ||
|
|
bebd804b7a | ||
|
|
4202013265 |
@@ -51,7 +51,7 @@ namespace AppStore
|
|||||||
|
|
||||||
// 初始化并添加应用信息
|
// 初始化并添加应用信息
|
||||||
infoLabel = new Label();
|
infoLabel = new Label();
|
||||||
infoLabel.Text = "kortapp-z\n版本: 1.2.9\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
infoLabel.Text = "kortapp-z\n版本: 1.3.0\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;
|
||||||
|
|||||||
@@ -1,41 +1,42 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<NoWarn>CS8622</NoWarn>
|
<NoWarn>CS8622</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<WarningsAsErrors>CS8618</WarningsAsErrors>
|
<WarningsAsErrors>CS8618</WarningsAsErrors>
|
||||||
<ApplicationIcon>img\ico\icon.ico</ApplicationIcon>
|
<ApplicationIcon>img\ico\icon.ico</ApplicationIcon>
|
||||||
<Platforms>x86;x64</Platforms>
|
<Platforms>x86;x64</Platforms>
|
||||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="help.txt" />
|
<None Include="help.txt" />
|
||||||
<None Include="resource\*.exe">
|
<None Include="resource\*.exe">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="img\png\*.png">
|
<None Include="img\png\*.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="img\jpg\*.jpg">
|
<None Include="img\jpg\*.jpg">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="img\resource\png\*.png">
|
<None Include="img\resource\png\*.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="img\ico\*.ico">
|
<None Include="img\ico\*.ico">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ZXing.Net" Version="0.16.9" />
|
<PackageReference Include="SunnyUI" Version="3.8.6" />
|
||||||
</ItemGroup>
|
<PackageReference Include="ZXing.Net" Version="0.16.9" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
|
||||||
|
</Project>
|
||||||
|
|||||||
125
MainForm.cs
125
MainForm.cs
@@ -8,14 +8,43 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using AppStore;
|
using AppStore;
|
||||||
|
using Sunny.UI;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace AppStore
|
namespace AppStore
|
||||||
{
|
{
|
||||||
/// <summary>
|
public class MainForm : UIForm
|
||||||
/// 主窗体类,负责应用程序的主界面显示和交互
|
|
||||||
/// </summary>
|
|
||||||
public class MainForm : Form
|
|
||||||
{
|
{
|
||||||
|
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
|
||||||
|
private static extern IntPtr CreateRoundRectRgn(
|
||||||
|
int nLeftRect,
|
||||||
|
int nTopRect,
|
||||||
|
int nRightRect,
|
||||||
|
int nBottomRect,
|
||||||
|
int nWidthEllipse,
|
||||||
|
int nHeightEllipse
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport("dwmapi.dll")]
|
||||||
|
private static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
|
||||||
|
|
||||||
|
[DllImport("dwmapi.dll")]
|
||||||
|
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||||
|
|
||||||
|
[DllImport("dwmapi.dll")]
|
||||||
|
private static extern int DwmIsCompositionEnabled(ref int pfEnabled);
|
||||||
|
|
||||||
|
private struct MARGINS
|
||||||
|
{
|
||||||
|
public int leftWidth;
|
||||||
|
public int rightWidth;
|
||||||
|
public int topHeight;
|
||||||
|
public int bottomHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private const int DWMWA_WINDOW_CORNER_PREFERENCE = 33;
|
||||||
|
private const int DWMWCP_ROUND = 2;
|
||||||
|
|
||||||
private static readonly string CacheDir = Path.Combine(
|
private static readonly string CacheDir = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"zsyg", "kortapp-z", ".cache");
|
"zsyg", "kortapp-z", ".cache");
|
||||||
@@ -139,10 +168,32 @@ namespace AppStore
|
|||||||
// 设置窗体基本属性
|
// 设置窗体基本属性
|
||||||
// 窗体基本设置
|
// 窗体基本设置
|
||||||
this.Text = "kortapp-z";
|
this.Text = "kortapp-z";
|
||||||
this.Size = new Size(1430, 1050); // 增加窗体高度
|
this.Size = new Size(1430, 1050);
|
||||||
this.MinimumSize = new Size(600, 600); // 设置最小尺寸
|
this.MinimumSize = new Size(600, 600);
|
||||||
this.StartPosition = FormStartPosition.CenterScreen;
|
this.StartPosition = FormStartPosition.CenterScreen;
|
||||||
this.Icon = new Icon("img/ico/icon.ico"); // 设置窗体图标
|
this.Icon = new Icon("img/ico/icon.ico");
|
||||||
|
this.Style = UIStyle.Custom;
|
||||||
|
this.FormBorderStyle = FormBorderStyle.None;
|
||||||
|
|
||||||
|
// 应用现代化圆角
|
||||||
|
this.Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height,
|
||||||
|
ThemeManager.FormRadius, ThemeManager.FormRadius));
|
||||||
|
|
||||||
|
// 启用窗口阴影
|
||||||
|
if (Environment.OSVersion.Version.Major >= 6)
|
||||||
|
{
|
||||||
|
int val = DWMWCP_ROUND;
|
||||||
|
DwmSetWindowAttribute(this.Handle, DWMWA_WINDOW_CORNER_PREFERENCE, ref val, sizeof(int));
|
||||||
|
|
||||||
|
MARGINS margins = new MARGINS()
|
||||||
|
{
|
||||||
|
leftWidth = 1,
|
||||||
|
rightWidth = 1,
|
||||||
|
topHeight = 1,
|
||||||
|
bottomHeight = 1
|
||||||
|
};
|
||||||
|
DwmExtendFrameIntoClientArea(this.Handle, ref margins);
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化系统托盘
|
// 初始化系统托盘
|
||||||
trayMenu = new ContextMenuStrip();
|
trayMenu = new ContextMenuStrip();
|
||||||
@@ -190,12 +241,68 @@ namespace AppStore
|
|||||||
// 现代化顶部导航栏
|
// 现代化顶部导航栏
|
||||||
Panel buttonPanel = new Panel();
|
Panel buttonPanel = new Panel();
|
||||||
buttonPanel.Dock = DockStyle.Top;
|
buttonPanel.Dock = DockStyle.Top;
|
||||||
buttonPanel.Height = 70;
|
buttonPanel.Height = 80;
|
||||||
buttonPanel.BackColor = ThemeManager.ControlBackgroundColor;
|
buttonPanel.BackColor = ThemeManager.ControlBackgroundColor;
|
||||||
buttonPanel.Padding = new Padding(10, 15, 10, 0);
|
buttonPanel.Padding = new Padding(15, 20, 15, 5);
|
||||||
buttonPanel.AutoScroll = true;
|
buttonPanel.AutoScroll = true;
|
||||||
buttonPanel.AutoSize = true;
|
buttonPanel.AutoSize = true;
|
||||||
buttonPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
buttonPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
|
||||||
|
// 添加支持作者按钮
|
||||||
|
UIButton btnSupport = new UIButton();
|
||||||
|
btnSupport.Text = "支持作者";
|
||||||
|
btnSupport.Font = new Font("微软雅黑", 10F, FontStyle.Bold);
|
||||||
|
btnSupport.Size = new Size(120, 45);
|
||||||
|
btnSupport.Location = new Point(buttonPanel.Width - 140, 15);
|
||||||
|
btnSupport.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
btnSupport.Style = UIStyle.Custom;
|
||||||
|
btnSupport.FillColor = ThemeManager.AccentColor;
|
||||||
|
btnSupport.ForeColor = Color.White;
|
||||||
|
btnSupport.Click += (s, e) => {
|
||||||
|
// 使用SunnyUI的现代化MessageBox
|
||||||
|
var form = new UIForm();
|
||||||
|
form.Style = UIStyle.Custom;
|
||||||
|
form.Text = "支持作者";
|
||||||
|
form.Size = new Size(400, 200);
|
||||||
|
form.StartPosition = FormStartPosition.CenterParent;
|
||||||
|
|
||||||
|
var label = new Label();
|
||||||
|
label.Text = "您确定要前往GitHub支持作者吗?";
|
||||||
|
label.Font = new Font("Microsoft YaHei", 10);
|
||||||
|
label.AutoSize = false;
|
||||||
|
label.Size = new Size(300, 40);
|
||||||
|
label.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
label.Location = new Point(50, 40);
|
||||||
|
form.Controls.Add(label);
|
||||||
|
|
||||||
|
var btnOK = new UIButton();
|
||||||
|
btnOK.Text = "确定";
|
||||||
|
btnOK.Style = UIStyle.Custom;
|
||||||
|
btnOK.Size = new Size(80, 30);
|
||||||
|
btnOK.Location = new Point(120, 100);
|
||||||
|
btnOK.Click += (s, e) => {
|
||||||
|
form.DialogResult = DialogResult.OK;
|
||||||
|
form.Close();
|
||||||
|
};
|
||||||
|
form.Controls.Add(btnOK);
|
||||||
|
|
||||||
|
var btnCancel = new UIButton();
|
||||||
|
btnCancel.Text = "取消";
|
||||||
|
btnCancel.Style = UIStyle.Custom;
|
||||||
|
btnCancel.Size = new Size(80, 30);
|
||||||
|
btnCancel.Location = new Point(220, 100);
|
||||||
|
btnCancel.Click += (s, e) => {
|
||||||
|
form.DialogResult = DialogResult.Cancel;
|
||||||
|
form.Close();
|
||||||
|
};
|
||||||
|
form.Controls.Add(btnCancel);
|
||||||
|
|
||||||
|
if (form.ShowDialog(this) == DialogResult.OK)
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo("https://github.com/zs-yg/kortapp-z") { UseShellExecute = true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
buttonPanel.Controls.Add(btnSupport);
|
||||||
|
|
||||||
// 导航按钮样式
|
// 导航按钮样式
|
||||||
Action<Button> styleButton = (Button btn) => {
|
Action<Button> styleButton = (Button btn) => {
|
||||||
|
|||||||
@@ -58,22 +58,26 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 浅色主题颜色
|
// 浅色主题颜色
|
||||||
private static readonly Color LightBackground = Color.FromArgb(255, 255, 255);
|
private static readonly Color LightBackground = Color.FromArgb(250, 250, 250);
|
||||||
private static readonly Color LightControlBackground = Color.FromArgb(240, 240, 240);
|
private static readonly Color LightControlBackground = Color.FromArgb(245, 245, 245);
|
||||||
private static readonly Color LightText = Color.FromArgb(30, 30, 30);
|
private static readonly Color LightText = Color.FromArgb(40, 40, 40);
|
||||||
private static readonly Color LightButtonHover = Color.FromArgb(230, 230, 230);
|
private static readonly Color LightButtonHover = Color.FromArgb(235, 235, 235);
|
||||||
private static readonly Color LightButtonActive = Color.FromArgb(220, 220, 220);
|
private static readonly Color LightButtonActive = Color.FromArgb(225, 225, 225);
|
||||||
|
private static readonly Color LightAccent = Color.FromArgb(0, 120, 215);
|
||||||
|
private static readonly Color LightAccentLight = Color.FromArgb(0, 150, 245);
|
||||||
|
|
||||||
// 深色主题颜色
|
// 深色主题颜色
|
||||||
private static readonly Color DarkBackground = Color.FromArgb(30, 30, 30);
|
private static readonly Color DarkBackground = Color.FromArgb(25, 25, 25);
|
||||||
private static readonly Color DarkControlBackground = Color.FromArgb(45, 45, 45);
|
private static readonly Color DarkControlBackground = Color.FromArgb(40, 40, 40);
|
||||||
private static readonly Color DarkText = Color.FromArgb(240, 240, 240);
|
private static readonly Color DarkText = Color.FromArgb(245, 245, 245);
|
||||||
private static readonly Color DarkButtonHover = Color.FromArgb(60, 60, 60);
|
private static readonly Color DarkButtonHover = Color.FromArgb(55, 55, 55);
|
||||||
private static readonly Color DarkButtonActive = Color.FromArgb(70, 70, 70);
|
private static readonly Color DarkButtonActive = Color.FromArgb(65, 65, 65);
|
||||||
private static readonly Color DarkBorder = Color.FromArgb(80, 80, 80);
|
private static readonly Color DarkBorder = Color.FromArgb(70, 70, 70);
|
||||||
|
private static readonly Color DarkAccent = Color.FromArgb(0, 150, 245);
|
||||||
|
private static readonly Color DarkAccentLight = Color.FromArgb(0, 180, 255);
|
||||||
|
|
||||||
// 浅色主题边框颜色
|
// 浅色主题边框颜色
|
||||||
private static readonly Color LightBorder = Color.FromArgb(180, 180, 180);
|
private static readonly Color LightBorder = Color.FromArgb(200, 200, 200);
|
||||||
|
|
||||||
public static event Action<ThemeMode> ThemeChanged = delegate {};
|
public static event Action<ThemeMode> ThemeChanged = delegate {};
|
||||||
|
|
||||||
@@ -109,6 +113,16 @@ namespace AppStore
|
|||||||
public static Color BorderColor =>
|
public static Color BorderColor =>
|
||||||
_currentTheme == ThemeMode.Light ? LightBorder : DarkBorder;
|
_currentTheme == ThemeMode.Light ? LightBorder : DarkBorder;
|
||||||
|
|
||||||
|
public static Color AccentColor =>
|
||||||
|
_currentTheme == ThemeMode.Light ? LightAccent : DarkAccent;
|
||||||
|
|
||||||
|
public static Color AccentLightColor =>
|
||||||
|
_currentTheme == ThemeMode.Light ? LightAccentLight : DarkAccentLight;
|
||||||
|
|
||||||
|
public static int ControlRadius => 8;
|
||||||
|
|
||||||
|
public static int FormRadius => 12;
|
||||||
|
|
||||||
public static void ApplyTheme(Control control)
|
public static void ApplyTheme(Control control)
|
||||||
{
|
{
|
||||||
ApplyThemeToControl(control);
|
ApplyThemeToControl(control);
|
||||||
@@ -125,6 +139,9 @@ namespace AppStore
|
|||||||
button.FlatAppearance.BorderSize = 0;
|
button.FlatAppearance.BorderSize = 0;
|
||||||
button.FlatAppearance.MouseOverBackColor = ButtonHoverColor;
|
button.FlatAppearance.MouseOverBackColor = ButtonHoverColor;
|
||||||
button.FlatAppearance.MouseDownBackColor = ButtonActiveColor;
|
button.FlatAppearance.MouseDownBackColor = ButtonActiveColor;
|
||||||
|
button.BackColor = ControlBackgroundColor;
|
||||||
|
button.Font = new Font(button.Font, FontStyle.Bold);
|
||||||
|
button.Padding = new Padding(10, 5, 10, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Control childControl in control.Controls)
|
foreach (Control childControl in control.Controls)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||||
|
|
||||||
#define MyAppName "kortapp-z"
|
#define MyAppName "kortapp-z"
|
||||||
#define MyAppVersion "1.2.9"
|
#define MyAppVersion "1.3.0"
|
||||||
#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.2.9"
|
#define MyAppVersion "1.3.0"
|
||||||
#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