2023-09-20 23:39:46 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace WinFormsLibrary
|
|
|
|
|
{
|
|
|
|
|
public partial class NumberTextBox : UserControl
|
|
|
|
|
{
|
2023-09-21 10:49:09 +04:00
|
|
|
|
public int maxValue;
|
|
|
|
|
public int minValue;
|
|
|
|
|
public bool error = false;
|
|
|
|
|
|
2023-09-20 23:39:46 +04:00
|
|
|
|
public NumberTextBox()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2023-09-21 10:49:09 +04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//публичное свойство
|
|
|
|
|
public string Selected
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (minValue == null)
|
|
|
|
|
{
|
|
|
|
|
error = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maxValue == null)
|
|
|
|
|
{
|
|
|
|
|
error = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Check_Value(Convert.ToInt32(numericUpDown.Value)))
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return numericUpDown.Value.ToString();
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (!Check_Value(Convert.ToInt32(numericUpDown.Value)))
|
|
|
|
|
{
|
|
|
|
|
error = true;
|
|
|
|
|
}
|
|
|
|
|
numericUpDown.Value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMaxValue(int number) // переделать через свойство
|
|
|
|
|
{
|
|
|
|
|
numericUpDown.Maximum = number;
|
|
|
|
|
maxValue = number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMinValue(int number) // переделать через свойство
|
|
|
|
|
{
|
|
|
|
|
numericUpDown.Minimum = number;
|
|
|
|
|
minValue = number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Check_Value(int number)
|
|
|
|
|
{
|
|
|
|
|
if (number < numericUpDown.Minimum || number > numericUpDown.Maximum)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2023-09-20 23:39:46 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|