Compare commits

...

11 Commits
main ... lab1

Author SHA1 Message Date
b9f471bee9 поправила пару незначительных ошибок 2024-10-07 11:53:49 +04:00
d79cf20111 рабочий третий компонент без символов начала и конца и спроверкой на нуллбл 2024-09-28 13:59:17 +04:00
d270df92c0 какие-то танцы с бубном по третьему компоненту и считыванию подстроки 2024-09-23 14:04:59 +04:00
da7b64ec6f чет проверила в лабе, подправила (в третьем компоненте...)
вроде работает
2024-09-23 01:06:36 +04:00
bbc5701cbc работает третий компонент :_) 2024-09-21 17:36:24 +04:00
0bd7fd69e3 второй компонент работает 2024-09-14 22:23:11 +04:00
89ceade732 в процессе разработки второго компонента 2024-09-06 22:21:18 +04:00
be6e8d0466 начинаю делать компонент ввода 2024-09-06 11:44:11 +04:00
33f373fde7 добавила тестовое приложение и протестировала компонент выбора из списка 2024-09-06 11:43:48 +04:00
8084f4f79a добавила компонент выбора из списка 2024-09-06 11:43:25 +04:00
34989eaa4a создание проекта 2024-09-06 10:02:55 +04:00
18 changed files with 1206 additions and 0 deletions

View File

@ -0,0 +1,93 @@
namespace TestAppForCheckComponentsWorking
{
partial class FormTest
{
/// <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()
{
selectComponent = new UserComponentsOption19.SelectComponent();
writeComponent = new UserComponentsOption19.WriteComponent();
listComponent = new UserComponentsOption19.ListComponent();
button = new Button();
SuspendLayout();
//
// selectComponent
//
selectComponent.Location = new Point(12, 12);
selectComponent.Name = "selectComponent";
selectComponent.SelectedValue = "";
selectComponent.Size = new Size(189, 36);
selectComponent.TabIndex = 0;
//
// writeComponent
//
writeComponent.Location = new Point(12, 65);
writeComponent.Name = "writeComponent";
writeComponent.Size = new Size(324, 44);
writeComponent.TabIndex = 1;
writeComponent.Template = null;
//
// listComponent
//
listComponent.Location = new Point(16, 120);
listComponent.Name = "listComponent";
listComponent.SelectedIndex = -1;
listComponent.Size = new Size(406, 315);
listComponent.TabIndex = 2;
listComponent.ChangeSelectedItem += ChangeSelectedItem;
//
// button
//
button.Location = new Point(414, 65);
button.Name = "button";
button.Size = new Size(94, 29);
button.TabIndex = 3;
button.Text = "button1";
button.UseVisualStyleBackColor = true;
button.Click += button_Click;
//
// FormTest
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(635, 533);
Controls.Add(button);
Controls.Add(listComponent);
Controls.Add(writeComponent);
Controls.Add(selectComponent);
Name = "FormTest";
Text = "нукась протестируем...";
ResumeLayout(false);
}
#endregion
private UserComponentsOption19.SelectComponent selectComponent;
private UserComponentsOption19.WriteComponent writeComponent;
private UserComponentsOption19.ListComponent listComponent;
private Button button;
}
}

View File

@ -0,0 +1,111 @@
using System.Text.RegularExpressions;
using UserComponentsOption19;
namespace TestAppForCheckComponentsWorking
{
public partial class FormTest : Form
{
public List<string> testList = new List<string>();
Random rand = new Random();
public FormTest()
{
InitializeComponent();
FillList(19);
SetTemplate();
FillListBox();
}
private void SelectComponent_SelectComponentChanged(object? sender, EventArgs e)
{
MessageBox.Show("íó âûçâàë òû ìåíÿ, è ÷òî äàëüøå?");
}
private void FillList(int num)
{
for (int i = 0; i <= num; i++)
{
testList.Add("ß ñúåì " + i.ToString() + " àðáóçîâ!");
}
selectComponent.FillList(testList);
}
Regex regex = new Regex(@"^[^@\s]+@[^@\s]+\.(com|net|org|gov|ru)$");
public void SetTemplate()
{
writeComponent.Template = regex;
writeComponent.SetTextTooltip("email@email.ru");
try
{
//writeComponent.WriteTextInTextBox.ToString();
//writeComponent.WriteTextInTextBox = writeComponent.WriteTextInTextBox.ToString();
writeComponent.WriteTextInTextBox = "email@email.com";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_Click(object sender, EventArgs e)
{
try
{
writeComponent.WriteTextInTextBox.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public class Cat()
{
public int? Age { get; set; }
public string? Name { get; set; }
}
public void FillListBox()
{
try
{
listComponent.FillTemplateString("Êîò: (Name), âîçðàñò: (Age)", "(", ")");
for (int i = 0; i <= 10; i++)
{
Cat cat = new Cat();
cat.Name = "kitti" + i.ToString();
cat.Age = i;
listComponent.AddObjectToListBox(cat);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ChangeSelectedItem(object sender, EventArgs e)
{
var newCat = listComponent.GetObjectFromSelectedRow<Cat>();
if (newCat != null)
{
MessageBox.Show(newCat.Name);
MessageBox.Show(newCat.Age.ToString());
}
string placeHolder = "(Name)";
//listComponent.GetNameOfProperty("Êîò ñ èìåíåì (Name)", placeHolder);
}
}
}

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

View File

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

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\UserComponentsOption19\UserComponentsOption19.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserComponentsOption19", "UserComponentsOption19\UserComponentsOption19.csproj", "{1BB1E87C-D5E4-41A6-9303-0F3E00F00507}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAppForCheckComponentsWorking", "TestAppForCheckComponentsWorking\TestAppForCheckComponentsWorking.csproj", "{4B5178B4-8A7C-4896-BC0C-6B0F6476B0B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1BB1E87C-D5E4-41A6-9303-0F3E00F00507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BB1E87C-D5E4-41A6-9303-0F3E00F00507}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BB1E87C-D5E4-41A6-9303-0F3E00F00507}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BB1E87C-D5E4-41A6-9303-0F3E00F00507}.Release|Any CPU.Build.0 = Release|Any CPU
{4B5178B4-8A7C-4896-BC0C-6B0F6476B0B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B5178B4-8A7C-4896-BC0C-6B0F6476B0B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B5178B4-8A7C-4896-BC0C-6B0F6476B0B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B5178B4-8A7C-4896-BC0C-6B0F6476B0B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5466B454-D3BC-46EA-8960-7193721A5CF0}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UserComponentsOption19
{
internal class InvalidInputException : Exception
{
public InvalidInputException(string message) : base (message) { }
}
}

View File

@ -0,0 +1,58 @@
namespace UserComponentsOption19
{
partial class ListComponent
{
/// <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();
SuspendLayout();
//
// listBox
//
listBox.BackColor = Color.Honeydew;
listBox.FormattingEnabled = true;
listBox.Location = new Point(3, 3);
listBox.Name = "listBox";
listBox.Size = new Size(319, 244);
listBox.TabIndex = 0;
listBox.SelectedIndexChanged += listBox_SelectedIndexChanged;
//
// ListComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Name = "ListComponent";
Size = new Size(325, 252);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,128 @@
namespace UserComponentsOption19
{
public partial class ListComponent : UserControl
{
private string? _templateString;
private string? _startPropertyChar;
private string? _endPropertyChar;
public event EventHandler? ChangeSelectedItem;
public ListComponent()
{
InitializeComponent();
}
/// <summary>
/// публичный метод заполнения макетной строки
/// </summary>
/// <param name="templateString"></param>
/// <param name="startPropertyChar"></param>
/// <param name="endPropertyChar"></param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="InvalidOperationException"></exception>
public void FillTemplateString(string templateString, string startPropertyChar, string endPropertyChar)
{
if (string.IsNullOrEmpty(templateString))
{
throw new ArgumentNullException("Введите макетную строку (не забудьте символы начала и конца свойства объекта :3)");
}
if (!templateString.Contains(startPropertyChar) || !templateString.Contains(endPropertyChar))
{
throw new InvalidOperationException("Вы не дописали символы начала и конца свойства объекта :_(");
}
_templateString = templateString;
_startPropertyChar = startPropertyChar;
_endPropertyChar = endPropertyChar;
}
/// <summary>
/// публичное свойство для получения/установки индекса строки
/// </summary>
public int SelectedIndex
{
get
{
if (listBox.SelectedIndex == -1) return -1;
return listBox.SelectedIndex;
}
set
{
if (listBox.SelectedIndex != -1)
{
listBox.SelectedIndex = value;
}
}
}
/// <summary>
/// Метод получения объекта из строки с заполнением свойств ентого объекта через рефлексию
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T? GetObjectFromSelectedRow<T>() where T : class, new()
{
if (listBox.SelectedIndex == -1 || listBox.SelectedItem == null)
return null;
string? selectedString = listBox.SelectedItem.ToString();
T obj = new T();
Type objectType = typeof(T);
char[] punctMarks = { ',', '.', ';', ':' };
string selString = selectedString;
string tempString = _templateString;
string[] selList = selString.Split();
string[] tempList = tempString.Split();
foreach (var property in objectType.GetProperties())
{
string placeholder = $"{_startPropertyChar}{property.Name}{_endPropertyChar}";
for (int i = 0; i < tempList.Length; i++)
{
if (placeholder == tempList[i].Trim(punctMarks))
{
Type propertyType = property.PropertyType;
Type? underlyingType = Nullable.GetUnderlyingType(propertyType);
if (underlyingType != null)
{
object? converted = string.IsNullOrWhiteSpace(selList[i]) ? null : Convert.ChangeType(selList[i].Trim(punctMarks), underlyingType);
property.SetValue(obj, converted);
}
else
{
property.SetValue(obj, Convert.ChangeType(selList[i].Trim(punctMarks), property.PropertyType));
}
}
}
}
return obj;
}
public void AddObjectToListBox<T>(T? obj)
{
Type objectType = obj.GetType();
string result = _templateString;
foreach (var propertyInfo in objectType.GetProperties())
{
string placeholder = $"{_startPropertyChar}{propertyInfo.Name}{_endPropertyChar}";
var value = propertyInfo.GetValue(obj)?.ToString() ?? string.Empty;
result = result.Replace(placeholder, value);
}
listBox.Items.Add(result);
}
private void listBox_SelectedIndexChanged(object sender, EventArgs e)
{
ChangeSelectedItem?.Invoke(this, e);
}
}
}

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

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UserComponentsOption19
{
internal class NoTemplateException : Exception
{
public NoTemplateException(string message) : base (message) { }
}
}

View File

@ -0,0 +1,58 @@
namespace UserComponentsOption19
{
partial class SelectComponent
{
/// <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();
SuspendLayout();
//
// comboBox
//
comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
comboBox.FormattingEnabled = true;
comboBox.Location = new Point(0, 0);
comboBox.Name = "comboBox";
comboBox.Size = new Size(151, 28);
comboBox.TabIndex = 0;
comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
//
// SelectComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(comboBox);
Name = "SelectComponent";
Size = new Size(151, 29);
ResumeLayout(false);
}
#endregion
private ComboBox comboBox;
}
}

View File

@ -0,0 +1,48 @@
namespace UserComponentsOption19
{
public partial class SelectComponent : UserControl
{
public event EventHandler? SelectComponentChanged;
Random rand = new Random();
public SelectComponent()
{
InitializeComponent();
//comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
}
public void FillList(List<string> list)
{
foreach (string item in list)
{
comboBox.Items.Add(item);
}
//comboBox.SelectedIndex = rand.Next(list.Count);
}
public void ClearList()
{
comboBox.Items.Clear();
}
public string SelectedValue
{
get
{
return comboBox.SelectedItem?.ToString() ?? string.Empty;
}
set
{
comboBox.SelectedItem = value;
}
}
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
SelectComponentChanged?.Invoke(this, e);
}
}
}

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

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,57 @@
namespace UserComponentsOption19
{
partial class WriteComponent
{
/// <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();
SuspendLayout();
//
// textBox
//
textBox.Location = new Point(3, 3);
textBox.Name = "textBox";
textBox.Size = new Size(310, 27);
textBox.TabIndex = 0;
textBox.TextChanged += textBox_TextChanged;
//
// WriteComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBox);
Name = "WriteComponent";
Size = new Size(320, 35);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
}
}

View File

@ -0,0 +1,74 @@
using System.Text.RegularExpressions;
namespace UserComponentsOption19
{
public partial class WriteComponent : UserControl
{
private Regex? regex;
private ToolTip toolTipTemplate = new ToolTip();
public event EventHandler? ChangeText;
public WriteComponent()
{
InitializeComponent();
}
public Regex? Template
{
get => regex;
set
{
regex = value;
}
}
public void SetTextTooltip(string toolTip)
{
toolTipTemplate.SetToolTip(textBox, toolTip);
}
private void textBox_TextChanged(object sender, EventArgs e)
{
ChangeText?.Invoke(this, e);
}
public string WriteTextInTextBox
{
get
{
if (Template == null)
{
throw new NoTemplateException("Не установлен шаблон");
}
if (!Template.IsMatch(textBox.Text))
{
throw new InvalidInputException("Введенное значение не соответствует шаблону");
}
return textBox.Text;
}
set
{
if (Template != null)
{
if (Template.IsMatch(value))
{
textBox.Text = value;
}
else
{
throw new InvalidInputException("Введенное значение не соответствует шаблону");
}
}
else
{
textBox.Text = string.Empty;
}
}
}
}
}

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