using PaintDotNet.Base;
using PaintDotNet.CustomControl;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace PaintDotNet.Data.Param
{
///
/// 多个范围输入框
///
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)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
((List)this.Value)[1] = ((DecimalScopeControl)sender).maxValue;
}
else
{
if (((NumericUpDown)sender).Tag.ToString().Equals("Min"))
((List)this.Value)[0] = ((DecimalScopeControl)sender).minValue;
if (((NumericUpDown)sender).Tag.ToString().Equals("Max"))
((List)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)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)this.Value)[1] = val;
}
else {
((List)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 valueL = new List();
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;
}
}
}
}