Made components

This commit is contained in:
ksenianeva 2023-10-06 00:52:09 +04:00
parent eb9dbb9eeb
commit 6ed4cc2635
13 changed files with 669 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}"
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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {447455FF-8051-47FF-92EB-BA0A9E60D10E}
EndGlobalSection
EndGlobal

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

View File

@ -0,0 +1,52 @@
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.SelectedValue.ToString() ?? "";
}
set
{
comboBoxCustom.SelectedValue = 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());
}
}
}

View File

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

View File

@ -0,0 +1,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;
}
}

View 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? getSelectedItems<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]) : 0;
int indexAfter = i < wordsTemplate.Length - 1 ? Array.IndexOf(words, wordsTemplate[i+1]) : wordsTemplate.Length - 1;
var fieldValue = String.Join(' ', words.Skip(indexBefore).Take(indexAfter - indexBefore - 1).ToArray());
field.SetValue(item, fieldValue);
}
}
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;
}
}
}

View File

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

View File

@ -0,0 +1,92 @@
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.checkBoxNull = new System.Windows.Forms.CheckBox();
this.labelCheckAddress = new System.Windows.Forms.Label();
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);
//
// checkBoxNull
//
this.checkBoxNull.AutoSize = true;
this.checkBoxNull.Location = new System.Drawing.Point(3, 36);
this.checkBoxNull.Name = "checkBoxNull";
this.checkBoxNull.Size = new System.Drawing.Size(126, 24);
this.checkBoxNull.TabIndex = 1;
this.checkBoxNull.Text = "Не заполнять";
this.checkBoxNull.UseVisualStyleBackColor = true;
this.checkBoxNull.CheckedChanged += new System.EventHandler(this.checkBoxNull_CheckedChanged);
//
// labelCheckAddress
//
this.labelCheckAddress.AutoSize = true;
this.labelCheckAddress.BackColor = System.Drawing.SystemColors.Control;
this.labelCheckAddress.ForeColor = System.Drawing.Color.Firebrick;
this.labelCheckAddress.Location = new System.Drawing.Point(5, 69);
this.labelCheckAddress.Name = "labelCheckAddress";
this.labelCheckAddress.Size = new System.Drawing.Size(0, 20);
this.labelCheckAddress.TabIndex = 2;
//
// toolTipEmail
//
this.toolTipEmail.Popup += new System.Windows.Forms.PopupEventHandler(this.toolTipEmail_Popup);
//
// MailControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.labelCheckAddress);
this.Controls.Add(this.checkBoxNull);
this.Controls.Add(this.textBoxMail);
this.Name = "MailControl";
this.Size = new System.Drawing.Size(264, 102);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxMail;
private CheckBox checkBoxNull;
private Label labelCheckAddress;
private ToolTip toolTipEmail;
}
}

View File

@ -0,0 +1,63 @@
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;
public string Email
{
get
{
return textBoxMail.Text;
}
set
{
if (validateEmailRegex == null) throw new NullSampleException("Пустой шаблон!");
if (!validateEmailRegex.IsMatch(value)) labelCheckAddress.Text = "Некорректный адрес эл. почты!";
else textBoxMail.Text = value;
}
}
private void checkBoxNull_CheckedChanged(object sender, EventArgs e) //enable entering a text + clean text area
{
if (checkBoxNull.Checked)
{
textBoxMail.Enabled = false;
}
else
{
textBoxMail.Enabled = true;
textBoxMail.Text = "";
}
}
private void textBoxMail_TextChanged(object sender, EventArgs e)
{
TextChange.Invoke(textBoxMail.Text);
}
public void toolTipEmail_Popup(object sender, PopupEventArgs e)
{
toolTipEmail.ToolTipTitle = "qwerty@gmail.com";
}
//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])?$");
}
}

View File

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

View File

@ -0,0 +1,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) { }
}
}

View File

@ -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) { }
}
}

View File

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