2023-11-07 08:36:50 +00:00
|
|
|
|
using MGdu.WinFormUI;
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
using ryCommon;
|
2025-06-27 02:17:38 +00:00
|
|
|
|
using ryControls.Skin;
|
2023-11-07 08:36:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-06-27 02:17:38 +00:00
|
|
|
|
using System.Windows.Forms;
|
2023-11-07 08:36:50 +00:00
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
|
|
|
|
|
|
|
namespace RySkins
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SkinSetting
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MGdu窗体的默认皮肤
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static ThemeFormBase FormSkin { get; set; } = new ThemeForm();
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tab标签鼠标移上时的颜色开始色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color TabMoveColorStart { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tab标签鼠标移上时的颜色结束色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color TabMoveColorEnd { get; set; }
|
|
|
|
|
|
/// <summary>
|
2025-06-27 02:17:38 +00:00
|
|
|
|
/// 整个Tab标签背景颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color AllTabBackColor { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图标颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color IconColor { get; set; }
|
|
|
|
|
|
public static bool DrawTabBorder { get; set; } = true;
|
|
|
|
|
|
/// <summary>
|
2023-11-07 08:36:50 +00:00
|
|
|
|
/// 最小化按钮字体色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color minForeColor { get; set; } = Color.Gray;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最小化按钮激活背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color minBackColorHover { get; set; } = Color.FromArgb(67, 139, 221);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最小化按钮按下背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color minBackColorPressed { get; set; } = Color.FromArgb(50, 125, 210);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大化按钮字体色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color maxForeColor { get; set; } = Color.Gray;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大化按钮激活背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color maxBackColorHover { get; set; } = Color.FromArgb(67, 139, 221);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大化按钮按下背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color maxBackColorPressed { get; set; } = Color.FromArgb(50, 125, 210);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭按钮字体色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color closeForeColor { get; set; } = Color.Gray;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭按钮激活背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color closeBackColorHover { get; set; } = Color.FromArgb(217, 71, 71);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭按钮按下背景色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color closeBackColorPressed { get; set; } = Color.FromArgb(188, 52, 52);
|
2025-06-27 02:17:38 +00:00
|
|
|
|
public static Color SvgColor{ get; set; } = Color.FromArgb(188, 52, 52);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 工具栏选中背景颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Color ToolBarSelectedColor { get; set; } = Color.SkyBlue;
|
2023-11-07 08:36:50 +00:00
|
|
|
|
public static void SaveCloseBtnSkin()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (FormSkin.CloseBoxColor == null) { FormSkin.CloseBoxColor = new ButtonColorTable(); }
|
|
|
|
|
|
FormSkin.CloseBoxColor.ForeColorNormal = FormSkin.CloseBoxColor.ForeColorHover
|
|
|
|
|
|
= FormSkin.CloseBoxColor.ForeColorPressed = closeForeColor;
|
|
|
|
|
|
FormSkin.CloseBoxColor.BackColorHover = closeBackColorHover;
|
|
|
|
|
|
FormSkin.CloseBoxColor.BackColorPressed = closeBackColorPressed;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void SaveMinBtnSkin()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (FormSkin.MinBoxColor == null) { FormSkin.MinBoxColor = new ButtonColorTable(); }
|
|
|
|
|
|
//FormSkin.MinBoxColor = new ButtonColorTable();
|
|
|
|
|
|
FormSkin.MinBoxColor.ForeColorNormal = FormSkin.MinBoxColor.ForeColorHover
|
|
|
|
|
|
= FormSkin.MinBoxColor.ForeColorPressed = minForeColor;
|
|
|
|
|
|
FormSkin.MinBoxColor.BackColorHover = minBackColorHover;
|
|
|
|
|
|
FormSkin.MinBoxColor.BackColorPressed = minBackColorPressed;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void SaveMaxBtnSkin()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (FormSkin.MaxBoxColor == null) { FormSkin.MaxBoxColor = new ButtonColorTable(); }
|
|
|
|
|
|
//FormSkin.MaxBoxColor = new ButtonColorTable();
|
|
|
|
|
|
FormSkin.MaxBoxColor.ForeColorNormal = FormSkin.MaxBoxColor.ForeColorHover
|
|
|
|
|
|
= FormSkin.MaxBoxColor.ForeColorPressed = maxForeColor;
|
|
|
|
|
|
FormSkin.MaxBoxColor.BackColorHover = maxBackColorHover;
|
|
|
|
|
|
FormSkin.MaxBoxColor.BackColorPressed = maxBackColorPressed;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载皮肤
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
|
public static void LoadSkin(string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!System.IO.File.Exists(path)) {
|
|
|
|
|
|
SaveMinBtnSkin();
|
|
|
|
|
|
SaveMaxBtnSkin();
|
|
|
|
|
|
SaveCloseBtnSkin();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var skin = FormSkin;
|
|
|
|
|
|
var skin_json= JObject.Parse(RyFiles.ReadAllText(path));
|
|
|
|
|
|
var skin_item = skin_json["skin"];
|
|
|
|
|
|
if (skin_item == null) { return; }
|
|
|
|
|
|
JObject jo = JObject.Parse(skin_item.ToString());
|
|
|
|
|
|
skin.CaptionBackColorTop = GetColor("CaptionBackColorTop", skin.CaptionBackColorTop);
|
|
|
|
|
|
skin.CaptionBackColorBottom = GetColor("CaptionBackColorBottom", skin.CaptionBackColorBottom);
|
|
|
|
|
|
skin.CaptionTextColor = GetColor("CaptionTextColor", skin.CaptionTextColor);
|
|
|
|
|
|
skin.IconLeftMargin = GetInt("IconLeftMargin", skin.IconLeftMargin);
|
2025-06-27 02:17:38 +00:00
|
|
|
|
IconColor = GetColor("IconColor", IconColor);
|
2023-11-07 08:36:50 +00:00
|
|
|
|
var icon_size = GetInt("IconSize", skin.IconSize.Width);
|
|
|
|
|
|
skin.IconSize = new Size(icon_size, icon_size);
|
|
|
|
|
|
skin.CaptionHeight = GetInt("CaptionHeight", skin.CaptionHeight);
|
|
|
|
|
|
minForeColor = GetColor("minForeColor", minForeColor);
|
|
|
|
|
|
minBackColorHover = GetColor("minBackColorHover", minBackColorHover);
|
|
|
|
|
|
minBackColorPressed = GetColor("minBackColorPressed", minBackColorPressed);
|
|
|
|
|
|
maxForeColor = GetColor("maxForeColor", maxForeColor);
|
|
|
|
|
|
maxBackColorHover = GetColor("maxBackColorHover", maxBackColorHover);
|
|
|
|
|
|
maxBackColorPressed = GetColor("maxBackColorPressed", maxBackColorPressed);
|
|
|
|
|
|
closeForeColor = GetColor("closeForeColor", closeForeColor);
|
|
|
|
|
|
closeBackColorHover = GetColor("closeBackColorHover", closeBackColorHover);
|
|
|
|
|
|
closeBackColorPressed = GetColor("closeBackColorPressed", closeBackColorPressed);
|
|
|
|
|
|
SaveMinBtnSkin();
|
|
|
|
|
|
SaveMaxBtnSkin();
|
|
|
|
|
|
SaveCloseBtnSkin();
|
|
|
|
|
|
skin.BorderWidth = GetInt("BorderWidth", skin.BorderWidth);
|
|
|
|
|
|
skin.FormBackColor = GetColor("FormBackColor", skin.FormBackColor);
|
|
|
|
|
|
skin.FormBorderOutterColor = GetColor("FormBorderOutterColor", skin.FormBorderOutterColor);
|
|
|
|
|
|
skin.FormBorderInnerColor = GetColor("FormBorderInnerColor", skin.FormBorderInnerColor);
|
|
|
|
|
|
skin.FormBorderInmostColor = GetColor("FormBorderInmostColor", skin.FormBorderInmostColor);
|
|
|
|
|
|
skin.ShowShadow = GetBool("ShowShadow", skin.ShowShadow);
|
|
|
|
|
|
skin.ShadowWidth = GetInt("ShadowWidth", skin.ShadowWidth);
|
|
|
|
|
|
skin.ShadowColor = GetColor("ShadowColor", skin.ShadowColor);
|
|
|
|
|
|
skin.ShadowAValueDark = GetInt("ShadowAValueDark", skin.ShadowAValueDark);
|
|
|
|
|
|
skin.ShadowAValueLight = GetInt("ShadowAValueLight", skin.ShadowAValueLight);
|
|
|
|
|
|
skin.Mdi_TabActiveBackColorTop = GetColor("TabActiveBackColorTop", skin.Mdi_TabActiveBackColorTop);
|
|
|
|
|
|
skin.Mdi_TabActiveBackColorBottom = GetColor("TabActiveBackColorBottom", skin.Mdi_TabActiveBackColorBottom);
|
|
|
|
|
|
skin.Mdi_TabDeactiveBackColorTop = GetColor("TabDeactiveBackColorTop", skin.Mdi_TabDeactiveBackColorTop);
|
2025-06-27 02:17:38 +00:00
|
|
|
|
skin.Mdi_TabDeactiveBackColorBottom = GetColor("TabDeactiveBackColorBottom", skin.Mdi_TabDeactiveBackColorBottom);
|
|
|
|
|
|
skin.Mdi_TabHeight = GetInt("TabHeight", 26);
|
|
|
|
|
|
skin.Mdi_TabAndTabSpace = GetInt("TabAndTabSpace", 2);
|
|
|
|
|
|
skin.TabRadius = GetInt("TabRadius", 8);
|
|
|
|
|
|
DrawTabBorder = GetBool("DrawTabBorder", DrawTabBorder);
|
|
|
|
|
|
TabMoveColorStart = GetColor("TabMoveColorStart", SkinSetting.TabMoveColorStart);
|
|
|
|
|
|
TabMoveColorEnd = GetColor("TabMoveColorEnd", SkinSetting.TabMoveColorEnd);
|
|
|
|
|
|
AllTabBackColor = GetColor("AllTabBackColor", SystemColors.Control);
|
|
|
|
|
|
SkinCommon.ButtonSkin.BackColor = GetColor("ButtonDefColor", SkinCommon.ButtonSkin.BackColor);
|
|
|
|
|
|
SkinCommon.ButtonSkin.ForeColor = GetColor("ButtonDefForeColor", SkinCommon.ButtonSkin.ForeColor);
|
|
|
|
|
|
SkinCommon.ButtonSkin.ColorGradient= GetBool("ButtonColorGradient", SkinCommon.ButtonSkin.ColorGradient);
|
|
|
|
|
|
SvgColor = GetColor("SvgColor", SvgColor);
|
|
|
|
|
|
ToolBarSelectedColor = GetColor("ToolBarSelectedColor", ToolBarSelectedColor);
|
2023-11-07 08:36:50 +00:00
|
|
|
|
string GetJItem(string id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = jo[id];
|
|
|
|
|
|
if (item == null) return "";
|
|
|
|
|
|
return item.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
Color GetColor(string id, Color defColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = GetJItem(id);
|
|
|
|
|
|
if (item.Length == 0) { return defColor; }
|
|
|
|
|
|
return System.Drawing.ColorTranslator.FromHtml(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { return defColor; }
|
|
|
|
|
|
}
|
|
|
|
|
|
int GetInt(string id, int defValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = GetJItem(id);
|
|
|
|
|
|
if (item.Length == 0) { return defValue; }
|
|
|
|
|
|
return item.ToInt();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { return defValue; }
|
|
|
|
|
|
}
|
|
|
|
|
|
bool GetBool(string id, bool defValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = GetJItem(id);
|
|
|
|
|
|
if (item.Length == 0) { return defValue; }
|
|
|
|
|
|
return item.ToBool();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { return defValue; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|