123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using PaintDotNet.Base;
- using PaintDotNet.CustomControl;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- namespace PaintDotNet.Data.Param
- {
- /// <summary>
- /// 多个范围输入框
- /// </summary>
- public class DecimalScope : Args
- {
- private int min;
- private int max;
- public void numberScope_ValueChanged(object sender, EventArgs e)
- {
- if (sender.GetType() == typeof(DecimalScopeControl))
- {
- if(((DecimalScopeControl)sender).Tag == null)
- {
- ((List<double>)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
- ((List<double>)this.Value)[1] = ((DecimalScopeControl)sender).maxValue;
- }
- else
- {
- if (((NumericUpDown)sender).Tag.ToString().Equals("Min"))
- ((List<double>)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
- if (((NumericUpDown)sender).Tag.ToString().Equals("Max"))
- ((List<double>)this.Value)[1] = ((DecimalScopeControl)sender).maxValue;
- }
- }
- else if (sender.GetType() == typeof(System.Windows.Forms.NumericUpDown))
- {
- if(((System.Windows.Forms.NumericUpDown)sender).Tag.ToString() == "min")
- {
- ((List<double>)this.Value)[0] = (double)((System.Windows.Forms.NumericUpDown)sender).Value;
- }
- else if(((System.Windows.Forms.NumericUpDown)sender).Tag.ToString() == "max")
- {
- double val = (double)((System.Windows.Forms.NumericUpDown)sender).Value;
- if (val <= max)
- {
- ((List<double>)this.Value)[1] = val;
- }
- else {
- ((List<double>)this.Value)[1] = max;
- ((System.Windows.Forms.NumericUpDown)sender).Value = max;
- }
- }
- }
- }
- public DecimalScope(int min, int max, int initValues, string key, string name)
- {
- this.Type = Dtryt.DecimalScope;
- this.min = min;
- this.max = max;
- this.initialValue = initValues;
- //初始化参数集合
- List<double> valueL = new List<double>();
- valueL.Add(initValues);
- valueL.Add(initValues);
- this.value = valueL;
- this.key = key;
- this.name = name;
- }
- public DecimalScope(int min, int max)
- {
- this.Type = Dtryt.DecimalScope;
- this.min = min;
- this.max = max;
- }
- public int Min
- {
- get
- {
- return this.min;
- }
- set
- {
- this.min = value;
- }
- }
- public int Max
- {
- get
- {
- return this.max;
- }
- set
- {
- this.max = value;
- }
- }
- }
- }
|