feat(lab1): do lab1
task2 is complited Some refactoring. Created folders for each components complete task 3 (maybe) some refactoring some refactor some minor fixes minor changes minor fixes minor fixes
This commit is contained in:
parent
d6360db5f1
commit
3ddd5b0500
31
ComponentLibrary1.sln
Normal file
31
ComponentLibrary1.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentLibrary1", "ComponentLibrary1\ComponentLibrary1.csproj", "{9AA4EAF0-DA17-4872-A45B-25DC4A7C82CD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp1", "TestApp1\TestApp1.csproj", "{E318008C-A386-40D8-B623-47E6C2C14FD0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9AA4EAF0-DA17-4872-A45B-25DC4A7C82CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9AA4EAF0-DA17-4872-A45B-25DC4A7C82CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9AA4EAF0-DA17-4872-A45B-25DC4A7C82CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9AA4EAF0-DA17-4872-A45B-25DC4A7C82CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E318008C-A386-40D8-B623-47E6C2C14FD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E318008C-A386-40D8-B623-47E6C2C14FD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E318008C-A386-40D8-B623-47E6C2C14FD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E318008C-A386-40D8-B623-47E6C2C14FD0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {27B1B7B6-7B2C-49EA-B19C-2C947CD4CF24}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
10
ComponentLibrary1/ComponentLibrary1.csproj
Normal file
10
ComponentLibrary1/ComponentLibrary1.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>
|
56
ComponentLibrary1/check_list/CheckList.Designer.cs
generated
Normal file
56
ComponentLibrary1/check_list/CheckList.Designer.cs
generated
Normal file
@ -0,0 +1,56 @@
|
||||
namespace ComponentLibrary1
|
||||
{
|
||||
partial class CheckList
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkedListBox = new CheckedListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkedListBox
|
||||
//
|
||||
checkedListBox.Dock = DockStyle.Fill;
|
||||
checkedListBox.FormattingEnabled = true;
|
||||
checkedListBox.Location = new Point(0, 0);
|
||||
checkedListBox.Name = "checkedListBox";
|
||||
checkedListBox.Size = new Size(209, 172);
|
||||
checkedListBox.TabIndex = 0;
|
||||
checkedListBox.SelectedIndexChanged += checkedListBox_SelectedIndexChanged;
|
||||
//
|
||||
// CheckList
|
||||
//
|
||||
Controls.Add(checkedListBox);
|
||||
Name = "CheckList";
|
||||
Size = new Size(209, 172);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox;
|
||||
}
|
||||
}
|
63
ComponentLibrary1/check_list/CheckList.cs
Normal file
63
ComponentLibrary1/check_list/CheckList.cs
Normal file
@ -0,0 +1,63 @@
|
||||
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 ComponentLibrary1
|
||||
{
|
||||
public partial class CheckList : UserControl
|
||||
{
|
||||
|
||||
private event EventHandler? _сhangeEvent;
|
||||
|
||||
public event EventHandler ChangeEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_сhangeEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_сhangeEvent -= value;
|
||||
}
|
||||
|
||||
}
|
||||
public string SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return checkedListBox.SelectedItem?.ToString() ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
checkedListBox.SelectedIndex = checkedListBox.Items.IndexOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
public CheckList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Input(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
throw new ArgumentNullException("input");
|
||||
checkedListBox.Items.Add(input);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
checkedListBox.Items.Clear();
|
||||
}
|
||||
private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_сhangeEvent?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
120
ComponentLibrary1/check_list/CheckList.resx
Normal file
120
ComponentLibrary1/check_list/CheckList.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>
|
58
ComponentLibrary1/limited_text/LimitedText.Designer.cs
generated
Normal file
58
ComponentLibrary1/limited_text/LimitedText.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace ComponentLibrary1
|
||||
{
|
||||
partial class LimitedText
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBox = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Dock = DockStyle.Fill;
|
||||
textBox.Location = new Point(0, 0);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(150, 23);
|
||||
textBox.TabIndex = 0;
|
||||
textBox.TextChanged += textBox_TextChanged;
|
||||
//
|
||||
// LimitedText
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(textBox);
|
||||
Name = "LimitedText";
|
||||
Size = new Size(150, 24);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox;
|
||||
}
|
||||
}
|
107
ComponentLibrary1/limited_text/LimitedText.cs
Normal file
107
ComponentLibrary1/limited_text/LimitedText.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using ComponentLibrary1.limited_text;
|
||||
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 ComponentLibrary1
|
||||
{
|
||||
public partial class LimitedText : UserControl
|
||||
{
|
||||
private event EventHandler? _changeEvent;
|
||||
public event EventHandler ChangeEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_changeEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_changeEvent -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private int? _min = null;
|
||||
public int? Min
|
||||
{
|
||||
get
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Max != null && value > Max)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_min = value;
|
||||
}
|
||||
}
|
||||
private int? _max = null;
|
||||
public int? Max
|
||||
{
|
||||
get
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Max != null && value < Min)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_max = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string TextField
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Min == null || Max == null)
|
||||
{
|
||||
throw new RangeUndefinedException();
|
||||
}
|
||||
if (textBox.Text.Length < Min || textBox.Text.Length > Max)
|
||||
{
|
||||
throw new OutOfRangeException((int)Min, (int)Max);
|
||||
}
|
||||
return textBox.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Min == null || Max == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (value.Length >= Min && value.Length <= Max)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LimitedText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_changeEvent?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
120
ComponentLibrary1/limited_text/LimitedText.resx
Normal file
120
ComponentLibrary1/limited_text/LimitedText.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>
|
19
ComponentLibrary1/limited_text/OutOfRangeException.cs
Normal file
19
ComponentLibrary1/limited_text/OutOfRangeException.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComponentLibrary1.limited_text
|
||||
{
|
||||
[Serializable]
|
||||
internal class OutOfRangeException : ApplicationException
|
||||
{
|
||||
public OutOfRangeException(int min, int max) : base($"Введенное значение не входит в диапазон от {min} до {max}") { }
|
||||
public OutOfRangeException() : base() { }
|
||||
public OutOfRangeException(string message) : base(message) { }
|
||||
public OutOfRangeException(string message, Exception exception) : base(message, exception) { }
|
||||
protected OutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
18
ComponentLibrary1/limited_text/RangeUndefinedException.cs
Normal file
18
ComponentLibrary1/limited_text/RangeUndefinedException.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 ComponentLibrary1.limited_text
|
||||
{
|
||||
[Serializable]
|
||||
internal class RangeUndefinedException : ApplicationException
|
||||
{
|
||||
public RangeUndefinedException() : base("Диапазон не определен") { }
|
||||
public RangeUndefinedException(string message) : base(message) { }
|
||||
public RangeUndefinedException(string message, Exception exception) : base(message, exception) { }
|
||||
protected RangeUndefinedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
55
ComponentLibrary1/tree_list/TreeList.Designer.cs
generated
Normal file
55
ComponentLibrary1/tree_list/TreeList.Designer.cs
generated
Normal file
@ -0,0 +1,55 @@
|
||||
namespace ComponentLibrary1.tree_list
|
||||
{
|
||||
partial class TreeList
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
treeView = new TreeView();
|
||||
SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
treeView.Dock = DockStyle.Fill;
|
||||
treeView.Location = new Point(0, 0);
|
||||
treeView.Name = "treeView";
|
||||
treeView.Size = new Size(150, 150);
|
||||
treeView.TabIndex = 0;
|
||||
//
|
||||
// TreeList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(treeView);
|
||||
Name = "TreeList";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeView treeView;
|
||||
}
|
||||
}
|
106
ComponentLibrary1/tree_list/TreeList.cs
Normal file
106
ComponentLibrary1/tree_list/TreeList.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
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;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ComponentLibrary1.tree_list
|
||||
{
|
||||
public partial class TreeList : UserControl
|
||||
{
|
||||
private List<string> CategoriesNames = new List<string>();
|
||||
|
||||
public TreeList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetCategories (List<string> categories)
|
||||
{
|
||||
CategoriesNames = categories;
|
||||
}
|
||||
|
||||
public void AddTreeListObject<T>(T treeListObject) where T : class, new()
|
||||
{
|
||||
if (CategoriesNames == null || CategoriesNames.Count == 0)
|
||||
{
|
||||
throw new Exception("CategoriesNames is null or empty");
|
||||
}
|
||||
if (treeListObject == null)
|
||||
{
|
||||
throw new ArgumentException("treeObject is null");
|
||||
}
|
||||
Queue<string> values = new Queue<string>();
|
||||
Type type = treeListObject.GetType();
|
||||
foreach (string categoryName in CategoriesNames)
|
||||
{
|
||||
string? value = type.GetProperty(categoryName)?.GetValue(treeListObject) as string;
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentException($"{type.Name}.{categoryName} is not found or is not a not empty string");
|
||||
}
|
||||
values.Enqueue(value);
|
||||
}
|
||||
TreeNodeCollection nodeCollection = treeView.Nodes;
|
||||
string hierarchyElement = values.Dequeue();
|
||||
while (values.Count > 0)
|
||||
{
|
||||
bool branchIsFind = false;
|
||||
foreach (TreeNode node in nodeCollection)
|
||||
{
|
||||
if (node.Text == hierarchyElement)
|
||||
{
|
||||
branchIsFind = true;
|
||||
nodeCollection = node.Nodes;
|
||||
hierarchyElement = values.Dequeue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (branchIsFind)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TreeNode newBranch = nodeCollection.Add(hierarchyElement);
|
||||
nodeCollection = newBranch.Nodes;
|
||||
hierarchyElement = values.Dequeue();
|
||||
}
|
||||
TreeNode newLeaf = nodeCollection.Add(hierarchyElement);
|
||||
for(TreeNode node = newLeaf; node != null; node = node.Parent)
|
||||
{
|
||||
node.Expand();
|
||||
}
|
||||
}
|
||||
|
||||
public T? GetSelectedObject<T>() where T : class, new()
|
||||
{
|
||||
if(treeView.SelectedNode == null)
|
||||
{
|
||||
throw new Exception("There are no selected nodes");
|
||||
}
|
||||
T result = new T();
|
||||
Type type = typeof(T);
|
||||
int i;
|
||||
TreeNode treeNode = treeView.SelectedNode;
|
||||
for (i = CategoriesNames.Count - 1; i >= 0 && treeNode != null; i--, treeNode = treeNode.Parent)
|
||||
{
|
||||
type.GetProperty(CategoriesNames[i])?.SetValue(result, treeNode.Text);
|
||||
}
|
||||
if(treeNode != null || i >= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
treeView.Nodes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
120
ComponentLibrary1/tree_list/TreeList.resx
Normal file
120
ComponentLibrary1/tree_list/TreeList.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>
|
28
TestApp1/Employee.cs
Normal file
28
TestApp1/Employee.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using ComponentLibrary1.tree_list;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApp1
|
||||
{
|
||||
internal class Employee
|
||||
{
|
||||
public string Department { get; set; }
|
||||
public string JobTitle { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public Employee()
|
||||
{
|
||||
Department = string.Empty;
|
||||
JobTitle = string.Empty;
|
||||
FullName = string.Empty;
|
||||
}
|
||||
public Employee(string department, string jobTitle, string fullName)
|
||||
{
|
||||
Department = department;
|
||||
JobTitle = jobTitle;
|
||||
FullName = fullName;
|
||||
}
|
||||
}
|
||||
}
|
377
TestApp1/Form1.Designer.cs
generated
Normal file
377
TestApp1/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,377 @@
|
||||
namespace TestApp1
|
||||
{
|
||||
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()
|
||||
{
|
||||
input = new Button();
|
||||
clear = new Button();
|
||||
textBox1 = new TextBox();
|
||||
set = new Button();
|
||||
get = new Button();
|
||||
checkList = new ComponentLibrary1.CheckList();
|
||||
changeBox = new CheckBox();
|
||||
groupBox1 = new GroupBox();
|
||||
groupBox2 = new GroupBox();
|
||||
numericMax = new NumericUpDown();
|
||||
numericMin = new NumericUpDown();
|
||||
inputMax = new Button();
|
||||
inputMin = new Button();
|
||||
limitedText = new ComponentLibrary1.LimitedText();
|
||||
write = new Button();
|
||||
read = new Button();
|
||||
textBox2 = new TextBox();
|
||||
changeBox2 = new CheckBox();
|
||||
groupBox3 = new GroupBox();
|
||||
textBoxOutput = new TextBox();
|
||||
treeList = new ComponentLibrary1.tree_list.TreeList();
|
||||
textBoxDepartment = new TextBox();
|
||||
textBoxJobTitle = new TextBox();
|
||||
add = new Button();
|
||||
clearTreeList = new Button();
|
||||
textBoxFullName = new TextBox();
|
||||
getObject = new Button();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericMax).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericMin).BeginInit();
|
||||
groupBox3.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// input
|
||||
//
|
||||
input.Location = new Point(6, 269);
|
||||
input.Name = "input";
|
||||
input.Size = new Size(70, 26);
|
||||
input.TabIndex = 0;
|
||||
input.Text = "input";
|
||||
input.UseVisualStyleBackColor = true;
|
||||
input.Click += input_Click;
|
||||
//
|
||||
// clear
|
||||
//
|
||||
clear.Location = new Point(82, 269);
|
||||
clear.Name = "clear";
|
||||
clear.Size = new Size(70, 26);
|
||||
clear.TabIndex = 1;
|
||||
clear.Text = "clear";
|
||||
clear.UseVisualStyleBackColor = true;
|
||||
clear.Click += clear_Click;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(6, 240);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(146, 23);
|
||||
textBox1.TabIndex = 2;
|
||||
//
|
||||
// set
|
||||
//
|
||||
set.Location = new Point(6, 301);
|
||||
set.Name = "set";
|
||||
set.Size = new Size(70, 26);
|
||||
set.TabIndex = 3;
|
||||
set.Text = "set";
|
||||
set.UseVisualStyleBackColor = true;
|
||||
set.Click += set_Click;
|
||||
//
|
||||
// get
|
||||
//
|
||||
get.Location = new Point(82, 301);
|
||||
get.Name = "get";
|
||||
get.Size = new Size(70, 26);
|
||||
get.TabIndex = 4;
|
||||
get.Text = "get";
|
||||
get.UseVisualStyleBackColor = true;
|
||||
get.Click += get_Click;
|
||||
//
|
||||
// checkList
|
||||
//
|
||||
checkList.Location = new Point(6, 22);
|
||||
checkList.Name = "checkList";
|
||||
checkList.SelectedItem = "";
|
||||
checkList.Size = new Size(146, 172);
|
||||
checkList.TabIndex = 5;
|
||||
//
|
||||
// changeBox
|
||||
//
|
||||
changeBox.AutoSize = true;
|
||||
changeBox.Location = new Point(6, 200);
|
||||
changeBox.Name = "changeBox";
|
||||
changeBox.Size = new Size(72, 19);
|
||||
changeBox.TabIndex = 6;
|
||||
changeBox.Text = "changed";
|
||||
changeBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(checkList);
|
||||
groupBox1.Controls.Add(input);
|
||||
groupBox1.Controls.Add(clear);
|
||||
groupBox1.Controls.Add(textBox1);
|
||||
groupBox1.Controls.Add(changeBox);
|
||||
groupBox1.Controls.Add(set);
|
||||
groupBox1.Controls.Add(get);
|
||||
groupBox1.Location = new Point(16, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(157, 332);
|
||||
groupBox1.TabIndex = 10;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Test1";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(numericMax);
|
||||
groupBox2.Controls.Add(numericMin);
|
||||
groupBox2.Controls.Add(inputMax);
|
||||
groupBox2.Controls.Add(inputMin);
|
||||
groupBox2.Controls.Add(limitedText);
|
||||
groupBox2.Controls.Add(write);
|
||||
groupBox2.Controls.Add(read);
|
||||
groupBox2.Controls.Add(textBox2);
|
||||
groupBox2.Controls.Add(changeBox2);
|
||||
groupBox2.Location = new Point(179, 12);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(157, 332);
|
||||
groupBox2.TabIndex = 11;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Test2";
|
||||
//
|
||||
// numericMax
|
||||
//
|
||||
numericMax.Location = new Point(7, 160);
|
||||
numericMax.Name = "numericMax";
|
||||
numericMax.Size = new Size(145, 23);
|
||||
numericMax.TabIndex = 11;
|
||||
//
|
||||
// numericMin
|
||||
//
|
||||
numericMin.Location = new Point(7, 131);
|
||||
numericMin.Name = "numericMin";
|
||||
numericMin.Size = new Size(145, 23);
|
||||
numericMin.TabIndex = 10;
|
||||
//
|
||||
// inputMax
|
||||
//
|
||||
inputMax.Location = new Point(82, 301);
|
||||
inputMax.Name = "inputMax";
|
||||
inputMax.Size = new Size(70, 26);
|
||||
inputMax.TabIndex = 9;
|
||||
inputMax.Text = "inputMax";
|
||||
inputMax.UseVisualStyleBackColor = true;
|
||||
inputMax.Click += inputMax_Click;
|
||||
//
|
||||
// inputMin
|
||||
//
|
||||
inputMin.Location = new Point(7, 301);
|
||||
inputMin.Name = "inputMin";
|
||||
inputMin.Size = new Size(70, 26);
|
||||
inputMin.TabIndex = 8;
|
||||
inputMin.Text = "inputMin";
|
||||
inputMin.UseVisualStyleBackColor = true;
|
||||
inputMin.Click += inputMin_Click;
|
||||
//
|
||||
// limitedText
|
||||
//
|
||||
limitedText.Location = new Point(7, 74);
|
||||
limitedText.Max = null;
|
||||
limitedText.Min = null;
|
||||
limitedText.Name = "limitedText";
|
||||
limitedText.Size = new Size(145, 26);
|
||||
limitedText.TabIndex = 7;
|
||||
//
|
||||
// write
|
||||
//
|
||||
write.Location = new Point(6, 269);
|
||||
write.Name = "write";
|
||||
write.Size = new Size(70, 26);
|
||||
write.TabIndex = 0;
|
||||
write.Text = "write";
|
||||
write.UseVisualStyleBackColor = true;
|
||||
write.Click += write_Click;
|
||||
//
|
||||
// read
|
||||
//
|
||||
read.Location = new Point(82, 269);
|
||||
read.Name = "read";
|
||||
read.Size = new Size(70, 26);
|
||||
read.TabIndex = 1;
|
||||
read.Text = "read";
|
||||
read.UseVisualStyleBackColor = true;
|
||||
read.Click += read_Click;
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
textBox2.Location = new Point(6, 240);
|
||||
textBox2.Name = "textBox2";
|
||||
textBox2.Size = new Size(146, 23);
|
||||
textBox2.TabIndex = 2;
|
||||
//
|
||||
// changeBox2
|
||||
//
|
||||
changeBox2.AutoSize = true;
|
||||
changeBox2.Location = new Point(6, 200);
|
||||
changeBox2.Name = "changeBox2";
|
||||
changeBox2.Size = new Size(72, 19);
|
||||
changeBox2.TabIndex = 6;
|
||||
changeBox2.Text = "changed";
|
||||
changeBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
groupBox3.Controls.Add(textBoxOutput);
|
||||
groupBox3.Controls.Add(treeList);
|
||||
groupBox3.Controls.Add(textBoxDepartment);
|
||||
groupBox3.Controls.Add(textBoxJobTitle);
|
||||
groupBox3.Controls.Add(add);
|
||||
groupBox3.Controls.Add(clearTreeList);
|
||||
groupBox3.Controls.Add(textBoxFullName);
|
||||
groupBox3.Controls.Add(getObject);
|
||||
groupBox3.Location = new Point(342, 12);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Size = new Size(157, 332);
|
||||
groupBox3.TabIndex = 11;
|
||||
groupBox3.TabStop = false;
|
||||
groupBox3.Text = "Test3";
|
||||
//
|
||||
// textBoxOutput
|
||||
//
|
||||
textBoxOutput.Location = new Point(6, 240);
|
||||
textBoxOutput.Name = "textBoxOutput";
|
||||
textBoxOutput.Size = new Size(146, 23);
|
||||
textBoxOutput.TabIndex = 15;
|
||||
//
|
||||
// treeList
|
||||
//
|
||||
treeList.Location = new Point(6, 22);
|
||||
treeList.Name = "treeList";
|
||||
treeList.Size = new Size(146, 125);
|
||||
treeList.TabIndex = 14;
|
||||
//
|
||||
// textBoxDepartment
|
||||
//
|
||||
textBoxDepartment.Location = new Point(6, 153);
|
||||
textBoxDepartment.Name = "textBoxDepartment";
|
||||
textBoxDepartment.Size = new Size(146, 23);
|
||||
textBoxDepartment.TabIndex = 13;
|
||||
//
|
||||
// textBoxJobTitle
|
||||
//
|
||||
textBoxJobTitle.Location = new Point(6, 182);
|
||||
textBoxJobTitle.Name = "textBoxJobTitle";
|
||||
textBoxJobTitle.Size = new Size(146, 23);
|
||||
textBoxJobTitle.TabIndex = 12;
|
||||
//
|
||||
// add
|
||||
//
|
||||
add.Location = new Point(6, 269);
|
||||
add.Name = "add";
|
||||
add.Size = new Size(70, 26);
|
||||
add.TabIndex = 0;
|
||||
add.Text = "add";
|
||||
add.UseVisualStyleBackColor = true;
|
||||
add.Click += add_Click;
|
||||
//
|
||||
// clearTreeList
|
||||
//
|
||||
clearTreeList.Location = new Point(6, 300);
|
||||
clearTreeList.Name = "clearTreeList";
|
||||
clearTreeList.Size = new Size(145, 26);
|
||||
clearTreeList.TabIndex = 1;
|
||||
clearTreeList.Text = "clear";
|
||||
clearTreeList.UseVisualStyleBackColor = true;
|
||||
clearTreeList.Click += clearTreeList_Click;
|
||||
//
|
||||
// textBoxFullName
|
||||
//
|
||||
textBoxFullName.Location = new Point(6, 211);
|
||||
textBoxFullName.Name = "textBoxFullName";
|
||||
textBoxFullName.Size = new Size(146, 23);
|
||||
textBoxFullName.TabIndex = 2;
|
||||
//
|
||||
// getObject
|
||||
//
|
||||
getObject.Location = new Point(81, 269);
|
||||
getObject.Name = "getObject";
|
||||
getObject.Size = new Size(70, 26);
|
||||
getObject.TabIndex = 3;
|
||||
getObject.Text = "get object";
|
||||
getObject.UseVisualStyleBackColor = true;
|
||||
getObject.Click += getObject_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(518, 357);
|
||||
Controls.Add(groupBox3);
|
||||
Controls.Add(groupBox2);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
groupBox2.ResumeLayout(false);
|
||||
groupBox2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericMax).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericMin).EndInit();
|
||||
groupBox3.ResumeLayout(false);
|
||||
groupBox3.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button input;
|
||||
private Button clear;
|
||||
private TextBox textBox1;
|
||||
private Button set;
|
||||
private Button get;
|
||||
private ComponentLibrary1.CheckList checkList;
|
||||
private CheckBox changeBox;
|
||||
private GroupBox groupBox1;
|
||||
private GroupBox groupBox2;
|
||||
private Button write;
|
||||
private Button read;
|
||||
private TextBox textBox2;
|
||||
private CheckBox changeBox2;
|
||||
private ComponentLibrary1.LimitedText limitedText;
|
||||
private Button inputMax;
|
||||
private Button inputMin;
|
||||
private NumericUpDown numericMin;
|
||||
private NumericUpDown numericMax;
|
||||
private GroupBox groupBox3;
|
||||
private Button add;
|
||||
private Button clearTreeList;
|
||||
private TextBox textBoxFullName;
|
||||
private Button getObject;
|
||||
private TextBox textBoxDepartment;
|
||||
private TextBox textBoxJobTitle;
|
||||
private ComponentLibrary1.tree_list.TreeList treeList;
|
||||
private TextBox textBoxOutput;
|
||||
}
|
||||
}
|
136
TestApp1/Form1.cs
Normal file
136
TestApp1/Form1.cs
Normal file
@ -0,0 +1,136 @@
|
||||
namespace TestApp1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
checkList.ChangeEvent += DoChange;
|
||||
limitedText.ChangeEvent += DoChange2;
|
||||
List<string> categories = new List<string>();
|
||||
categories.Add("Department");
|
||||
categories.Add("JobTitle");
|
||||
categories.Add("FullName");
|
||||
treeList.SetCategories(categories);
|
||||
}
|
||||
|
||||
#region test1
|
||||
private void input_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
checkList.Input(textBox1.Text);
|
||||
textBox1.Text = string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void clear_Click(object sender, EventArgs e)
|
||||
{
|
||||
checkList.Clear();
|
||||
}
|
||||
|
||||
private void set_Click(object sender, EventArgs e)
|
||||
{
|
||||
checkList.SelectedItem = textBox1.Text;
|
||||
}
|
||||
|
||||
private void get_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = checkList.SelectedItem;
|
||||
}
|
||||
private void DoChange(object? sender, EventArgs e)
|
||||
{
|
||||
changeBox.Checked = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region test2
|
||||
private void write_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
limitedText.TextField = textBox2.Text;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void read_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
textBox2.Text = limitedText.TextField;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void inputMin_Click(object sender, EventArgs e)
|
||||
{
|
||||
limitedText.Min = (int)numericMin.Value;
|
||||
}
|
||||
|
||||
private void inputMax_Click(object sender, EventArgs e)
|
||||
{
|
||||
limitedText.Max = (int)numericMax.Value;
|
||||
}
|
||||
|
||||
private void DoChange2(object? sender, EventArgs e)
|
||||
{
|
||||
changeBox2.Checked = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region test3
|
||||
private void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxDepartment.Text) ||
|
||||
string.IsNullOrEmpty(textBoxJobTitle.Text) ||
|
||||
string.IsNullOrEmpty(textBoxFullName.Text))
|
||||
{
|
||||
throw new Exception("Çàïîëíèòå äàííûå ñîòðóäíèêà");
|
||||
}
|
||||
treeList.AddTreeListObject(new Employee(textBoxDepartment.Text, textBoxJobTitle.Text, textBoxFullName.Text));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTreeList_Click(object sender, EventArgs e)
|
||||
{
|
||||
treeList.Clear();
|
||||
}
|
||||
|
||||
private void getObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Employee? employee = treeList.GetSelectedObject<Employee>();
|
||||
if (employee == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxDepartment.Text = employee.Department;
|
||||
textBoxJobTitle.Text = employee.JobTitle;
|
||||
textBoxFullName.Text = employee.FullName;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
120
TestApp1/Form1.resx
Normal file
120
TestApp1/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>
|
17
TestApp1/Program.cs
Normal file
17
TestApp1/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace TestApp1
|
||||
{
|
||||
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
TestApp1/TestApp1.csproj
Normal file
15
TestApp1/TestApp1.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="..\ComponentLibrary1\ComponentLibrary1.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user