diff --git a/Component_1/Component_1.csproj b/Component_1/Component_1.csproj
deleted file mode 100644
index 060aa1c..0000000
--- a/Component_1/Component_1.csproj
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- net6.0-windows
- enable
- true
- enable
-
-
-
diff --git a/Component_1/List_with_choice.cs b/Component_1/List_with_choice.cs
deleted file mode 100644
index 05baf52..0000000
--- a/Component_1/List_with_choice.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Component_1
-{
- public partial class List_with_choice : UserControl
- {
- private event EventHandler? _checkedlistChanged;
- private event Action? _errorOccured;
- public string Error { get; private set; }
-
- public String Element
- {
- get
- {
- if (checkedListBox1.SelectedItem != null) return checkedListBox1.SelectedItem.ToString();
- else return string.Empty;
- }
- set
- {
- checkedListBox1.SelectedItem = value;
- }
- }
-
- public event EventHandler Checkedlist
- {
- add { _checkedlistChanged += value; }
- remove { _checkedlistChanged -= value; }
- }
- public event Action AnErrorOccurred
- {
- add { _errorOccured += value; }
- remove { _errorOccured -= value; }
- }
-
- public List_with_choice()
- {
- InitializeComponent();
- Error = string.Empty;
- }
-
- public void Fill_List(string str) //метод заполнения списка
- {
- if (str == null)
- {
- MessageBox.Show("Вы не ввели строку");
- return;
- }
-
- string[] list = str.Split(' ');
- foreach (string s in list)
- {
- checkedListBox1.Items.Add(s);
- }
- }
- public void Clean_List() //метод очистки списка
- {
- checkedListBox1.Items.Clear();
- }
- private void button_Load_Click(object sender, EventArgs e)
- {
- string value = "";
- if (InputBox("Заполнение списка", "Пожалуйста введите строку", ref value) == DialogResult.OK)
- {
- try
- {
- Fill_List(value);
- _checkedlistChanged?.Invoke(this, e);
- }
- catch (Exception ex)
- {
- Error = ex.Message;
- _errorOccured?.Invoke();
- }
- }
- }
-
- private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- }
- public static DialogResult InputBox(string title, string promptText, ref string value)//диалоговое окно
- {
- Form form = new Form();
- Label label = new Label();
- TextBox textBox = new TextBox();
- Button buttonOk = new Button();
- Button buttonCancel = new Button();
- form.Text = title;
- label.Text = promptText;
- buttonOk.Text = "OK";
- buttonCancel.Text = "Cancel";
- buttonOk.DialogResult = DialogResult.OK;
- buttonCancel.DialogResult = DialogResult.Cancel;
- label.SetBounds(36, 36, 372, 13);
- textBox.SetBounds(36, 86, 700, 20);
- buttonOk.SetBounds(228, 160, 160, 60);
- buttonCancel.SetBounds(400, 160, 160, 60);
- label.AutoSize = true;
- form.ClientSize = new Size(796, 307);
- form.FormBorderStyle = FormBorderStyle.FixedDialog;
- form.StartPosition = FormStartPosition.CenterScreen;
- form.MinimizeBox = false;
- form.MaximizeBox = false;
- form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
- form.AcceptButton = buttonOk;
- form.CancelButton = buttonCancel;
- DialogResult dialogResult = form.ShowDialog();
- value = textBox.Text;
- return dialogResult;
- }
- private void button_Clean_Click(object sender, EventArgs e)
- {
- Clean_List();
- }
- }
-}
diff --git a/Components/Form1.Designer.cs b/Components/Form1.Designer.cs
deleted file mode 100644
index 5f886be..0000000
--- a/Components/Form1.Designer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-namespace Components
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- list_with_choice1 = new Component_1.List_with_choice();
- SuspendLayout();
- //
- // list_with_choice1
- //
- list_with_choice1.Element = "";
- list_with_choice1.Location = new Point(131, 60);
- list_with_choice1.Name = "list_with_choice1";
- list_with_choice1.Size = new Size(464, 248);
- list_with_choice1.TabIndex = 0;
- //
- // Form1
- //
- AutoScaleDimensions = new SizeF(8F, 20F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
- Controls.Add(list_with_choice1);
- Name = "Form1";
- Text = "Form1";
- ResumeLayout(false);
- }
-
- #endregion
-
- private Component_1.List_with_choice list_with_choice1;
- }
-}
\ No newline at end of file
diff --git a/Components/Form1.cs b/Components/Form1.cs
deleted file mode 100644
index f7f2d20..0000000
--- a/Components/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Components
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/TestView/Book.cs b/TestView/Book.cs
new file mode 100644
index 0000000..9a3bc9e
--- /dev/null
+++ b/TestView/Book.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TestView
+{
+ public class Book
+ {
+ public string Genre;
+ public string Author;
+ public string Title;
+
+ public Book(string Genre, string Author, string Title)
+ {
+ this.Genre = Genre;
+ this.Author = Author;
+ this.Title = Title;
+ }
+
+ public Book()
+ {
+ Genre = string.Empty;
+ Author = string.Empty;
+ Title= string.Empty;
+ }
+ }
+}
diff --git a/TestView/Form1.Designer.cs b/TestView/Form1.Designer.cs
new file mode 100644
index 0000000..f4948c5
--- /dev/null
+++ b/TestView/Form1.Designer.cs
@@ -0,0 +1,226 @@
+namespace TestView
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ buttonAdd = new Button();
+ buttonClear = new Button();
+ buttonSelect = new Button();
+ list_with_choice = new ViewComponents.List_with_choice();
+ input_text = new ViewComponents.Input_text();
+ buttonDip = new Button();
+ buttonVal = new Button();
+ buttonCheck = new Button();
+ buttonIerarhy = new Button();
+ buttonAddBook = new Button();
+ buttonGetValue = new Button();
+ buttonGetIndex = new Button();
+ buttonSetIndex = new Button();
+ myTreeView = new ViewComponents.MyTreeView();
+ SuspendLayout();
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(25, 137);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(94, 29);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonClear
+ //
+ buttonClear.Location = new Point(163, 137);
+ buttonClear.Name = "buttonClear";
+ buttonClear.Size = new Size(94, 29);
+ buttonClear.TabIndex = 2;
+ buttonClear.Text = "Очистить";
+ buttonClear.UseVisualStyleBackColor = true;
+ buttonClear.Click += buttonClear_Click;
+ //
+ // buttonSelect
+ //
+ buttonSelect.Location = new Point(60, 172);
+ buttonSelect.Name = "buttonSelect";
+ buttonSelect.Size = new Size(163, 29);
+ buttonSelect.TabIndex = 3;
+ buttonSelect.Text = "Выбранный элемент";
+ buttonSelect.UseVisualStyleBackColor = true;
+ buttonSelect.Click += buttonSelect_Click;
+ //
+ // list_with_choice
+ //
+ list_with_choice.Element = "";
+ list_with_choice.Location = new Point(25, 12);
+ list_with_choice.Name = "list_with_choice";
+ list_with_choice.Size = new Size(232, 119);
+ list_with_choice.TabIndex = 4;
+ list_with_choice.SelectedItemChange += list_with_choice_SelectedItemChange;
+ //
+ // input_text
+ //
+ input_text.Location = new Point(312, 12);
+ input_text.MaxLen = null;
+ input_text.MinLen = null;
+ input_text.Name = "input_text";
+ input_text.Size = new Size(240, 119);
+ input_text.TabIndex = 5;
+ input_text.ItemChange += input_text_ItemChange;
+ //
+ // buttonDip
+ //
+ buttonDip.Location = new Point(312, 137);
+ buttonDip.Name = "buttonDip";
+ buttonDip.Size = new Size(94, 29);
+ buttonDip.TabIndex = 6;
+ buttonDip.Text = "Диапазон";
+ buttonDip.UseVisualStyleBackColor = true;
+ buttonDip.Click += buttonDip_Click;
+ //
+ // buttonVal
+ //
+ buttonVal.Location = new Point(458, 137);
+ buttonVal.Name = "buttonVal";
+ buttonVal.Size = new Size(94, 29);
+ buttonVal.TabIndex = 7;
+ buttonVal.Text = "Значение";
+ buttonVal.UseVisualStyleBackColor = true;
+ buttonVal.Click += buttonVal_Click;
+ //
+ // buttonCheck
+ //
+ buttonCheck.Location = new Point(360, 172);
+ buttonCheck.Name = "buttonCheck";
+ buttonCheck.Size = new Size(143, 29);
+ buttonCheck.TabIndex = 8;
+ buttonCheck.Text = " Проверка текста";
+ buttonCheck.UseVisualStyleBackColor = true;
+ buttonCheck.Click += buttonCheck_Click;
+ //
+ // buttonIerarhy
+ //
+ buttonIerarhy.Location = new Point(652, 32);
+ buttonIerarhy.Name = "buttonIerarhy";
+ buttonIerarhy.Size = new Size(168, 29);
+ buttonIerarhy.TabIndex = 10;
+ buttonIerarhy.Text = "Задать иерархию";
+ buttonIerarhy.UseVisualStyleBackColor = true;
+ buttonIerarhy.Click += buttonIerarhy_Click;
+ //
+ // buttonAddBook
+ //
+ buttonAddBook.Location = new Point(652, 67);
+ buttonAddBook.Name = "buttonAddBook";
+ buttonAddBook.Size = new Size(168, 29);
+ buttonAddBook.TabIndex = 11;
+ buttonAddBook.Text = "Добавить книги";
+ buttonAddBook.UseVisualStyleBackColor = true;
+ buttonAddBook.Click += buttonAddBook_Click;
+ //
+ // buttonGetValue
+ //
+ buttonGetValue.Location = new Point(652, 102);
+ buttonGetValue.Name = "buttonGetValue";
+ buttonGetValue.Size = new Size(168, 29);
+ buttonGetValue.TabIndex = 12;
+ buttonGetValue.Text = "Получить значение";
+ buttonGetValue.UseVisualStyleBackColor = true;
+ buttonGetValue.Click += buttonGetValue_Click;
+ //
+ // buttonGetIndex
+ //
+ buttonGetIndex.Location = new Point(652, 137);
+ buttonGetIndex.Name = "buttonGetIndex";
+ buttonGetIndex.Size = new Size(168, 29);
+ buttonGetIndex.TabIndex = 13;
+ buttonGetIndex.Text = "Получить индекс";
+ buttonGetIndex.UseVisualStyleBackColor = true;
+ buttonGetIndex.Click += buttonGetIndex_Click;
+ //
+ // buttonSetIndex
+ //
+ buttonSetIndex.Location = new Point(652, 172);
+ buttonSetIndex.Name = "buttonSetIndex";
+ buttonSetIndex.Size = new Size(168, 29);
+ buttonSetIndex.TabIndex = 14;
+ buttonSetIndex.Text = "Установить индекс";
+ buttonSetIndex.UseVisualStyleBackColor = true;
+ buttonSetIndex.Click += buttonSetIndex_Click;
+ //
+ // myTreeView
+ //
+ myTreeView.Location = new Point(629, 218);
+ myTreeView.Name = "myTreeView";
+ myTreeView.SelectedNodeIndex = -1;
+ myTreeView.Size = new Size(226, 204);
+ myTreeView.TabIndex = 8;
+ //
+ // Form1
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(909, 450);
+ Controls.Add(myTreeView);
+ Controls.Add(buttonSetIndex);
+ Controls.Add(buttonGetIndex);
+ Controls.Add(buttonGetValue);
+ Controls.Add(buttonAddBook);
+ Controls.Add(buttonIerarhy);
+ Controls.Add(buttonCheck);
+ Controls.Add(buttonVal);
+ Controls.Add(buttonDip);
+ Controls.Add(input_text);
+ Controls.Add(list_with_choice);
+ Controls.Add(buttonSelect);
+ Controls.Add(buttonClear);
+ Controls.Add(buttonAdd);
+ Name = "Form1";
+ Text = "Form1";
+ Load += Form1_Load;
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonAdd;
+ private Button buttonClear;
+ private Button buttonSelect;
+ private ViewComponents.List_with_choice list_with_choice;
+ private ViewComponents.Input_text input_text;
+ private Button buttonDip;
+ private Button buttonVal;
+ private Button buttonCheck;
+ private Button buttonIerarhy;
+ private Button buttonAddBook;
+ private Button buttonGetValue;
+ private Button buttonGetIndex;
+ private Button buttonSetIndex;
+ private ViewComponents.MyTreeView myTreeView;
+ }
+}
\ No newline at end of file
diff --git a/TestView/Form1.cs b/TestView/Form1.cs
new file mode 100644
index 0000000..aca5d9d
--- /dev/null
+++ b/TestView/Form1.cs
@@ -0,0 +1,106 @@
+using ViewComponents.Exeption;
+
+namespace TestView
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ string str = " ";
+
+ list_with_choice.Fill_List(str);
+ list_with_choice.Element = "";
+ }
+
+ private void buttonClear_Click(object sender, EventArgs e)
+ {
+ list_with_choice.Clean_List();
+ }
+
+ private void buttonSelect_Click(object sender, EventArgs e)
+ {
+ MessageBox.Show(list_with_choice.Element ?? "null", " ");
+ }
+
+ private void list_with_choice_SelectedItemChange(string obj)
+ {
+ MessageBox.Show(obj, " ");
+ }
+
+ private void buttonDip_Click(object sender, EventArgs e)
+ {
+ input_text.MinLen = 5;
+ input_text.MaxLen = 25;
+
+ MessageBox.Show($"Min: {input_text.minlen}; Max: {input_text.maxlen}");
+ }
+
+ private void buttonVal_Click(object sender, EventArgs e)
+ {
+ input_text.Element = "";
+ }
+
+ private void input_text_ItemChange(string obj)
+ {
+ MessageBox.Show(obj, " ");
+ }
+
+ private void buttonCheck_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ string val = input_text.Element;
+ MessageBox.Show(val, " ");
+ }
+ catch (TextBoundsNotSetExeption ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ catch (TextOutOfBoundsExeption ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ private void buttonIerarhy_Click(object sender, EventArgs e)
+ {
+ myTreeView.setHierarchy(new List<(string, bool)> { ("Genre", false), ("Author", false), ("Title", true) });
+ MessageBox.Show(" ");
+ }
+
+ private void buttonAddBook_Click(object sender, EventArgs e)
+ {
+
+ myTreeView.addItem(new Book("", " ..", "̸ "));
+ myTreeView.addItem(new Book("", " ..", " "));
+ myTreeView.addItem(new Book("", " ", "1984"));
+ }
+
+ private void buttonGetValue_Click(object sender, EventArgs e)
+ {
+ Book? book = myTreeView.getSelecetedNodeValue();
+ if (book == null) return;
+ MessageBox.Show(": " + book.Genre + ", : " + book.Author + ", : " + book.Title);
+ }
+
+ private void buttonGetIndex_Click(object sender, EventArgs e)
+ {
+ MessageBox.Show(myTreeView.SelectedNodeIndex.ToString());
+ }
+
+ private void buttonSetIndex_Click(object sender, EventArgs e)
+ {
+ myTreeView.SelectedNodeIndex = 0;
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Components/Form1.resx b/TestView/Form1.resx
similarity index 100%
rename from Components/Form1.resx
rename to TestView/Form1.resx
diff --git a/Components/Program.cs b/TestView/Program.cs
similarity index 94%
rename from Components/Program.cs
rename to TestView/Program.cs
index 152253d..f48de6e 100644
--- a/Components/Program.cs
+++ b/TestView/Program.cs
@@ -1,4 +1,4 @@
-namespace Components
+namespace TestView
{
internal static class Program
{
diff --git a/TestView/TestView.csproj b/TestView/TestView.csproj
new file mode 100644
index 0000000..6a6365a
--- /dev/null
+++ b/TestView/TestView.csproj
@@ -0,0 +1,22 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+ TestView
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Components/Components.sln b/TestView/TestView.sln
similarity index 66%
rename from Components/Components.sln
rename to TestView/TestView.sln
index e57d51c..903e4f7 100644
--- a/Components/Components.sln
+++ b/TestView/TestView.sln
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "Components.csproj", "{637B2B5F-8015-4DE8-B264-74F24B115812}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestView", "TestView.csproj", "{637B2B5F-8015-4DE8-B264-74F24B115812}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Component_1", "..\Component_1\Component_1.csproj", "{9E53BE81-4309-40C4-B6F8-0C80756EE09E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewComponents", "..\ViewComponents\ViewComponents.csproj", "{45A652EE-B79B-4F5B-BB2A-2A51F5BEA2F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +17,10 @@ Global
{637B2B5F-8015-4DE8-B264-74F24B115812}.Debug|Any CPU.Build.0 = Debug|Any CPU
{637B2B5F-8015-4DE8-B264-74F24B115812}.Release|Any CPU.ActiveCfg = Release|Any CPU
{637B2B5F-8015-4DE8-B264-74F24B115812}.Release|Any CPU.Build.0 = Release|Any CPU
- {9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {45A652EE-B79B-4F5B-BB2A-2A51F5BEA2F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {45A652EE-B79B-4F5B-BB2A-2A51F5BEA2F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {45A652EE-B79B-4F5B-BB2A-2A51F5BEA2F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {45A652EE-B79B-4F5B-BB2A-2A51F5BEA2F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ViewComponents/Exeption/TextBoundsNotSetExeption.cs b/ViewComponents/Exeption/TextBoundsNotSetExeption.cs
new file mode 100644
index 0000000..36c5b76
--- /dev/null
+++ b/ViewComponents/Exeption/TextBoundsNotSetExeption.cs
@@ -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 ViewComponents.Exeption
+{
+ [Serializable]
+ public class TextBoundsNotSetExeption: ApplicationException
+ {
+ public TextBoundsNotSetExeption() : base() { }
+ public TextBoundsNotSetExeption(string message) : base(message) { }
+ public TextBoundsNotSetExeption(string message, Exception exception) : base(message, exception) { }
+ protected TextBoundsNotSetExeption(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
+ }
+}
diff --git a/ViewComponents/Exeption/TextOutOfBoundsExeption.cs b/ViewComponents/Exeption/TextOutOfBoundsExeption.cs
new file mode 100644
index 0000000..0ef2d94
--- /dev/null
+++ b/ViewComponents/Exeption/TextOutOfBoundsExeption.cs
@@ -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 ViewComponents.Exeption
+{
+ [Serializable]
+ public class TextOutOfBoundsExeption: ApplicationException
+ {
+ public TextOutOfBoundsExeption() : base() { }
+ public TextOutOfBoundsExeption(string message) : base(message) { }
+ public TextOutOfBoundsExeption(string message, Exception exception) : base(message, exception) { }
+ protected TextOutOfBoundsExeption(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
+ }
+}
diff --git a/ViewComponents/Input_text.Designer.cs b/ViewComponents/Input_text.Designer.cs
new file mode 100644
index 0000000..0117cc0
--- /dev/null
+++ b/ViewComponents/Input_text.Designer.cs
@@ -0,0 +1,58 @@
+namespace ViewComponents
+{
+ partial class Input_text
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором компонентов
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ textBox1 = new TextBox();
+ SuspendLayout();
+ //
+ // textBox1
+ //
+ textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ textBox1.Location = new Point(19, 25);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(154, 27);
+ textBox1.TabIndex = 0;
+ textBox1.TextChanged += textBox1_TextChanged;
+ //
+ // Input_text
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ Controls.Add(textBox1);
+ Name = "Input_text";
+ Size = new Size(192, 79);
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBox1;
+ }
+}
diff --git a/ViewComponents/Input_text.cs b/ViewComponents/Input_text.cs
new file mode 100644
index 0000000..28d216e
--- /dev/null
+++ b/ViewComponents/Input_text.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using ViewComponents.Exeption;
+
+namespace ViewComponents
+{
+ public partial class Input_text : UserControl
+ {
+ public Input_text()
+ {
+ InitializeComponent();
+ }
+
+ public event Action ItemChange;
+ private bool isMin = false;
+ private bool isMax = false;
+
+ public int? minlen;
+ public int? maxlen;
+ public string? Element
+ {
+ get
+ {
+ if (!isMax || !isMin) throw new TextBoundsNotSetExeption("Диапазон не задан");
+ if(textBox1.Text.Length < minlen || textBox1.Text.Length > maxlen) throw new TextOutOfBoundsExeption("Слово не из диапазона");
+ return textBox1.Text;
+ }
+ set
+ {
+ if (isMin && isMax && value != null && value.Length >= minlen && value.Length <= maxlen) textBox1.Text = value;
+ }
+ }
+
+ public int? MinLen
+ {
+ get
+ {
+ if (isMin == true) return minlen;
+ else return null;
+ }
+ set
+ {
+ if (value.HasValue)
+ {
+ minlen = value;
+ isMin = true;
+ }
+ }
+ }
+
+ public int? MaxLen
+ {
+ get
+ {
+ if (isMax == true) return maxlen;
+ else return null;
+ }
+ set
+ {
+ if (value.HasValue)
+ {
+ maxlen = value;
+ isMax = true;
+ }
+ }
+ }
+
+ private void textBox1_TextChanged(object sender, EventArgs e)
+ {
+ ItemChange?.Invoke(textBox1.Text);
+ }
+ }
+}
diff --git a/Component_1/List_with_choice.resx b/ViewComponents/Input_text.resx
similarity index 100%
rename from Component_1/List_with_choice.resx
rename to ViewComponents/Input_text.resx
diff --git a/Component_1/List_with_choice.Designer.cs b/ViewComponents/List_with_choice.Designer.cs
similarity index 57%
rename from Component_1/List_with_choice.Designer.cs
rename to ViewComponents/List_with_choice.Designer.cs
index 0328fe5..e3861a7 100644
--- a/Component_1/List_with_choice.Designer.cs
+++ b/ViewComponents/List_with_choice.Designer.cs
@@ -1,4 +1,4 @@
-namespace Component_1
+namespace ViewComponents
{
partial class List_with_choice
{
@@ -29,58 +29,30 @@
private void InitializeComponent()
{
checkedListBox1 = new CheckedListBox();
- button_Load = new Button();
- button_Clean = new Button();
SuspendLayout();
//
// checkedListBox1
//
- checkedListBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ checkedListBox1.Dock = DockStyle.Fill;
checkedListBox1.FormattingEnabled = true;
- checkedListBox1.Location = new Point(85, 23);
+ checkedListBox1.Location = new Point(0, 0);
checkedListBox1.Name = "checkedListBox1";
- checkedListBox1.Size = new Size(201, 92);
+ checkedListBox1.Size = new Size(208, 150);
checkedListBox1.TabIndex = 0;
checkedListBox1.SelectedIndexChanged += checkedListBox1_SelectedIndexChanged;
//
- // button_Load
- //
- button_Load.Anchor = AnchorStyles.Bottom;
- button_Load.Location = new Point(6, 146);
- button_Load.Name = "button_Load";
- button_Load.Size = new Size(161, 29);
- button_Load.TabIndex = 1;
- button_Load.Text = "Заполнить список";
- button_Load.UseVisualStyleBackColor = true;
- button_Load.Click += button_Load_Click;
- //
- // button_Clean
- //
- button_Clean.Anchor = AnchorStyles.Bottom;
- button_Clean.Location = new Point(203, 146);
- button_Clean.Name = "button_Clean";
- button_Clean.Size = new Size(153, 29);
- button_Clean.TabIndex = 2;
- button_Clean.Text = "Очистить список";
- button_Clean.UseVisualStyleBackColor = true;
- button_Clean.Click += button_Clean_Click;
- //
// List_with_choice
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- Controls.Add(button_Clean);
- Controls.Add(button_Load);
Controls.Add(checkedListBox1);
Name = "List_with_choice";
- Size = new Size(371, 198);
+ Size = new Size(208, 150);
ResumeLayout(false);
}
#endregion
private CheckedListBox checkedListBox1;
- private Button button_Load;
- private Button button_Clean;
}
}
diff --git a/ViewComponents/List_with_choice.cs b/ViewComponents/List_with_choice.cs
new file mode 100644
index 0000000..f8d67d0
--- /dev/null
+++ b/ViewComponents/List_with_choice.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ViewComponents
+{
+ public partial class List_with_choice : UserControl
+ {
+ public List_with_choice()
+ {
+ InitializeComponent();
+ }
+
+ public event Action SelectedItemChange;
+
+ public string? Element
+ {
+ get
+ {
+ if (checkedListBox1.SelectedItem != null) return checkedListBox1.SelectedItem.ToString();
+ else return string.Empty;
+ }
+ set
+ {
+ if (value != null && checkedListBox1.Items.Contains(value)) checkedListBox1.SelectedItem = value;
+ }
+ }
+
+ public void Fill_List(string str) //метод заполнения списка
+ {
+ if (str == null)
+ {
+ MessageBox.Show("Вы не ввели строку");
+ return;
+ }
+
+ string[] list = str.Split(' ');
+ foreach (string s in list)
+ {
+ checkedListBox1.Items.Add(s);
+ }
+ }
+ public void Clean_List() //метод очистки списка
+ {
+ checkedListBox1.Items.Clear();
+ }
+
+ private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ SelectedItemChange?.Invoke(checkedListBox1.SelectedItem.ToString());
+ }
+
+ }
+}
diff --git a/ViewComponents/List_with_choice.resx b/ViewComponents/List_with_choice.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/ViewComponents/List_with_choice.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ViewComponents/MyTreeView.Designer.cs b/ViewComponents/MyTreeView.Designer.cs
new file mode 100644
index 0000000..3ad94a4
--- /dev/null
+++ b/ViewComponents/MyTreeView.Designer.cs
@@ -0,0 +1,55 @@
+namespace ViewComponents
+{
+ partial class MyTreeView
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором компонентов
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ treeView = new TreeView();
+ SuspendLayout();
+ //
+ // treeView
+ //
+ treeView.Location = new Point(13, 18);
+ treeView.Name = "treeView";
+ treeView.Size = new Size(176, 148);
+ treeView.TabIndex = 0;
+ //
+ // MyTreeView
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ Controls.Add(treeView);
+ Name = "MyTreeView";
+ Size = new Size(204, 192);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TreeView treeView;
+ }
+}
diff --git a/ViewComponents/MyTreeView.cs b/ViewComponents/MyTreeView.cs
new file mode 100644
index 0000000..f5dab4c
--- /dev/null
+++ b/ViewComponents/MyTreeView.cs
@@ -0,0 +1,88 @@
+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;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
+namespace ViewComponents
+{
+ public partial class MyTreeView : UserControl
+ {
+ public MyTreeView()
+ {
+ InitializeComponent();
+ }
+ private List<(string, bool)> hierarchy = new List<(string, bool)>();
+
+ public int SelectedNodeIndex
+ {
+ get
+ {
+ return treeView.SelectedNode?.Index ?? -1;
+ }
+ set
+ {
+ if (treeView.SelectedNode == null) treeView.SelectedNode = value >= 0 && value < treeView.Nodes.Count ? treeView.Nodes[value] : treeView.SelectedNode;
+ else treeView.SelectedNode = value >= 0 && value < treeView.SelectedNode.Nodes.Count ? treeView.SelectedNode.Nodes[value] : treeView.SelectedNode;
+ }
+ }
+
+ public T? getSelecetedNodeValue()
+ {
+ if (treeView.SelectedNode == null || treeView.SelectedNode.Nodes.Count > 0) return default(T);
+
+ TreeNode? node = treeView.SelectedNode;
+
+ var type = typeof(T);
+ var fields = type.GetFields();
+
+ var item = Activator.CreateInstance(type);
+
+ while (node != null)
+ {
+ var field = fields.FirstOrDefault(x => x.Name == node.Name);
+ if (field != null)
+ {
+ field.SetValue(item, node.Text);
+ }
+ node = node.Parent;
+ }
+
+ return item != null ? (T)item : default(T);
+ }
+
+ public void setHierarchy(List<(string, bool)> fields)
+ {
+ hierarchy = fields;
+ }
+
+ public void addItem(T item)
+ {
+ var type = typeof(T);
+ var fields = type.GetFields();
+ TreeNodeCollection nodes = treeView.Nodes;
+ for (int i = 0; i < hierarchy.Count; i++)
+ {
+ var field = fields.FirstOrDefault(x => x.Name.Equals(hierarchy[i].Item1));
+ if (field is not null)
+ {
+ var node = nodes.Find(field.Name, false).FirstOrDefault(x => x.Text == field.GetValue(item).ToString());
+ if (node is not null && !hierarchy[i].Item2)
+ {
+ nodes = node.Nodes;
+ }
+ else
+ {
+ TreeNode newNode = nodes.Add(field.Name, field.GetValue(item).ToString());
+ nodes = newNode.Nodes;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/ViewComponents/MyTreeView.resx b/ViewComponents/MyTreeView.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/ViewComponents/MyTreeView.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Components/Components.csproj b/ViewComponents/ViewComponents.csproj
similarity index 63%
rename from Components/Components.csproj
rename to ViewComponents/ViewComponents.csproj
index 88864a0..cb2cc1c 100644
--- a/Components/Components.csproj
+++ b/ViewComponents/ViewComponents.csproj
@@ -1,7 +1,6 @@
- WinExe
net6.0-windows
enable
true
@@ -9,7 +8,10 @@
-
+
+ UserControl
+ TestView
+
-
\ No newline at end of file
+