2023-09-21 17:03:20 +04:00
|
|
|
|
using CustomComponents.Exceptions;
|
|
|
|
|
using System;
|
2023-09-09 14:11:29 +04:00
|
|
|
|
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 CustomComponents
|
|
|
|
|
{
|
|
|
|
|
public partial class frameTextBox : UserControl
|
|
|
|
|
{
|
|
|
|
|
private string? _text;
|
2023-09-21 17:03:20 +04:00
|
|
|
|
|
|
|
|
|
public event EventHandler taskHandler;
|
|
|
|
|
|
2023-09-09 14:11:29 +04:00
|
|
|
|
public frameTextBox()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string? Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _text;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_text = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckBoxStateChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-09-21 17:03:20 +04:00
|
|
|
|
try
|
2023-09-09 14:11:29 +04:00
|
|
|
|
{
|
2023-09-21 17:03:20 +04:00
|
|
|
|
if (ruleCheckBox.Checked)
|
|
|
|
|
{
|
|
|
|
|
textBox.Enabled = false;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_text))
|
|
|
|
|
{
|
|
|
|
|
throw new ContentException(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2023-09-09 14:11:29 +04:00
|
|
|
|
{
|
2023-09-21 17:03:20 +04:00
|
|
|
|
textBox.Enabled = true;
|
|
|
|
|
if (string.IsNullOrEmpty(_text))
|
|
|
|
|
{
|
|
|
|
|
throw new ContentException(false);
|
|
|
|
|
}
|
2023-09-09 14:11:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-21 17:03:20 +04:00
|
|
|
|
catch(ContentException ex)
|
2023-09-09 14:11:29 +04:00
|
|
|
|
{
|
2023-09-21 17:03:20 +04:00
|
|
|
|
taskHandler += (sender, e) => MessageBox.Show(ex.Message);
|
2023-09-09 14:11:29 +04:00
|
|
|
|
}
|
2023-09-21 17:03:20 +04:00
|
|
|
|
taskHandler?.Invoke(this, e);
|
|
|
|
|
|
2023-09-09 14:11:29 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckTextBoxValueType(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Value = textBox.Text;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Convert.ToInt32(Value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|