using Prism.Mvvm;
using System;
using System.Reflection;
namespace TeamAAS.Models
{
[Serializable]
public class SystemConfiguration : BindableBase
{
public SystemConfiguration()
{
try
{
var version = Assembly.GetEntryAssembly()?.GetName()?.Version?.ToString();
if (string.IsNullOrEmpty(version))
version = Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString();
SoftwareVersion = version ?? "1.0.0.0";
}
catch
{
SoftwareVersion = "1.0.0.0";
}
Title = "Team Vision";
Font = new FontSizeSettings();
Theme = "Light"; // 默认亮色(白色)主题
AccentColor = "#2D6CDF"; // 默认主色(HandyControl 蓝)
}
private string _softwareVersion;
public string SoftwareVersion
{
get => _softwareVersion;
set => SetProperty(ref _softwareVersion, value);
}
private string _title;
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
private string _companyTitle;
public string CompanyTitle
{
get => _companyTitle;
set => SetProperty(ref _companyTitle, value);
}
private FontSizeSettings _font;
public FontSizeSettings Font
{
get => _font;
set => SetProperty(ref _font, value);
}
private string _theme = "Light";
/// 主题:"Light"(默认)/ "Dark"
public string Theme
{
get => _theme;
set => SetProperty(ref _theme, string.IsNullOrWhiteSpace(value) ? "Light" : value);
}
private string _accentColor = "#2D6CDF";
/// 主色(十六进制 #RRGGBB)
public string AccentColor
{
get => _accentColor;
set => SetProperty(ref _accentColor, string.IsNullOrWhiteSpace(value) ? "#2D6CDF" : value);
}
private string _language = "zh-CN";
/// 界面语言:"zh-CN"(简体中文,默认)/ "en-US"(英语)/ "ja-JP"(日语)/ "ko-KR"(韩语)
public string Language
{
get => _language;
set => SetProperty(ref _language, string.IsNullOrWhiteSpace(value) ? "zh-CN" : value);
}
private VisionSettings _vision = new VisionSettings();
/// 视觉引擎与主页画面配置
public VisionSettings Vision
{
get => _vision;
set => SetProperty(ref _vision, value);
}
private TeamAAS.Logging.PluginLogConfig _pluginLog = new TeamAAS.Logging.PluginLogConfig();
/// 任务插件日志配置(等级默认值/日志根目录/路径命名公式),统一在此管理
public TeamAAS.Logging.PluginLogConfig PluginLog
{
get => _pluginLog;
set => SetProperty(ref _pluginLog, value);
}
}
///
/// 视觉引擎与主页画面配置。
/// EngineName:当前视觉引擎(对应 IVisualEngine.EngineName,程序启动时反射探测到的实现之一);
/// HomePageFrameCount:主页视觉框数量(1-9);
/// HomeFrameArrange:框排列方式,1=水平最优行列,2=垂直最优行列;
/// FrameNames:各视觉框的用户可见名称,用“;”分隔,按序对应视觉框。
///
[Serializable]
public class VisionSettings : BindableBase
{
private string _engineName = "";
public string EngineName
{
get => _engineName;
set => SetProperty(ref _engineName, value);
}
private int _homePageFrameCount = 1;
/// 主页视觉框数量(1-9)
public int HomePageFrameCount
{
get => _homePageFrameCount;
set => SetProperty(ref _homePageFrameCount, Math.Max(1, Math.Min(9, value)));
}
private int _homeFrameArrange = 1;
/// 主页框排列方式:1=水平最优行列,2=垂直最优行列
public int HomeFrameArrange
{
get => _homeFrameArrange;
set => SetProperty(ref _homeFrameArrange, value == 2 ? 2 : 1);
}
private string _frameNames = "主画面";
public string FrameNames
{
get => _frameNames;
set => SetProperty(ref _frameNames, value ?? "");
}
/// 取第 index 个画面的显示名称(配置缺失时自动补“画面N”)
public string GetFrameName(int index)
{
var names = (_frameNames ?? "").Split(new[] { ';', ';' }, StringSplitOptions.RemoveEmptyEntries);
if (index >= 0 && index < names.Length) return names[index].Trim();
return $"画面{index + 1}";
}
}
[Serializable]
public class FontSizeSettings : BindableBase
{
private double _topBarHeight = 96;
public double TopBarHeight
{
get => _topBarHeight;
set => SetProperty(ref _topBarHeight, value);
}
private double _centerTitleFont = 48;
public double CenterTitleFont
{
get => _centerTitleFont;
set => SetProperty(ref _centerTitleFont, value);
}
private double _statusBarHeight = 38;
public double StatusBarHeight
{
get => _statusBarHeight;
set => SetProperty(ref _statusBarHeight, value);
}
private double _statusBarFont = 16;
public double StatusBarFont
{
get => _statusBarFont;
set => SetProperty(ref _statusBarFont, value);
}
private double _navButtonWidth = 88;
public double NavButtonWidth
{
get => _navButtonWidth;
set => SetProperty(ref _navButtonWidth, value);
}
private double _navButtonHeight = 80;
public double NavButtonHeight
{
get => _navButtonHeight;
set => SetProperty(ref _navButtonHeight, value);
}
private double _navButtonFont = 23;
public double NavButtonFont
{
get => _navButtonFont;
set => SetProperty(ref _navButtonFont, value);
}
private double _themeIconSize = 33;
public double ThemeIconSize
{
get => _themeIconSize;
set => SetProperty(ref _themeIconSize, value);
}
private double _navIconSize = 38;
public double NavIconSize
{
get => _navIconSize;
set => SetProperty(ref _navIconSize, value);
}
}
}