Compare commits

...

1 Commits
main ... lab_1

Author SHA1 Message Date
Алексей Крюков
28ddf245dc lab_1 2024-09-22 10:42:52 +04:00
21 changed files with 1314 additions and 0 deletions

6
COP/KryukovLib/Class1.cs Normal file
View File

@ -0,0 +1,6 @@
namespace KryukovLib
{
public class Class1
{
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KryukovLib
{
public class ColumnsConfiguratoin
{
public int ColumnsCount { get; set; }
public string[] NameColumn { get; set; }
public int[] Width { get; set; }
public bool[] Visible { get; set; }
public string[] PropertiesObject { get; set; }
}
}

View File

@ -0,0 +1,63 @@
namespace KryukovLib
{
partial class CustomDataGridView
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
dataGridViewItems = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridViewItems).BeginInit();
SuspendLayout();
//
// dataGridViewItems
//
dataGridViewItems.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridViewItems.BackgroundColor = SystemColors.ButtonHighlight;
dataGridViewItems.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewItems.Location = new Point(0, 0);
dataGridViewItems.Name = "dataGridViewItems";
dataGridViewItems.RowHeadersWidth = 51;
dataGridViewItems.RowTemplate.Height = 29;
dataGridViewItems.Size = new Size(583, 353);
dataGridViewItems.TabIndex = 0;
//
// CustomDataGridView
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(dataGridViewItems);
Margin = new Padding(3, 4, 3, 4);
Name = "CustomDataGridView";
Size = new Size(583, 353);
((System.ComponentModel.ISupportInitialize)dataGridViewItems).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewItems;
}
}

View File

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Forms;
namespace KryukovLib
{
public partial class CustomDataGridView : UserControl
{
private DataGridView dataGridView;
public CustomDataGridView()
{
InitializeComponent();
}
public DataGridViewRowCollection Rows
{
get { return dataGridViewItems.Rows; }
}
public int SelectedRow
{
get { return dataGridViewItems.SelectedRows[0].Index; }
set
{
if (dataGridViewItems.SelectedRows.Count <= value || value < 0)
throw new ArgumentException(string.Format("{0} is an invalid row index.", value));
else
{
dataGridViewItems.ClearSelection();
dataGridViewItems.Rows[value].Selected = true;
}
}
}
public void ClearDataGrid()
{
dataGridViewItems.DataSource = null;
dataGridViewItems.Rows.Clear();
}
public void ConfigColumn(ColumnsConfiguratoin columnsData)
{
dataGridViewItems.ColumnCount = columnsData.ColumnsCount;
for (int i = 0; i < columnsData.ColumnsCount; i++)
{
dataGridViewItems.Columns[i].Name = columnsData.NameColumn[i];
dataGridViewItems.Columns[i].Width = columnsData.Width[i];
dataGridViewItems.Columns[i].Visible = columnsData.Visible[i];
dataGridViewItems.Columns[i].DataPropertyName = columnsData.PropertiesObject[i];
}
}
public T GetSelectedObjectInRow<T>() where T : class, new()
{
T val = new();
var propertiesObj = typeof(T).GetProperties();
foreach (var properties in propertiesObj)
{
bool propIsExist = false;
int columnIndex = 0;
for (; columnIndex < dataGridViewItems.Columns.Count; columnIndex++)
{
if (dataGridViewItems.Columns[columnIndex].DataPropertyName.ToString() == properties.Name)
{
propIsExist = true;
break;
}
}
if (propIsExist)
{
object value = dataGridViewItems.SelectedRows[0].Cells[columnIndex].Value;
properties.SetValue(val, Convert.ChangeType(value, properties?.PropertyType));
};
}
return val;
}
public void AddItem<T>(T item, int RowIndex, int ColumnIndex)
{
if (item == null)
return;
string propertyName = dataGridViewItems.Columns[ColumnIndex].DataPropertyName.ToString();
string? value = item.GetType().GetProperty(propertyName)?.GetValue(item)?.ToString();
if (RowIndex >= dataGridViewItems.Rows.Count)
{
dataGridViewItems.RowCount = RowIndex + 1;
}
dataGridViewItems.Rows[RowIndex].Cells[ColumnIndex].Value = value;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

61
COP/KryukovLib/CustomListBox.Designer.cs generated Normal file
View File

@ -0,0 +1,61 @@

namespace KryukovLib
{
//Список значений. Список заполняется через публичное свойство
partial class CustomListBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
listBoxCustom = new ListBox();
SuspendLayout();
//
// listBoxCustom
//
listBoxCustom.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
listBoxCustom.FormattingEnabled = true;
listBoxCustom.ItemHeight = 20;
listBoxCustom.Location = new Point(0, 0);
listBoxCustom.Name = "listBoxCustom";
listBoxCustom.Size = new Size(245, 224);
listBoxCustom.TabIndex = 0;
//
// CustomListBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBoxCustom);
Margin = new Padding(3, 4, 3, 4);
Name = "CustomListBox";
Size = new Size(245, 252);
ResumeLayout(false);
}
#endregion
private ListBox listBoxCustom;
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace KryukovLib
{
public partial class CustomListBox : UserControl
{
private ListBox listBox;
public CustomListBox()
{
InitializeComponent();
InitializeListBox();
}
private void InitializeListBox()
{
listBox = new ListBox
{
Dock = DockStyle.Fill,
SelectionMode = SelectionMode.One
};
this.Controls.Add(listBox);
}
// Публичное свойство для получения и установки выбранного значения
public string SelectedValue
{
get => listBox.SelectedItem?.ToString() ?? string.Empty;
set
{
if (listBox.Items.Contains(value))
listBox.SelectedItem = value;
}
}
// Публичное свойство для прямого доступа к элементам Items
public ListBox.ObjectCollection ItemCollection
{
get => listBox.Items;
}
// Публичный метод для очистки списка
public void ClearList()
{
listBox.Items.Clear();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,68 @@
namespace KryukovLib
{
partial class DateBoxWithNull
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
checkBoxNull = new CheckBox();
textBoxDate = new TextBox();
SuspendLayout();
//
// checkBoxNull
//
checkBoxNull.AutoSize = true;
checkBoxNull.Location = new Point(4, 8);
checkBoxNull.Name = "checkBoxNull";
checkBoxNull.Size = new Size(18, 17);
checkBoxNull.TabIndex = 0;
checkBoxNull.UseVisualStyleBackColor = true;
//
// textBoxDate
//
textBoxDate.Location = new Point(28, 2);
textBoxDate.Name = "textBoxDate";
textBoxDate.Size = new Size(227, 27);
textBoxDate.TabIndex = 1;
//
// DateBoxWithNull
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBoxDate);
Controls.Add(checkBoxNull);
Name = "DateBoxWithNull";
Size = new Size(267, 36);
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxNull;
private TextBox textBoxDate;
}
}

View File

@ -0,0 +1,58 @@
using System;
using System.Globalization;
using System.Windows.Forms;
namespace KryukovLib
{
public partial class DateBoxWithNull : UserControl
{
public event EventHandler? CombinedEvent;
public Exception? Error;
public DateBoxWithNull()
{
InitializeComponent();
}
public DateTime? Value
{
get
{
if (!checkBoxNull.Checked)
{
if (string.IsNullOrEmpty(textBoxDate.Text))
{
throw new NotFilledException("Text box can't be empty, click checkbox if value must be empty!");
}
if (DateTime.TryParseExact(textBoxDate.Text, "dd.MM.yyyy", null, DateTimeStyles.None, out DateTime parsedDate))
{
return parsedDate;
}
else
{
throw new ParseException($"Wrong format <{textBoxDate.Text}>!");
}
}
return null;
}
set
{
bool isNull = value is null;
checkBoxNull.Checked = isNull;
textBoxDate.Text = isNull ? string.Empty : value?.ToString("dd.MM.yyyy");
}
}
private void TextBoxDate_TextChanged(object sender, EventArgs e)
{
CombinedEvent?.Invoke(sender, e);
}
private void CheckBoxNull_CheckedChanged(object sender, EventArgs e)
{
textBoxDate.Enabled = !checkBoxNull.Checked;
CombinedEvent?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KryukovLib", "KryukovLib.csproj", "{6DEAD422-A1FA-4B5E-A503-DC29B38E6D68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "..\Test\Test.csproj", "{F604D5F3-AB10-416A-A4FB-DD59DD2406D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6DEAD422-A1FA-4B5E-A503-DC29B38E6D68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DEAD422-A1FA-4B5E-A503-DC29B38E6D68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DEAD422-A1FA-4B5E-A503-DC29B38E6D68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DEAD422-A1FA-4B5E-A503-DC29B38E6D68}.Release|Any CPU.Build.0 = Release|Any CPU
{F604D5F3-AB10-416A-A4FB-DD59DD2406D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F604D5F3-AB10-416A-A4FB-DD59DD2406D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F604D5F3-AB10-416A-A4FB-DD59DD2406D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F604D5F3-AB10-416A-A4FB-DD59DD2406D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E1146CA-163B-4CF5-AD14-38B99E730AB0}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KryukovLib
{
public class NotFilledException : Exception
{
public NotFilledException() {}
public NotFilledException(string message) : base(message) {}
public NotFilledException(string message, Exception inner) : base(message, inner) {}
}
}

View File

@ -0,0 +1,9 @@
namespace KryukovLib
{
public class ParseException : Exception
{
public ParseException() { }
public ParseException(string message) : base(message) { }
public ParseException(string message, Exception innerException) : base(message, innerException) { }
}
}

26
COP/Test/Car.cs Normal file
View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public class Car
{
public int Id { get; set; }
public string marka { get; set; } = string.Empty;
public int? weight { get; set; }
public int? maxSpeed { get; set; }
public Car (int id, string marka, int? weight, int? maxSpeed)
{
Id = id;
this.marka = marka;
this.weight = weight;
this.maxSpeed = maxSpeed;
}
public Car() { }
}
}

171
COP/Test/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,171 @@
namespace Test
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
customDataGridView1 = new KryukovLib.CustomDataGridView();
customListBox1 = new KryukovLib.CustomListBox();
dateBoxWithNull1 = new KryukovLib.DateBoxWithNull();
buttonClear = new Button();
buttonLoad = new Button();
buttonClearTable = new Button();
buttonTableAdd = new Button();
buttonGetValue = new Button();
buttonGetValueCheckBox = new Button();
buttonSetValueCheckBox = new Button();
SuspendLayout();
//
// customDataGridView1
//
customDataGridView1.Location = new Point(480, 36);
customDataGridView1.Margin = new Padding(3, 4, 3, 4);
customDataGridView1.Name = "customDataGridView1";
customDataGridView1.Size = new Size(295, 231);
customDataGridView1.TabIndex = 0;
//
// customListBox1
//
customListBox1.Location = new Point(12, 13);
customListBox1.Margin = new Padding(3, 4, 3, 4);
customListBox1.Name = "customListBox1";
customListBox1.SelectedValue = "";
customListBox1.Size = new Size(283, 186);
customListBox1.TabIndex = 1;
//
// dateBoxWithNull1
//
dateBoxWithNull1.Location = new Point(33, 288);
dateBoxWithNull1.Name = "dateBoxWithNull1";
dateBoxWithNull1.Size = new Size(262, 34);
dateBoxWithNull1.TabIndex = 2;
dateBoxWithNull1.Value = null;
//
// buttonClear
//
buttonClear.Location = new Point(201, 206);
buttonClear.Name = "buttonClear";
buttonClear.Size = new Size(94, 29);
buttonClear.TabIndex = 3;
buttonClear.Text = "Clear List";
buttonClear.UseVisualStyleBackColor = true;
buttonClear.Click += buttonClear_Click;
//
// buttonLoad
//
buttonLoad.Location = new Point(12, 206);
buttonLoad.Name = "buttonLoad";
buttonLoad.Size = new Size(94, 29);
buttonLoad.TabIndex = 4;
buttonLoad.Text = "Load List";
buttonLoad.UseVisualStyleBackColor = true;
buttonLoad.Click += buttonLoad_Click;
//
// buttonClearTable
//
buttonClearTable.Location = new Point(480, 293);
buttonClearTable.Name = "buttonClearTable";
buttonClearTable.Size = new Size(94, 29);
buttonClearTable.TabIndex = 5;
buttonClearTable.Text = "Table clear";
buttonClearTable.UseVisualStyleBackColor = true;
buttonClearTable.Click += buttonClearTable_Click;
//
// buttonTableAdd
//
buttonTableAdd.Location = new Point(580, 293);
buttonTableAdd.Name = "buttonTableAdd";
buttonTableAdd.Size = new Size(94, 29);
buttonTableAdd.TabIndex = 6;
buttonTableAdd.Text = "Add Table";
buttonTableAdd.UseVisualStyleBackColor = true;
buttonTableAdd.Click += buttonTableAdd_Click;
//
// buttonGetValue
//
buttonGetValue.Location = new Point(681, 293);
buttonGetValue.Name = "buttonGetValue";
buttonGetValue.Size = new Size(94, 29);
buttonGetValue.TabIndex = 7;
buttonGetValue.Text = "Get Value";
buttonGetValue.UseVisualStyleBackColor = true;
buttonGetValue.Click += buttonGetValue_Click;
//
// buttonGetValueCheckBox
//
buttonGetValueCheckBox.Location = new Point(59, 328);
buttonGetValueCheckBox.Name = "buttonGetValueCheckBox";
buttonGetValueCheckBox.Size = new Size(182, 35);
buttonGetValueCheckBox.TabIndex = 8;
buttonGetValueCheckBox.Text = "Get value";
buttonGetValueCheckBox.UseVisualStyleBackColor = true;
buttonGetValueCheckBox.Click += buttonGetValueCheckBox_Click;
//
// buttonSetValueCheckBox
//
buttonSetValueCheckBox.Location = new Point(59, 369);
buttonSetValueCheckBox.Name = "buttonSetValueCheckBox";
buttonSetValueCheckBox.Size = new Size(182, 35);
buttonSetValueCheckBox.TabIndex = 9;
buttonSetValueCheckBox.Text = "Set value";
buttonSetValueCheckBox.UseVisualStyleBackColor = true;
buttonSetValueCheckBox.Click += buttonSetValueCheckBox_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonSetValueCheckBox);
Controls.Add(buttonGetValueCheckBox);
Controls.Add(buttonGetValue);
Controls.Add(buttonTableAdd);
Controls.Add(buttonClearTable);
Controls.Add(buttonLoad);
Controls.Add(buttonClear);
Controls.Add(dateBoxWithNull1);
Controls.Add(customListBox1);
Controls.Add(customDataGridView1);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
}
#endregion
private KryukovLib.CustomDataGridView customDataGridView1;
private KryukovLib.CustomListBox customListBox1;
private KryukovLib.DateBoxWithNull dateBoxWithNull1;
private Button buttonClear;
private Button buttonLoad;
private Button buttonClearTable;
private Button buttonTableAdd;
private Button buttonGetValue;
private Button buttonGetValueCheckBox;
private Button buttonSetValueCheckBox;
}
}

117
COP/Test/Form1.cs Normal file
View File

@ -0,0 +1,117 @@
using KryukovLib;
using Microsoft.VisualBasic.Devices;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
using static KryukovLib.CustomDataGridView;
namespace Test
{
public partial class Form1 : Form
{
private bool EmptyFill = false;
readonly List<Car> cars = new()
{
new Car { Id = 0, marka = "Nissan terrano", weight = 1300, maxSpeed = 155 },
new Car { Id = 1, marka = "Nissan X-Trail", weight = 1500, maxSpeed = 170 },
new Car { Id = 2, marka = "Zhigyl)", weight = 400, maxSpeed = 100 },
new Car { Id = 3, marka = "Chevrolet rezo", weight = 1200, maxSpeed = 140 },
};
readonly List<string> items = new()
{
new string("item1"),
new string("item2"),
new string("item3"),
new string("item4"),
new string("item5"),
new string("item6"),
new string("item7"),
};
public Form1()
{
InitializeComponent();
CreateList();
customListBox1.ValueChanged += CustomListBox1_ValueChanged;
}
private void CustomListBox1_ValueChanged(object sender, EventArgs e)
{
// Âûâîäèì âûáðàííîå çíà÷åíèå
MessageBox.Show($"Selected item: {customListBox1.SelectedValue}");
}
private void CreateList()
{
customListBox1.PopulateList(items);
}
private void CreateTable()
{
customDataGridView1.ConfigColumn(new()
{
ColumnsCount = 4,
NameColumn = new string[] { "Id", "marka", "weight", "maxSpeed" },
Width = new int[] { 10, 150, 250, 200 },
Visible = new bool[] { false, true, true, true },
PropertiesObject = new string[] { "Id", "marka", "weight", "maxSpeed" }
});
foreach (Car car in cars)
{
int rowIndex = customDataGridView1.Rows.Add();
for (int i = 0; i < 4; i++)
{
customDataGridView1.AddItem(car, rowIndex, i);
}
}
}
private void buttonClear_Click(object sender, EventArgs e)
{
customListBox1.ClearList();
}
private void buttonLoad_Click(object sender, EventArgs e)
{
CreateList();
customListBox1.Refresh();
}
private void buttonClearTable_Click(object sender, EventArgs e)
{
customDataGridView1.ClearDataGrid();
}
private void buttonTableAdd_Click(object sender, EventArgs e)
{
CreateTable();
}
private void buttonGetValue_Click(object sender, EventArgs e)
{
}
private void buttonGetValueCheckBox_Click(object sender, EventArgs e)
{
MessageBox.Show($"Value is {dateBoxWithNull1.Value}");
}
private void buttonSetValueCheckBox_Click(object sender, EventArgs e)
{
if (EmptyFill)
{
dateBoxWithNull1.Value = DateTime.Now;
}
else
{
dateBoxWithNull1.Value = null;
}
EmptyFill = !EmptyFill;
}
}
}

120
COP/Test/Form1.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

17
COP/Test/Program.cs Normal file
View File

@ -0,0 +1,17 @@
namespace Test
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

15
COP/Test/Test.csproj Normal file
View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\KryukovLib\KryukovLib.csproj" />
</ItemGroup>
</Project>