do
This commit is contained in:
parent
7d7ce6cb91
commit
a9749528c7
28
Library15Gerimovich/DefaultList.Designer.cs
generated
28
Library15Gerimovich/DefaultList.Designer.cs
generated
@ -28,30 +28,34 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.listBox = new System.Windows.Forms.ListBox();
|
this.MainListBox = new System.Windows.Forms.ListBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// listBox
|
// MainListBox
|
||||||
//
|
//
|
||||||
this.listBox.FormattingEnabled = true;
|
this.MainListBox.FormattingEnabled = true;
|
||||||
this.listBox.ItemHeight = 15;
|
this.MainListBox.ItemHeight = 15;
|
||||||
this.listBox.Location = new System.Drawing.Point(3, 3);
|
this.MainListBox.Items.AddRange(new object[] {
|
||||||
this.listBox.Name = "listBox";
|
"RITG",
|
||||||
this.listBox.Size = new System.Drawing.Size(144, 109);
|
"SimbirSoft",
|
||||||
this.listBox.TabIndex = 0;
|
"MediaSoft"});
|
||||||
|
this.MainListBox.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.MainListBox.Name = "MainListBox";
|
||||||
|
this.MainListBox.Size = new System.Drawing.Size(144, 109);
|
||||||
|
this.MainListBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// DefoltList
|
// DefaultList
|
||||||
//
|
//
|
||||||
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.listBox);
|
this.Controls.Add(this.MainListBox);
|
||||||
this.Name = "DefoltList";
|
this.Name = "DefaultList";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ListBox listBox;
|
private ListBox MainListBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,47 +12,91 @@ namespace Library15Gerimovich
|
|||||||
{
|
{
|
||||||
public partial class DefaultList : UserControl
|
public partial class DefaultList : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler? SelectedValueChanged;
|
private event EventHandler? _itemSelected;
|
||||||
|
|
||||||
public string SelectedValue
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
int index = checkedListBox1.Items.IndexOf(value);
|
|
||||||
if (index >= 0)
|
|
||||||
{
|
|
||||||
checkedListBox1.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
checkedListBox1.ClearSelected();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DefaultList()
|
public DefaultList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddItemToList(string item)
|
|
||||||
|
// метод, передающий строку
|
||||||
|
public void SetItems(string Items)
|
||||||
{
|
{
|
||||||
ListBox.Items.Add(item);
|
string[] itemArray = Items.Split(','); // разбиваем по запятым
|
||||||
|
|
||||||
|
MainListBox.Items.Clear();
|
||||||
|
|
||||||
|
foreach (var item in itemArray)
|
||||||
|
{
|
||||||
|
MainListBox.Items.Add(item.Trim()); // Trim для удаления пробелов
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ClearList()
|
||||||
|
{
|
||||||
|
MainListBox.Items.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedIndexChanged(object sender, EventArgs e)
|
// установка, получение выбранного элемента
|
||||||
|
public string SelectedItem
|
||||||
{
|
{
|
||||||
SelectedValueChanged?.Invoke(this, e);
|
get { return (string?)MainListBox.SelectedItem ?? string.Empty; }
|
||||||
|
set { MainListBox.SelectedItem = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearComboBox()
|
public event EventHandler? ItemSelected
|
||||||
{
|
{
|
||||||
checkedListBox1.Items.Clear();
|
add { _itemSelected += value; }
|
||||||
|
remove { _itemSelected -= value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// контролируем смену значений
|
||||||
|
private void MainListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_itemSelected?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public event EventHandler? SelectedValueChanged;
|
||||||
|
|
||||||
|
//public string SelectedValue
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
||||||
|
// }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// int index = checkedListBox1.Items.IndexOf(value);
|
||||||
|
// if (index >= 0)
|
||||||
|
// {
|
||||||
|
// checkedListBox1.SelectedIndex = index;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// checkedListBox1.ClearSelected();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public DefaultList()
|
||||||
|
//{
|
||||||
|
// InitializeComponent();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public void AddItemToList(string item)
|
||||||
|
//{
|
||||||
|
// ListBox.Items.Add(item);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private void SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
//{
|
||||||
|
// SelectedValueChanged?.Invoke(this, e);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public void ClearComboBox()
|
||||||
|
//{
|
||||||
|
// checkedListBox1.Items.Clear();
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
Library15Gerimovich/InputRealNumber.Designer.cs
generated
2
Library15Gerimovich/InputRealNumber.Designer.cs
generated
@ -41,6 +41,7 @@
|
|||||||
this.IsNullCheckBox.TabIndex = 0;
|
this.IsNullCheckBox.TabIndex = 0;
|
||||||
this.IsNullCheckBox.Text = "Нулевое значение";
|
this.IsNullCheckBox.Text = "Нулевое значение";
|
||||||
this.IsNullCheckBox.UseVisualStyleBackColor = true;
|
this.IsNullCheckBox.UseVisualStyleBackColor = true;
|
||||||
|
this.IsNullCheckBox.CheckedChanged += new System.EventHandler(this.IsNullCheckBox_CheckedChanged);
|
||||||
//
|
//
|
||||||
// MainTextBox
|
// MainTextBox
|
||||||
//
|
//
|
||||||
@ -48,6 +49,7 @@
|
|||||||
this.MainTextBox.Name = "MainTextBox";
|
this.MainTextBox.Name = "MainTextBox";
|
||||||
this.MainTextBox.Size = new System.Drawing.Size(127, 23);
|
this.MainTextBox.Size = new System.Drawing.Size(127, 23);
|
||||||
this.MainTextBox.TabIndex = 1;
|
this.MainTextBox.TabIndex = 1;
|
||||||
|
this.MainTextBox.TextChanged += new System.EventHandler(this.MainTextBox_TextChanged);
|
||||||
//
|
//
|
||||||
// InputRealNumber
|
// InputRealNumber
|
||||||
//
|
//
|
||||||
|
@ -20,10 +20,7 @@ namespace Library15Gerimovich
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public double? DoubleValue
|
||||||
/// Установка и получение введенного значения
|
|
||||||
/// </summary>
|
|
||||||
public int? IntValue
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -37,10 +34,10 @@ namespace Library15Gerimovich
|
|||||||
throw new EmptyValueException();
|
throw new EmptyValueException();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ParsedInt;
|
double ParsedDouble;
|
||||||
if (Int32.TryParse(MainTextBox.Text, out ParsedInt))
|
if (double.TryParse(MainTextBox.Text, out ParsedDouble))
|
||||||
{
|
{
|
||||||
return ParsedInt;
|
return ParsedDouble;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -57,9 +54,6 @@ namespace Library15Gerimovich
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Событие, вызываемое при смене значения (либо при смене CheckBox)
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler? ValueChanged
|
public event EventHandler? ValueChanged
|
||||||
{
|
{
|
||||||
add { _valueChanged += value; }
|
add { _valueChanged += value; }
|
||||||
|
@ -68,30 +68,30 @@ namespace Library15Gerimovich
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TType? GetRow<TType>(int rowIndex)
|
//public TType? GetRow<TType>(int rowIndex)
|
||||||
{
|
//{
|
||||||
Type type = typeof(TType);
|
// Type type = typeof(TType);
|
||||||
var element = type.GetConstructor([])?.Invoke([]);
|
// var element = type.GetConstructor([])?.Invoke([]);
|
||||||
|
|
||||||
if (element is null)
|
// if (element is null)
|
||||||
{
|
// {
|
||||||
return default;
|
// return default;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var row = dataGridViewOut.Rows[rowIndex].Cells;
|
// var row = dataGridViewOut.Rows[rowIndex].Cells;
|
||||||
|
|
||||||
for (int i = 0; i < dataGridViewOut.ColumnCount; i++)
|
// for (int i = 0; i < dataGridViewOut.ColumnCount; i++)
|
||||||
{
|
// {
|
||||||
if (string.IsNullOrEmpty(_columnsFildsNames[i]))
|
// if (string.IsNullOrEmpty(_columnsFildsNames[i]))
|
||||||
{
|
// {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
var field = type.GetProperty(_columnsFildsNames[i]);
|
// var field = type.GetProperty(_columnsFildsNames[i]);
|
||||||
field?.SetValue(element, row[i].Value);
|
// field?.SetValue(element, row[i].Value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (TType)element;
|
// return (TType)element;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public void Fill<TType>(IList<TType> insertValues)
|
public void Fill<TType>(IList<TType> insertValues)
|
||||||
{
|
{
|
||||||
|
33
WinFormsAppTest/Form1.Designer.cs
generated
33
WinFormsAppTest/Form1.Designer.cs
generated
@ -29,20 +29,48 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.userControl11 = new Library15Gerimovich.UserControl1();
|
this.userControl11 = new Library15Gerimovich.UserControl1();
|
||||||
|
this.defaultList1 = new Library15Gerimovich.DefaultList();
|
||||||
|
this.inputRealNumber1 = new Library15Gerimovich.InputRealNumber();
|
||||||
|
this.outputTableResults1 = new Library15Gerimovich.OutputTableResults();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// userControl11
|
// userControl11
|
||||||
//
|
//
|
||||||
this.userControl11.Location = new System.Drawing.Point(54, 19);
|
this.userControl11.Avatar = null;
|
||||||
|
this.userControl11.Location = new System.Drawing.Point(12, 242);
|
||||||
this.userControl11.Name = "userControl11";
|
this.userControl11.Name = "userControl11";
|
||||||
this.userControl11.Size = new System.Drawing.Size(150, 144);
|
this.userControl11.Size = new System.Drawing.Size(150, 144);
|
||||||
this.userControl11.TabIndex = 0;
|
this.userControl11.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// defaultList1
|
||||||
|
//
|
||||||
|
this.defaultList1.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.defaultList1.Name = "defaultList1";
|
||||||
|
this.defaultList1.Size = new System.Drawing.Size(150, 150);
|
||||||
|
this.defaultList1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// inputRealNumber1
|
||||||
|
//
|
||||||
|
this.inputRealNumber1.Location = new System.Drawing.Point(202, 34);
|
||||||
|
this.inputRealNumber1.Name = "inputRealNumber1";
|
||||||
|
this.inputRealNumber1.Size = new System.Drawing.Size(135, 101);
|
||||||
|
this.inputRealNumber1.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// outputTableResults1
|
||||||
|
//
|
||||||
|
this.outputTableResults1.Location = new System.Drawing.Point(422, 34);
|
||||||
|
this.outputTableResults1.Name = "outputTableResults1";
|
||||||
|
this.outputTableResults1.Size = new System.Drawing.Size(259, 245);
|
||||||
|
this.outputTableResults1.TabIndex = 3;
|
||||||
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
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.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.outputTableResults1);
|
||||||
|
this.Controls.Add(this.inputRealNumber1);
|
||||||
|
this.Controls.Add(this.defaultList1);
|
||||||
this.Controls.Add(this.userControl11);
|
this.Controls.Add(this.userControl11);
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
@ -53,5 +81,8 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Library15Gerimovich.UserControl1 userControl11;
|
private Library15Gerimovich.UserControl1 userControl11;
|
||||||
|
private Library15Gerimovich.DefaultList defaultList1;
|
||||||
|
private Library15Gerimovich.InputRealNumber inputRealNumber1;
|
||||||
|
private Library15Gerimovich.OutputTableResults outputTableResults1;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user