DecimalScope.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using SmartCoalApplication.Base;
  2. using SmartCoalApplication.Core.CustomControl;
  3. using SmartCoalApplication.CustomControl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Windows.Forms;
  7. namespace SmartCoalApplication.Core.Param
  8. {
  9. /// <summary>
  10. /// 多个范围输入框
  11. /// </summary>
  12. public class DecimalScope : Args
  13. {
  14. private int min;
  15. private int max;
  16. public void numberScope_ValueChanged(object sender, EventArgs e)
  17. {
  18. if (sender.GetType() == typeof(DecimalScopeControl))
  19. {
  20. if(((DecimalScopeControl)sender).Tag == null)
  21. {
  22. ((List<double>)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
  23. ((List<double>)this.Value)[1] = ((DecimalScopeControl)sender).maxValue;
  24. }
  25. else
  26. {
  27. if (((NumericUpDown)sender).Tag.ToString().Equals("Min"))
  28. ((List<double>)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
  29. if (((NumericUpDown)sender).Tag.ToString().Equals("Max"))
  30. ((List<double>)this.Value)[1] = ((DecimalScopeControl)sender).maxValue;
  31. }
  32. }
  33. else if (sender.GetType() == typeof(System.Windows.Forms.NumericUpDown))
  34. {
  35. if(((System.Windows.Forms.NumericUpDown)sender).Tag.ToString() == "min")
  36. {
  37. ((List<double>)this.Value)[0] = (double)((System.Windows.Forms.NumericUpDown)sender).Value;
  38. }
  39. else if(((System.Windows.Forms.NumericUpDown)sender).Tag.ToString() == "max")
  40. {
  41. double val = (double)((System.Windows.Forms.NumericUpDown)sender).Value;
  42. if (val <= max)
  43. {
  44. ((List<double>)this.Value)[1] = val;
  45. }
  46. else {
  47. ((List<double>)this.Value)[1] = max;
  48. ((System.Windows.Forms.NumericUpDown)sender).Value = max;
  49. }
  50. }
  51. }
  52. }
  53. public DecimalScope(int min, int max, int initValues, string key, string name)
  54. {
  55. this.Type = Dtryt.DecimalScope;
  56. this.min = min;
  57. this.max = max;
  58. this.initialValue = initValues;
  59. //初始化参数集合
  60. List<double> valueL = new List<double>();
  61. valueL.Add(initValues);
  62. valueL.Add(initValues);
  63. this.value = valueL;
  64. this.key = key;
  65. this.name = name;
  66. }
  67. public DecimalScope(int min, int max)
  68. {
  69. this.Type = Dtryt.DecimalScope;
  70. this.min = min;
  71. this.max = max;
  72. }
  73. public int Min
  74. {
  75. get
  76. {
  77. return this.min;
  78. }
  79. set
  80. {
  81. this.min = value;
  82. }
  83. }
  84. public int Max
  85. {
  86. get
  87. {
  88. return this.max;
  89. }
  90. set
  91. {
  92. this.max = value;
  93. }
  94. }
  95. }
  96. }