SystemConfiguration.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Reflection;
  4. namespace TeamAAS.Models
  5. {
  6. [Serializable]
  7. public class SystemConfiguration : BindableBase
  8. {
  9. public SystemConfiguration()
  10. {
  11. try
  12. {
  13. var version = Assembly.GetEntryAssembly()?.GetName()?.Version?.ToString();
  14. if (string.IsNullOrEmpty(version))
  15. version = Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString();
  16. SoftwareVersion = version ?? "1.0.0.0";
  17. }
  18. catch
  19. {
  20. SoftwareVersion = "1.0.0.0";
  21. }
  22. Title = "Team Vision";
  23. Font = new FontSizeSettings();
  24. Theme = "Light"; // 默认亮色(白色)主题
  25. AccentColor = "#2D6CDF"; // 默认主色(HandyControl 蓝)
  26. }
  27. private string _softwareVersion;
  28. public string SoftwareVersion
  29. {
  30. get => _softwareVersion;
  31. set => SetProperty(ref _softwareVersion, value);
  32. }
  33. private string _title;
  34. public string Title
  35. {
  36. get => _title;
  37. set => SetProperty(ref _title, value);
  38. }
  39. private string _companyTitle;
  40. public string CompanyTitle
  41. {
  42. get => _companyTitle;
  43. set => SetProperty(ref _companyTitle, value);
  44. }
  45. private FontSizeSettings _font;
  46. public FontSizeSettings Font
  47. {
  48. get => _font;
  49. set => SetProperty(ref _font, value);
  50. }
  51. private string _theme = "Light";
  52. /// <summary>主题:"Light"(默认)/ "Dark"</summary>
  53. public string Theme
  54. {
  55. get => _theme;
  56. set => SetProperty(ref _theme, string.IsNullOrWhiteSpace(value) ? "Light" : value);
  57. }
  58. private string _accentColor = "#2D6CDF";
  59. /// <summary>主色(十六进制 #RRGGBB)</summary>
  60. public string AccentColor
  61. {
  62. get => _accentColor;
  63. set => SetProperty(ref _accentColor, string.IsNullOrWhiteSpace(value) ? "#2D6CDF" : value);
  64. }
  65. private string _language = "zh-CN";
  66. /// <summary>界面语言:"zh-CN"(简体中文,默认)/ "en-US"(英语)/ "ja-JP"(日语)/ "ko-KR"(韩语)</summary>
  67. public string Language
  68. {
  69. get => _language;
  70. set => SetProperty(ref _language, string.IsNullOrWhiteSpace(value) ? "zh-CN" : value);
  71. }
  72. private VisionSettings _vision = new VisionSettings();
  73. /// <summary>视觉引擎与主页画面配置</summary>
  74. public VisionSettings Vision
  75. {
  76. get => _vision;
  77. set => SetProperty(ref _vision, value);
  78. }
  79. private TeamAAS.Logging.PluginLogConfig _pluginLog = new TeamAAS.Logging.PluginLogConfig();
  80. /// <summary>任务插件日志配置(等级默认值/日志根目录/路径命名公式),统一在此管理</summary>
  81. public TeamAAS.Logging.PluginLogConfig PluginLog
  82. {
  83. get => _pluginLog;
  84. set => SetProperty(ref _pluginLog, value);
  85. }
  86. }
  87. /// <summary>
  88. /// 视觉引擎与主页画面配置。
  89. /// EngineName:当前视觉引擎(对应 IVisualEngine.EngineName,程序启动时反射探测到的实现之一);
  90. /// HomePageFrameCount:主页视觉框数量(1-9);
  91. /// HomeFrameArrange:框排列方式,1=水平最优行列,2=垂直最优行列;
  92. /// FrameNames:各视觉框的用户可见名称,用“;”分隔,按序对应视觉框。
  93. /// </summary>
  94. [Serializable]
  95. public class VisionSettings : BindableBase
  96. {
  97. private string _engineName = "";
  98. public string EngineName
  99. {
  100. get => _engineName;
  101. set => SetProperty(ref _engineName, value);
  102. }
  103. private int _homePageFrameCount = 1;
  104. /// <summary>主页视觉框数量(1-9)</summary>
  105. public int HomePageFrameCount
  106. {
  107. get => _homePageFrameCount;
  108. set => SetProperty(ref _homePageFrameCount, Math.Max(1, Math.Min(9, value)));
  109. }
  110. private int _homeFrameArrange = 1;
  111. /// <summary>主页框排列方式:1=水平最优行列,2=垂直最优行列</summary>
  112. public int HomeFrameArrange
  113. {
  114. get => _homeFrameArrange;
  115. set => SetProperty(ref _homeFrameArrange, value == 2 ? 2 : 1);
  116. }
  117. private string _frameNames = "主画面";
  118. public string FrameNames
  119. {
  120. get => _frameNames;
  121. set => SetProperty(ref _frameNames, value ?? "");
  122. }
  123. /// <summary>取第 index 个画面的显示名称(配置缺失时自动补“画面N”)</summary>
  124. public string GetFrameName(int index)
  125. {
  126. var names = (_frameNames ?? "").Split(new[] { ';', ';' }, StringSplitOptions.RemoveEmptyEntries);
  127. if (index >= 0 && index < names.Length) return names[index].Trim();
  128. return $"画面{index + 1}";
  129. }
  130. }
  131. [Serializable]
  132. public class FontSizeSettings : BindableBase
  133. {
  134. private double _topBarHeight = 96;
  135. public double TopBarHeight
  136. {
  137. get => _topBarHeight;
  138. set => SetProperty(ref _topBarHeight, value);
  139. }
  140. private double _centerTitleFont = 48;
  141. public double CenterTitleFont
  142. {
  143. get => _centerTitleFont;
  144. set => SetProperty(ref _centerTitleFont, value);
  145. }
  146. private double _statusBarHeight = 38;
  147. public double StatusBarHeight
  148. {
  149. get => _statusBarHeight;
  150. set => SetProperty(ref _statusBarHeight, value);
  151. }
  152. private double _statusBarFont = 16;
  153. public double StatusBarFont
  154. {
  155. get => _statusBarFont;
  156. set => SetProperty(ref _statusBarFont, value);
  157. }
  158. private double _navButtonWidth = 88;
  159. public double NavButtonWidth
  160. {
  161. get => _navButtonWidth;
  162. set => SetProperty(ref _navButtonWidth, value);
  163. }
  164. private double _navButtonHeight = 80;
  165. public double NavButtonHeight
  166. {
  167. get => _navButtonHeight;
  168. set => SetProperty(ref _navButtonHeight, value);
  169. }
  170. private double _navButtonFont = 23;
  171. public double NavButtonFont
  172. {
  173. get => _navButtonFont;
  174. set => SetProperty(ref _navButtonFont, value);
  175. }
  176. private double _themeIconSize = 33;
  177. public double ThemeIconSize
  178. {
  179. get => _themeIconSize;
  180. set => SetProperty(ref _themeIconSize, value);
  181. }
  182. private double _navIconSize = 38;
  183. public double NavIconSize
  184. {
  185. get => _navIconSize;
  186. set => SetProperty(ref _navIconSize, value);
  187. }
  188. }
  189. }