版博士V2.0程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

59 linhas
2.0 KiB

  1. using MaiMuAOI.SysUI.StepUI.PropExtend;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  10. {
  11. public class LightProp
  12. {
  13. [PropertyOrder(1), Browsable(true), Category("1 参数"), DisplayName("1.1 通道"), Description("选择光源通道")]
  14. public int ChannelIndex { get; set; } = 1;
  15. [PropertyOrder(2), Browsable(true), Category("1 参数"), DisplayName("1.2 亮度"), Description("设置光源亮度")]
  16. public int DigitalValue { get; set; }
  17. [PropertyOrder(6), Browsable(true), Category("2 控制"), DisplayName("2.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  18. public bool Disable { get; set; }
  19. public LightProp()
  20. {
  21. ChannelIndex = 1;
  22. DigitalValue = 100;
  23. Disable = false;
  24. }
  25. /// <summary>
  26. /// 序列化
  27. /// </summary>
  28. /// <param name="obj"></param>
  29. /// <returns></returns>
  30. public string serialize()
  31. {
  32. return JsonConvert.SerializeObject(this);
  33. }
  34. /// <summary>
  35. /// 反序列化
  36. /// </summary>
  37. /// <param name="json"></param>
  38. /// <returns></returns>
  39. public void deserialize(string json)
  40. {
  41. var o = JsonConvert.DeserializeObject<LightProp>(json);
  42. Type type = o.GetType();
  43. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  44. foreach (System.Reflection.PropertyInfo property in properties)
  45. {
  46. string name = property.Name;
  47. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  48. {
  49. var value = property.GetValue(o);
  50. this.GetType().GetProperty(name).SetValue(this, value);
  51. }
  52. }
  53. }
  54. }
  55. }