Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
0b05d77cdd | |||
b5f9121ce7 | |||
c3b6b08a4e |
31
KOP_Labs/KOP_Labs.sln
Normal file
31
KOP_Labs/KOP_Labs.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34031.279
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library_var_4_lab_1", "Library_var_4_lab_1\Library_var_4_lab_1.csproj", "{54FEDC65-63CA-474A-9D78-FCACE673AA3F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProj", "TestProj\TestProj.csproj", "{0FF632B3-8D31-403E-AC25-61283C15D2C9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{54FEDC65-63CA-474A-9D78-FCACE673AA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{54FEDC65-63CA-474A-9D78-FCACE673AA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{54FEDC65-63CA-474A-9D78-FCACE673AA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{54FEDC65-63CA-474A-9D78-FCACE673AA3F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0FF632B3-8D31-403E-AC25-61283C15D2C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0FF632B3-8D31-403E-AC25-61283C15D2C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0FF632B3-8D31-403E-AC25-61283C15D2C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0FF632B3-8D31-403E-AC25-61283C15D2C9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0115D661-19A6-4D29-9906-E1EA34CC92B2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
57
KOP_Labs/Library_var_4_lab_1/CustomListBox.Designer.cs
generated
Normal file
57
KOP_Labs/Library_var_4_lab_1/CustomListBox.Designer.cs
generated
Normal file
@ -0,0 +1,57 @@
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
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()
|
||||
{
|
||||
listBox = new ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.ItemHeight = 20;
|
||||
listBox.Location = new Point(3, 3);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(446, 144);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// CustomListBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(listBox);
|
||||
Name = "CustomListBox";
|
||||
Size = new Size(454, 188);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
107
KOP_Labs/Library_var_4_lab_1/CustomListBox.cs
Normal file
107
KOP_Labs/Library_var_4_lab_1/CustomListBox.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
public partial class CustomListBox : UserControl
|
||||
{
|
||||
private List<string> properties = new();
|
||||
string StartSimbol = string.Empty;
|
||||
string EndSimbol = string.Empty;
|
||||
private List<List<object>> values = new List<List<object>>();
|
||||
private string Template = string.Empty;
|
||||
private Regex Regex = new(string.Empty);
|
||||
|
||||
public CustomListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetTemplate(string startSimbol, string endSimbol, string template)
|
||||
{
|
||||
string pattern = "\\" + startSimbol + "([^"+endSimbol+"]*)\\" + endSimbol;
|
||||
Template = template;
|
||||
StartSimbol = startSimbol;
|
||||
EndSimbol = endSimbol;
|
||||
Regex = new Regex(pattern);
|
||||
properties.Clear();
|
||||
listBox.Items.Clear();
|
||||
values.Clear();
|
||||
foreach (Match match in Regex.Matches(template))
|
||||
properties.Add(match.Groups[1].Value);
|
||||
for (int i = 0; i < properties.Count; i++)
|
||||
{
|
||||
values.Add(new List<object>());
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add<T>(T Object)
|
||||
{
|
||||
var tmpTemplate = Template;
|
||||
int i = 0;
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var tmpValue = typeof(T)?.GetProperty(property)?.GetValue(Object);
|
||||
tmpTemplate = tmpTemplate.Replace(StartSimbol + property + EndSimbol, tmpValue?.ToString() ?? string.Empty);
|
||||
values[i].Add(tmpValue ?? string.Empty);
|
||||
i++;
|
||||
|
||||
}
|
||||
listBox.Items.Add(tmpTemplate);
|
||||
}
|
||||
|
||||
public T GetSelected<T>() where T : class, new()
|
||||
{
|
||||
string SelectedStr = "";
|
||||
if (listBox.SelectedIndex != -1)
|
||||
{
|
||||
SelectedStr = listBox.SelectedItem.ToString();
|
||||
}
|
||||
|
||||
T currentObject = new T();
|
||||
Type objectType = typeof(T);
|
||||
int rowIndex = listBox.SelectedIndex;
|
||||
int colIndex = 0;
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
var field = objectType.GetProperty(prop);
|
||||
if (!field?.CanWrite ?? false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int startS = SelectedStr.IndexOf(values[colIndex][rowIndex].ToString());
|
||||
if (startS == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
string propValue = SelectedStr.Substring(startS, values[colIndex][rowIndex].ToString().Length);
|
||||
if (SelectedStr.Length > startS + values[colIndex][rowIndex].ToString().Length + 1)
|
||||
SelectedStr = SelectedStr.Substring(startS + values[colIndex][rowIndex].ToString().Length + 1);
|
||||
field?.SetValue(currentObject, Convert.ChangeType(propValue, field.PropertyType));
|
||||
colIndex++;
|
||||
}
|
||||
return currentObject;
|
||||
}
|
||||
}
|
||||
}
|
120
KOP_Labs/Library_var_4_lab_1/CustomListBox.resx
Normal file
120
KOP_Labs/Library_var_4_lab_1/CustomListBox.resx
Normal 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
KOP_Labs/Library_var_4_lab_1/DateInputBox.Designer.cs
generated
Normal file
61
KOP_Labs/Library_var_4_lab_1/DateInputBox.Designer.cs
generated
Normal file
@ -0,0 +1,61 @@
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
partial class DateInputBox
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
textBoxDateInput = new TextBox();
|
||||
toolTip1 = new ToolTip(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxDateInput
|
||||
//
|
||||
textBoxDateInput.Location = new Point(3, 3);
|
||||
textBoxDateInput.Name = "textBoxDateInput";
|
||||
textBoxDateInput.Size = new Size(238, 27);
|
||||
textBoxDateInput.TabIndex = 0;
|
||||
textBoxDateInput.TextChanged += textBox_ValueChanged;
|
||||
textBoxDateInput.MouseMove += textBox_MouseMove;
|
||||
//
|
||||
// DateInputBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(textBoxDateInput);
|
||||
Name = "DateInputBox";
|
||||
Size = new Size(246, 39);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxDateInput;
|
||||
private ToolTip toolTip1;
|
||||
}
|
||||
}
|
66
KOP_Labs/Library_var_4_lab_1/DateInputBox.cs
Normal file
66
KOP_Labs/Library_var_4_lab_1/DateInputBox.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
public partial class DateInputBox : UserControl
|
||||
{
|
||||
public string Template = string.Empty;
|
||||
private string Example = string.Empty;
|
||||
public string Date
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Template))
|
||||
throw new TemplateNotSetException();
|
||||
Regex regex = new Regex(Template);
|
||||
if (regex.IsMatch(textBoxDateInput.Text))
|
||||
return textBoxDateInput.Text;
|
||||
else throw new InvalidArgumentException();
|
||||
}
|
||||
set
|
||||
{
|
||||
Regex regex = new Regex(Template);
|
||||
if (!string.IsNullOrEmpty(Template) && regex.IsMatch(value))
|
||||
textBoxDateInput.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
private event EventHandler? _changeValue;
|
||||
|
||||
public event EventHandler ChangeValue
|
||||
{
|
||||
add => _changeValue += value;
|
||||
remove => _changeValue -= value;
|
||||
}
|
||||
public DateInputBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void setExample(string example)
|
||||
{
|
||||
Example = example;
|
||||
}
|
||||
|
||||
private void textBox_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
toolTip1.SetToolTip(textBoxDateInput, Example);
|
||||
}
|
||||
|
||||
private void textBox_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
_changeValue?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
123
KOP_Labs/Library_var_4_lab_1/DateInputBox.resx
Normal file
123
KOP_Labs/Library_var_4_lab_1/DateInputBox.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
59
KOP_Labs/Library_var_4_lab_1/DropDownList.Designer.cs
generated
Normal file
59
KOP_Labs/Library_var_4_lab_1/DropDownList.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
partial class DropDownList
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
comboBox = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBox
|
||||
//
|
||||
comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Location = new Point(3, 3);
|
||||
comboBox.Name = "comboBox";
|
||||
comboBox.Size = new Size(305, 28);
|
||||
comboBox.TabIndex = 0;
|
||||
comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
|
||||
//
|
||||
// DropDownList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(comboBox);
|
||||
Name = "DropDownList";
|
||||
Size = new Size(311, 230);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
}
|
||||
}
|
51
KOP_Labs/Library_var_4_lab_1/DropDownList.cs
Normal file
51
KOP_Labs/Library_var_4_lab_1/DropDownList.cs
Normal file
@ -0,0 +1,51 @@
|
||||
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 Library_var_4_lab_1
|
||||
{
|
||||
public partial class DropDownList : UserControl
|
||||
{
|
||||
private event EventHandler? _changeIndex;
|
||||
|
||||
public event EventHandler ChangeIndex
|
||||
{
|
||||
add => _changeIndex += value;
|
||||
remove => _changeIndex -= value;
|
||||
}
|
||||
|
||||
public DropDownList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string SelectedItem
|
||||
{
|
||||
get => comboBox.SelectedItem?.ToString() ?? string.Empty;
|
||||
set => comboBox.SelectedIndex = comboBox.Items.IndexOf(value);
|
||||
}
|
||||
|
||||
public void Input(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
throw new ArgumentNullException("value");
|
||||
comboBox.Items.Add(value);
|
||||
}
|
||||
|
||||
public void ClearList()
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
}
|
||||
|
||||
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_changeIndex?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
120
KOP_Labs/Library_var_4_lab_1/DropDownList.resx
Normal file
120
KOP_Labs/Library_var_4_lab_1/DropDownList.resx
Normal 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>
|
18
KOP_Labs/Library_var_4_lab_1/InvalidArgumentException.cs
Normal file
18
KOP_Labs/Library_var_4_lab_1/InvalidArgumentException.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
[Serializable]
|
||||
internal class InvalidArgumentException : ApplicationException
|
||||
{
|
||||
public InvalidArgumentException() : base("Значение не соответсвует шаблону") { }
|
||||
public InvalidArgumentException(string message) : base(message) { }
|
||||
public InvalidArgumentException(string message, Exception exception) : base(message, exception) { }
|
||||
public InvalidArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
10
KOP_Labs/Library_var_4_lab_1/Library_var_4_lab_1.csproj
Normal file
10
KOP_Labs/Library_var_4_lab_1/Library_var_4_lab_1.csproj
Normal 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>
|
14
KOP_Labs/Library_var_4_lab_1/TemplateNotSetException.cs
Normal file
14
KOP_Labs/Library_var_4_lab_1/TemplateNotSetException.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Library_var_4_lab_1
|
||||
{
|
||||
[Serializable]
|
||||
internal class TemplateNotSetException : ApplicationException
|
||||
{
|
||||
public TemplateNotSetException() : base("Шаблон не задан") { }
|
||||
public TemplateNotSetException(string message) : base(message) { }
|
||||
public TemplateNotSetException(string message, Exception exception) : base(message, exception) { }
|
||||
public TemplateNotSetException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
367
KOP_Labs/TestProj/Form1.Designer.cs
generated
Normal file
367
KOP_Labs/TestProj/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,367 @@
|
||||
namespace TestProj
|
||||
{
|
||||
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()
|
||||
{
|
||||
dropDownList1 = new Library_var_4_lab_1.DropDownList();
|
||||
textBox1 = new TextBox();
|
||||
buttonAdd = new Button();
|
||||
buttonGet = new Button();
|
||||
buttonSet = new Button();
|
||||
buttonClear = new Button();
|
||||
checkBox = new CheckBox();
|
||||
dateInputBox1 = new Library_var_4_lab_1.DateInputBox();
|
||||
buttonSetDate = new Button();
|
||||
buttonGetDate = new Button();
|
||||
buttonSetExample = new Button();
|
||||
buttonSetTemplate = new Button();
|
||||
customListBox1 = new Library_var_4_lab_1.CustomListBox();
|
||||
textBoxInput = new TextBox();
|
||||
textBoxEndSimbol = new TextBox();
|
||||
textBoxStartSimbol = new TextBox();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAge = new TextBox();
|
||||
textBoxSurName = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
buttonSetPattern = new Button();
|
||||
buttonGetIndex = new Button();
|
||||
buttonSetItem = new Button();
|
||||
buttonGetObject = new Button();
|
||||
buttonSetIndex = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dropDownList1
|
||||
//
|
||||
dropDownList1.Location = new Point(12, 12);
|
||||
dropDownList1.Name = "dropDownList1";
|
||||
dropDownList1.SelectedItem = "";
|
||||
dropDownList1.Size = new Size(329, 44);
|
||||
dropDownList1.TabIndex = 0;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(12, 62);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(314, 27);
|
||||
textBox1.TabIndex = 1;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(12, 108);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_OnClick;
|
||||
//
|
||||
// buttonGet
|
||||
//
|
||||
buttonGet.Location = new Point(121, 108);
|
||||
buttonGet.Name = "buttonGet";
|
||||
buttonGet.Size = new Size(94, 29);
|
||||
buttonGet.TabIndex = 3;
|
||||
buttonGet.Text = "Get";
|
||||
buttonGet.UseVisualStyleBackColor = true;
|
||||
buttonGet.Click += buttonGet_OnClick;
|
||||
//
|
||||
// buttonSet
|
||||
//
|
||||
buttonSet.Location = new Point(232, 108);
|
||||
buttonSet.Name = "buttonSet";
|
||||
buttonSet.Size = new Size(94, 29);
|
||||
buttonSet.TabIndex = 4;
|
||||
buttonSet.Text = "Set";
|
||||
buttonSet.UseVisualStyleBackColor = true;
|
||||
buttonSet.Click += buttonSet_OnClick;
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(12, 143);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(94, 29);
|
||||
buttonClear.TabIndex = 5;
|
||||
buttonClear.Text = "Очистка";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClear_OnClick;
|
||||
//
|
||||
// checkBox
|
||||
//
|
||||
checkBox.AutoSize = true;
|
||||
checkBox.Location = new Point(371, 56);
|
||||
checkBox.Name = "checkBox";
|
||||
checkBox.Size = new Size(93, 24);
|
||||
checkBox.TabIndex = 6;
|
||||
checkBox.Text = "checkBox";
|
||||
checkBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dateInputBox1
|
||||
//
|
||||
dateInputBox1.Location = new Point(529, 12);
|
||||
dateInputBox1.Name = "dateInputBox1";
|
||||
dateInputBox1.Size = new Size(245, 49);
|
||||
dateInputBox1.TabIndex = 7;
|
||||
//
|
||||
// buttonSetDate
|
||||
//
|
||||
buttonSetDate.Location = new Point(12, 230);
|
||||
buttonSetDate.Name = "buttonSetDate";
|
||||
buttonSetDate.Size = new Size(94, 29);
|
||||
buttonSetDate.TabIndex = 8;
|
||||
buttonSetDate.Text = "Ввод даты";
|
||||
buttonSetDate.UseVisualStyleBackColor = true;
|
||||
buttonSetDate.Click += buttonSetDate_OnClick;
|
||||
//
|
||||
// buttonGetDate
|
||||
//
|
||||
buttonGetDate.Location = new Point(142, 230);
|
||||
buttonGetDate.Name = "buttonGetDate";
|
||||
buttonGetDate.Size = new Size(109, 29);
|
||||
buttonGetDate.TabIndex = 9;
|
||||
buttonGetDate.Text = "Вывод даты";
|
||||
buttonGetDate.UseVisualStyleBackColor = true;
|
||||
buttonGetDate.Click += buttonGetDate_OnClick;
|
||||
//
|
||||
// buttonSetExample
|
||||
//
|
||||
buttonSetExample.Location = new Point(142, 195);
|
||||
buttonSetExample.Name = "buttonSetExample";
|
||||
buttonSetExample.Size = new Size(134, 29);
|
||||
buttonSetExample.TabIndex = 10;
|
||||
buttonSetExample.Text = "Ввод примера";
|
||||
buttonSetExample.UseVisualStyleBackColor = true;
|
||||
buttonSetExample.Click += buttonSetExample_OnClick;
|
||||
//
|
||||
// buttonSetTemplate
|
||||
//
|
||||
buttonSetTemplate.Location = new Point(12, 195);
|
||||
buttonSetTemplate.Name = "buttonSetTemplate";
|
||||
buttonSetTemplate.Size = new Size(124, 29);
|
||||
buttonSetTemplate.TabIndex = 11;
|
||||
buttonSetTemplate.Text = "Ввод шаблона";
|
||||
buttonSetTemplate.UseVisualStyleBackColor = true;
|
||||
buttonSetTemplate.Click += buttonSetTemplate_OnClick;
|
||||
//
|
||||
// customListBox1
|
||||
//
|
||||
customListBox1.SelectedIndex = -1;
|
||||
customListBox1.Location = new Point(529, 83);
|
||||
customListBox1.Name = "customListBox1";
|
||||
customListBox1.Size = new Size(463, 176);
|
||||
customListBox1.TabIndex = 12;
|
||||
//
|
||||
// textBoxInput
|
||||
//
|
||||
textBoxInput.Location = new Point(529, 255);
|
||||
textBoxInput.Name = "textBoxInput";
|
||||
textBoxInput.Size = new Size(450, 27);
|
||||
textBoxInput.TabIndex = 13;
|
||||
//
|
||||
// textBoxEndSimbol
|
||||
//
|
||||
textBoxEndSimbol.Location = new Point(946, 298);
|
||||
textBoxEndSimbol.Name = "textBoxEndSimbol";
|
||||
textBoxEndSimbol.Size = new Size(33, 27);
|
||||
textBoxEndSimbol.TabIndex = 14;
|
||||
//
|
||||
// textBoxStartSimbol
|
||||
//
|
||||
textBoxStartSimbol.Location = new Point(880, 298);
|
||||
textBoxStartSimbol.Name = "textBoxStartSimbol";
|
||||
textBoxStartSimbol.Size = new Size(33, 27);
|
||||
textBoxStartSimbol.TabIndex = 15;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(529, 345);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(161, 27);
|
||||
textBoxName.TabIndex = 16;
|
||||
//
|
||||
// textBoxAge
|
||||
//
|
||||
textBoxAge.Location = new Point(529, 448);
|
||||
textBoxAge.Name = "textBoxAge";
|
||||
textBoxAge.Size = new Size(161, 27);
|
||||
textBoxAge.TabIndex = 17;
|
||||
//
|
||||
// textBoxSurName
|
||||
//
|
||||
textBoxSurName.Location = new Point(529, 395);
|
||||
textBoxSurName.Name = "textBoxSurName";
|
||||
textBoxSurName.Size = new Size(161, 27);
|
||||
textBoxSurName.TabIndex = 18;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(529, 322);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(39, 20);
|
||||
label1.TabIndex = 19;
|
||||
label1.Text = "Имя";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(529, 375);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(73, 20);
|
||||
label2.TabIndex = 20;
|
||||
label2.Text = "Фамилия";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(529, 425);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(64, 20);
|
||||
label3.TabIndex = 21;
|
||||
label3.Text = "Возраст";
|
||||
//
|
||||
// buttonSetPattern
|
||||
//
|
||||
buttonSetPattern.Location = new Point(701, 343);
|
||||
buttonSetPattern.Name = "buttonSetPattern";
|
||||
buttonSetPattern.Size = new Size(136, 29);
|
||||
buttonSetPattern.TabIndex = 22;
|
||||
buttonSetPattern.Text = "Задать шаблон";
|
||||
buttonSetPattern.UseVisualStyleBackColor = true;
|
||||
buttonSetPattern.Click += buttonSetPattern_OnClick;
|
||||
//
|
||||
// buttonGetIndex
|
||||
//
|
||||
buttonGetIndex.Location = new Point(843, 343);
|
||||
buttonGetIndex.Name = "buttonGetIndex";
|
||||
buttonGetIndex.Size = new Size(136, 29);
|
||||
buttonGetIndex.TabIndex = 23;
|
||||
buttonGetIndex.Text = "Получит индекс";
|
||||
buttonGetIndex.UseVisualStyleBackColor = true;
|
||||
buttonGetIndex.Click += buttonGetIndex_Click;
|
||||
//
|
||||
// buttonSetItem
|
||||
//
|
||||
buttonSetItem.Location = new Point(696, 446);
|
||||
buttonSetItem.Name = "buttonSetItem";
|
||||
buttonSetItem.Size = new Size(141, 29);
|
||||
buttonSetItem.TabIndex = 24;
|
||||
buttonSetItem.Text = "Добавить пункт";
|
||||
buttonSetItem.UseVisualStyleBackColor = true;
|
||||
buttonSetItem.Click += buttonSetObject_OnClick;
|
||||
//
|
||||
// buttonGetObject
|
||||
//
|
||||
buttonGetObject.Location = new Point(843, 446);
|
||||
buttonGetObject.Name = "buttonGetObject";
|
||||
buttonGetObject.Size = new Size(136, 29);
|
||||
buttonGetObject.TabIndex = 25;
|
||||
buttonGetObject.Text = "Получить объект";
|
||||
buttonGetObject.UseVisualStyleBackColor = true;
|
||||
buttonGetObject.Click += buttonGetObject_OnClick;
|
||||
//
|
||||
// buttonSetIndex
|
||||
//
|
||||
buttonSetIndex.Location = new Point(843, 378);
|
||||
buttonSetIndex.Name = "buttonSetIndex";
|
||||
buttonSetIndex.Size = new Size(136, 29);
|
||||
buttonSetIndex.TabIndex = 26;
|
||||
buttonSetIndex.Text = "Задать индекс";
|
||||
buttonSetIndex.UseVisualStyleBackColor = true;
|
||||
buttonSetIndex.Click += buttonSetIndex_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1007, 549);
|
||||
Controls.Add(buttonSetIndex);
|
||||
Controls.Add(buttonGetObject);
|
||||
Controls.Add(buttonSetItem);
|
||||
Controls.Add(buttonGetIndex);
|
||||
Controls.Add(buttonSetPattern);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxSurName);
|
||||
Controls.Add(textBoxAge);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(textBoxStartSimbol);
|
||||
Controls.Add(textBoxEndSimbol);
|
||||
Controls.Add(textBoxInput);
|
||||
Controls.Add(customListBox1);
|
||||
Controls.Add(buttonSetTemplate);
|
||||
Controls.Add(buttonSetExample);
|
||||
Controls.Add(buttonGetDate);
|
||||
Controls.Add(buttonSetDate);
|
||||
Controls.Add(dateInputBox1);
|
||||
Controls.Add(checkBox);
|
||||
Controls.Add(buttonClear);
|
||||
Controls.Add(buttonSet);
|
||||
Controls.Add(buttonGet);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(textBox1);
|
||||
Controls.Add(dropDownList1);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Library_var_4_lab_1.DropDownList dropDownList1;
|
||||
private TextBox textBox1;
|
||||
private Button buttonAdd;
|
||||
private Button buttonGet;
|
||||
private Button buttonSet;
|
||||
private Button buttonClear;
|
||||
private CheckBox checkBox;
|
||||
private Library_var_4_lab_1.DateInputBox dateInputBox1;
|
||||
private Button buttonSetDate;
|
||||
private Button buttonGetDate;
|
||||
private Button buttonSetExample;
|
||||
private Button buttonSetTemplate;
|
||||
private Library_var_4_lab_1.CustomListBox customListBox1;
|
||||
private TextBox textBoxInput;
|
||||
private TextBox textBoxEndSimbol;
|
||||
private TextBox textBoxStartSimbol;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAge;
|
||||
private TextBox textBoxSurName;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Button buttonSetPattern;
|
||||
private Button buttonGetIndex;
|
||||
private Button buttonSetItem;
|
||||
private Button buttonGetObject;
|
||||
private Button buttonSetIndex;
|
||||
}
|
||||
}
|
99
KOP_Labs/TestProj/Form1.cs
Normal file
99
KOP_Labs/TestProj/Form1.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using Library_var_4_lab_1;
|
||||
|
||||
namespace TestProj
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
dropDownList1.ChangeIndex += IsChanged;
|
||||
dateInputBox1.ChangeValue += IsChanged;
|
||||
}
|
||||
|
||||
//ïåðâàÿ òàñêà
|
||||
private void buttonAdd_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
dropDownList1.Input(textBox1.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonClear_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList1.ClearList();
|
||||
}
|
||||
|
||||
private void buttonSet_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList1.SelectedItem = textBox1.Text;
|
||||
}
|
||||
private void buttonGet_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = dropDownList1.SelectedItem;
|
||||
}
|
||||
private void IsChanged(object? sender, EventArgs e)
|
||||
{
|
||||
checkBox.Checked = true;
|
||||
}
|
||||
|
||||
// âòîðàÿ òàñêà
|
||||
private void buttonSetTemplate_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
dateInputBox1.Template = textBox1.Text;
|
||||
}
|
||||
private void buttonSetExample_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
dateInputBox1.setExample(textBox1.Text);
|
||||
}
|
||||
|
||||
private void buttonSetDate_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
dateInputBox1.Date = textBox1.Text;
|
||||
}
|
||||
|
||||
private void buttonGetDate_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = dateInputBox1.Date;
|
||||
}
|
||||
|
||||
// òðåòüÿ òàñêà
|
||||
private void buttonSetPattern_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
customListBox1.SetTemplate(textBoxStartSimbol.Text, textBoxEndSimbol.Text, textBoxInput.Text);
|
||||
}
|
||||
|
||||
private void buttonSetObject_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
Human human = new Human();
|
||||
human.Name = textBoxName.Text;
|
||||
human.SurName = textBoxSurName.Text;
|
||||
human.Age = Convert.ToInt32(textBoxAge.Text);
|
||||
customListBox1.Add<Human>(human);
|
||||
}
|
||||
|
||||
private void buttonGetObject_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
Human human = customListBox1.GetSelected<Human>();
|
||||
textBoxName.Text = human.Name;
|
||||
textBoxSurName.Text = human.SurName;
|
||||
textBoxAge.Text = human.Age.ToString();
|
||||
}
|
||||
|
||||
private void buttonSetIndex_Click(object sender, EventArgs e)
|
||||
{
|
||||
customListBox1.SelectedIndex = Convert.ToInt32(textBoxInput.Text);
|
||||
}
|
||||
|
||||
private void buttonGetIndex_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxInput.Text = customListBox1.SelectedIndex.ToString();
|
||||
}
|
||||
}
|
||||
}
|
120
KOP_Labs/TestProj/Form1.resx
Normal file
120
KOP_Labs/TestProj/Form1.resx
Normal 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>
|
15
KOP_Labs/TestProj/Human.cs
Normal file
15
KOP_Labs/TestProj/Human.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestProj
|
||||
{
|
||||
public class Human
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string SurName { get; set; } = string.Empty;
|
||||
public int Age { get; set; }
|
||||
}
|
||||
}
|
17
KOP_Labs/TestProj/Program.cs
Normal file
17
KOP_Labs/TestProj/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace TestProj
|
||||
{
|
||||
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
KOP_Labs/TestProj/TestProj.csproj
Normal file
15
KOP_Labs/TestProj/TestProj.csproj
Normal 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="..\Library_var_4_lab_1\Library_var_4_lab_1.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user