try2
This commit is contained in:
parent
6fa97bdc0a
commit
7d7ce6cb91
@ -1,6 +1,6 @@
|
|||||||
namespace Library15Gerimovich
|
namespace Library15Gerimovich
|
||||||
{
|
{
|
||||||
partial class DefoltList
|
partial class DefaultList
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обязательная переменная конструктора.
|
/// Обязательная переменная конструктора.
|
@ -10,7 +10,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Library15Gerimovich
|
namespace Library15Gerimovich
|
||||||
{
|
{
|
||||||
public partial class DefoltList : UserControl
|
public partial class DefaultList : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler? SelectedValueChanged;
|
public event EventHandler? SelectedValueChanged;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace Library15Gerimovich
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefoltList()
|
public DefaultList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
15
Library15Gerimovich/Exceptions/EmptyValueException.cs
Normal file
15
Library15Gerimovich/Exceptions/EmptyValueException.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Library15Gerimovich.Exceptions
|
||||||
|
{
|
||||||
|
public class EmptyValueException : ApplicationException
|
||||||
|
{
|
||||||
|
public EmptyValueException()
|
||||||
|
: base("Значение не введено")
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
15
Library15Gerimovich/Exceptions/MalformedRealException.cs
Normal file
15
Library15Gerimovich/Exceptions/MalformedRealException.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Library15Gerimovich.Exceptions
|
||||||
|
{
|
||||||
|
public class MalformedRealException : ApplicationException
|
||||||
|
{
|
||||||
|
public MalformedRealException()
|
||||||
|
: base("Введенное значение не является вещественным")
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
18
Library15Gerimovich/InputRealNumber.Designer.cs
generated
18
Library15Gerimovich/InputRealNumber.Designer.cs
generated
@ -29,25 +29,34 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.IsNullCheckBox = new System.Windows.Forms.CheckBox();
|
this.IsNullCheckBox = new System.Windows.Forms.CheckBox();
|
||||||
|
this.MainTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// IsNullCheckBox
|
// IsNullCheckBox
|
||||||
//
|
//
|
||||||
this.IsNullCheckBox.AutoSize = true;
|
this.IsNullCheckBox.AutoSize = true;
|
||||||
this.IsNullCheckBox.Location = new System.Drawing.Point(42, 103);
|
this.IsNullCheckBox.Location = new System.Drawing.Point(3, 62);
|
||||||
this.IsNullCheckBox.Name = "IsNullCheckBox";
|
this.IsNullCheckBox.Name = "IsNullCheckBox";
|
||||||
this.IsNullCheckBox.Size = new System.Drawing.Size(83, 19);
|
this.IsNullCheckBox.Size = new System.Drawing.Size(127, 19);
|
||||||
this.IsNullCheckBox.TabIndex = 0;
|
this.IsNullCheckBox.TabIndex = 0;
|
||||||
this.IsNullCheckBox.Text = "checkBox1";
|
this.IsNullCheckBox.Text = "Нулевое значение";
|
||||||
this.IsNullCheckBox.UseVisualStyleBackColor = true;
|
this.IsNullCheckBox.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// MainTextBox
|
||||||
|
//
|
||||||
|
this.MainTextBox.Location = new System.Drawing.Point(3, 20);
|
||||||
|
this.MainTextBox.Name = "MainTextBox";
|
||||||
|
this.MainTextBox.Size = new System.Drawing.Size(127, 23);
|
||||||
|
this.MainTextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
// InputRealNumber
|
// InputRealNumber
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.MainTextBox);
|
||||||
this.Controls.Add(this.IsNullCheckBox);
|
this.Controls.Add(this.IsNullCheckBox);
|
||||||
this.Name = "InputRealNumber";
|
this.Name = "InputRealNumber";
|
||||||
this.Size = new System.Drawing.Size(188, 187);
|
this.Size = new System.Drawing.Size(135, 101);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@ -56,5 +65,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private CheckBox IsNullCheckBox;
|
private CheckBox IsNullCheckBox;
|
||||||
|
private TextBox MainTextBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,85 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Library15Gerimovich.Exceptions;
|
||||||
|
|
||||||
namespace Library15Gerimovich
|
namespace Library15Gerimovich
|
||||||
{
|
{
|
||||||
public partial class InputRealNumber : UserControl
|
public partial class InputRealNumber : UserControl
|
||||||
{
|
{
|
||||||
|
private event EventHandler? _valueChanged;
|
||||||
|
|
||||||
public InputRealNumber()
|
public InputRealNumber()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Установка и получение введенного значения
|
||||||
|
/// </summary>
|
||||||
|
public int? IntValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsNullCheckBox.Checked)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(MainTextBox.Text))
|
||||||
|
{
|
||||||
|
throw new EmptyValueException();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ParsedInt;
|
||||||
|
if (Int32.TryParse(MainTextBox.Text, out ParsedInt))
|
||||||
|
{
|
||||||
|
return ParsedInt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new MalformedRealException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetNullState(value is null, true);
|
||||||
|
if (value is not null)
|
||||||
|
{
|
||||||
|
MainTextBox.Text = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие, вызываемое при смене значения (либо при смене CheckBox)
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler? ValueChanged
|
||||||
|
{
|
||||||
|
add { _valueChanged += value; }
|
||||||
|
remove { _valueChanged -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNullState(bool IsNull, bool ClearText = false)
|
||||||
|
{
|
||||||
|
IsNullCheckBox.Checked = IsNull;
|
||||||
|
MainTextBox.Enabled = !IsNull;
|
||||||
|
|
||||||
|
if (ClearText)
|
||||||
|
{
|
||||||
|
MainTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void IsNullCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SetNullState(IsNullCheckBox.Checked);
|
||||||
|
_valueChanged?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainTextBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_valueChanged?.Invoke(this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
Library15Gerimovich/Models/CustomDataTableColumnParameter.cs
Normal file
13
Library15Gerimovich/Models/CustomDataTableColumnParameter.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace Library15Gerimovich.Models
|
||||||
|
{
|
||||||
|
public record CustomDataTableColumnParameter
|
||||||
|
{
|
||||||
|
public string HeaderName { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
public int Width { get; init; } = 0;
|
||||||
|
|
||||||
|
public bool Visible { get; init; } = true;
|
||||||
|
|
||||||
|
public string PropertyName { get; init; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Library15Gerimovich.Models;
|
||||||
|
|
||||||
namespace Library15Gerimovich
|
namespace Library15Gerimovich
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user