2/3 компонентов, 1 лабораторная

This commit is contained in:
sardq 2024-09-22 20:37:12 +04:00
parent c9e7efdd2d
commit c92c2779b8
17 changed files with 1074 additions and 0 deletions

31
WinForms.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLibrary", "WinFormsLibrary\WinFormsLibrary.csproj", "{FA2C000C-0815-44C4-BBA7-FB37C33DE121}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{AA566691-FB51-4E4C-BB7B-9BA77AD20FD1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA2C000C-0815-44C4-BBA7-FB37C33DE121}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA2C000C-0815-44C4-BBA7-FB37C33DE121}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA2C000C-0815-44C4-BBA7-FB37C33DE121}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA2C000C-0815-44C4-BBA7-FB37C33DE121}.Release|Any CPU.Build.0 = Release|Any CPU
{AA566691-FB51-4E4C-BB7B-9BA77AD20FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA566691-FB51-4E4C-BB7B-9BA77AD20FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA566691-FB51-4E4C-BB7B-9BA77AD20FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA566691-FB51-4E4C-BB7B-9BA77AD20FD1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {078F9A05-555B-4C61-9BDB-BAD29FC4166B}
EndGlobalSection
EndGlobal

218
WinForms/FormComponents.Designer.cs generated Normal file
View File

@ -0,0 +1,218 @@
namespace WinForms
{
partial class FormComponents
{
/// <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()
{
this.dropDownList = new WinFormsLibrary.DropDownList();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonClear = new System.Windows.Forms.Button();
this.buttonInfo = new System.Windows.Forms.Button();
this.labelInfo = new System.Windows.Forms.Label();
this.emailTextBox = new WinFormsLibrary.EmailTextBox();
this.buttonExample = new System.Windows.Forms.Button();
this.buttonShow = new System.Windows.Forms.Button();
this.labelEmail = new System.Windows.Forms.Label();
this.textBoxExample = new System.Windows.Forms.TextBox();
this.listBoxValues = new WinFormsLibrary.ListBoxValues();
this.buttonAddValues = new System.Windows.Forms.Button();
this.buttonShowItem = new System.Windows.Forms.Button();
this.labelShowInput = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// dropDownList
//
this.dropDownList.Location = new System.Drawing.Point(-1, 3);
this.dropDownList.Name = "dropDownList";
this.dropDownList.Selected = "";
this.dropDownList.Size = new System.Drawing.Size(191, 104);
this.dropDownList.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(12, 135);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(163, 40);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonClear
//
this.buttonClear.Location = new System.Drawing.Point(12, 227);
this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(163, 40);
this.buttonClear.TabIndex = 2;
this.buttonClear.Text = "Очистить";
this.buttonClear.UseVisualStyleBackColor = true;
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
//
// buttonInfo
//
this.buttonInfo.Location = new System.Drawing.Point(12, 181);
this.buttonInfo.Name = "buttonInfo";
this.buttonInfo.Size = new System.Drawing.Size(163, 40);
this.buttonInfo.TabIndex = 3;
this.buttonInfo.Text = "Показать";
this.buttonInfo.UseVisualStyleBackColor = true;
this.buttonInfo.Click += new System.EventHandler(this.buttonInfo_Click);
//
// labelInfo
//
this.labelInfo.AutoSize = true;
this.labelInfo.Location = new System.Drawing.Point(64, 107);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(58, 25);
this.labelInfo.TabIndex = 4;
this.labelInfo.Text = "Инфо";
//
// emailTextBox
//
this.emailTextBox.Location = new System.Drawing.Point(196, 3);
this.emailTextBox.Name = "emailTextBox";
this.emailTextBox.Pattern = null;
this.emailTextBox.Size = new System.Drawing.Size(185, 104);
this.emailTextBox.TabIndex = 5;
//
// buttonExample
//
this.buttonExample.Location = new System.Drawing.Point(202, 236);
this.buttonExample.Name = "buttonExample";
this.buttonExample.Size = new System.Drawing.Size(147, 68);
this.buttonExample.TabIndex = 6;
this.buttonExample.Text = "Поменять пример";
this.buttonExample.UseVisualStyleBackColor = true;
this.buttonExample.Click += new System.EventHandler(this.buttonSetExample_Click);
//
// buttonShow
//
this.buttonShow.Location = new System.Drawing.Point(196, 107);
this.buttonShow.Name = "buttonShow";
this.buttonShow.Size = new System.Drawing.Size(185, 40);
this.buttonShow.TabIndex = 7;
this.buttonShow.Text = "Ввести";
this.buttonShow.UseVisualStyleBackColor = true;
this.buttonShow.Click += new System.EventHandler(this.buttonShow_Click);
//
// labelEmail
//
this.labelEmail.AutoSize = true;
this.labelEmail.Location = new System.Drawing.Point(221, 150);
this.labelEmail.Name = "labelEmail";
this.labelEmail.Size = new System.Drawing.Size(128, 25);
this.labelEmail.TabIndex = 8;
this.labelEmail.Text = "Для проверки";
//
// textBoxExample
//
this.textBoxExample.Location = new System.Drawing.Point(199, 199);
this.textBoxExample.Name = "textBoxExample";
this.textBoxExample.Size = new System.Drawing.Size(182, 31);
this.textBoxExample.TabIndex = 9;
//
// listBoxValues
//
this.listBoxValues.Location = new System.Drawing.Point(437, 30);
this.listBoxValues.Name = "listBoxValues";
this.listBoxValues.SelectedIndex = -1;
this.listBoxValues.Size = new System.Drawing.Size(594, 237);
this.listBoxValues.TabIndex = 10;
//
// buttonAddValues
//
this.buttonAddValues.Location = new System.Drawing.Point(437, 273);
this.buttonAddValues.Name = "buttonAddValues";
this.buttonAddValues.Size = new System.Drawing.Size(112, 34);
this.buttonAddValues.TabIndex = 11;
this.buttonAddValues.Text = "Добавить";
this.buttonAddValues.UseVisualStyleBackColor = true;
this.buttonAddValues.Click += new System.EventHandler(this.buttonAddValues_Click);
//
// buttonShowItem
//
this.buttonShowItem.Location = new System.Drawing.Point(437, 313);
this.buttonShowItem.Name = "buttonShowItem";
this.buttonShowItem.Size = new System.Drawing.Size(112, 34);
this.buttonShowItem.TabIndex = 12;
this.buttonShowItem.Text = "Получить";
this.buttonShowItem.UseVisualStyleBackColor = true;
this.buttonShowItem.Click += new System.EventHandler(this.buttonShowItem_Click);
//
// labelShowInput
//
this.labelShowInput.AutoSize = true;
this.labelShowInput.Location = new System.Drawing.Point(437, 359);
this.labelShowInput.Name = "labelShowInput";
this.labelShowInput.Size = new System.Drawing.Size(128, 25);
this.labelShowInput.TabIndex = 13;
this.labelShowInput.Text = "Для проверки";
//
// FormComponents
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1067, 450);
this.Controls.Add(this.labelShowInput);
this.Controls.Add(this.buttonShowItem);
this.Controls.Add(this.buttonAddValues);
this.Controls.Add(this.listBoxValues);
this.Controls.Add(this.textBoxExample);
this.Controls.Add(this.labelEmail);
this.Controls.Add(this.buttonShow);
this.Controls.Add(this.buttonExample);
this.Controls.Add(this.emailTextBox);
this.Controls.Add(this.labelInfo);
this.Controls.Add(this.buttonInfo);
this.Controls.Add(this.buttonClear);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dropDownList);
this.Name = "FormComponents";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private WinFormsLibrary.DropDownList dropDownList;
private Button buttonAdd;
private Button buttonClear;
private Button buttonInfo;
private Label labelInfo;
private WinFormsLibrary.EmailTextBox emailTextBox;
private Button buttonExample;
private Button buttonShow;
private Label labelEmail;
private TextBox textBoxExample;
private WinFormsLibrary.ListBoxValues listBoxValues;
private Button buttonAddValues;
private Button buttonShowItem;
private Label labelShowInput;
}
}

View File

@ -0,0 +1,81 @@
using System.Collections.Generic;
using WinFormsLibrary;
using WinFormsLibrary.Object;
namespace WinForms
{
public partial class FormComponents : Form
{
List<string> list = new List<string>();
List<Client> clients = new List<Client>();
public FormComponents()
{
list = new List<string>();
list.AddRange(new string[] { "привет", "пока", "бб" });
Client client1 = new Client("Сергей", "нет", "Идиот", 3);
Client client2 = new Client("Давид", "да-11", "Гений", 1);
Client client3 = new Client("Руслан", "Асу", "Летальный", 4);
clients.Add(client1);
clients.Add(client2);
clients.Add(client3);
InitializeComponent();
dropDownList.LoadValues(new List<string>() { "чего", "забей", "пример" });
emailTextBox.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
listBoxValues.SetLayout("ФИО [FIO] Обзор [Review] Статус [Status] сумма [Sum]", "[", "]");
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.Selected;
}
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)
{
labelEmail.Text = emailTextBox.TextBoxValue;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void buttonShowItem_Click(object sender, EventArgs e)
{
string str = listBoxValues.GetObjectFromStr<Client>().FIO + " " + listBoxValues.GetObjectFromStr<Client>().Review + " " + listBoxValues.GetObjectFromStr<Client>().Status + " " + listBoxValues.GetObjectFromStr<Client>().Sum;
labelShowInput.Text = str;
}
private void buttonAddValues_Click(object sender, EventArgs e)
{
listBoxValues.AddInListBox<Client>(clients);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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
WinForms/Program.cs Normal file
View File

@ -0,0 +1,17 @@
namespace WinForms
{
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 FormComponents());
}
}
}

15
WinForms/WinForms.csproj Normal file
View 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="..\WinFormsLibrary\WinFormsLibrary.csproj" />
</ItemGroup>
</Project>

71
WinFormsLibrary/DropDownList.Designer.cs generated Normal file
View File

@ -0,0 +1,71 @@
namespace WinFormsLibrary
{
partial class DropDownList
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.comboBox = new System.Windows.Forms.ComboBox();
this.labelDropDownList = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBox
//
this.comboBox.FormattingEnabled = true;
this.comboBox.Location = new System.Drawing.Point(3, 60);
this.comboBox.Name = "comboBox";
this.comboBox.Size = new System.Drawing.Size(182, 33);
this.comboBox.TabIndex = 0;
this.comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
//
// labelDropDownList
//
this.labelDropDownList.AutoSize = true;
this.labelDropDownList.Location = new System.Drawing.Point(3, 12);
this.labelDropDownList.Name = "labelDropDownList";
this.labelDropDownList.Size = new System.Drawing.Size(184, 25);
this.labelDropDownList.TabIndex = 1;
this.labelDropDownList.Text = "Выпадающий список";
//
// DropDownList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.labelDropDownList);
this.Controls.Add(this.comboBox);
this.Name = "DropDownList";
this.Size = new System.Drawing.Size(199, 105);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBox;
private Label labelDropDownList;
}
}

View File

@ -0,0 +1,60 @@
namespace WinFormsLibrary
{
public partial class DropDownList : UserControl
{
public DropDownList()
{
InitializeComponent();
}
public void Clear()
{
comboBox.Items.Clear();
}
public void LoadValues(List<string> values)
{
if (values.Count == 0)
{
return;
}
comboBox.Items.AddRange(values.ToArray());
}
public string Selected
{
get
{
if(comboBox.Items.Count == 0)
{
return "";
}
if(comboBox.SelectedItem == null)
{
return "";
}
return comboBox.SelectedItem.ToString()!;
}
set
{
if (comboBox.Items.Contains(value))
{
comboBox.SelectedItem = value;
}
}
}
public ComboBox.ObjectCollection comboBoxItems
{
get { return comboBox.Items; }
}
private EventHandler _onValueChanged;
public event EventHandler ValueChanged
{
add { _onValueChanged += value; }
remove { _onValueChanged -= value; }
}
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
_onValueChanged?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

74
WinFormsLibrary/EmailTextBox.Designer.cs generated Normal file
View File

@ -0,0 +1,74 @@
namespace WinFormsLibrary
{
partial class EmailTextBox
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.toolTipEmail = new System.Windows.Forms.ToolTip(this.components);
this.labelEmail = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBoxEmail
//
this.textBoxEmail.Location = new System.Drawing.Point(0, 55);
this.textBoxEmail.Name = "textBoxEmail";
this.textBoxEmail.Size = new System.Drawing.Size(181, 31);
this.textBoxEmail.TabIndex = 0;
this.textBoxEmail.TextChanged += new System.EventHandler(this.textBoxEmail_TextChanged);
this.textBoxEmail.MouseEnter += new System.EventHandler(this.textBoxEmail_MouseEnter);
//
// labelEmail
//
this.labelEmail.AutoSize = true;
this.labelEmail.Location = new System.Drawing.Point(3, 6);
this.labelEmail.Name = "labelEmail";
this.labelEmail.Size = new System.Drawing.Size(129, 25);
this.labelEmail.TabIndex = 1;
this.labelEmail.Text = "Введите почту";
//
// EmailTextBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.labelEmail);
this.Controls.Add(this.textBoxEmail);
this.Name = "EmailTextBox";
this.Size = new System.Drawing.Size(209, 118);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxEmail;
private ToolTip toolTipEmail;
private Label labelEmail;
}
}

View File

@ -0,0 +1,79 @@
using System.Text.RegularExpressions;
namespace WinFormsLibrary
{
public partial class EmailTextBox : UserControl
{
public EmailTextBox()
{
InitializeComponent();
}
private string _pattern;
private string example = "hello@mail.ru";
private EventHandler _onValueChanged;
public string Pattern
{
get { return _pattern; }
set { _pattern = value; }
}
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;
}
}
public string TextBoxValue
{
get
{
Regex regex = new Regex(Pattern);
if (regex.IsMatch(textBoxEmail.Text))
{
return textBoxEmail.Text;
}
else
{
Error = "Некорректный ввод";
return null;
}
}
set
{
Regex regex = new Regex(Pattern);
if (regex.IsMatch(value))
{
textBoxEmail.Text = value;
}
else
{
Error = "Некорректный ввод";
}
}
}
private void textBoxEmail_MouseEnter(object sender, EventArgs e)
{
toolTipEmail.Show(example, textBoxEmail, 30, -20);
}
public event EventHandler ValueChanged
{
add { _onValueChanged += value; }
remove { _onValueChanged -= value; }
}
private void textBoxEmail_TextChanged(object sender, EventArgs e)
{
_onValueChanged?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTipEmail.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,59 @@
namespace WinFormsLibrary
{
partial class ListBoxValues
{
/// <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()
{
this.listBoxObjects = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBoxObjects
//
this.listBoxObjects.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBoxObjects.FormattingEnabled = true;
this.listBoxObjects.ItemHeight = 25;
this.listBoxObjects.Location = new System.Drawing.Point(0, 0);
this.listBoxObjects.Name = "listBoxObjects";
this.listBoxObjects.Size = new System.Drawing.Size(223, 158);
this.listBoxObjects.TabIndex = 0;
//
// ListBoxValues
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listBoxObjects);
this.Name = "ListBoxValues";
this.Size = new System.Drawing.Size(223, 158);
this.ResumeLayout(false);
}
#endregion
private ListBox listBoxObjects;
}
}

View File

@ -0,0 +1,94 @@
using System.Text;
namespace WinFormsLibrary
{
public partial class ListBoxValues : UserControl
{
private string _layout;
private string _endSymbol;
private string _startSymbol;
public ListBoxValues()
{
InitializeComponent();
}
public void SetLayout(string layout, string startSymbol, string endSymbol)
{
if (layout == null || startSymbol == null || endSymbol == null)
{
return;
}
_layout = layout;
_endSymbol = endSymbol;
_startSymbol = startSymbol;
}
public int SelectedIndex
{
get
{
if (listBoxObjects.SelectedIndex == -1)
{
return -1;
}
return listBoxObjects.SelectedIndex;
}
set
{
if (listBoxObjects.SelectedItems.Count != 0)
{
listBoxObjects.SelectedIndex = value;
}
}
}
public T GetObjectFromStr<T>() where T : class, new()
{
string selectedString = "";
if (listBoxObjects.SelectedIndex != -1)
{
selectedString = listBoxObjects.SelectedItem.ToString();
}
T curObject = new T();
foreach (var pr in typeof(T).GetProperties())
{
if (!pr.CanWrite)
{
continue;
}
int borderOne = selectedString.IndexOf(_startSymbol);
StringBuilder sb = new StringBuilder(selectedString);
selectedString = sb.ToString();
int borderTwo = selectedString.IndexOf(_endSymbol);
if (borderOne == -1 || borderTwo == -1) break;
string propertyValue = selectedString.Substring(borderOne + 1, borderTwo - borderOne-1);
selectedString = selectedString.Substring(borderTwo + 1);
pr.SetValue(curObject, Convert.ChangeType(propertyValue, pr.PropertyType));
}
return curObject;
}
public void AddInListBox<T>(List<T> values)
{
if (_layout == null || _startSymbol == null || _endSymbol == null)
{
MessageBox.Show("заполните информацию о макетной строке");
return;
}
if (!_layout.Contains(_startSymbol) || !_layout.Contains(_endSymbol))
{
MessageBox.Show("Макетная строка не содержит нужные элементы");
return;
}
foreach (var item in values)
{
string str = _layout;
foreach (var prop in item.GetType().GetProperties())
{
string str1 = $"{_startSymbol}" + $"{prop.Name}" + $"{_endSymbol}";
str = str.Replace(str1, $"{_startSymbol}" + prop.GetValue(item).ToString() + $"{_endSymbol}");
}
listBoxObjects.Items.Add(str);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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>

View File

@ -0,0 +1,22 @@
namespace WinFormsLibrary.Object
{
public class Client
{
public string FIO { get; set; }
public string Review { get; set; }
public string Status { get; set; }
public int Sum { get; set; }
public Client(string fio, string review, string status, int sum)
{
FIO = fio;
Review = review;
Status = status;
Sum = sum;
}
public Client()
{
}
}
}

View 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>