Лабораторная №1 готовая
This commit is contained in:
parent
a1b45db67b
commit
c098865918
9
COP/COP.csproj
Normal file
9
COP/COP.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
25
COP/COP.sln
Normal file
25
COP/COP.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COP", "COP.csproj", "{E146CFBA-8D76-44BC-8010-59FE2109E1F6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {156893E4-8829-479A-A3C9-A042674F4ACD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
COP/Class1.cs
Normal file
7
COP/Class1.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace COP
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
COPWinForms/COPWinForms.csproj
Normal file
11
COPWinForms/COPWinForms.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
57
COPWinForms/ComponentCBox.Designer.cs
generated
Normal file
57
COPWinForms/ComponentCBox.Designer.cs
generated
Normal file
@ -0,0 +1,57 @@
|
||||
namespace COPWinForms
|
||||
{
|
||||
partial class ComponentCBox
|
||||
{
|
||||
/// <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.SuspendLayout();
|
||||
//
|
||||
// comboBox
|
||||
//
|
||||
this.comboBox.FormattingEnabled = true;
|
||||
this.comboBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.comboBox.Name = "comboBox";
|
||||
this.comboBox.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBox.TabIndex = 0;
|
||||
this.comboBox.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
|
||||
//
|
||||
// ComponentCBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.comboBox);
|
||||
this.Name = "ComponentCBox";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
}
|
||||
}
|
78
COPWinForms/ComponentCBox.cs
Normal file
78
COPWinForms/ComponentCBox.cs
Normal file
@ -0,0 +1,78 @@
|
||||
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 COPWinForms
|
||||
{
|
||||
public partial class ComponentCBox : UserControl
|
||||
{
|
||||
public ComponentCBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
//метод, у которого в передаваемых параметрах идет список строк и через этот список идет заполнение ComboBox;
|
||||
public void AddingToList(List<string> Values)
|
||||
{
|
||||
if (Values.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
comboBox.Items.AddRange(Values.ToArray());
|
||||
}
|
||||
|
||||
//Отдельный публичный метод отчистки списка.
|
||||
public void Clear()
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
}
|
||||
|
||||
//публичное свойство(set, get) для установки и получения выбранного значения (возвращает пустую строку, если нет выбранного значения)
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_explicitEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_explicitEvent -= value;
|
||||
}
|
||||
}
|
||||
//событие, вызываемое при смене значения в ComboBox.
|
||||
private void comboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
60
COPWinForms/ComponentCBox.resx
Normal file
60
COPWinForms/ComponentCBox.resx
Normal 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>
|
59
COPWinForms/ComponentLBox.Designer.cs
generated
Normal file
59
COPWinForms/ComponentLBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace COPWinForms
|
||||
{
|
||||
partial class ComponentLBox
|
||||
{
|
||||
/// <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.listBox = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
this.listBox.FormattingEnabled = true;
|
||||
this.listBox.HorizontalScrollbar = true;
|
||||
this.listBox.ItemHeight = 20;
|
||||
this.listBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.listBox.Name = "listBox";
|
||||
this.listBox.Size = new System.Drawing.Size(278, 144);
|
||||
this.listBox.TabIndex = 0;
|
||||
//
|
||||
// ComponentLBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.listBox);
|
||||
this.Name = "ComponentLBox";
|
||||
this.Size = new System.Drawing.Size(281, 150);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
113
COPWinForms/ComponentLBox.cs
Normal file
113
COPWinForms/ComponentLBox.cs
Normal file
@ -0,0 +1,113 @@
|
||||
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 COPWinForms
|
||||
{
|
||||
public partial class ComponentLBox : UserControl
|
||||
{
|
||||
//Макетная строка
|
||||
private string layoutString;
|
||||
//стартовый символ для обнаружения св-в/полей
|
||||
private string startSymbol;
|
||||
//конечный символ для обнаружения св-в/полей
|
||||
private string endSymbol;
|
||||
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
public ComponentLBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
|
||||
//Метод для установки информации о макетной строке и символах (стартового и конечного)
|
||||
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 (listBox.SelectedIndex == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (listBox.SelectedItems.Count != 0)
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Публичный параметризованный метод для получения объекта из выбранной строки(создать объект и через рефлексию заполнить свойства его).
|
||||
public T GetObjectFromStr<T>() where T : class, new()
|
||||
{
|
||||
string selStr = "";
|
||||
if (listBox.SelectedIndex != -1)
|
||||
{
|
||||
selStr = listBox.SelectedItem.ToString()!;
|
||||
}
|
||||
T curObject = new T();
|
||||
foreach (var property in typeof(T).GetProperties())
|
||||
{
|
||||
if (!property.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int borderOne = selStr.IndexOf(startSymbol);
|
||||
StringBuilder sb = new StringBuilder(selStr);
|
||||
sb[borderOne] = 'a';
|
||||
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);
|
||||
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||
}
|
||||
return curObject;
|
||||
}
|
||||
//параметризованный метод, у которого в передаваемых параметрах идет список объектов какого-то класса и через этот список идет заполнение ListBox;
|
||||
public void AddInListBox<T>(List<T> objects)
|
||||
{
|
||||
if (layoutString == null || startSymbol == null || endSymbol == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!layoutString.Contains(startSymbol) || !layoutString.Contains(endSymbol))
|
||||
{
|
||||
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}");
|
||||
}
|
||||
listBox.Items.Add(str);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
60
COPWinForms/ComponentLBox.resx
Normal file
60
COPWinForms/ComponentLBox.resx
Normal 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>
|
62
COPWinForms/ComponentTBox.Designer.cs
generated
Normal file
62
COPWinForms/ComponentTBox.Designer.cs
generated
Normal file
@ -0,0 +1,62 @@
|
||||
namespace COPWinForms
|
||||
{
|
||||
partial class ComponentTBox
|
||||
{
|
||||
/// <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.textBox = new System.Windows.Forms.TextBox();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
this.textBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.textBox.Name = "textBox";
|
||||
this.textBox.Size = new System.Drawing.Size(150, 27);
|
||||
this.textBox.TabIndex = 0;
|
||||
this.textBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
|
||||
this.textBox.Enter += new System.EventHandler(this.textBox_Enter);
|
||||
//
|
||||
// ComponentTBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.textBox);
|
||||
this.Name = "ComponentTBox";
|
||||
this.Size = new System.Drawing.Size(150, 51);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox;
|
||||
private ToolTip toolTip1;
|
||||
}
|
||||
}
|
156
COPWinForms/ComponentTBox.cs
Normal file
156
COPWinForms/ComponentTBox.cs
Normal file
@ -0,0 +1,156 @@
|
||||
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.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace COPWinForms
|
||||
{
|
||||
public partial class ComponentTBox : UserControl
|
||||
{
|
||||
//Шаблон для textbox
|
||||
private string? pattern;
|
||||
//Пример ввода
|
||||
private string example = "example@gmail.com";
|
||||
private event Action? _errorOccured;
|
||||
|
||||
|
||||
public string Error { get; private set; }
|
||||
|
||||
public ComponentTBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
|
||||
}
|
||||
//Публичное свойство для получения и заполнения шаблона
|
||||
public string? Pattern
|
||||
{
|
||||
get { return pattern; }
|
||||
set { pattern = value; }
|
||||
}
|
||||
//Публичное свойство для получения и заполнения значения
|
||||
public string? TextBoxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (pattern != null) {
|
||||
Regex regex = new Regex(Pattern);
|
||||
bool isValid = regex.IsMatch(textBox.Text);
|
||||
if (isValid)
|
||||
{
|
||||
return textBox.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "Is not email";
|
||||
_errorOccured?.Invoke();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Error = "No pattern";
|
||||
_errorOccured?.Invoke();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (pattern != null)
|
||||
{
|
||||
Regex regex = new Regex(Pattern);
|
||||
bool isValid = regex.IsMatch(value);
|
||||
if (isValid)
|
||||
{
|
||||
textBox.Text = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "Is not email";
|
||||
_errorOccured?.Invoke();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "No pattern";
|
||||
_errorOccured?.Invoke();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Метод для заполнения примера
|
||||
public void setExample(string str)
|
||||
{
|
||||
if (pattern != null)
|
||||
{
|
||||
Regex regex = new Regex(Pattern);
|
||||
bool isValid = regex.IsMatch(str);
|
||||
if (isValid)
|
||||
{
|
||||
example = str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "No pattern";
|
||||
_errorOccured?.Invoke();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//ToolTip для вывода примера
|
||||
private void textBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
int VisibleTime = 3000; //in milliseconds
|
||||
|
||||
ToolTip tt = new ToolTip();
|
||||
tt.Show(example, textBox, 0, 20, VisibleTime);
|
||||
}
|
||||
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_explicitEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_explicitEvent -= value;
|
||||
}
|
||||
}
|
||||
public event Action AnErrorOccurred
|
||||
{
|
||||
add { _errorOccured += value; }
|
||||
remove { _errorOccured -= value; }
|
||||
}
|
||||
|
||||
//событие при смене значения
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error = ex.Message;
|
||||
_errorOccured?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
63
COPWinForms/ComponentTBox.resx
Normal file
63
COPWinForms/ComponentTBox.resx
Normal 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="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>22, 26</value>
|
||||
</metadata>
|
||||
</root>
|
17
COPWinForms/Program.cs
Normal file
17
COPWinForms/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace COPWinForms
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
24
COPWinForms/Student.cs
Normal file
24
COPWinForms/Student.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace COPWinForms
|
||||
{
|
||||
public class Student
|
||||
{
|
||||
public string FIO { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Email { get; set; }
|
||||
|
||||
public Student(string fIO, string group, string email)
|
||||
{
|
||||
FIO = fIO;
|
||||
Group = group;
|
||||
Email = email;
|
||||
}
|
||||
|
||||
public Student() { }
|
||||
}
|
||||
}
|
9
COP_1/COP_1.csproj
Normal file
9
COP_1/COP_1.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
37
COP_1/COP_1.sln
Normal file
37
COP_1/COP_1.sln
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP_1", "COP_1.csproj", "{3A354E62-6788-412B-8F8F-5A3484373BDA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COPWinForms", "..\COPWinForms\COPWinForms.csproj", "{C88D51BC-B17E-40DD-BC69-480DD08ED488}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsTest", "..\WinFormsTest\WinFormsTest.csproj", "{75E77B58-7C69-4C52-8283-03EBC03D2C85}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3A354E62-6788-412B-8F8F-5A3484373BDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3A354E62-6788-412B-8F8F-5A3484373BDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A354E62-6788-412B-8F8F-5A3484373BDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3A354E62-6788-412B-8F8F-5A3484373BDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C88D51BC-B17E-40DD-BC69-480DD08ED488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C88D51BC-B17E-40DD-BC69-480DD08ED488}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C88D51BC-B17E-40DD-BC69-480DD08ED488}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C88D51BC-B17E-40DD-BC69-480DD08ED488}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7DE53E23-1C86-4BF5-A79B-AEC5B8C88A43}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
COP_1/Class1.cs
Normal file
7
COP_1/Class1.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace COP_1
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
199
WinFormsTest/FormTestApp.Designer.cs
generated
Normal file
199
WinFormsTest/FormTestApp.Designer.cs
generated
Normal file
@ -0,0 +1,199 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
partial class FormTestApp
|
||||
{
|
||||
/// <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.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.buttonShow = new System.Windows.Forms.Button();
|
||||
this.textBoxShow = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.buttonShowTB = new System.Windows.Forms.Button();
|
||||
this.textBoxShowTB = new System.Windows.Forms.TextBox();
|
||||
this.buttonShowItem = new System.Windows.Forms.Button();
|
||||
this.componenttBox1 = new COPWinForms.ComponentTBox();
|
||||
this.componentlBox1 = new COPWinForms.ComponentLBox();
|
||||
this.textBoxShowItem = new System.Windows.Forms.TextBox();
|
||||
this.componentcBox1 = new COPWinForms.ComponentCBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(36, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(83, 20);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "ComboBox";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(369, 12);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(61, 20);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "TextBox";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(736, 12);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(56, 20);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "ListBox";
|
||||
//
|
||||
// buttonShow
|
||||
//
|
||||
this.buttonShow.Location = new System.Drawing.Point(32, 126);
|
||||
this.buttonShow.Name = "buttonShow";
|
||||
this.buttonShow.Size = new System.Drawing.Size(149, 29);
|
||||
this.buttonShow.TabIndex = 6;
|
||||
this.buttonShow.Text = "Показать";
|
||||
this.buttonShow.UseVisualStyleBackColor = true;
|
||||
this.buttonShow.Click += new System.EventHandler(this.buttonShow_Click);
|
||||
//
|
||||
// textBoxShow
|
||||
//
|
||||
this.textBoxShow.Location = new System.Drawing.Point(32, 161);
|
||||
this.textBoxShow.Name = "textBoxShow";
|
||||
this.textBoxShow.Size = new System.Drawing.Size(149, 27);
|
||||
this.textBoxShow.TabIndex = 7;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(32, 194);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(149, 29);
|
||||
this.button1.TabIndex = 8;
|
||||
this.button1.Text = "Очистить";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.buttonClear_Click);
|
||||
//
|
||||
// buttonShowTB
|
||||
//
|
||||
this.buttonShowTB.Location = new System.Drawing.Point(369, 126);
|
||||
this.buttonShowTB.Name = "buttonShowTB";
|
||||
this.buttonShowTB.Size = new System.Drawing.Size(163, 29);
|
||||
this.buttonShowTB.TabIndex = 9;
|
||||
this.buttonShowTB.Text = "Проверить";
|
||||
this.buttonShowTB.UseVisualStyleBackColor = true;
|
||||
this.buttonShowTB.Click += new System.EventHandler(this.buttonShowTB_Click);
|
||||
//
|
||||
// textBoxShowTB
|
||||
//
|
||||
this.textBoxShowTB.Location = new System.Drawing.Point(369, 161);
|
||||
this.textBoxShowTB.Name = "textBoxShowTB";
|
||||
this.textBoxShowTB.Size = new System.Drawing.Size(163, 27);
|
||||
this.textBoxShowTB.TabIndex = 10;
|
||||
//
|
||||
// buttonShowItem
|
||||
//
|
||||
this.buttonShowItem.Location = new System.Drawing.Point(711, 207);
|
||||
this.buttonShowItem.Name = "buttonShowItem";
|
||||
this.buttonShowItem.Size = new System.Drawing.Size(279, 29);
|
||||
this.buttonShowItem.TabIndex = 15;
|
||||
this.buttonShowItem.Text = "Получить значение";
|
||||
this.buttonShowItem.UseVisualStyleBackColor = true;
|
||||
this.buttonShowItem.Click += new System.EventHandler(this.buttonShowItem_Click);
|
||||
//
|
||||
// componenttBox1
|
||||
//
|
||||
this.componenttBox1.Location = new System.Drawing.Point(369, 53);
|
||||
this.componenttBox1.Name = "componenttBox1";
|
||||
this.componenttBox1.Pattern = null;
|
||||
this.componenttBox1.Size = new System.Drawing.Size(188, 46);
|
||||
this.componenttBox1.TabIndex = 16;
|
||||
//
|
||||
// componentlBox1
|
||||
//
|
||||
this.componentlBox1.Location = new System.Drawing.Point(711, 53);
|
||||
this.componentlBox1.Name = "componentlBox1";
|
||||
this.componentlBox1.SelectedIndex = -1;
|
||||
this.componentlBox1.Size = new System.Drawing.Size(351, 148);
|
||||
this.componentlBox1.TabIndex = 17;
|
||||
//
|
||||
// textBoxShowItem
|
||||
//
|
||||
this.textBoxShowItem.Location = new System.Drawing.Point(711, 249);
|
||||
this.textBoxShowItem.Name = "textBoxShowItem";
|
||||
this.textBoxShowItem.Size = new System.Drawing.Size(279, 27);
|
||||
this.textBoxShowItem.TabIndex = 18;
|
||||
//
|
||||
// componentcBox1
|
||||
//
|
||||
this.componentcBox1.Location = new System.Drawing.Point(32, 49);
|
||||
this.componentcBox1.Name = "componentcBox1";
|
||||
this.componentcBox1.Selected = "";
|
||||
this.componentcBox1.Size = new System.Drawing.Size(188, 50);
|
||||
this.componentcBox1.TabIndex = 19;
|
||||
this.componentcBox1.CursorChanged += new System.EventHandler(this.componentcBox1_ExplicitEvent);
|
||||
//
|
||||
// FormTestApp
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1027, 288);
|
||||
this.Controls.Add(this.componentcBox1);
|
||||
this.Controls.Add(this.textBoxShowItem);
|
||||
this.Controls.Add(this.componentlBox1);
|
||||
this.Controls.Add(this.componenttBox1);
|
||||
this.Controls.Add(this.buttonShowItem);
|
||||
this.Controls.Add(this.textBoxShowTB);
|
||||
this.Controls.Add(this.buttonShowTB);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBoxShow);
|
||||
this.Controls.Add(this.buttonShow);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormTestApp";
|
||||
this.Text = "Тест";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Button buttonShow;
|
||||
private TextBox textBoxShow;
|
||||
private Button button1;
|
||||
private Button buttonShowTB;
|
||||
private TextBox textBoxShowTB;
|
||||
private Button buttonShowItem;
|
||||
private COPWinForms.ComponentTBox componenttBox1;
|
||||
private COPWinForms.ComponentLBox componentlBox1;
|
||||
private TextBox textBoxShowItem;
|
||||
private COPWinForms.ComponentCBox componentcBox1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
98
WinFormsTest/FormTestApp.cs
Normal file
98
WinFormsTest/FormTestApp.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using COPWinForms;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public partial class FormTestApp : Form
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
List<Student> students = new List<Student>();
|
||||
public FormTestApp()
|
||||
{
|
||||
list = new List<string>();
|
||||
list.AddRange(new string[] { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5" });
|
||||
|
||||
Student student1 = new Student("Ðîãàøîâà Å.À.", "ÏÈáä-32", "rogashovae@mail.ru");
|
||||
Student student2 = new Student("Ïåòðîâ Ï.Â.", "Ýóáä-11", "petrov@gmail.com");
|
||||
Student student3 = new Student("Íîñêîâà À.À.", "ÏÌáä-41", "noskovaaa@gmail.com");
|
||||
Student student4 = new Student("Íîñêîâ À.À.", "ÏCáä-41", "noskovaa@gmail.com");
|
||||
|
||||
students.Add(student1);
|
||||
students.Add(student2);
|
||||
students.Add(student3);
|
||||
students.Add(student4);
|
||||
InitializeComponent();
|
||||
|
||||
componenttBox1.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
|
||||
componentlBox1.SetLayoutInfo("ÔÈÎ: *FIO* Ãðóïïà: *Group* Email: *Email*", "*", "*");
|
||||
componentlBox1.AddInListBox(students);
|
||||
componentcBox1.AddingToList(new List<string>() { "ïðèâåò", "ÿ", "êîìïîíåíò" });
|
||||
componentcBox1.ExplicitEvent += Event_Handler;
|
||||
componenttBox1.ExplicitEvent += Event_Handler;
|
||||
componenttBox1.setExample("eeee@mail.ru");
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
componentcBox1.AddingToList(list);
|
||||
}
|
||||
|
||||
private void Event_Handler(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Èçìåíåííî");
|
||||
}
|
||||
|
||||
private void buttonShow_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxShow.Text = componentcBox1.Selected;
|
||||
}
|
||||
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
componentcBox1.Clear();
|
||||
}
|
||||
|
||||
|
||||
//private void buttonSetExample_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// if (textBoxExample.Text == String.Empty)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// componenttBox1.setExample(textBoxExample.Text);
|
||||
//}
|
||||
|
||||
private void buttonShowTB_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (componenttBox1.TextBoxValue != null)
|
||||
{
|
||||
textBoxShowTB.Text = "true";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
componentlBox1.AddInListBox<Student>(students);
|
||||
}
|
||||
|
||||
private void buttonShowItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string str = componentlBox1.GetObjectFromStr<Student>().FIO + " " + componentlBox1.GetObjectFromStr<Student>().Group + " " + componentlBox1.GetObjectFromStr<Student>().Email;
|
||||
textBoxShowItem.Text = str;
|
||||
}
|
||||
private void componentcBox1_ExplicitEvent(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Change avatar");
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsTest/FormTestApp.resx
Normal file
60
WinFormsTest/FormTestApp.resx
Normal 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
WinFormsTest/Program.cs
Normal file
17
WinFormsTest/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
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 FormTestApp());
|
||||
}
|
||||
}
|
||||
}
|
15
WinFormsTest/WinFormsTest.csproj
Normal file
15
WinFormsTest/WinFormsTest.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COPWinForms\COPWinForms.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user