Compare commits
2 Commits
eb9dbb9eeb
...
fa6498b47d
Author | SHA1 | Date | |
---|---|---|---|
|
fa6498b47d | ||
|
6ed4cc2635 |
31
NevaevaLibrary/NevaevaLibrary.sln
Normal file
31
NevaevaLibrary/NevaevaLibrary.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
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}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {447455FF-8051-47FF-92EB-BA0A9E60D10E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
58
NevaevaLibrary/NevaevaLibrary/Components/ComboBoxControl.Designer.cs
generated
Normal file
58
NevaevaLibrary/NevaevaLibrary/Components/ComboBoxControl.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
namespace NevaevaLibrary
|
||||||
|
{
|
||||||
|
partial class ComboBoxControl
|
||||||
|
{
|
||||||
|
/// <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.comboBoxCustom = new System.Windows.Forms.ComboBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxCustom
|
||||||
|
//
|
||||||
|
this.comboBoxCustom.FormattingEnabled = true;
|
||||||
|
this.comboBoxCustom.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.comboBoxCustom.Name = "comboBoxCustom";
|
||||||
|
this.comboBoxCustom.Size = new System.Drawing.Size(321, 28);
|
||||||
|
this.comboBoxCustom.TabIndex = 0;
|
||||||
|
this.comboBoxCustom.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustom_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// ComboBoxControl
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.comboBoxCustom);
|
||||||
|
this.Name = "ComboBoxControl";
|
||||||
|
this.Size = new System.Drawing.Size(328, 35);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxCustom;
|
||||||
|
}
|
||||||
|
}
|
55
NevaevaLibrary/NevaevaLibrary/Components/ComboBoxControl.cs
Normal file
55
NevaevaLibrary/NevaevaLibrary/Components/ComboBoxControl.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
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 NevaevaLibrary
|
||||||
|
{
|
||||||
|
public partial class ComboBoxControl : UserControl
|
||||||
|
{
|
||||||
|
public ComboBoxControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SelectedValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return comboBoxCustom.SelectedItem != null ? comboBoxCustom.SelectedItem.ToString() : "";
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(comboBoxCustom.Items.Contains(value)) //если есть такой элемент, то помечаем, если нет, ничего не делаем
|
||||||
|
{
|
||||||
|
comboBoxCustom.SelectedItem = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<string?> SelectedValueChange;
|
||||||
|
|
||||||
|
public void addItems(List<string> items)
|
||||||
|
{
|
||||||
|
foreach (string item in items)
|
||||||
|
{
|
||||||
|
comboBoxCustom.Items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
comboBoxCustom.Items.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxCustom_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedValueChange?.Invoke(comboBoxCustom.SelectedItem.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
58
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.Designer.cs
generated
Normal file
58
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
namespace NevaevaLibrary
|
||||||
|
{
|
||||||
|
partial class ListBoxControl
|
||||||
|
{
|
||||||
|
/// <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.ItemHeight = 20;
|
||||||
|
this.listBox.Location = new System.Drawing.Point(0, 8);
|
||||||
|
this.listBox.Name = "listBox";
|
||||||
|
this.listBox.Size = new System.Drawing.Size(599, 224);
|
||||||
|
this.listBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ListBoxControl
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.listBox);
|
||||||
|
this.Name = "ListBoxControl";
|
||||||
|
this.Size = new System.Drawing.Size(599, 250);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ListBox listBox;
|
||||||
|
}
|
||||||
|
}
|
92
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.cs
Normal file
92
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using NevaevaLibrary.Exceptions;
|
||||||
|
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 NevaevaLibrary
|
||||||
|
{
|
||||||
|
public partial class ListBoxControl : UserControl
|
||||||
|
{
|
||||||
|
public ListBoxControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? template;
|
||||||
|
public char? fromChar;
|
||||||
|
public char? toChar;
|
||||||
|
|
||||||
|
public void setItems<T>(List<T> items)
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
if (template == null || !fromChar.HasValue || !toChar.HasValue) throw new ArgumentException("Не хватает данных!");
|
||||||
|
listBox.Items.Clear();
|
||||||
|
var type = typeof(T);
|
||||||
|
var fields = type.GetFields();
|
||||||
|
foreach (T item in items)
|
||||||
|
{
|
||||||
|
string result = template;
|
||||||
|
foreach (var field in fields)
|
||||||
|
{
|
||||||
|
string search = fromChar.Value + field.Name + toChar.Value;
|
||||||
|
result = result.Replace(search, field.GetValue(item).ToString());
|
||||||
|
}
|
||||||
|
listBox.Items.Add(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? getSelectedItem<T>()
|
||||||
|
{
|
||||||
|
if (template == null || !fromChar.HasValue || !toChar.HasValue || listBox.SelectedIndex == -1) throw new ArgumentException("Не хватает данных!");
|
||||||
|
var type = typeof(T);
|
||||||
|
var fields = type.GetFields();
|
||||||
|
|
||||||
|
var item = Activator.CreateInstance(type);
|
||||||
|
|
||||||
|
string[] wordsTemplate = template.Split(' ');
|
||||||
|
string[] words = listBox.SelectedItem.ToString().Split(' ');
|
||||||
|
for (int i = 0; i < wordsTemplate.Length; i++)
|
||||||
|
{
|
||||||
|
string word = wordsTemplate[i];
|
||||||
|
if (word.StartsWith(fromChar.Value))
|
||||||
|
{
|
||||||
|
string fieldName = word.Substring(1, word.Length - 2);
|
||||||
|
var field = fields.FirstOrDefault(x => x.Name == fieldName);
|
||||||
|
if (field == null) continue;
|
||||||
|
int indexBefore = i > 0 ? Array.IndexOf(words, wordsTemplate[i-1]) : -1;
|
||||||
|
int indexAfter = i < wordsTemplate.Length - 1 ? Array.IndexOf(words, wordsTemplate[i+1]) : wordsTemplate.Length - 1;
|
||||||
|
var fieldValue = String.Join(' ', words.Skip(indexBefore + 1).Take(indexAfter - indexBefore - 1).ToArray());
|
||||||
|
field.SetValue(item, Convert.ChangeType(fieldValue, field.FieldType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item != null ? (T)item : default(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SelectedIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return listBox.SelectedIndex;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
listBox.SelectedIndex = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(string template, char fromChar, char toChar)
|
||||||
|
{
|
||||||
|
this.template = template;
|
||||||
|
this.fromChar = fromChar;
|
||||||
|
this.toChar = toChar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.resx
Normal file
60
NevaevaLibrary/NevaevaLibrary/Components/ListBoxControl.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>
|
67
NevaevaLibrary/NevaevaLibrary/Components/MailControl.Designer.cs
generated
Normal file
67
NevaevaLibrary/NevaevaLibrary/Components/MailControl.Designer.cs
generated
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
namespace NevaevaLibrary
|
||||||
|
{
|
||||||
|
partial class MailControl
|
||||||
|
{
|
||||||
|
/// <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 Component 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.components = new System.ComponentModel.Container();
|
||||||
|
this.textBoxMail = new System.Windows.Forms.TextBox();
|
||||||
|
this.toolTipEmail = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxMail
|
||||||
|
//
|
||||||
|
this.textBoxMail.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.textBoxMail.Name = "textBoxMail";
|
||||||
|
this.textBoxMail.Size = new System.Drawing.Size(257, 27);
|
||||||
|
this.textBoxMail.TabIndex = 0;
|
||||||
|
this.textBoxMail.TextChanged += new System.EventHandler(this.textBoxMail_TextChanged);
|
||||||
|
this.textBoxMail.MouseEnter += new System.EventHandler(this.textBoxMail_MouseEnter);
|
||||||
|
//
|
||||||
|
// toolTipEmail
|
||||||
|
//
|
||||||
|
this.toolTipEmail.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||||
|
this.toolTipEmail.ToolTipTitle = "Пример ввода";
|
||||||
|
//
|
||||||
|
// MailControl
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.textBoxMail);
|
||||||
|
this.Name = "MailControl";
|
||||||
|
this.Size = new System.Drawing.Size(264, 34);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxMail;
|
||||||
|
private ToolTip toolTipEmail;
|
||||||
|
}
|
||||||
|
}
|
70
NevaevaLibrary/NevaevaLibrary/Components/MailControl.cs
Normal file
70
NevaevaLibrary/NevaevaLibrary/Components/MailControl.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using NevaevaLibrary.Exceptions;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace NevaevaLibrary
|
||||||
|
{
|
||||||
|
public partial class MailControl : UserControl
|
||||||
|
{
|
||||||
|
public MailControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Regex? validateEmailRegex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<string> TextChange;
|
||||||
|
private string? tooltipText;
|
||||||
|
public string errorMessage = "";
|
||||||
|
|
||||||
|
|
||||||
|
public string? Email
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
//не забыл ли пользователь ввести регулярку и соответствует ли она
|
||||||
|
if (validateEmailRegex == null)
|
||||||
|
{
|
||||||
|
errorMessage = "Пустой шаблон!";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if (!validateEmailRegex.IsMatch(textBoxMail.Text))
|
||||||
|
{
|
||||||
|
errorMessage = "Некорректный адрес эл. почты!";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else return textBoxMail.Text;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (validateEmailRegex == null) errorMessage = "Пустой шаблон!";
|
||||||
|
else if (!validateEmailRegex.IsMatch(value)) errorMessage = "Некорректный адрес эл. почты!";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textBoxMail.Text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void textBoxMail_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TextChange?.Invoke(textBoxMail.Text);
|
||||||
|
Email = textBoxMail.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTooltipText(string text)
|
||||||
|
{
|
||||||
|
tooltipText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void textBoxMail_MouseEnter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
toolTipEmail.Show(tooltipText ?? "", textBoxMail);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
63
NevaevaLibrary/NevaevaLibrary/Components/MailControl.resx
Normal file
63
NevaevaLibrary/NevaevaLibrary/Components/MailControl.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="toolTipEmail.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NevaevaLibrary.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class EmptySymbolsException : ApplicationException
|
||||||
|
{
|
||||||
|
public EmptySymbolsException() : base() { }
|
||||||
|
public EmptySymbolsException(string message) : base(message) { }
|
||||||
|
public EmptySymbolsException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected EmptySymbolsException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NevaevaLibrary.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class NullSampleException : ApplicationException
|
||||||
|
{
|
||||||
|
public NullSampleException() : base() { }
|
||||||
|
public NullSampleException(string message) : base(message) { }
|
||||||
|
public NullSampleException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected NullSampleException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
|
}
|
10
NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
Normal file
10
NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
173
NevaevaLibrary/TestApp/FormTest.Designer.cs
generated
Normal file
173
NevaevaLibrary/TestApp/FormTest.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
this.comboBoxControl = new NevaevaLibrary.ComboBoxControl();
|
||||||
|
this.buttonInsert = new System.Windows.Forms.Button();
|
||||||
|
this.buttonClear = new System.Windows.Forms.Button();
|
||||||
|
this.buttonGetSelected = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSetSelected = new System.Windows.Forms.Button();
|
||||||
|
this.mailControl = new NevaevaLibrary.MailControl();
|
||||||
|
this.buttonAddTemplate = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxControl = new NevaevaLibrary.ListBoxControl();
|
||||||
|
this.buttonInsertList = new System.Windows.Forms.Button();
|
||||||
|
this.buttonGetSelectedList = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxControl
|
||||||
|
//
|
||||||
|
this.comboBoxControl.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.comboBoxControl.Name = "comboBoxControl";
|
||||||
|
this.comboBoxControl.SelectedValue = "";
|
||||||
|
this.comboBoxControl.Size = new System.Drawing.Size(366, 44);
|
||||||
|
this.comboBoxControl.TabIndex = 0;
|
||||||
|
this.comboBoxControl.SelectedValueChange += new System.Action<string>(this.comboBoxControl_SelectedValueChange);
|
||||||
|
//
|
||||||
|
// buttonInsert
|
||||||
|
//
|
||||||
|
this.buttonInsert.Location = new System.Drawing.Point(12, 48);
|
||||||
|
this.buttonInsert.Name = "buttonInsert";
|
||||||
|
this.buttonInsert.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonInsert.TabIndex = 1;
|
||||||
|
this.buttonInsert.Text = "Заполнить";
|
||||||
|
this.buttonInsert.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonInsert.Click += new System.EventHandler(this.buttonInsert_Click);
|
||||||
|
//
|
||||||
|
// buttonClear
|
||||||
|
//
|
||||||
|
this.buttonClear.Location = new System.Drawing.Point(112, 48);
|
||||||
|
this.buttonClear.Name = "buttonClear";
|
||||||
|
this.buttonClear.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonClear.TabIndex = 2;
|
||||||
|
this.buttonClear.Text = "Очистить";
|
||||||
|
this.buttonClear.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
|
||||||
|
//
|
||||||
|
// buttonGetSelected
|
||||||
|
//
|
||||||
|
this.buttonGetSelected.Location = new System.Drawing.Point(212, 48);
|
||||||
|
this.buttonGetSelected.Name = "buttonGetSelected";
|
||||||
|
this.buttonGetSelected.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonGetSelected.TabIndex = 3;
|
||||||
|
this.buttonGetSelected.Text = "Получить";
|
||||||
|
this.buttonGetSelected.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonGetSelected.Click += new System.EventHandler(this.buttonGetSelected_Click);
|
||||||
|
//
|
||||||
|
// buttonSetSelected
|
||||||
|
//
|
||||||
|
this.buttonSetSelected.Location = new System.Drawing.Point(312, 48);
|
||||||
|
this.buttonSetSelected.Name = "buttonSetSelected";
|
||||||
|
this.buttonSetSelected.Size = new System.Drawing.Size(99, 29);
|
||||||
|
this.buttonSetSelected.TabIndex = 4;
|
||||||
|
this.buttonSetSelected.Text = "Установить";
|
||||||
|
this.buttonSetSelected.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSetSelected.Click += new System.EventHandler(this.buttonSetSelected_Click);
|
||||||
|
//
|
||||||
|
// mailControl
|
||||||
|
//
|
||||||
|
this.mailControl.Email = "";
|
||||||
|
this.mailControl.Location = new System.Drawing.Point(11, 95);
|
||||||
|
this.mailControl.Name = "mailControl";
|
||||||
|
this.mailControl.Size = new System.Drawing.Size(312, 94);
|
||||||
|
this.mailControl.TabIndex = 5;
|
||||||
|
this.mailControl.validateEmailRegex = null;
|
||||||
|
//
|
||||||
|
// buttonAddTemplate
|
||||||
|
//
|
||||||
|
this.buttonAddTemplate.Location = new System.Drawing.Point(12, 160);
|
||||||
|
this.buttonAddTemplate.Name = "buttonAddTemplate";
|
||||||
|
this.buttonAddTemplate.Size = new System.Drawing.Size(143, 29);
|
||||||
|
this.buttonAddTemplate.TabIndex = 6;
|
||||||
|
this.buttonAddTemplate.Text = "Передать шаблон";
|
||||||
|
this.buttonAddTemplate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddTemplate.Click += new System.EventHandler(this.buttonAddTemplate_Click);
|
||||||
|
//
|
||||||
|
// listBoxControl
|
||||||
|
//
|
||||||
|
this.listBoxControl.Location = new System.Drawing.Point(479, 12);
|
||||||
|
this.listBoxControl.Name = "listBoxControl";
|
||||||
|
this.listBoxControl.SelectedIndex = -1;
|
||||||
|
this.listBoxControl.Size = new System.Drawing.Size(608, 237);
|
||||||
|
this.listBoxControl.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonInsertList
|
||||||
|
//
|
||||||
|
this.buttonInsertList.Location = new System.Drawing.Point(483, 268);
|
||||||
|
this.buttonInsertList.Name = "buttonInsertList";
|
||||||
|
this.buttonInsertList.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonInsertList.TabIndex = 8;
|
||||||
|
this.buttonInsertList.Text = "Заполнить";
|
||||||
|
this.buttonInsertList.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonInsertList.Click += new System.EventHandler(this.buttonInsertList_Click);
|
||||||
|
//
|
||||||
|
// buttonGetSelectedList
|
||||||
|
//
|
||||||
|
this.buttonGetSelectedList.Location = new System.Drawing.Point(596, 268);
|
||||||
|
this.buttonGetSelectedList.Name = "buttonGetSelectedList";
|
||||||
|
this.buttonGetSelectedList.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonGetSelectedList.TabIndex = 9;
|
||||||
|
this.buttonGetSelectedList.Text = "Получить";
|
||||||
|
this.buttonGetSelectedList.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonGetSelectedList.Click += new System.EventHandler(this.buttonGetSelectedList_Click);
|
||||||
|
//
|
||||||
|
// FormTest
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1109, 316);
|
||||||
|
this.Controls.Add(this.buttonGetSelectedList);
|
||||||
|
this.Controls.Add(this.buttonInsertList);
|
||||||
|
this.Controls.Add(this.listBoxControl);
|
||||||
|
this.Controls.Add(this.buttonAddTemplate);
|
||||||
|
this.Controls.Add(this.mailControl);
|
||||||
|
this.Controls.Add(this.buttonSetSelected);
|
||||||
|
this.Controls.Add(this.buttonGetSelected);
|
||||||
|
this.Controls.Add(this.buttonClear);
|
||||||
|
this.Controls.Add(this.buttonInsert);
|
||||||
|
this.Controls.Add(this.comboBoxControl);
|
||||||
|
this.Name = "FormTest";
|
||||||
|
this.Text = "FormTest";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private NevaevaLibrary.ComboBoxControl comboBoxControl;
|
||||||
|
private Button buttonInsert;
|
||||||
|
private Button buttonClear;
|
||||||
|
private Button buttonGetSelected;
|
||||||
|
private Button buttonSetSelected;
|
||||||
|
private NevaevaLibrary.MailControl mailControl;
|
||||||
|
private Button buttonAddTemplate;
|
||||||
|
private NevaevaLibrary.ListBoxControl listBoxControl;
|
||||||
|
private Button buttonInsertList;
|
||||||
|
private Button buttonGetSelectedList;
|
||||||
|
}
|
||||||
|
}
|
70
NevaevaLibrary/TestApp/FormTest.cs
Normal file
70
NevaevaLibrary/TestApp/FormTest.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
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 TestApp
|
||||||
|
{
|
||||||
|
public partial class FormTest : Form
|
||||||
|
{
|
||||||
|
public FormTest()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonInsert_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
List<string> testStrings = new List<string>() { "str1", "str2", "str3" };
|
||||||
|
comboBoxControl.addItems(testStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonClear_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
comboBoxControl.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonGetSelected_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(comboBoxControl.SelectedValue, "Полученное значение");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSetSelected_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
comboBoxControl.SelectedValue = "str2";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxControl_SelectedValueChange(string obj)
|
||||||
|
{
|
||||||
|
MessageBox.Show(obj, "event");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddTemplate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
mailControl.validateEmailRegex = new Regex("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$");
|
||||||
|
mailControl.setTooltipText("qwerty@gmail.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonInsertList_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
listBoxControl.setParams("{name} works in {department} for {workYears} year(s)", '{', '}');
|
||||||
|
Worker w1 = new Worker("Vasya", "Management", 5);
|
||||||
|
Worker w2 = new Worker("Vasya Utkin", "Tech department cool stuff", 1);
|
||||||
|
Worker w3 = new Worker("Ivan", "Management", 2);
|
||||||
|
|
||||||
|
List <Worker> workers = new List<Worker> { w1, w2, w3 };
|
||||||
|
listBoxControl.setItems(workers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonGetSelectedList_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Worker? worker = listBoxControl.getSelectedItem<Worker>();
|
||||||
|
if (worker is not null) MessageBox.Show(worker.ToString() + $"\n{worker.name}, {worker.department}, {worker.workYears}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
NevaevaLibrary/TestApp/FormTest.resx
Normal file
60
NevaevaLibrary/TestApp/FormTest.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
NevaevaLibrary/TestApp/Program.cs
Normal file
17
NevaevaLibrary/TestApp/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
NevaevaLibrary/TestApp/TestApp.csproj
Normal file
15
NevaevaLibrary/TestApp/TestApp.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="..\NevaevaLibrary\NevaevaLibrary.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
25
NevaevaLibrary/TestApp/Worker.cs
Normal file
25
NevaevaLibrary/TestApp/Worker.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Worker
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public string department;
|
||||||
|
public int workYears;
|
||||||
|
|
||||||
|
public Worker(string name, string department, int workYears)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.department = department;
|
||||||
|
this.workYears = workYears;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Worker()
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user