DecimalScope.cs 3.1 KB

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