From f47f91884e1e69d4efdff73f50a15006dfc43a20 Mon Sep 17 00:00:00 2001 From: Ismailov_Rovshan Date: Wed, 20 Sep 2023 23:39:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE-=D1=82=D0=BE=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinForms/VisualComponentsLib/Class1.cs | 6 - .../MyDropDownList.Designer.cs | 2 +- .../VisualComponentsLib/MyDropDownList.cs | 2 +- .../VisualComponentsLib/MyDropDownList.resx | 62 ++++- .../MyEmailTextBox.Designer.cs | 2 +- .../VisualComponentsLib/MyEmailTextBox.cs | 2 +- .../VisualComponentsLib/MyEmailTextBox.resx | 62 ++++- .../MyListBoxObjects.Designer.cs | 1 + .../VisualComponentsLib/MyListBoxObjects.cs | 1 + .../VisualComponentsLib/Object/Student.cs | 27 ++ .../VisualComponentsLib.csproj | 9 - .../WinForms/FormForComponents.Designer.cs | 231 ++++++++++++++++++ WinForms/WinForms/FormForComponents.cs | 88 +++++++ ...Components.resx => FormForComponents.resx} | 0 .../WinForms/FormForMyComponents.Designer.cs | 39 --- WinForms/WinForms/FormForMyComponents.cs | 10 - WinForms/WinForms/Program.cs | 2 +- 17 files changed, 475 insertions(+), 71 deletions(-) delete mode 100644 WinForms/VisualComponentsLib/Class1.cs create mode 100644 WinForms/VisualComponentsLib/Object/Student.cs create mode 100644 WinForms/WinForms/FormForComponents.Designer.cs create mode 100644 WinForms/WinForms/FormForComponents.cs rename WinForms/WinForms/{FormForMyComponents.resx => FormForComponents.resx} (100%) delete mode 100644 WinForms/WinForms/FormForMyComponents.Designer.cs delete mode 100644 WinForms/WinForms/FormForMyComponents.cs diff --git a/WinForms/VisualComponentsLib/Class1.cs b/WinForms/VisualComponentsLib/Class1.cs deleted file mode 100644 index 9ccbd59..0000000 --- a/WinForms/VisualComponentsLib/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -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 index 598d04b..ff19c0d 100644 --- a/WinForms/VisualComponentsLib/MyDropDownList.Designer.cs +++ b/WinForms/VisualComponentsLib/MyDropDownList.Designer.cs @@ -1,4 +1,4 @@ -namespace WinForms +namespace VisualComponentsLib { partial class MyDropDownList { diff --git a/WinForms/VisualComponentsLib/MyDropDownList.cs b/WinForms/VisualComponentsLib/MyDropDownList.cs index 8418261..1b7bb54 100644 --- a/WinForms/VisualComponentsLib/MyDropDownList.cs +++ b/WinForms/VisualComponentsLib/MyDropDownList.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace WinForms +namespace VisualComponentsLib { public partial class MyDropDownList : UserControl { diff --git a/WinForms/VisualComponentsLib/MyDropDownList.resx b/WinForms/VisualComponentsLib/MyDropDownList.resx index f298a7b..1af7de1 100644 --- a/WinForms/VisualComponentsLib/MyDropDownList.resx +++ b/WinForms/VisualComponentsLib/MyDropDownList.resx @@ -1,4 +1,64 @@ - + + + diff --git a/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs b/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs index 4538fcc..8fefada 100644 --- a/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs +++ b/WinForms/VisualComponentsLib/MyEmailTextBox.Designer.cs @@ -1,4 +1,4 @@ -namespace WinForms +namespace VisualComponentsLib { partial class MyEmailTextBox { diff --git a/WinForms/VisualComponentsLib/MyEmailTextBox.cs b/WinForms/VisualComponentsLib/MyEmailTextBox.cs index 5fecd29..bd2d2ea 100644 --- a/WinForms/VisualComponentsLib/MyEmailTextBox.cs +++ b/WinForms/VisualComponentsLib/MyEmailTextBox.cs @@ -9,7 +9,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; -namespace WinForms +namespace VisualComponentsLib { public partial class MyEmailTextBox : UserControl { diff --git a/WinForms/VisualComponentsLib/MyEmailTextBox.resx b/WinForms/VisualComponentsLib/MyEmailTextBox.resx index f298a7b..1af7de1 100644 --- a/WinForms/VisualComponentsLib/MyEmailTextBox.resx +++ b/WinForms/VisualComponentsLib/MyEmailTextBox.resx @@ -1,4 +1,64 @@ - + + + diff --git a/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs b/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs index 38f4bf8..c142c65 100644 --- a/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs +++ b/WinForms/VisualComponentsLib/MyListBoxObjects.Designer.cs @@ -57,3 +57,4 @@ private System.Windows.Forms.ListBox listBoxObj; } } + diff --git a/WinForms/VisualComponentsLib/MyListBoxObjects.cs b/WinForms/VisualComponentsLib/MyListBoxObjects.cs index d91d172..36fd78e 100644 --- a/WinForms/VisualComponentsLib/MyListBoxObjects.cs +++ b/WinForms/VisualComponentsLib/MyListBoxObjects.cs @@ -106,3 +106,4 @@ namespace VisualComponentsLib } } } +} \ No newline at end of file diff --git a/WinForms/VisualComponentsLib/Object/Student.cs b/WinForms/VisualComponentsLib/Object/Student.cs new file mode 100644 index 0000000..4421128 --- /dev/null +++ b/WinForms/VisualComponentsLib/Object/Student.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VisualComponentsLib.Object +{ + public class Student + { + public string Name { get; set; } + public string Group { get; set; } + public string Faculty { get; set; } + public int Course { get; set; } + + public Student(string name, string group, string faculty, int course) + { + Name = name; + Group = group; + Faculty = faculty; + Course = course; + } + public Student() + { + } + } +} diff --git a/WinForms/VisualComponentsLib/VisualComponentsLib.csproj b/WinForms/VisualComponentsLib/VisualComponentsLib.csproj index 823907c..060aa1c 100644 --- a/WinForms/VisualComponentsLib/VisualComponentsLib.csproj +++ b/WinForms/VisualComponentsLib/VisualComponentsLib.csproj @@ -7,13 +7,4 @@ enable - - - UserControl - - - UserControl - - - diff --git a/WinForms/WinForms/FormForComponents.Designer.cs b/WinForms/WinForms/FormForComponents.Designer.cs new file mode 100644 index 0000000..6e00361 --- /dev/null +++ b/WinForms/WinForms/FormForComponents.Designer.cs @@ -0,0 +1,231 @@ +namespace WinForms +{ + partial class FormForComponents + { + /// + /// 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() + { + dropDownList = new VisualComponentsLib.MyDropDownList(); + buttonAdd = new Button(); + buttonInfo = new Button(); + labelInfo = new Label(); + buttonClear = new Button(); + emailTextBox = new VisualComponentsLib.MyEmailTextBox(); + labelShow = new Label(); + buttonShow = new Button(); + buttonSetExample = new Button(); + labelExample = new Label(); + textBoxExample = new TextBox(); + listBoxObj = new VisualComponentsLib.MyListBoxObjects(); + buttonAddObjects = new Button(); + buttonShowItem = new Button(); + labelShowInput = new Label(); + SuspendLayout(); + // + // dropDownList + // + dropDownList.Location = new Point(3, 3); + dropDownList.Margin = new Padding(3, 4, 3, 4); + dropDownList.Name = "dropDownList"; + dropDownList.SelectedValue = ""; + dropDownList.Size = new Size(196, 36); + dropDownList.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(3, 46); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(92, 29); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonInfo + // + buttonInfo.Location = new Point(211, 46); + buttonInfo.Name = "buttonInfo"; + buttonInfo.Size = new Size(94, 29); + buttonInfo.TabIndex = 2; + buttonInfo.Text = "показать"; + buttonInfo.UseVisualStyleBackColor = true; + buttonInfo.Click += buttonInfo_Click; + // + // labelInfo + // + labelInfo.AutoSize = true; + labelInfo.Location = new Point(205, 9); + labelInfo.Name = "labelInfo"; + labelInfo.Size = new Size(154, 20); + labelInfo.TabIndex = 3; + labelInfo.Text = "Выбранный элемент"; + // + // buttonClear + // + buttonClear.Location = new Point(101, 46); + buttonClear.Name = "buttonClear"; + buttonClear.Size = new Size(94, 29); + buttonClear.TabIndex = 4; + buttonClear.Text = "очистить"; + buttonClear.UseVisualStyleBackColor = true; + buttonClear.Click += buttonClear_Click; + // + // emailTextBox + // + emailTextBox.Location = new Point(12, 132); + emailTextBox.Margin = new Padding(3, 4, 3, 4); + emailTextBox.Name = "emailTextBox"; + emailTextBox.Pattern = null; + emailTextBox.Size = new Size(179, 34); + emailTextBox.TabIndex = 5; + // + // labelShow + // + labelShow.AutoSize = true; + labelShow.Location = new Point(12, 170); + labelShow.Name = "labelShow"; + labelShow.Size = new Size(76, 20); + labelShow.TabIndex = 10; + labelShow.Text = "проверка"; + // + // buttonShow + // + buttonShow.Location = new Point(12, 196); + buttonShow.Name = "buttonShow"; + buttonShow.Size = new Size(94, 29); + buttonShow.TabIndex = 9; + buttonShow.Text = "Проверка"; + buttonShow.UseVisualStyleBackColor = true; + buttonShow.Click += buttonShow_Click; + // + // buttonSetExample + // + buttonSetExample.Location = new Point(12, 328); + buttonSetExample.Name = "buttonSetExample"; + buttonSetExample.Size = new Size(188, 29); + buttonSetExample.TabIndex = 8; + buttonSetExample.Text = "Поменять пример"; + buttonSetExample.UseVisualStyleBackColor = true; + buttonSetExample.Click += buttonSetExample_Click; + // + // labelExample + // + labelExample.AutoSize = true; + labelExample.Location = new Point(12, 263); + labelExample.Name = "labelExample"; + labelExample.Size = new Size(147, 20); + labelExample.TabIndex = 7; + labelExample.Text = "Для ввода примера"; + // + // textBoxExample + // + textBoxExample.Location = new Point(12, 295); + textBoxExample.Name = "textBoxExample"; + textBoxExample.Size = new Size(188, 27); + textBoxExample.TabIndex = 6; + // + // listBoxObj + // + listBoxObj.Location = new Point(388, 13); + listBoxObj.Margin = new Padding(3, 4, 3, 4); + listBoxObj.Name = "listBoxObj"; + listBoxObj.SelectedIndex = -1; + listBoxObj.Size = new Size(368, 159); + listBoxObj.TabIndex = 11; + // + // buttonAddObjects + // + buttonAddObjects.Location = new Point(388, 179); + buttonAddObjects.Name = "buttonAddObjects"; + buttonAddObjects.Size = new Size(380, 29); + buttonAddObjects.TabIndex = 12; + buttonAddObjects.Text = "Добавить"; + buttonAddObjects.UseVisualStyleBackColor = true; + buttonAddObjects.Click += buttonAddObjects_Click; + // + // buttonShowItem + // + buttonShowItem.Location = new Point(388, 310); + buttonShowItem.Name = "buttonShowItem"; + buttonShowItem.Size = new Size(380, 29); + buttonShowItem.TabIndex = 13; + buttonShowItem.Text = "Получить"; + buttonShowItem.UseVisualStyleBackColor = true; + buttonShowItem.Click += buttonShowItem_Click; + // + // labelShowInput + // + labelShowInput.AutoSize = true; + labelShowInput.Location = new Point(388, 273); + labelShowInput.Name = "labelShowInput"; + labelShowInput.Size = new Size(54, 20); + labelShowInput.TabIndex = 14; + labelShowInput.Text = "Вывод"; + // + // Form1 + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dropDownList); + Controls.Add(buttonAdd); + Controls.Add(buttonInfo); + Controls.Add(labelInfo); + Controls.Add(buttonClear); + Controls.Add(emailTextBox); + Controls.Add(textBoxExample); + Controls.Add(labelExample); + Controls.Add(buttonSetExample); + Controls.Add(labelShow); + Controls.Add(buttonShow); + Controls.Add(listBoxObj); + Controls.Add(buttonAddObjects); + Controls.Add(buttonShowItem); + Controls.Add(labelShowInput); + Name = "Form1"; + Text = "Form1"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private VisualComponentsLib.MyDropDownList dropDownList; + private Button buttonAdd; + private Button buttonInfo; + private Label labelInfo; + private Button buttonClear; + private VisualComponentsLib.MyEmailTextBox emailTextBox; + private TextBox textBoxExample; + private Label labelExample; + private Button buttonSetExample; + private Label labelShow; + private Button buttonShow; + private VisualComponentsLib.MyListBoxObjects listBoxObj; + private Button buttonAddObjects; + private Button buttonShowItem; + private Label labelShowInput; + } +} \ No newline at end of file diff --git a/WinForms/WinForms/FormForComponents.cs b/WinForms/WinForms/FormForComponents.cs new file mode 100644 index 0000000..33b1602 --- /dev/null +++ b/WinForms/WinForms/FormForComponents.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 VisualComponentsLib.Object; + +namespace WinForms +{ + public partial class FormForComponents : Form + { + List list = new List(); + List students = new List(); + public FormForComponents() + { + list = new List(); + list.AddRange(new string[] { "хлеб", "молоко", "колбаса" }); + Student student1 = new Student("Васильев", "ПИбд-32", "ФИСТ", 3); + Student student2 = new Student("Иванов", "РТбд-11", "РТФ", 1); + Student student3 = new Student("Смирнова", "ЛМККбд-41", "ГФ", 4); + students.Add(student1); + students.Add(student2); + students.Add(student3); + InitializeComponent(); + dropDownList.LoadValues(new List() { "сок", "яблоко", "лук" }); + emailTextBox.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"; + listBoxObj.SetLayoutInfo("Фамилия *Name* Группа *Group* Факультет *Faculty* Курс *Course*", "*", "*"); + dropDownList.ValueChanged += CustomEventHandler; + } + private void CustomEventHandler(object sender, EventArgs e) + { + MessageBox.Show("Выбранный элемент изменен"); + } + private void buttonAdd_Click(object sender, EventArgs e) + { + dropDownList.LoadValues(list); + } + + private void buttonInfo_Click(object sender, EventArgs e) + { + labelInfo.Text = dropDownList.SelectedValue; + } + + private void buttonClear_Click(object sender, EventArgs e) + { + dropDownList.Clear(); + } + + private void buttonSetExample_Click(object sender, EventArgs e) + { + if (textBoxExample.Text == String.Empty) + { + return; + } + emailTextBox.setExample(textBoxExample.Text); + } + + private void buttonShow_Click(object sender, EventArgs e) + { + try + { + if (emailTextBox.TextBoxValue != null) + { + labelShow.Text = "подходит"; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void buttonAddObjects_Click(object sender, EventArgs e) + { + listBoxObj.AddInListBox(students); + } + + private void buttonShowItem_Click(object sender, EventArgs e) + { + string str = listBoxObj.GetObjectFromStr().Name + " " + listBoxObj.GetObjectFromStr().Group + " " + listBoxObj.GetObjectFromStr().Faculty + " " + listBoxObj.GetObjectFromStr().Course; + labelShowInput.Text = str; + } + } +} diff --git a/WinForms/WinForms/FormForMyComponents.resx b/WinForms/WinForms/FormForComponents.resx similarity index 100% rename from WinForms/WinForms/FormForMyComponents.resx rename to WinForms/WinForms/FormForComponents.resx diff --git a/WinForms/WinForms/FormForMyComponents.Designer.cs b/WinForms/WinForms/FormForMyComponents.Designer.cs deleted file mode 100644 index 1554ba4..0000000 --- a/WinForms/WinForms/FormForMyComponents.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace WinForms -{ - partial class FormForMyComponents - { - /// - /// 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() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/WinForms/WinForms/FormForMyComponents.cs b/WinForms/WinForms/FormForMyComponents.cs deleted file mode 100644 index 907d5c8..0000000 --- a/WinForms/WinForms/FormForMyComponents.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WinForms -{ - public partial class FormForMyComponents : Form - { - public FormForMyComponents() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/WinForms/WinForms/Program.cs b/WinForms/WinForms/Program.cs index 371be84..09cad38 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 FormForMyComponents()); + Application.Run(new FormForComponents()); } } } \ No newline at end of file