ChannelConfig.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace TeamAAS_VP.Models.Lights
  8. {
  9. /// <summary>
  10. /// 表示单个灯通道的配置项。
  11. /// 包含通道名称、描述、控制器内索引、系统全局索引以及默认亮度等信息。
  12. /// 该类继承自 <see cref="BindableBase"/>,支持属性变更通知,适用于 WPF 数据绑定。
  13. /// </summary>
  14. public class ChannelConfig: BindableBase
  15. {
  16. private string _Name;
  17. /// <summary>
  18. /// 通道名称。
  19. /// 用于界面显示和识别通道,可为空字符串。
  20. /// </summary>
  21. public string Name
  22. {
  23. get { return _Name; }
  24. set { SetProperty(ref _Name, value); }
  25. }
  26. private string _Description;
  27. /// <summary>
  28. /// 通道描述。
  29. /// 对通道的补充说明,可用于显示在工具提示或详细信息面板中。
  30. /// </summary>
  31. public string Description
  32. {
  33. get { return _Description; }
  34. set { SetProperty(ref _Description, value); }
  35. }
  36. private int _LocalIndex;
  37. /// <summary>
  38. /// 控制器内的通道索引(局部索引)。
  39. /// 表示该通道在所属控制器中的位置,通常从 0 或 1 开始,取决于系统约定。
  40. /// </summary>
  41. public int LocalIndex
  42. {
  43. get { return _LocalIndex; }
  44. set { SetProperty(ref _LocalIndex, value); }
  45. }
  46. private int _GlobalIndex;
  47. /// <summary>
  48. /// 系统中的全局通道索引(全局唯一)。
  49. /// 在多控制器环境中用于唯一标识一个通道。
  50. /// </summary>
  51. public int GlobalIndex
  52. {
  53. get { return _GlobalIndex; }
  54. set { SetProperty(ref _GlobalIndex, value); }
  55. }
  56. private int _DefaultBrightness = 255;
  57. /// <summary>
  58. /// 默认亮度(百分比)。
  59. /// 范围通常为 0 到 100,表示通道的默认亮度设置。默认值为 100(表示最大亮度)。
  60. /// </summary>
  61. public int DefaultBrightness
  62. {
  63. get { return _DefaultBrightness; }
  64. set { SetProperty(ref _DefaultBrightness, value); }
  65. }
  66. /// <summary>
  67. /// 初始化 <see cref="ChannelConfig"/> 的新实例。
  68. /// 创建一个默认的通道配置对象,属性使用默认值。
  69. /// </summary>
  70. public ChannelConfig()
  71. {
  72. }
  73. /// <summary>
  74. /// 使用指定的索引和可选信息初始化 <see cref="ChannelConfig"/> 的新实例。
  75. /// </summary>
  76. /// <param name="localIndex">控制器内的通道索引(局部索引)。</param>
  77. /// <param name="globalIndex">系统中的全局通道索引(全局唯一)。</param>
  78. /// <param name="name">通道名称,可选,默认为空字符串。</param>
  79. /// <param name="description">通道描述,可选,默认为空字符串。</param>
  80. /// <param name="defaultBrightness">默认亮度(百分比),可选,默认值为 100。期望范围为 0 到 100。</param>
  81. public ChannelConfig(int localIndex, int globalIndex, string name = "", string description = "", int defaultBrightness = 100)
  82. {
  83. LocalIndex = localIndex;
  84. GlobalIndex = globalIndex;
  85. Name = name;
  86. Description = description;
  87. DefaultBrightness = defaultBrightness;
  88. }
  89. }
  90. public class ChannelConfigEx: ChannelConfig
  91. {
  92. //是否选中
  93. private bool _IsSelected;
  94. public bool IsSelected
  95. {
  96. get { return _IsSelected; }
  97. set { SetProperty(ref _IsSelected, value); }
  98. }
  99. public ChannelConfigEx() : base()
  100. {
  101. }
  102. public ChannelConfigEx(ChannelConfig channelConfig)
  103. {
  104. this.LocalIndex = channelConfig.LocalIndex;
  105. this.GlobalIndex = channelConfig.GlobalIndex;
  106. this.Name = channelConfig.Name;
  107. this.Description = channelConfig.Description;
  108. this.DefaultBrightness = channelConfig.DefaultBrightness;
  109. }
  110. public ChannelConfig ToChannelConfig()
  111. {
  112. return new ChannelConfig(this.LocalIndex, this.GlobalIndex, this.Name, this.Description, this.DefaultBrightness);
  113. }
  114. }
  115. }