Compare commits

..

6 Commits
main ... Lab_2

34 changed files with 2196 additions and 0 deletions

31
COP/COP.sln Normal file
View 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}") = "Components", "Components\Components.csproj", "{218522CC-CD60-403C-9B12-C683EEA06E32}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{AFFC45E9-4318-4446-89E4-FEB441CD92F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{218522CC-CD60-403C-9B12-C683EEA06E32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{218522CC-CD60-403C-9B12-C683EEA06E32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{218522CC-CD60-403C-9B12-C683EEA06E32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{218522CC-CD60-403C-9B12-C683EEA06E32}.Release|Any CPU.Build.0 = Release|Any CPU
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5BF17EB-25A7-411A-9B3C-049D6C7E8C56}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Words" Version="24.9.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,59 @@
namespace Components.Components
{
partial class UserDropDownList
{
/// <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.dropDownList = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// dropDownList
//
this.dropDownList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.dropDownList.FormattingEnabled = true;
this.dropDownList.Location = new System.Drawing.Point(3, 3);
this.dropDownList.Name = "dropDownList";
this.dropDownList.Size = new System.Drawing.Size(187, 24);
this.dropDownList.TabIndex = 0;
this.dropDownList.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
//
// UserDropDownList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.dropDownList);
this.Name = "UserDropDownList";
this.Size = new System.Drawing.Size(193, 30);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox dropDownList;
}
}

View File

@ -0,0 +1,65 @@
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 Components.Components
{
public partial class UserDropDownList : UserControl
{
public UserDropDownList()
{
InitializeComponent();
}
public void LoadValues(List<string> Values)
{
if (Values.Count == 0)
{
return;
}
dropDownList.Items.AddRange(Values.ToArray());
}
public void Clear()
{
dropDownList.Items.Clear();
}
public string SelectedValue
{
get
{
return dropDownList.SelectedItem?.ToString() ?? string.Empty;
}
set
{
if (dropDownList.Items.Contains(value))
{
dropDownList.SelectedItem = value;
}
}
}
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
private void comboBox_SelectedValueChanged(object sender, EventArgs e)
{
onValueChanged?.Invoke(sender, e);
}
}
}

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,59 @@
namespace Components.Components
{
partial class UserEmailTextBox
{
/// <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.emailTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// emailTextBox
//
this.emailTextBox.Location = new System.Drawing.Point(3, 3);
this.emailTextBox.Name = "emailTextBox";
this.emailTextBox.Size = new System.Drawing.Size(170, 22);
this.emailTextBox.TabIndex = 0;
this.emailTextBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
this.emailTextBox.Enter += new System.EventHandler(this.textBox_Enter);
//
// UserEmailTextBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.emailTextBox);
this.Name = "UserEmailTextBox";
this.Size = new System.Drawing.Size(177, 30);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox emailTextBox;
}
}

View File

@ -0,0 +1,125 @@
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;
using Components.Exceptions;
namespace Components.Components
{
public partial class UserEmailTextBox : UserControl
{
private string pattern;
private string example = "example@yandex.ru";
public UserEmailTextBox()
{
InitializeComponent();
emailTextBox.Enter += textBox_Enter;
emailTextBox.TextChanged += textBox_TextChanged;
}
public string Pattern
{
get { return pattern; }
set
{
if (string.IsNullOrEmpty(value))
{
throw new NullPatternException("Шаблон не может быть нулевым или пустым");
}
pattern = value;
}
}
public string TextBoxValue
{
get
{
if (string.IsNullOrEmpty(Pattern))
{
throw new NullPatternException("Шаблон не задан");
}
Regex rg = new Regex(Pattern);
bool address = rg.IsMatch(emailTextBox.Text);
if (address)
{
return emailTextBox.Text;
}
else
{
throw new NotMatchPatternException("Введенный адрес электронной почты не соответствует шаблону.");
}
}
set
{
if (string.IsNullOrEmpty(Pattern))
{
return;
}
Regex rg = new Regex(Pattern);
bool address = rg.IsMatch(value);
if (address)
{
emailTextBox.Text = value;
}
}
}
public string Error
{
get; private set;
}
public void SetExample(string str)
{
if (string.IsNullOrEmpty(Pattern))
{
throw new NullPatternException("Pattern is not set.");
}
Regex rg = new Regex(Pattern);
bool address = rg.IsMatch(str);
if (address)
{
example = str;
}
else
{
throw new NotMatchPatternException("The provided example does not match the pattern.");
}
}
private void textBox_Enter(object sender, EventArgs e)
{
int VisibleTime = 2000; //ms
ToolTip tooltip = new ToolTip();
tooltip.Show(example, emailTextBox, 30, -20, VisibleTime);
}
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
private void textBox_TextChanged(object sender, EventArgs e)
{
onValueChanged?.Invoke(sender, e);
}
}
}

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,59 @@
namespace Components.Components
{
partial class UserListBoxObject
{
/// <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.listBoxObj = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBoxObj
//
this.listBoxObj.FormattingEnabled = true;
this.listBoxObj.HorizontalScrollbar = true;
this.listBoxObj.ItemHeight = 16;
this.listBoxObj.Location = new System.Drawing.Point(3, 3);
this.listBoxObj.Name = "listBoxObj";
this.listBoxObj.Size = new System.Drawing.Size(353, 116);
this.listBoxObj.TabIndex = 0;
//
// UserListBoxObjects
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listBoxObj);
this.Name = "UserListBoxObjects";
this.Size = new System.Drawing.Size(359, 133);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBoxObj;
}
}

View File

@ -0,0 +1,99 @@
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 Components.Components
{
public partial class UserListBoxObject : UserControl
{
private string? _template;
private char? _fromChar;
private char? _toChar;
public int SelectedIndex
{
get
{
return listBoxObj.SelectedIndex;
}
set
{
listBoxObj.SelectedIndex = value;
}
}
public UserListBoxObject()
{
InitializeComponent();
}
public void SetParams(string template, char fromChar, char toChar)
{
_template = template;
_fromChar = fromChar;
_toChar = toChar;
}
public T? GetObject<T>()
{
if (listBoxObj.SelectedIndex == -1 || string.IsNullOrEmpty(_template) || !_fromChar.HasValue || !_toChar.HasValue)
throw new ArgumentException("Не хватает данных");
var type = typeof(T);
var properties = type.GetProperties();
var curObject = Activator.CreateInstance(type);
string[] wordsTemplate = _template.Split(' ');
string[] words = listBoxObj.SelectedItem.ToString().Split(' ');
for (int i = 0; i < wordsTemplate.Length; i++)
{
string word = wordsTemplate[i];
if (word.Contains(_fromChar.Value) && word.Contains(_toChar.Value))
{
int startCharIndex = word.IndexOf(_fromChar.Value);
int endCharIndex = word.LastIndexOf(_toChar.Value);
string propertyName = word.Substring(startCharIndex + 1, endCharIndex - startCharIndex - 1);
var property = properties.FirstOrDefault(x => x.Name == propertyName);
if (property == null)
continue;
int extraCharsBefore = startCharIndex;
int extraCharsAfter = word.Length - endCharIndex - 1;
string propertyValue = words[i].Substring(extraCharsBefore,
words[i].Length - extraCharsBefore - extraCharsAfter);
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
}
}
return (T?)curObject;
}
public void AddItems<T>(List<T> items)
where T : class
{
if (string.IsNullOrEmpty(_template) || !_fromChar.HasValue || !_toChar.HasValue)
throw new ArgumentException("Не хватает данных");
listBoxObj.Items.Clear();
var type = typeof(T);
var properties = type.GetProperties();
foreach (T item in items)
{
string result = _template;
foreach (var property in properties)
{
string search = _fromChar.Value + property.Name + _toChar.Value;
result = result.Replace(search, property.GetValue(item)?.ToString() ?? "");
}
listBoxObj.Items.Add(result);
}
}
}
}

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,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace Components.Exceptions
{
[Serializable]
public class NotMatchPatternException : ApplicationException
{
public NotMatchPatternException() : base() { }
public NotMatchPatternException(string message) : base(message) { }
public NotMatchPatternException(string message, Exception exception) : base(message, exception) { }
protected NotMatchPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace Components.Exceptions
{
[Serializable]
public class NullPatternException : ApplicationException
{
public NullPatternException() : base() { }
public NullPatternException(string message) : base(message) { }
public NullPatternException(string message, Exception exception) : base(message, exception) { }
protected NullPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

View File

@ -0,0 +1,36 @@
namespace Components.NonVisualComponents
{
partial class WordLineChart
{
/// <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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Drawing.Charts;
using Components.SupportClasses;
using Document = Aspose.Words.Document;
namespace Components.NonVisualComponents
{
public partial class WordLineChart : Component
{
public WordLineChart()
{
InitializeComponent();
}
public WordLineChart(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void AddLineChart(SimpleLineChart simpleLineChart)
{
if (!CheckData(simpleLineChart.DataList))
{
throw new Exception("Не данные заполнены");
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Aspose.Words.Font font = builder.Font;
font.Size = 24;
font.Bold = true;
font.Color = Color.Black;
font.Name = "Times New Roman";
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.SpaceAfter = 24;
paragraphFormat.Alignment = ParagraphAlignment.Center;
paragraphFormat.KeepTogether = true;
builder.Writeln(simpleLineChart.FileHeader);
Shape shape = builder.InsertChart(ChartType.Line, 500, 270);
Chart chart = shape.Chart;
chart.Title.Text = simpleLineChart.LineChartName;
ChartSeriesCollection seriesColl = chart.Series;
Console.WriteLine(seriesColl.Count);
seriesColl.Clear();
foreach (var data in simpleLineChart.DataList)
{
seriesColl.Add(data.NameSeries, data.NameData, data.Data);
}
ChartLegend legend = chart.Legend;
legend.Position = (LegendPosition)simpleLineChart.AreaLegend;
legend.Overlay = true;
doc.Save(simpleLineChart.FilePath);
}
static bool CheckData(List<DataLineChart> data)
{
foreach (var _data in data)
{
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.NameData.ToString()) || string.IsNullOrEmpty(_data.Data.ToString()))
{
return false;
}
}
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace Components.NonVisualComponents
{
partial class WordTable
{
/// <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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Components.SupportClasses;
using Aspose.Words;
using Aspose.Words.Tables;
namespace Components.NonVisualComponents
{
public partial class WordTable : Component
{
public WordTable()
{
InitializeComponent();
}
public WordTable(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateTable<T>(BigTable<T> bigTable)
{
if (bigTable.Data == null)
{
throw new ArgumentException("Не заданы все данные");
}
foreach (var columnDefenition in bigTable.ColumnDefenitions)
{
if (string.IsNullOrEmpty(columnDefenition.PropertyName))
{
throw new ArgumentException($"Не задано свойство столбца: {columnDefenition.Header}");
}
}
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
titleStyle.Font.Size = 16;
titleStyle.Font.Bold = true;
builder.ParagraphFormat.Style = titleStyle;
builder.Writeln(bigTable.DocumentTitle);
Table table = builder.StartTable();
foreach (var columnDefenition in bigTable.ColumnDefenitions)
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefenition.Weight);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write(columnDefenition.Header);
}
foreach (var mergedColumn in bigTable.MergedColumns)
{
int startCellIndex = mergedColumn[0];
int endCellIndex = mergedColumn[mergedColumn.Length - 1];
for (int i = startCellIndex; i <= endCellIndex; i++)
{
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First;
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
}
for (int i = startCellIndex + 1; i <= endCellIndex; i++)
{
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
}
}
builder.EndRow();
foreach (var columnDefenition in bigTable.ColumnDefenitions)
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefenition.Weight);
builder.Write(columnDefenition.Header);
}
builder.EndRow();
int columnIndex;
foreach (var columnDefinition in bigTable.ColumnDefenitions)
{
string currentHeader = columnDefinition.Header;
columnIndex = 0;
foreach (var columnDefenition in bigTable.ColumnDefenitions)
{
string currentHeader1 = columnDefenition.Header;
if (currentHeader == currentHeader1)
{
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
}
columnIndex++;
}
}
foreach (var item in bigTable.Data)
{
foreach (var columnDefenition in bigTable.ColumnDefenitions)
{
builder.InsertCell();
var propertyValue = item.GetType()
.GetProperty(columnDefenition.PropertyName)?
.GetValue(item)?.ToString();
builder.Write(propertyValue ?? "");
}
builder.EndRow();
}
builder.EndTable();
document.Save(bigTable.FilePath);
}
}
}

View File

@ -0,0 +1,36 @@
namespace Components.NonVisualComponents
{
partial class WordText
{
/// <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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,106 @@
using System;
using System.ComponentModel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using Components.SupportClasses;
using DocumentFormat.OpenXml;
namespace Components.NonVisualComponents
{
public partial class WordText : Component
{
public WordText()
{
InitializeComponent();
}
public WordText(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateWordText(LargeText largeText)
{
if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || !CheckData(largeText.TextData))
{
throw new Exception("Не все данные заполнены");
}
using (var wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document))
{
// Вытаскиваем главную часть из вордовского документа
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
// Генерируем тело основной части документа
Body docBody = mainPart.Document.AppendChild(new Body());
// Добавляем текст
AddText(docBody, largeText);
}
}
private void AddText(Body docBody, LargeText largeText)
{
#region Создание заголовка
ParagraphProperties paragraphProperties = new();
paragraphProperties.AppendChild(new Justification
{
Val = JustificationValues.Center
});
paragraphProperties.AppendChild(new Indentation());
Paragraph header = new();
header.AppendChild(paragraphProperties);
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize
{
Val = "48"
});
properties.AppendChild(new Bold());
docRun.AppendChild(properties);
docRun.AppendChild(new Text(largeText.DocumentTitle));
header.AppendChild(docRun);
docBody.Append(header);
#endregion
#region Создание текста
for (int i = 0; i < largeText.TextData.Length; i++)
{
ParagraphProperties paragraphProperties2 = new();
paragraphProperties2.AppendChild(new Justification
{
Val = JustificationValues.Both
});
paragraphProperties2.AppendChild(new Indentation());
Paragraph text = new();
text.AppendChild(paragraphProperties2);
var docRun2 = new Run();
var properties2 = new RunProperties();
properties2.AppendChild(new FontSize
{
Val = "24"
});
docRun2.AppendChild(properties2);
docRun2.AppendChild(new Text(largeText.TextData[i]));
text.AppendChild(docRun2);
docBody.Append(text);
}
#endregion
}
bool CheckData(string[] data)
{
for (int i = 0; i < data.Length; i++)
{
if (string.IsNullOrEmpty(data[i])) return false;
}
return true;
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses
{
public class BigTable<T>
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty;
public List<string> Header;
public List<ColumnDefenitions> ColumnDefenitions;
public List<T> Data;
public List<int[]> MergedColumns;
public BigTable(string filePath, string documentTitle, List<string> header, List<ColumnDefenitions> columnDefenitions, List<T> data, List<int[]> mergedColumns)
{
FilePath = filePath;
DocumentTitle = documentTitle;
Header = header;
Data = data;
MergedColumns = mergedColumns;
ColumnDefenitions = columnDefenitions;
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses
{
public class ColumnDefenitions
{
public string Header;
public string PropertyName;
public double Weight;
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses
{
public class DataLineChart
{
public string NameSeries { get; set; } = string.Empty;
public string[] NameData { get; set; }
public double[] Data { get; set; }
public DataLineChart(string nameSeries, string[] nameData, double[] data)
{
NameSeries = nameSeries;
NameData = nameData;
Data = data;
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses.Enums
{
public enum EnumAreaLegend
{
None,
Left,
Top,
Right,
Bottom,
TopRight
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses
{
public class LargeText
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty;
public string[] TextData;
public LargeText(string filePath, string documentTitle, string[] textData)
{
FilePath = filePath;
DocumentTitle = documentTitle;
TextData = textData;
}
}
}

View File

@ -0,0 +1,31 @@
using Components.SupportClasses.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.SupportClasses
{
public class SimpleLineChart
{
public string FilePath = string.Empty;
public string FileHeader = string.Empty;
public string LineChartName = string.Empty;
public EnumAreaLegend AreaLegend;
public List<DataLineChart> DataList = new();
public SimpleLineChart(string filePath, string fileHeader, string lineChartName, EnumAreaLegend areaLegend, List<DataLineChart> dataList)
{
FilePath = filePath;
FileHeader = fileHeader;
LineChartName = lineChartName;
AreaLegend = areaLegend;
DataList = dataList;
}
}
}

228
COP/WinForms/FormForComponents.Designer.cs generated Normal file
View File

@ -0,0 +1,228 @@
namespace WinForms
{
partial class FormForComponents
{
/// <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.dropDownList = new Components.Components.UserDropDownList();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonInfo = new System.Windows.Forms.Button();
this.labelInfo = new System.Windows.Forms.Label();
this.buttonClear = new System.Windows.Forms.Button();
this.emailTextBox = new Components.Components.UserEmailTextBox();
this.labelShow = new System.Windows.Forms.Label();
this.buttonShow = new System.Windows.Forms.Button();
this.buttonSetExample = new System.Windows.Forms.Button();
this.labelExample = new System.Windows.Forms.Label();
this.textBoxExample = new System.Windows.Forms.TextBox();
this.listBoxObj = new Components.Components.UserListBoxObject();
this.buttonAddObjects = new System.Windows.Forms.Button();
this.buttonShowItem = new System.Windows.Forms.Button();
this.labelShowInput = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// dropDownList
//
this.dropDownList.Location = new System.Drawing.Point(3, 3);
this.dropDownList.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dropDownList.Name = "dropDownList";
this.dropDownList.SelectedValue = "";
this.dropDownList.Size = new System.Drawing.Size(196, 36);
this.dropDownList.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(3, 46);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(92, 29);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonInfo
//
this.buttonInfo.Location = new System.Drawing.Point(211, 46);
this.buttonInfo.Name = "buttonInfo";
this.buttonInfo.Size = new System.Drawing.Size(94, 29);
this.buttonInfo.TabIndex = 2;
this.buttonInfo.Text = "показать";
this.buttonInfo.UseVisualStyleBackColor = true;
this.buttonInfo.Click += new System.EventHandler(this.buttonInfo_Click);
//
// labelInfo
//
this.labelInfo.AutoSize = true;
this.labelInfo.Location = new System.Drawing.Point(205, 9);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(154, 20);
this.labelInfo.TabIndex = 3;
this.labelInfo.Text = "Выбранный элемент";
//
// buttonClear
//
this.buttonClear.Location = new System.Drawing.Point(101, 46);
this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(94, 29);
this.buttonClear.TabIndex = 4;
this.buttonClear.Text = "очистить";
this.buttonClear.UseVisualStyleBackColor = true;
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
//
// emailTextBox
//
this.emailTextBox.Location = new System.Drawing.Point(12, 132);
this.emailTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.emailTextBox.Name = "emailTextBox";
this.emailTextBox.Pattern = null;
this.emailTextBox.Size = new System.Drawing.Size(179, 34);
this.emailTextBox.TabIndex = 5;
//
// labelShow
//
this.labelShow.AutoSize = true;
this.labelShow.Location = new System.Drawing.Point(12, 170);
this.labelShow.Name = "labelShow";
this.labelShow.Size = new System.Drawing.Size(76, 20);
this.labelShow.TabIndex = 10;
this.labelShow.Text = "проверка";
//
// buttonShow
//
this.buttonShow.Location = new System.Drawing.Point(12, 196);
this.buttonShow.Name = "buttonShow";
this.buttonShow.Size = new System.Drawing.Size(94, 29);
this.buttonShow.TabIndex = 9;
this.buttonShow.Text = "Проверка";
this.buttonShow.UseVisualStyleBackColor = true;
//
// buttonSetExample
//
this.buttonSetExample.Location = new System.Drawing.Point(12, 328);
this.buttonSetExample.Name = "buttonSetExample";
this.buttonSetExample.Size = new System.Drawing.Size(188, 29);
this.buttonSetExample.TabIndex = 8;
this.buttonSetExample.Text = "Поменять пример";
this.buttonSetExample.UseVisualStyleBackColor = true;
//
// labelExample
//
this.labelExample.AutoSize = true;
this.labelExample.Location = new System.Drawing.Point(12, 263);
this.labelExample.Name = "labelExample";
this.labelExample.Size = new System.Drawing.Size(147, 20);
this.labelExample.TabIndex = 7;
this.labelExample.Text = "Для ввода примера";
//
// textBoxExample
//
this.textBoxExample.Location = new System.Drawing.Point(12, 295);
this.textBoxExample.Name = "textBoxExample";
this.textBoxExample.Size = new System.Drawing.Size(188, 27);
this.textBoxExample.TabIndex = 6;
//
// listBoxObj
//
this.listBoxObj.Location = new System.Drawing.Point(388, 13);
this.listBoxObj.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBoxObj.Name = "listBoxObj";
this.listBoxObj.SelectedIndex = -1;
this.listBoxObj.Size = new System.Drawing.Size(368, 159);
this.listBoxObj.TabIndex = 11;
//
// buttonAddObjects
//
this.buttonAddObjects.Location = new System.Drawing.Point(388, 179);
this.buttonAddObjects.Name = "buttonAddObjects";
this.buttonAddObjects.Size = new System.Drawing.Size(380, 29);
this.buttonAddObjects.TabIndex = 12;
this.buttonAddObjects.Text = "Добавить";
this.buttonAddObjects.UseVisualStyleBackColor = true;
//
// buttonShowItem
//
this.buttonShowItem.Location = new System.Drawing.Point(388, 310);
this.buttonShowItem.Name = "buttonShowItem";
this.buttonShowItem.Size = new System.Drawing.Size(380, 29);
this.buttonShowItem.TabIndex = 13;
this.buttonShowItem.Text = "Получить";
this.buttonShowItem.UseVisualStyleBackColor = true;
//
// labelShowInput
//
this.labelShowInput.AutoSize = true;
this.labelShowInput.Location = new System.Drawing.Point(388, 273);
this.labelShowInput.Name = "labelShowInput";
this.labelShowInput.Size = new System.Drawing.Size(54, 20);
this.labelShowInput.TabIndex = 14;
this.labelShowInput.Text = "Вывод";
//
// FormForComponents
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dropDownList);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.buttonInfo);
this.Controls.Add(this.labelInfo);
this.Controls.Add(this.buttonClear);
this.Controls.Add(this.emailTextBox);
this.Controls.Add(this.textBoxExample);
this.Controls.Add(this.labelExample);
this.Controls.Add(this.buttonSetExample);
this.Controls.Add(this.labelShow);
this.Controls.Add(this.buttonShow);
this.Controls.Add(this.listBoxObj);
this.Controls.Add(this.buttonAddObjects);
this.Controls.Add(this.buttonShowItem);
this.Controls.Add(this.labelShowInput);
this.Name = "FormForComponents";
this.Text = "FormForComponents";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Components.Components.UserDropDownList dropDownList;
private Button buttonAdd;
private Button buttonInfo;
private Label labelInfo;
private Button buttonClear;
private Components.Components.UserEmailTextBox emailTextBox;
private TextBox textBoxExample;
private Label labelExample;
private Button buttonSetExample;
private Label labelShow;
private Button buttonShow;
private Components.Components.UserListBoxObject listBoxObj;
private Button buttonAddObjects;
private Button buttonShowItem;
private Label labelShowInput;
}
}

View File

@ -0,0 +1,75 @@
using Components.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;
namespace WinForms
{
public partial class FormForComponents : Form
{
List<string> list = new List<string>();
List<Worker> students = new List<Worker>();
public FormForComponents()
{
InitializeComponent();
list = new List<string>();
list.AddRange(new string[] { "слон", "волк", "кролик" });
listBoxObj.SetParams("Имя: {FirstName}, Фамилия: {LastName}. {Experience} ({Age}) лет.", '{', '}');
listBoxObj.AddItems(new List<Worker> { new() { Name = "Иван", LastName = "Иванов", Age = 23, Experience = 5 },
new() { Name = "Егор", LastName = "Булаткин", Age = 30, Experience = 10 },
new() { Name = "Арбуз", LastName = "Арбуз", Age = 40, Experience = 7 } });
dropDownList.LoadValues(new List<string>() { "котенок", "собачка", "лиса" });
emailTextBox.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
}
private void CustomEventHandler(object sender, EventArgs e)
{
MessageBox.Show("Выбранный элемент изменен");
}
private void buttonAdd_Click(object sender, EventArgs e)
{
dropDownList.LoadValues(list);
}
private void buttonInfo_Click(object sender, EventArgs e)
{
labelInfo.Text = dropDownList.SelectedValue;
}
private void buttonClear_Click(object sender, EventArgs e)
{
dropDownList.Clear();
}
private void buttonSetExample_Click(object sender, EventArgs e)
{
if (textBoxExample.Text == String.Empty)
{
return;
}
//emailTextBox.setExample(textBoxExample.Text);
}
private void buttonShow_Click(object sender, EventArgs e)
{
try
{
if (emailTextBox.TextBoxValue != null)
{
labelShow.Text = "подходит";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

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>

134
COP/WinForms/FormWord.Designer.cs generated Normal file
View File

@ -0,0 +1,134 @@
namespace WinForms
{
partial class FormWord
{
/// <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()
{
components = new System.ComponentModel.Container();
wordText = new Components.NonVisualComponents.WordText(components);
groupBox1 = new GroupBox();
button1 = new Button();
wordLineChart = new Components.NonVisualComponents.WordLineChart(components);
groupBox3 = new GroupBox();
button3 = new Button();
groupBox2 = new GroupBox();
button2 = new Button();
wordTable = new Components.NonVisualComponents.WordTable(components);
groupBox1.SuspendLayout();
groupBox3.SuspendLayout();
groupBox2.SuspendLayout();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(button1);
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(120, 80);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Большой текст";
//
// button1
//
button1.Location = new Point(6, 45);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 0;
button1.Text = "Создать";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// groupBox3
//
groupBox3.Controls.Add(button3);
groupBox3.Location = new Point(331, 12);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(120, 80);
groupBox3.TabIndex = 1;
groupBox3.TabStop = false;
groupBox3.Text = "Линейная диаграмма";
//
// button3
//
button3.Location = new Point(6, 45);
button3.Name = "button3";
button3.Size = new Size(94, 29);
button3.TabIndex = 0;
button3.Text = "Создать";
button3.UseVisualStyleBackColor = true;
button3.Click += button3_Click;
//
// groupBox2
//
groupBox2.Controls.Add(button2);
groupBox2.Location = new Point(171, 12);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(120, 80);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Таблица";
//
// button2
//
button2.Location = new Point(6, 45);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 0;
button2.Text = "Создать";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// FormWord
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(463, 114);
Controls.Add(groupBox2);
Controls.Add(groupBox3);
Controls.Add(groupBox1);
Name = "FormWord";
Text = "Невизуальные компоненты";
groupBox1.ResumeLayout(false);
groupBox3.ResumeLayout(false);
groupBox2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Components.NonVisualComponents.WordText wordText;
private GroupBox groupBox1;
private Button button1;
private Components.NonVisualComponents.WordLineChart wordLineChart;
private GroupBox groupBox3;
private Button button3;
private GroupBox groupBox2;
private Button button2;
private Components.NonVisualComponents.WordTable wordTable;
}
}

137
COP/WinForms/FormWord.cs Normal file
View File

@ -0,0 +1,137 @@
using Components.NonVisualComponents;
using Components.SupportClasses.Enums;
using Components.SupportClasses;
using DocumentFormat.OpenXml.Wordprocessing;
using Components.Components;
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.Net.WebRequestMethods;
namespace WinForms
{
public partial class FormWord : Form
{
string[] testArray = { "У психолога Сергея Васнецова большие проблемы. От него ушла жена, оставив пятерых дочерей. Да каких - с ума сойти! Первая - модница, вторая - отличница, третья - неформалка, " +
"четвертая - спортсменка, а пятая - совсем крошка Пуговка. Все очень шумные. " +
"И никто не умеет убирать и готовить! Кажется, доктору Васнецову самому скоро понадобится помощь специалиста..."};
public FormWord()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
LargeText largeText = new(dialog.FileName, "Папины дочки", testArray);
wordText.CreateWordText(largeText);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
List<int[]> mergedColumns = new()
{
new int[] { 0, 1, 2 }
};
List<string> header = new List<string>
{
"Работа",
"",
"",
"Фамилия"
};
List<ColumnDefenitions> columnDefenitions = new List<ColumnDefenitions>
{
new ColumnDefenitions { Header = "Возраст", PropertyName = "Age", Weight = 20 },
new ColumnDefenitions { Header = "Опыт", PropertyName = "Experience", Weight = 20 },
new ColumnDefenitions { Header = "Должность", PropertyName = "Position", Weight = 20 },
new ColumnDefenitions { Header = "Фамилия", PropertyName = "LastName", Weight = 20 }
};
List<Worker> data = new List<Worker>
{
new Worker {Id = 1, Gender = "мужской", Name = "Егор", LastName = "Булаткин", Age = 30, Experience = 10, Position="певец"},
new Worker {Id = 2, Gender = "женский", Name = "Алевтина", LastName = "Антонова", Age = 22, Experience = 3, Position="стоматолог"},
new Worker {Id = 3, Gender = "женский", Name = "Брошка", LastName = "Кулончикова", Age = 25, Experience = 15, Position="комик"},
new Worker {Id = 4, Gender = "мужской", Name = "Милош", LastName = "Коваль", Age = 33, Experience = 1, Position="актер"},
new Worker {Id = 5, Gender = "женский", Name = "Василина", LastName = "Моисеева", Age = 20, Experience = 5, Position="Программист"}
};
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
BigTable<Worker> bigTable = new(dialog.FileName, "Задание 2", header, columnDefenitions, data, mergedColumns);
wordTable.CreateTable(bigTable);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
string[] month = { "Январь", "Февраль", "Март" };
double[] profit1 = { 300, 440, 270 };
double[] profit2 = { 500, 620, 310 };
double[] profit3 = { 420, 189, 430 };
SimpleLineChart lineChart = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataLineChart> {
new DataLineChart("Компания 1", month, profit1), new DataLineChart("Компания 2", month, profit2), new DataLineChart("Компания 3", month, profit3),
});
wordLineChart.AddLineChart(lineChart);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

120
COP/WinForms/FormWord.resx Normal file
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>

17
COP/WinForms/Program.cs Normal file
View File

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

View File

@ -0,0 +1,19 @@
<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>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Components\Components.csproj" />
</ItemGroup>
</Project>

25
COP/WinForms/Worker.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinForms
{
public class Worker
{
public int Id { get; set; }
public string Gender { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public int Age { get; set; }
public int Experience { get; set; }
public string Position { get; set; } = string.Empty;
}
}