че то закину
This commit is contained in:
parent
f17a388a73
commit
2cba8c4690
33
COP_1/Album.cs
Normal file
33
COP_1/Album.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public class Album
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Performer { get; set; }
|
||||
public string Genre { get; set; }
|
||||
public string Year { get; set; }
|
||||
|
||||
public Album(string title, string performer, string genre, string year)
|
||||
{
|
||||
Title = title;
|
||||
Performer = performer;
|
||||
Genre = genre;
|
||||
Year = year;
|
||||
}
|
||||
|
||||
public Album() { }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string temp = Title + ", " + Performer + ", " + Genre + ", " + Year;
|
||||
return temp;
|
||||
//return (Title+", "+Performer+", "+Genre+", "+Year);
|
||||
}
|
||||
}
|
||||
}
|
16
COP_1/COP_1.csproj
Normal file
16
COP_1/COP_1.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
31
COP_1/COP_1.sln
Normal file
31
COP_1/COP_1.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP_1", "COP_1.csproj", "{41597675-2261-45D0-B8A3-F6C00D687FDC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COP_1Test", "..\COP_1Test\COP_1Test.csproj", "{3926A945-603A-4E7F-B674-2240C8B5B794}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {44FCB702-AF4F-4B33-B037-E657C1CC86F4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
72
COP_1/cop_1/DropDownList.Designer.cs
generated
Normal file
72
COP_1/cop_1/DropDownList.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
namespace COP_1
|
||||
{
|
||||
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()
|
||||
{
|
||||
comboBox = new ComboBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBox
|
||||
//
|
||||
comboBox.Dock = DockStyle.Bottom;
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Location = new Point(0, 22);
|
||||
comboBox.Name = "comboBox";
|
||||
comboBox.Size = new Size(225, 28);
|
||||
comboBox.TabIndex = 1;
|
||||
comboBox.SelectedValueChanged += comboBox_SelectedValueChanged;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 2);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(156, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Выпадающий список";
|
||||
//
|
||||
// DropDownList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBox);
|
||||
Name = "DropDownList";
|
||||
Size = new Size(225, 50);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
68
COP_1/cop_1/DropDownList.cs
Normal file
68
COP_1/cop_1/DropDownList.cs
Normal file
@ -0,0 +1,68 @@
|
||||
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 COP_1
|
||||
{
|
||||
public partial class DropDownList : UserControl
|
||||
{
|
||||
public DropDownList()
|
||||
{
|
||||
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
|
||||
{
|
||||
return comboBox.SelectedItem?.ToString() ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBox.SelectedItem = value;
|
||||
}
|
||||
}
|
||||
//подписка(отписка) на изменения в ComboBox, и при изменении автоматически вызываются все обработчики, подписанные на описание события ExplicitEvent.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1/cop_1/DropDownList.resx
Normal file
120
COP_1/cop_1/DropDownList.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
120
COP_1/cop_1/EmailBox.cs
Normal file
120
COP_1/cop_1/EmailBox.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public partial class emailBox : UserControl
|
||||
{
|
||||
private string _pattern;
|
||||
private string example = "example@gmail.com";
|
||||
// Событие для обработки ошибок
|
||||
private event Action? _errorOccurred;
|
||||
// Свойство для хранения сообщения об ошибке
|
||||
public string Error { get; private set; }
|
||||
|
||||
public string Pattern
|
||||
{
|
||||
get => _pattern;
|
||||
set => _pattern = value;
|
||||
}
|
||||
|
||||
// Публичное свойство для получения и установки значения текстового поля
|
||||
public string? TextBoxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Pattern))
|
||||
{
|
||||
throw new ArgumentException("Invalid pattern format.", nameof(Pattern));
|
||||
}
|
||||
|
||||
if (!IsValidEmail(textBox.Text))
|
||||
{
|
||||
throw new FormatException("Invalid email format.");
|
||||
}
|
||||
|
||||
return textBox.Text == string.Empty ? null : textBox.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsValidEmail(value))
|
||||
{
|
||||
textBox.Text = value;
|
||||
Error = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
TriggerError("Invalid email format.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tooltip для вывода примера
|
||||
private void textBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
int visibleTime = 3000; // Время отображения в миллисекундах
|
||||
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 => _errorOccurred += value;
|
||||
remove => _errorOccurred -= value;
|
||||
}
|
||||
public emailBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
// Событие при изменении текста
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TriggerError(ex.Message);
|
||||
}
|
||||
}
|
||||
private bool IsValidEmail(string email)
|
||||
{
|
||||
return !string.IsNullOrEmpty(Pattern) && Regex.IsMatch(email, Pattern);
|
||||
}
|
||||
// Метод для установки примера
|
||||
public void SetExample(string str)
|
||||
{
|
||||
if (IsValidEmail(str))
|
||||
{
|
||||
example = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
TriggerError("Invalid example format.");
|
||||
}
|
||||
}
|
||||
// Метод для запуска события ошибки
|
||||
private void TriggerError(string errorMessage)
|
||||
{
|
||||
Error = errorMessage;
|
||||
_errorOccurred?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
73
COP_1/cop_1/ValuesList.Designer.cs
generated
Normal file
73
COP_1/cop_1/ValuesList.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
namespace COP_1
|
||||
{
|
||||
partial class ValuesList
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
listBox = new ListBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
listBox.Dock = DockStyle.Bottom;
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.HorizontalScrollbar = true;
|
||||
listBox.ItemHeight = 20;
|
||||
listBox.Location = new Point(0, 21);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(238, 104);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 1);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(130, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Список значений";
|
||||
//
|
||||
// ValuesList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(listBox);
|
||||
Name = "ValuesList";
|
||||
Size = new Size(238, 125);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
139
COP_1/cop_1/ValuesList.cs
Normal file
139
COP_1/cop_1/ValuesList.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public partial class ValuesList : UserControl
|
||||
{
|
||||
private string template;
|
||||
private string start;
|
||||
private string end;
|
||||
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
public ValuesList()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
//Метод для установки информации о макетной строке и символах (стартового и конечного)
|
||||
public void SetLayoutInfo(string layout, string startS, string endS)
|
||||
{
|
||||
if (layout == null || startS == null || endS == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
template = layout;
|
||||
start = startS;
|
||||
end = endS;
|
||||
}
|
||||
|
||||
//св-во для получения и заполнения индекса выбранного элемента
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
//Публичный параметризованный метод для получения объекта из выбранной строки(создать объект и через рефлексию заполнить свойства его).
|
||||
public T GetObjectFromStr<T>() where T : class, new()
|
||||
{
|
||||
if (listBox.SelectedIndex < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string initString = listBox.SelectedItem.ToString();//изначальная строка, получаемая из листбокса
|
||||
T curObject = new T();
|
||||
|
||||
string[] tempWords = template.Split(new[] { char.Parse(start), char.Parse(end) }, StringSplitOptions.RemoveEmptyEntries);//все слова в шаблонной строке
|
||||
|
||||
StringBuilder valuesString = new StringBuilder(initString);//воспользуемся stringbuilder, т.к. будем проводить операции со строкой
|
||||
|
||||
List <string> replaceablePatterns = new(); //заменяемые слова шаблона(title, performer, genre, year)
|
||||
|
||||
foreach (var word in tempWords)
|
||||
{
|
||||
if (initString.Contains(word))
|
||||
{
|
||||
// Удаляем первое слово, остальные заменяем на символ конца
|
||||
if (valuesString.ToString().StartsWith(word))
|
||||
{
|
||||
valuesString.Replace(word, string.Empty); // Удаляем первое слово
|
||||
}
|
||||
else
|
||||
{
|
||||
valuesString.Replace(word, end.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceablePatterns.Add(word);
|
||||
}
|
||||
}
|
||||
|
||||
string[] values = valuesString.ToString().Split(new[] { end }, StringSplitOptions.RemoveEmptyEntries);
|
||||
StringBuilder result = new StringBuilder(template);
|
||||
for (int j = 0; j < replaceablePatterns.Count; j++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(replaceablePatterns[j]))
|
||||
{
|
||||
result.Replace(replaceablePatterns[j], values[j]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var property in typeof(T).GetProperties())
|
||||
{
|
||||
if (!property.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int startBorder = result.ToString().IndexOf(start);
|
||||
int endBorder = result.ToString().IndexOf(end, startBorder + 1);
|
||||
if (startBorder == -1 || endBorder == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
string propertyValue = result.ToString(startBorder + 1, endBorder - startBorder - 1); //с какого символа и сколько смволов вперед
|
||||
result.Remove(0, endBorder + 1);
|
||||
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||
}
|
||||
return curObject;
|
||||
}
|
||||
|
||||
public void AddInListBox<T>(T dataObject, int rowIndex)
|
||||
{
|
||||
while (listBox.Items.Count <= rowIndex)
|
||||
{
|
||||
listBox.Items.Add(template);
|
||||
}
|
||||
|
||||
string row = listBox.Items[rowIndex].ToString();
|
||||
PropertyInfo[] properties = dataObject.GetType().GetProperties();
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
if (property != null)
|
||||
{
|
||||
var propertyValue = property.GetValue(dataObject);
|
||||
row = row.Replace($"{start}{property.Name}{end}", propertyValue.ToString());
|
||||
listBox.Items[rowIndex] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1/cop_1/ValuesList.resx
Normal file
120
COP_1/cop_1/ValuesList.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
72
COP_1/cop_1/emailBox.Designer.cs
generated
Normal file
72
COP_1/cop_1/emailBox.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
namespace COP_1
|
||||
{
|
||||
partial class emailBox
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBox = new TextBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Dock = DockStyle.Bottom;
|
||||
textBox.Location = new Point(0, 23);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(225, 27);
|
||||
textBox.TabIndex = 2;
|
||||
textBox.TextChanged += textBox_TextChanged;
|
||||
textBox.Enter += textBox_Enter;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 3);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(168, 20);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Ввод и проверка email";
|
||||
//
|
||||
// emailBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBox);
|
||||
Name = "emailBox";
|
||||
Size = new Size(225, 50);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
120
COP_1/cop_1/emailBox.resx
Normal file
120
COP_1/cop_1/emailBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
15
COP_1Test/COP_1Test.csproj
Normal file
15
COP_1Test/COP_1Test.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="..\COP_1\COP_1.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
167
COP_1Test/Form1.Designer.cs
generated
Normal file
167
COP_1Test/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
||||
namespace COP_1Test
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dropDownList = new COP_1.DropDownList();
|
||||
valuesList = new COP_1.ValuesList();
|
||||
emailBox = new COP_1.emailBox();
|
||||
buttonCheck = new Button();
|
||||
label1 = new Label();
|
||||
buttonGet = new Button();
|
||||
textBoxShowItem = new TextBox();
|
||||
buttonGetDown = new Button();
|
||||
textBoxResult = new TextBox();
|
||||
buttonClear = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
dropDownList.Location = new Point(12, 12);
|
||||
dropDownList.Name = "dropDownList";
|
||||
dropDownList.Selected = "";
|
||||
dropDownList.Size = new Size(281, 49);
|
||||
dropDownList.TabIndex = 0;
|
||||
//
|
||||
// valuesList
|
||||
//
|
||||
valuesList.Location = new Point(374, 12);
|
||||
valuesList.Name = "valuesList";
|
||||
valuesList.SelectedIndex = -1;
|
||||
valuesList.Size = new Size(298, 125);
|
||||
valuesList.TabIndex = 1;
|
||||
//
|
||||
// emailBox
|
||||
//
|
||||
emailBox.Location = new Point(12, 178);
|
||||
emailBox.Name = "emailBox";
|
||||
emailBox.Pattern = null;
|
||||
emailBox.Size = new Size(281, 62);
|
||||
emailBox.TabIndex = 2;
|
||||
//
|
||||
// buttonCheck
|
||||
//
|
||||
buttonCheck.Location = new Point(12, 246);
|
||||
buttonCheck.Name = "buttonCheck";
|
||||
buttonCheck.Size = new Size(281, 29);
|
||||
buttonCheck.TabIndex = 3;
|
||||
buttonCheck.Text = "Проверить";
|
||||
buttonCheck.UseVisualStyleBackColor = true;
|
||||
buttonCheck.Click += buttonCheck_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Segoe UI Black", 12F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
label1.ForeColor = Color.Chartreuse;
|
||||
label1.Location = new Point(295, 210);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(69, 28);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "label1";
|
||||
label1.Visible = false;
|
||||
//
|
||||
// buttonGet
|
||||
//
|
||||
buttonGet.Location = new Point(374, 143);
|
||||
buttonGet.Name = "buttonGet";
|
||||
buttonGet.Size = new Size(298, 29);
|
||||
buttonGet.TabIndex = 5;
|
||||
buttonGet.Text = "Получить значение";
|
||||
buttonGet.UseVisualStyleBackColor = true;
|
||||
buttonGet.Click += buttonGet_Click;
|
||||
//
|
||||
// textBoxShowItem
|
||||
//
|
||||
textBoxShowItem.Location = new Point(374, 180);
|
||||
textBoxShowItem.Name = "textBoxShowItem";
|
||||
textBoxShowItem.Size = new Size(297, 27);
|
||||
textBoxShowItem.TabIndex = 6;
|
||||
//
|
||||
// buttonGetDown
|
||||
//
|
||||
buttonGetDown.Location = new Point(12, 64);
|
||||
buttonGetDown.Name = "buttonGetDown";
|
||||
buttonGetDown.Size = new Size(139, 51);
|
||||
buttonGetDown.TabIndex = 7;
|
||||
buttonGetDown.Text = "Получить значение";
|
||||
buttonGetDown.UseVisualStyleBackColor = true;
|
||||
buttonGetDown.Click += buttonGetDown_Click;
|
||||
//
|
||||
// textBoxResult
|
||||
//
|
||||
textBoxResult.Location = new Point(12, 121);
|
||||
textBoxResult.Name = "textBoxResult";
|
||||
textBoxResult.Size = new Size(281, 27);
|
||||
textBoxResult.TabIndex = 8;
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(154, 64);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(139, 51);
|
||||
buttonClear.TabIndex = 9;
|
||||
buttonClear.Text = "Очистить";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClear_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(684, 286);
|
||||
Controls.Add(buttonClear);
|
||||
Controls.Add(textBoxResult);
|
||||
Controls.Add(buttonGetDown);
|
||||
Controls.Add(textBoxShowItem);
|
||||
Controls.Add(buttonGet);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCheck);
|
||||
Controls.Add(emailBox);
|
||||
Controls.Add(valuesList);
|
||||
Controls.Add(dropDownList);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private COP_1.DropDownList dropDownList;
|
||||
private COP_1.ValuesList valuesList;
|
||||
private COP_1.emailBox emailBox;
|
||||
private Button buttonCheck;
|
||||
private Label label1;
|
||||
private Button buttonGet;
|
||||
private TextBox textBoxShowItem;
|
||||
private Button buttonGetDown;
|
||||
private TextBox textBoxResult;
|
||||
private Button buttonClear;
|
||||
}
|
||||
}
|
88
COP_1Test/Form1.cs
Normal file
88
COP_1Test/Form1.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using COP_1;
|
||||
using System;
|
||||
|
||||
namespace COP_1Test
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.BackColor = GetRandomPastelColor();
|
||||
list = new List<string>();
|
||||
list.AddRange(new string[] { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5", "Çíà÷åíèå 6" });
|
||||
|
||||
Album album1 = new Album("Meds", "Placebo", "Alternative", "2006");
|
||||
Album album2 = new Album("Iowa", "Slipknot", "Nu-Metal", "2001");
|
||||
Album album3 = new Album("Showbiz", "Muse", "Alternative", "1999");
|
||||
Album album4 = new Album("Chocolate Starfish and the Hot Dog Flavored Water", "Limp Bizkit", "Nu-metal", "2011");
|
||||
|
||||
valuesList.SetLayoutInfo("Íàçâàíèå: {Title} Èñïîëíèòåëü: {Performer} Æàíð: {Genre} Ãîä: {Year}", "{", "}");
|
||||
valuesList.AddInListBox(album1, 0);
|
||||
valuesList.AddInListBox(album2, 1);
|
||||
valuesList.AddInListBox(album3, 2);
|
||||
valuesList.AddInListBox(album4, 3);
|
||||
|
||||
emailBox.Pattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";
|
||||
|
||||
dropDownList.AddingToList(new List<string>() { "Placebo", "Slipknot", "Blue October", "The Used", "Muse", "The Cure" });
|
||||
dropDownList.ExplicitEvent += Event_Handler;
|
||||
|
||||
emailBox.ExplicitEvent += Event_Handler;
|
||||
emailBox.SetExample("eeee@mail.ru");
|
||||
}
|
||||
private Color GetRandomPastelColor()
|
||||
{
|
||||
Random random = new Random();
|
||||
int red = random.Next(128, 256);
|
||||
int green = random.Next(128, 256);
|
||||
int blue = random.Next(128, 256);
|
||||
|
||||
return Color.FromArgb(red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
private void Event_Handler(object sender, EventArgs e)
|
||||
{
|
||||
this.BackColor = GetRandomPastelColor();
|
||||
}
|
||||
|
||||
|
||||
private void buttonGet_Click(object sender, EventArgs e)
|
||||
{
|
||||
string str = valuesList.GetObjectFromStr<Album>().Title + " " + valuesList.GetObjectFromStr<Album>().Performer + " " + valuesList.GetObjectFromStr<Album>().Genre + " " + valuesList.GetObjectFromStr<Album>().Year;
|
||||
textBoxShowItem.Text = str;
|
||||
}
|
||||
private void buttonCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (emailBox.TextBoxValue != null)
|
||||
{
|
||||
label1.Visible = true;
|
||||
label1.Text = "true";
|
||||
label1.ForeColor = Color.Green;
|
||||
}
|
||||
else
|
||||
{
|
||||
label1.Visible = true;
|
||||
label1.Text = "false";
|
||||
label1.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList.Clear();
|
||||
}
|
||||
private void buttonGetDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxResult.Text = dropDownList.Selected;
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1Test/Form1.resx
Normal file
120
COP_1Test/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user