diff --git a/WinForms/VisualComponentsLib/Class1.cs b/WinForms/VisualComponentsLib/Class1.cs
new file mode 100644
index 0000000..9ccbd59
--- /dev/null
+++ b/WinForms/VisualComponentsLib/Class1.cs
@@ -0,0 +1,6 @@
+namespace VisualComponentsLib
+{
+ public class Class1
+ {
+ }
+}
\ No newline at end of file
diff --git a/WinForms/VisualComponentsLib/MyDropDownList.Designer.cs b/WinForms/VisualComponentsLib/MyDropDownList.Designer.cs
new file mode 100644
index 0000000..598d04b
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyDropDownList.Designer.cs
@@ -0,0 +1,59 @@
+namespace WinForms
+{
+ partial class MyDropDownList
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ 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()
+ {
+ this.dropDownList = new System.Windows.Forms.ComboBox();
+ this.SuspendLayout();
+ //
+ // dropDownList
+ //
+ this.dropDownList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.dropDownList.FormattingEnabled = true;
+ this.dropDownList.Location = new System.Drawing.Point(3, 3);
+ this.dropDownList.Name = "dropDownList";
+ this.dropDownList.Size = new System.Drawing.Size(187, 24);
+ this.dropDownList.TabIndex = 0;
+ this.dropDownList.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
+ //
+ // MyDropDownList
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.dropDownList);
+ this.Name = "MyDropDownList";
+ this.Size = new System.Drawing.Size(193, 30);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ComboBox dropDownList;
+ }
+}
diff --git a/WinForms/VisualComponentsLib/MyDropDownList.cs b/WinForms/VisualComponentsLib/MyDropDownList.cs
new file mode 100644
index 0000000..8418261
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyDropDownList.cs
@@ -0,0 +1,74 @@
+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 WinForms
+{
+ public partial class MyDropDownList : UserControl
+ {
+ public MyDropDownList()
+ {
+ InitializeComponent();
+ }
+
+ public void LoadValues(List Values)
+ {
+ if (Values.Count == 0)
+ {
+ return;
+ }
+ dropDownList.Items.AddRange(Values.ToArray());
+ }
+ public void Clear()
+ {
+ dropDownList.Items.Clear();
+ }
+
+ public string SelectedValue
+ {
+ get
+ {
+ if (dropDownList.Items.Count == 0)
+ {
+ return "";
+ }
+ if (dropDownList.SelectedItem == null)
+ {
+ return "";
+ }
+ return dropDownList.SelectedItem.ToString();
+ }
+ set
+ {
+ if (dropDownList.Items.Contains(value))
+ {
+ dropDownList.SelectedItem = value;
+ }
+ }
+ }
+
+ private EventHandler onValueChanged;
+ public event EventHandler ValueChanged
+ {
+ add
+ {
+ onValueChanged += value;
+ }
+ remove
+ {
+ onValueChanged -= value;
+ }
+ }
+
+ private void comboBox_SelectedValueChanged(object sender, EventArgs e)
+ {
+ onValueChanged?.Invoke(sender, e);
+ }
+ }
+}
diff --git a/WinForms/VisualComponentsLib/MyDropDownList.resx b/WinForms/VisualComponentsLib/MyDropDownList.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyDropDownList.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/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs b/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs
new file mode 100644
index 0000000..4538fcc
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs
@@ -0,0 +1,59 @@
+namespace WinForms
+{
+ partial class MyEmailTextBox
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ 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()
+ {
+ this.emailTextBox = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // emailTextBox
+ //
+ this.emailTextBox.Location = new System.Drawing.Point(3, 3);
+ this.emailTextBox.Name = "emailTextBox";
+ this.emailTextBox.Size = new System.Drawing.Size(170, 22);
+ this.emailTextBox.TabIndex = 0;
+ this.emailTextBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
+ this.emailTextBox.Enter += new System.EventHandler(this.textBox_Enter);
+ //
+ // MyEmailTextBox
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.emailTextBox);
+ this.Name = "MyEmailTextBox";
+ this.Size = new System.Drawing.Size(177, 30);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox emailTextBox;
+ }
+}
diff --git a/WinForms/VisualComponentsLib/MyEmailTextBox.cs b/WinForms/VisualComponentsLib/MyEmailTextBox.cs
new file mode 100644
index 0000000..5fecd29
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyEmailTextBox.cs
@@ -0,0 +1,98 @@
+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;
+
+namespace WinForms
+{
+ public partial class MyEmailTextBox : UserControl
+ {
+ //Шаблон для textbox
+ private string pattern;
+ //Пример ввода
+ private string example = "ti@gmail.com";
+ public MyEmailTextBox()
+ {
+ InitializeComponent();
+ }
+ public string Pattern
+ {
+ get { return pattern; }
+ set { pattern = value; }
+ }
+ public string TextBoxValue
+ {
+ get
+ {
+ Regex rg = new Regex(Pattern);
+ bool address = rg.IsMatch(emailTextBox.Text);
+ if (address)
+ {
+ return emailTextBox.Text;
+ }
+ else
+ {
+ Error = "Некорректный ввод";
+ return null;
+ }
+ }
+ set
+ {
+ Regex rg = new Regex(Pattern);
+ bool address = rg.IsMatch(value);
+ if (address)
+ {
+ emailTextBox.Text = value;
+ }
+ else
+ {
+ Error = "Некорректный ввод";
+ }
+ }
+ }
+ public string Error
+ {
+ get; private set;
+ }
+ public void setExample(string str)
+ {
+ Regex rg = new Regex(Pattern);
+ bool address = rg.IsMatch(str);
+ if (address)
+ {
+ example = str;
+ }
+
+ }
+ private void textBox_Enter(object sender, EventArgs e)
+ {
+ int VisibleTime = 2000; //ms
+ ToolTip tooltip = new ToolTip();
+ tooltip.Show(example, emailTextBox, 30, -20, VisibleTime);
+ }
+
+ private EventHandler onValueChanged;
+ public event EventHandler ValueChanged
+ {
+ add
+ {
+ onValueChanged += value;
+ }
+ remove
+ {
+ onValueChanged -= value;
+ }
+ }
+
+ private void textBox_TextChanged(object sender, EventArgs e)
+ {
+ onValueChanged?.Invoke(sender, e);
+ }
+ }
+}
diff --git a/WinForms/VisualComponentsLib/MyEmailTextBox.resx b/WinForms/VisualComponentsLib/MyEmailTextBox.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyEmailTextBox.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/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs b/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs
new file mode 100644
index 0000000..38f4bf8
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs
@@ -0,0 +1,59 @@
+namespace VisualComponentsLib
+{
+ partial class MyListBoxObjects
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ 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()
+ {
+ this.listBoxObj = new System.Windows.Forms.ListBox();
+ this.SuspendLayout();
+ //
+ // listBoxObj
+ //
+ this.listBoxObj.FormattingEnabled = true;
+ this.listBoxObj.HorizontalScrollbar = true;
+ this.listBoxObj.ItemHeight = 16;
+ this.listBoxObj.Location = new System.Drawing.Point(3, 3);
+ this.listBoxObj.Name = "listBoxObj";
+ this.listBoxObj.Size = new System.Drawing.Size(353, 116);
+ this.listBoxObj.TabIndex = 0;
+ //
+ // MyListBoxObjects
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.listBoxObj);
+ this.Name = "MyListBoxObjects";
+ this.Size = new System.Drawing.Size(359, 133);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListBox listBoxObj;
+ }
+}
diff --git a/WinForms/VisualComponentsLib/MyListBoxObjects.cs b/WinForms/VisualComponentsLib/MyListBoxObjects.cs
new file mode 100644
index 0000000..d91d172
--- /dev/null
+++ b/WinForms/VisualComponentsLib/MyListBoxObjects.cs
@@ -0,0 +1,108 @@
+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 VisualComponentsLib
+{
+ public partial class MyListBoxObjects : UserControl
+ {
+ //Макетная строка
+ private string layoutString;
+ //начальный символ для обнаружения свойств/полей
+ private string startSymbol;
+ //конечный символ для обнаружения свойств/полей
+ private string endSymbol;
+ public MyListBoxObjects()
+ {
+ InitializeComponent();
+ }
+ //Метод для установки информации о макетной строке и символах (начального и конечного)
+ public void SetLayoutInfo(string layout, string startS, string endS)
+ {
+ if (layout == null || startS == null || endS == null)
+ {
+ return;
+ }
+ layoutString = layout;
+ startSymbol = startS;
+ endSymbol = endS;
+ }
+
+ //свойство для получения и заполнения индекса выбранного элемента
+ public int SelectedIndex
+ {
+ get
+ {
+ if (listBoxObj.SelectedIndex == -1)
+ {
+ return -1;
+ }
+ return listBoxObj.SelectedIndex;
+ }
+ set
+ {
+ if (listBoxObj.SelectedItems.Count != 0)
+ {
+ listBoxObj.SelectedIndex = value;
+ }
+ }
+ }
+
+ //Публичный параметризованный метод для получения объекта из выбранной строки(создать объект и через рефлексию заполнить свойства его).
+ public T GetObjectFromStr() where T : class, new()
+ {
+ string selStr = "";
+ if (listBoxObj.SelectedIndex != -1)
+ {
+ selStr = listBoxObj.SelectedItem.ToString();
+ }
+ T curObject = new T();
+ foreach (var pr in typeof(T).GetProperties())
+ {
+ if (!pr.CanWrite)
+ {
+ continue;
+ }
+ int borderOne = selStr.IndexOf(startSymbol);
+ StringBuilder sb = new StringBuilder(selStr);
+ sb[borderOne] = 'z';
+ selStr = sb.ToString();
+ int borderTwo = selStr.IndexOf(endSymbol);
+ if (borderOne == -1 || borderTwo == -1) break;
+ string propertyValue = selStr.Substring(borderOne + 1, borderTwo - borderOne - 1);
+ selStr = selStr.Substring(borderTwo + 1);
+ pr.SetValue(curObject, Convert.ChangeType(propertyValue, pr.PropertyType));
+ }
+ return curObject;
+ }
+ //параметризованный метод, у которого в передаваемых параметрах идет список объектов некого класса и через этот список идет заполнение ListBox;
+ public void AddInListBox(List objects)
+ {
+ if (layoutString == null || startSymbol == null || endSymbol == null)
+ {
+ MessageBox.Show("заполните информацию о макетной строке");
+ return;
+ }
+ if (!layoutString.Contains(startSymbol) || !layoutString.Contains(endSymbol))
+ {
+ MessageBox.Show("Макетная строка не содержит нужные элементы");
+ return;
+ }
+ foreach (var item in objects)
+ {
+ string str = layoutString;
+ foreach (var prop in item.GetType().GetProperties())
+ {
+ string str1 = $"{startSymbol}" + $"{prop.Name}" + $"{endSymbol}";
+ str = str.Replace(str1, $"{startSymbol}" + prop.GetValue(item).ToString() + $"{endSymbol}");
+ }
+ listBoxObj.Items.Add(str);
+ }
+ }
+ }
diff --git a/WinForms/WinForms/Form1.resx b/WinForms/VisualComponentsLib/MyListBoxObjects.resx
similarity index 100%
rename from WinForms/WinForms/Form1.resx
rename to WinForms/VisualComponentsLib/MyListBoxObjects.resx
diff --git a/WinForms/VisualComponentsLib/VisualComponentsLib.csproj b/WinForms/VisualComponentsLib/VisualComponentsLib.csproj
new file mode 100644
index 0000000..823907c
--- /dev/null
+++ b/WinForms/VisualComponentsLib/VisualComponentsLib.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+ UserControl
+
+
+ UserControl
+
+
+
+
diff --git a/WinForms/WinForms.sln b/WinForms/WinForms.sln
index 6559fa6..748d0d8 100644
--- a/WinForms/WinForms.sln
+++ b/WinForms/WinForms.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/WinForms/WinForms/Form1.cs b/WinForms/WinForms/Form1.cs
deleted file mode 100644
index b34c462..0000000
--- a/WinForms/WinForms/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace WinForms
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/WinForms/WinForms/Form1.Designer.cs b/WinForms/WinForms/FormForMyComponents.Designer.cs
similarity index 96%
rename from WinForms/WinForms/Form1.Designer.cs
rename to WinForms/WinForms/FormForMyComponents.Designer.cs
index e15634b..1554ba4 100644
--- a/WinForms/WinForms/Form1.Designer.cs
+++ b/WinForms/WinForms/FormForMyComponents.Designer.cs
@@ -1,6 +1,6 @@
namespace WinForms
{
- partial class Form1
+ partial class FormForMyComponents
{
///
/// Required designer variable.
diff --git a/WinForms/WinForms/FormForMyComponents.cs b/WinForms/WinForms/FormForMyComponents.cs
new file mode 100644
index 0000000..907d5c8
--- /dev/null
+++ b/WinForms/WinForms/FormForMyComponents.cs
@@ -0,0 +1,10 @@
+namespace WinForms
+{
+ public partial class FormForMyComponents : Form
+ {
+ public FormForMyComponents()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/WinForms/WinForms/FormForMyComponents.resx b/WinForms/WinForms/FormForMyComponents.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/WinForms/WinForms/FormForMyComponents.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/WinForms/WinForms/Program.cs b/WinForms/WinForms/Program.cs
index bf8b7fb..371be84 100644
--- a/WinForms/WinForms/Program.cs
+++ b/WinForms/WinForms/Program.cs
@@ -11,7 +11,7 @@ namespace WinForms
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormForMyComponents());
}
}
}
\ No newline at end of file
diff --git a/WinForms/WinForms/WinForms.csproj b/WinForms/WinForms/WinForms.csproj
index b57c89e..6a94a95 100644
--- a/WinForms/WinForms/WinForms.csproj
+++ b/WinForms/WinForms/WinForms.csproj
@@ -8,4 +8,8 @@
enable
+
+
+
+
\ No newline at end of file