ChoiseArray.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using SmartCoalApplication.Base;
  2. using SmartCoalApplication.Core.Param;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows.Forms;
  6. namespace SmartCoalApplication.Core.Param
  7. {
  8. /// <summary>
  9. /// 抉择类型,针对脚本
  10. /// 使用其下的choiseList数据
  11. /// </summary>
  12. public class ChoiseArray : Args
  13. {
  14. /// <summary>
  15. /// 设置参数的方案:0(默认方案,使用[index+initial]的赋值方式); 1(晶粒度辅助线处使用,选项中key和value都是辅助线名称,通过辅助线名称给value赋值)
  16. /// </summary>
  17. public int valueType = 0;
  18. public void numberParam_ValueChanged(object sender, EventArgs e)
  19. {
  20. if (sender.GetType() == typeof(Button))
  21. {
  22. if (((Button)sender).Text == "反选")
  23. {
  24. this.Value = 0;
  25. for (int i = 0; i < this.choiseList.Count; i++)
  26. {
  27. Args args = this.choiseList[i];
  28. if (i == 0)
  29. {
  30. args.Value = 1;
  31. }
  32. else
  33. {
  34. args.Value = 0;
  35. }
  36. }
  37. }
  38. else//取消反选
  39. {
  40. this.Value = 1;
  41. //((Button)sender).Select
  42. for (int i = 0; i < this.choiseList.Count; i++)
  43. {
  44. Args args = this.choiseList[i];
  45. if (i == 1)
  46. {
  47. args.Value = 1;
  48. }
  49. else
  50. {
  51. args.Value = 0;
  52. }
  53. }
  54. }
  55. //}
  56. //else if (sender.GetType() == typeof(NumericUpDown))
  57. //{
  58. // this.Value = (int)((NumericUpDown)sender).Value;
  59. }
  60. else if(sender.GetType() == typeof(RadioButton))
  61. {
  62. if (((RadioButton)sender).Checked)
  63. this.value = ((RadioButton)sender).Tag;// (Enum)(((RadioButton)sender).Tag);
  64. }
  65. }
  66. public ChoiseArray(string key, string name, BooleanObject[] arr)
  67. {
  68. this.Type = Dtryt.Choise;
  69. this.initialValue = 0;
  70. this.value = 0;
  71. this.key = key;
  72. this.name = name;
  73. if(arr!=null)
  74. {
  75. this.choiseList = new List<Args>(arr);
  76. }
  77. }
  78. public ChoiseArray(string key, string name, BooleanObject[] arr,object value)
  79. {
  80. this.Type = Dtryt.Choise;
  81. this.initialValue = 0;
  82. this.value = value;
  83. this.key = key;
  84. this.name = name;
  85. if (arr != null)
  86. {
  87. this.choiseList = new List<Args>(arr);
  88. }
  89. }
  90. //public ChoiseArray(List<Args> list)
  91. //{
  92. // this.Type = Dtryt.Choise;
  93. // this.choiseList = list;
  94. // this.Value = 0;
  95. //}
  96. }
  97. }