using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace JwKdsV.Component
{
public partial class NumSpinners : UserControl
{
public NumSpinners()
{
InitializeComponent();
}
private decimal _defaultValue = 0;
[Category("杂项"), Description("默认值"), DefaultValue(0)]
public decimal DefaultValue
{
get
{
return _defaultValue;
}
set
{
_defaultValue = value;
this.textBox1.Text = _defaultValue + "";
}
}
[Category("杂项"), Description("步长,每次增减标准"), DefaultValue(1)]
public decimal StepValue { get; set; }
[Category("杂项"), Description("最大值"), DefaultValue(100)]
public decimal MaxValue { get; set; }
[Category("杂项"), Description("最小值"), DefaultValue(0)]
public decimal MinValue { get; set; }
public decimal NumValue
{
get
{
var test = this.textBox1.Text;
decimal value = 0;
decimal.TryParse(test, out value);
this.textBox1.Text = value + "";
return value;
}
}
///
/// 减法
///
///
///
private void OnSubClick(object sender, EventArgs e)
{
if(this.NumValue - this.StepValue >= this.MinValue)
{
this.textBox1.Text = (this.NumValue - this.StepValue).ToString();
}
}
///
/// 加法
///
///
///
private void OnPlusClick(object sender, EventArgs e)
{
if (this.NumValue + this.StepValue <= this.MaxValue)
{
this.textBox1.Text = (this.NumValue + this.StepValue).ToString();
}
}
}
}