ChoiseArray.cs 3.1 KB

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