Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0e3c10c66 |
33
COP_1/Album.cs
Normal file
33
COP_1/Album.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public class Album
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Performer { get; set; }
|
||||
public string Genre { get; set; }
|
||||
public string Year { get; set; }
|
||||
|
||||
public Album(string title, string performer, string genre, string year)
|
||||
{
|
||||
Title = title;
|
||||
Performer = performer;
|
||||
Genre = genre;
|
||||
Year = year;
|
||||
}
|
||||
|
||||
public Album() { }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string temp = Title + ", " + Performer + ", " + Genre + ", " + Year;
|
||||
return temp;
|
||||
//return (Title+", "+Performer+", "+Genre+", "+Year);
|
||||
}
|
||||
}
|
||||
}
|
16
COP_1/COP_1.csproj
Normal file
16
COP_1/COP_1.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
31
COP_1/COP_1.sln
Normal file
31
COP_1/COP_1.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP_1", "COP_1.csproj", "{41597675-2261-45D0-B8A3-F6C00D687FDC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COP_1Test", "..\COP_1Test\COP_1Test.csproj", "{3926A945-603A-4E7F-B674-2240C8B5B794}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{41597675-2261-45D0-B8A3-F6C00D687FDC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3926A945-603A-4E7F-B674-2240C8B5B794}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {44FCB702-AF4F-4B33-B037-E657C1CC86F4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
72
COP_1/cop_1/DropDownList.Designer.cs
generated
Normal file
72
COP_1/cop_1/DropDownList.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
namespace COP_1
|
||||
{
|
||||
partial class DropDownList
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
comboBox = new ComboBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBox
|
||||
//
|
||||
comboBox.Dock = DockStyle.Bottom;
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Location = new Point(0, 22);
|
||||
comboBox.Name = "comboBox";
|
||||
comboBox.Size = new Size(225, 28);
|
||||
comboBox.TabIndex = 1;
|
||||
comboBox.SelectedValueChanged += comboBox_SelectedValueChanged;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 2);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(156, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Выпадающий список";
|
||||
//
|
||||
// DropDownList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBox);
|
||||
Name = "DropDownList";
|
||||
Size = new Size(225, 50);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
68
COP_1/cop_1/DropDownList.cs
Normal file
68
COP_1/cop_1/DropDownList.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public partial class DropDownList : UserControl
|
||||
{
|
||||
public DropDownList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//метод, у которого в передаваемых параметрах идет список строк и через этот список идет заполнение ComboBox;
|
||||
public void AddingToList(List<string> Values)
|
||||
{
|
||||
if (Values.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
comboBox.Items.AddRange(Values.ToArray());
|
||||
}
|
||||
|
||||
//Отдельный публичный метод отчистки списка.
|
||||
public void Clear()
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
}
|
||||
|
||||
//публичное свойство(set, get) для установки и получения выбранного значения (возвращает пустую строку, если нет выбранного значения)
|
||||
public string Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return comboBox.SelectedItem?.ToString() ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBox.SelectedItem = value;
|
||||
}
|
||||
}
|
||||
//подписка(отписка) на изменения в ComboBox, и при изменении автоматически вызываются все обработчики, подписанные на описание события ExplicitEvent.
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_explicitEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_explicitEvent -= value;
|
||||
}
|
||||
}
|
||||
//событие, вызываемое при смене значения в ComboBox.
|
||||
private void comboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1/cop_1/DropDownList.resx
Normal file
120
COP_1/cop_1/DropDownList.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
120
COP_1/cop_1/EmailBox.cs
Normal file
120
COP_1/cop_1/EmailBox.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public partial class emailBox : UserControl
|
||||
{
|
||||
private string _pattern;
|
||||
private string example = "example@gmail.com";
|
||||
// Событие для обработки ошибок
|
||||
private event Action? _errorOccurred;
|
||||
// Свойство для хранения сообщения об ошибке
|
||||
public string Error { get; private set; }
|
||||
|
||||
public string Pattern
|
||||
{
|
||||
get => _pattern;
|
||||
set => _pattern = value;
|
||||
}
|
||||
|
||||
// Публичное свойство для получения и установки значения текстового поля
|
||||
public string? TextBoxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Pattern))
|
||||
{
|
||||
throw new ArgumentException("Invalid pattern format.", nameof(Pattern));
|
||||
}
|
||||
|
||||
if (!IsValidEmail(textBox.Text))
|
||||
{
|
||||
throw new FormatException("Invalid email format.");
|
||||
}
|
||||
|
||||
return textBox.Text == string.Empty ? null : textBox.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsValidEmail(value))
|
||||
{
|
||||
textBox.Text = value;
|
||||
Error = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
TriggerError("Invalid email format.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tooltip для вывода примера
|
||||
private void textBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
int visibleTime = 3000; // Время отображения в миллисекундах
|
||||
ToolTip tt = new ToolTip();
|
||||
tt.Show(example, textBox, 0, 20, visibleTime);
|
||||
}
|
||||
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add => _explicitEvent += value;
|
||||
remove => _explicitEvent -= value;
|
||||
}
|
||||
|
||||
public event Action AnErrorOccurred
|
||||
{
|
||||
add => _errorOccurred += value;
|
||||
remove => _errorOccurred -= value;
|
||||
}
|
||||
public emailBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
// Событие при изменении текста
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TriggerError(ex.Message);
|
||||
}
|
||||
}
|
||||
private bool IsValidEmail(string email)
|
||||
{
|
||||
return !string.IsNullOrEmpty(Pattern) && Regex.IsMatch(email, Pattern);
|
||||
}
|
||||
// Метод для установки примера
|
||||
public void SetExample(string str)
|
||||
{
|
||||
if (IsValidEmail(str))
|
||||
{
|
||||
example = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
TriggerError("Invalid example format.");
|
||||
}
|
||||
}
|
||||
// Метод для запуска события ошибки
|
||||
private void TriggerError(string errorMessage)
|
||||
{
|
||||
Error = errorMessage;
|
||||
_errorOccurred?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
73
COP_1/cop_1/ValuesList.Designer.cs
generated
Normal file
73
COP_1/cop_1/ValuesList.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
namespace COP_1
|
||||
{
|
||||
partial class ValuesList
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
listBox = new ListBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
listBox.Dock = DockStyle.Bottom;
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.HorizontalScrollbar = true;
|
||||
listBox.ItemHeight = 20;
|
||||
listBox.Location = new Point(0, 21);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(238, 104);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 1);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(130, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Список значений";
|
||||
//
|
||||
// ValuesList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(listBox);
|
||||
Name = "ValuesList";
|
||||
Size = new Size(238, 125);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
139
COP_1/cop_1/ValuesList.cs
Normal file
139
COP_1/cop_1/ValuesList.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace COP_1
|
||||
{
|
||||
public partial class ValuesList : UserControl
|
||||
{
|
||||
private string template;
|
||||
private string start;
|
||||
private string end;
|
||||
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
public ValuesList()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
//Метод для установки информации о макетной строке и символах (стартового и конечного)
|
||||
public void SetLayoutInfo(string layout, string startS, string endS)
|
||||
{
|
||||
if (layout == null || startS == null || endS == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
template = layout;
|
||||
start = startS;
|
||||
end = endS;
|
||||
}
|
||||
|
||||
//св-во для получения и заполнения индекса выбранного элемента
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
//Публичный параметризованный метод для получения объекта из выбранной строки(создать объект и через рефлексию заполнить свойства его).
|
||||
public T GetObjectFromStr<T>() where T : class, new()
|
||||
{
|
||||
if (listBox.SelectedIndex < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string initString = listBox.SelectedItem.ToString();//изначальная строка, получаемая из листбокса
|
||||
T curObject = new T();
|
||||
|
||||
string[] tempWords = template.Split(new[] { char.Parse(start), char.Parse(end) }, StringSplitOptions.RemoveEmptyEntries);//все слова в шаблонной строке
|
||||
|
||||
StringBuilder valuesString = new StringBuilder(initString);//воспользуемся stringbuilder, т.к. будем проводить операции со строкой
|
||||
|
||||
List <string> replaceablePatterns = new(); //заменяемые слова шаблона(title, performer, genre, year)
|
||||
|
||||
foreach (var word in tempWords)
|
||||
{
|
||||
if (initString.Contains(word))
|
||||
{
|
||||
// Удаляем первое слово, остальные заменяем на символ конца
|
||||
if (valuesString.ToString().StartsWith(word))
|
||||
{
|
||||
valuesString.Replace(word, string.Empty); // Удаляем первое слово
|
||||
}
|
||||
else
|
||||
{
|
||||
valuesString.Replace(word, end.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceablePatterns.Add(word);
|
||||
}
|
||||
}
|
||||
|
||||
string[] values = valuesString.ToString().Split(new[] { end }, StringSplitOptions.RemoveEmptyEntries);
|
||||
StringBuilder result = new StringBuilder(template);
|
||||
for (int j = 0; j < replaceablePatterns.Count; j++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(replaceablePatterns[j]))
|
||||
{
|
||||
result.Replace(replaceablePatterns[j], values[j]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var property in typeof(T).GetProperties())
|
||||
{
|
||||
if (!property.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int startBorder = result.ToString().IndexOf(start);
|
||||
int endBorder = result.ToString().IndexOf(end, startBorder + 1);
|
||||
if (startBorder == -1 || endBorder == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
string propertyValue = result.ToString(startBorder + 1, endBorder - startBorder - 1); //с какого символа и сколько смволов вперед
|
||||
result.Remove(0, endBorder + 1);
|
||||
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||
}
|
||||
return curObject;
|
||||
}
|
||||
|
||||
public void AddInListBox<T>(T dataObject, int rowIndex)
|
||||
{
|
||||
while (listBox.Items.Count <= rowIndex)
|
||||
{
|
||||
listBox.Items.Add(template);
|
||||
}
|
||||
|
||||
string row = listBox.Items[rowIndex].ToString();
|
||||
PropertyInfo[] properties = dataObject.GetType().GetProperties();
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
if (property != null)
|
||||
{
|
||||
var propertyValue = property.GetValue(dataObject);
|
||||
row = row.Replace($"{start}{property.Name}{end}", propertyValue.ToString());
|
||||
listBox.Items[rowIndex] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1/cop_1/ValuesList.resx
Normal file
120
COP_1/cop_1/ValuesList.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
72
COP_1/cop_1/emailBox.Designer.cs
generated
Normal file
72
COP_1/cop_1/emailBox.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
namespace COP_1
|
||||
{
|
||||
partial class emailBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
textBox = new TextBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Dock = DockStyle.Bottom;
|
||||
textBox.Location = new Point(0, 23);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(225, 27);
|
||||
textBox.TabIndex = 2;
|
||||
textBox.TextChanged += textBox_TextChanged;
|
||||
textBox.Enter += textBox_Enter;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Dock = DockStyle.Bottom;
|
||||
label1.Location = new Point(0, 3);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(168, 20);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Ввод и проверка email";
|
||||
//
|
||||
// emailBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBox);
|
||||
Name = "emailBox";
|
||||
Size = new Size(225, 50);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
120
COP_1/cop_1/emailBox.resx
Normal file
120
COP_1/cop_1/emailBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
36
COP_1/cop_2/WordBigText.Designer.cs
generated
Normal file
36
COP_1/cop_2/WordBigText.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
partial class WordBigText
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
127
COP_1/cop_2/WordBigText.cs
Normal file
127
COP_1/cop_2/WordBigText.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
using System.ComponentModel;
|
||||
using COP_1.cop_2.helpers;
|
||||
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
public partial class WordBigText : Component
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
|
||||
public WordBigText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordBigText(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateWordText(WordBigTextInfo largeText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.Title) || !CheckData(largeText.Paragraphs))
|
||||
{
|
||||
throw new Exception("Не все данные заполнены");
|
||||
}
|
||||
_wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document);
|
||||
|
||||
//вытаскиваем главную часть из вордовского документа
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
|
||||
mainPart.Document = new Document();
|
||||
|
||||
//генерируем тело основной части документа
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
||||
_wordDocument.Dispose();
|
||||
|
||||
AddText(largeText);
|
||||
}
|
||||
|
||||
private void AddText(WordBigTextInfo largeText)
|
||||
{
|
||||
using (var document = WordprocessingDocument.Open(largeText.FilePath, true))
|
||||
{
|
||||
var doc = document.MainDocumentPart.Document;
|
||||
//Создание заголовка
|
||||
|
||||
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.Title));
|
||||
|
||||
header.AppendChild(docRun);
|
||||
doc.Body.Append(header);
|
||||
|
||||
//Создание текста
|
||||
|
||||
for (int i = 0; i < largeText.Paragraphs.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.Paragraphs[i]));
|
||||
|
||||
text.AppendChild(docRun2);
|
||||
doc.Body.Append(text);
|
||||
}
|
||||
doc.Save();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckData(string[] data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
36
COP_1/cop_2/WordDiagram.Designer.cs
generated
Normal file
36
COP_1/cop_2/WordDiagram.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
partial class WordDiagram
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
107
COP_1/cop_2/WordDiagram.cs
Normal file
107
COP_1/cop_2/WordDiagram.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using COP_1.cop_2.helpers;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
public partial class WordDiagram : Component
|
||||
{
|
||||
public WordDiagram()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDiagram(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
string[] cats;
|
||||
string[] doubs;
|
||||
|
||||
public void AddDiagram(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 = "Correction Tape";
|
||||
|
||||
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();
|
||||
string[] cats;
|
||||
double[] doubs;
|
||||
|
||||
foreach (var data in simpleLineChart.DataList)
|
||||
{
|
||||
cats = new string[simpleLineChart.DataList.Count];
|
||||
doubs = new double[simpleLineChart.DataList.Count];
|
||||
int i = 0;
|
||||
foreach(var (name, value) in data.LineData)
|
||||
{
|
||||
cats[i] = name;
|
||||
doubs[i] = value;
|
||||
i++;
|
||||
}
|
||||
|
||||
//var (name, values) = data.LineData;
|
||||
seriesColl.Add(data.LineName, cats, doubs);
|
||||
}
|
||||
|
||||
ChartLegend legend = chart.Legend;
|
||||
|
||||
legend.Position = (LegendPosition)simpleLineChart.AreaLegend;
|
||||
|
||||
legend.Overlay = true;
|
||||
|
||||
doc.Save(simpleLineChart.FilePath);
|
||||
}
|
||||
static bool CheckData(List<DataLineChart> data)
|
||||
{
|
||||
string[] cats = new string[data.Count];
|
||||
double[] doubs = new double[data.Count];
|
||||
|
||||
foreach (var _data in data)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var (name, value) in _data.LineData)
|
||||
{
|
||||
cats[i] = name;
|
||||
doubs[i] = value;
|
||||
i++;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_data.LineName) || cats.Length == 0 || doubs.Length == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
36
COP_1/cop_2/WordTable.Designer.cs
generated
Normal file
36
COP_1/cop_2/WordTable.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
115
COP_1/cop_2/WordTable.cs
Normal file
115
COP_1/cop_2/WordTable.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Tables;
|
||||
using COP_1.cop_2.helpers;
|
||||
|
||||
namespace COP_1.cop_2
|
||||
{
|
||||
public partial class WordTable : Component
|
||||
{
|
||||
public WordTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable<T>(WordTableInfo<T> tableWord) where T : class
|
||||
{
|
||||
// Проверка наличия данных и определений столбцов
|
||||
if (tableWord.Items == null || tableWord.Items.Count == 0 || tableWord.ColumnParameters == null || tableWord.ColumnParameters.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("Data or column definitions are null or empty");
|
||||
}
|
||||
|
||||
// Проверка, что все ячейки шапки заполнены и для каждого столбца определено свойство/поле класса
|
||||
foreach (var columnDefinition in tableWord.ColumnParameters)
|
||||
{
|
||||
if (string.IsNullOrEmpty(columnDefinition.PropertyName))
|
||||
{
|
||||
throw new ArgumentException($"Incomplete column definition: {columnDefinition.FirstRowHeader}");
|
||||
}
|
||||
}
|
||||
|
||||
// Создание документа
|
||||
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(tableWord.Title);
|
||||
|
||||
// Создание таблицы
|
||||
Table table = builder.StartTable();
|
||||
|
||||
// Создание первой строки (заголовок)
|
||||
foreach (var columnDefinition in tableWord.ColumnParameters)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Width);
|
||||
builder.Write(columnDefinition.FirstRowHeader);
|
||||
}
|
||||
// Создание второй строки (вторые заголовки)
|
||||
builder.EndRow(); // Завершение первой строки заголовка
|
||||
foreach (var columnDefinition in tableWord.ColumnParameters)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Width);
|
||||
builder.Write(columnDefinition.SecondRowHeader);
|
||||
}
|
||||
builder.EndRow();
|
||||
|
||||
int startCellIndex = -1;
|
||||
int endCellIndex = -1;
|
||||
// Объединение ячеек в первой строке шапки таблицы (если необходимо)
|
||||
foreach (var mergedColumn in tableWord.MergedColumns)
|
||||
{
|
||||
startCellIndex = mergedColumn[0];
|
||||
endCellIndex = mergedColumn[^1];
|
||||
|
||||
for (int i = startCellIndex; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = i == startCellIndex ? CellMerge.First : CellMerge.Previous;
|
||||
}
|
||||
}
|
||||
|
||||
// Установка вертикального объединения заголовков
|
||||
for (int columnIndex = 0; columnIndex < tableWord.ColumnParameters.Count; columnIndex++)
|
||||
{
|
||||
if (startCellIndex == columnIndex || endCellIndex == columnIndex)
|
||||
continue;
|
||||
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
|
||||
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
|
||||
}
|
||||
|
||||
// Вставка данных в таблицу
|
||||
foreach (var item in tableWord.Items)
|
||||
{
|
||||
foreach (var columnDefinition in tableWord.ColumnParameters)
|
||||
{
|
||||
builder.InsertCell();
|
||||
// Получение значения свойства/поля объекта по заданному имени
|
||||
var propertyValue = item.GetType().GetProperty(columnDefinition.PropertyName)?.GetValue(item)?.ToString();
|
||||
builder.Write(propertyValue ?? string.Empty);
|
||||
}
|
||||
builder.EndRow();
|
||||
}
|
||||
|
||||
builder.EndTable();
|
||||
|
||||
// Сохранение документа в файл
|
||||
document.Save(tableWord.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
11
COP_1/cop_2/helpers/ColumnParams.cs
Normal file
11
COP_1/cop_2/helpers/ColumnParams.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace COP_1.cop_2.helpers
|
||||
{
|
||||
public class ColumnParams
|
||||
{
|
||||
public string FirstRowHeader { get; set; } = string.Empty;
|
||||
public string SecondRowHeader { get; set; } = string.Empty;
|
||||
public string PropertyName { get; set; } = string.Empty;
|
||||
public double Width { get; set; }
|
||||
}
|
||||
}
|
||||
|
15
COP_1/cop_2/helpers/DataLineChart.cs
Normal file
15
COP_1/cop_2/helpers/DataLineChart.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace COP_1.cop_2.helpers
|
||||
{
|
||||
public class DataLineChart
|
||||
{
|
||||
public string LineName { get; set; } = string.Empty;
|
||||
|
||||
public (string, double)[] LineData { get; set; }
|
||||
|
||||
public DataLineChart(string nameSeries, (string, double)[] lineData)
|
||||
{
|
||||
LineName = nameSeries;
|
||||
LineData = lineData;
|
||||
}
|
||||
}
|
||||
}
|
26
COP_1/cop_2/helpers/SimpleLineChart.cs
Normal file
26
COP_1/cop_2/helpers/SimpleLineChart.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using COP_1.cop_2.helpers.enums;
|
||||
|
||||
namespace COP_1.cop_2.helpers
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
16
COP_1/cop_2/helpers/WordBigTextInfo.cs
Normal file
16
COP_1/cop_2/helpers/WordBigTextInfo.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace COP_1.cop_2.helpers
|
||||
{
|
||||
public class WordBigTextInfo
|
||||
{
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string[] Paragraphs { get; set; } = Array.Empty<string>();
|
||||
|
||||
public WordBigTextInfo(string filePath, string title, string[] paragraphs)
|
||||
{
|
||||
FilePath = filePath;
|
||||
Title = title;
|
||||
Paragraphs = paragraphs;
|
||||
}
|
||||
}
|
||||
}
|
24
COP_1/cop_2/helpers/WordTableInfo.cs
Normal file
24
COP_1/cop_2/helpers/WordTableInfo.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace COP_1.cop_2.helpers
|
||||
{
|
||||
public class WordTableInfo<T>
|
||||
{
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ColumnParams> ColumnParameters { get; set; } = new();
|
||||
|
||||
public List<T> Items { get; set; } = new();
|
||||
|
||||
public List<int[]> MergedColumns { get; set; } = new();
|
||||
|
||||
public WordTableInfo(string filePath, string title, List<ColumnParams> columnParameters, List<T> data, List<int[]> mergedColumns)
|
||||
{
|
||||
FilePath = filePath;
|
||||
Title = title;
|
||||
ColumnParameters = columnParameters;
|
||||
Items = data;
|
||||
MergedColumns = mergedColumns;
|
||||
}
|
||||
}
|
||||
}
|
17
COP_1/cop_2/helpers/enums/EnumAreaLegend.cs
Normal file
17
COP_1/cop_2/helpers/enums/EnumAreaLegend.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace COP_1.cop_2.helpers.enums
|
||||
{
|
||||
public enum EnumAreaLegend
|
||||
{
|
||||
None,
|
||||
|
||||
Left,
|
||||
|
||||
Top,
|
||||
|
||||
Right,
|
||||
|
||||
Bottom,
|
||||
|
||||
TopRight
|
||||
}
|
||||
}
|
15
COP_1Test/COP_1Test.csproj
Normal file
15
COP_1Test/COP_1Test.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COP_1\COP_1.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
167
COP_1Test/Form1.Designer.cs
generated
Normal file
167
COP_1Test/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
||||
namespace COP_1Test
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dropDownList = new COP_1.DropDownList();
|
||||
valuesList = new COP_1.ValuesList();
|
||||
emailBox = new COP_1.emailBox();
|
||||
buttonCheck = new Button();
|
||||
label1 = new Label();
|
||||
buttonGet = new Button();
|
||||
textBoxShowItem = new TextBox();
|
||||
buttonGetDown = new Button();
|
||||
textBoxResult = new TextBox();
|
||||
buttonClear = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
dropDownList.Location = new Point(12, 12);
|
||||
dropDownList.Name = "dropDownList";
|
||||
dropDownList.Selected = "";
|
||||
dropDownList.Size = new Size(281, 49);
|
||||
dropDownList.TabIndex = 0;
|
||||
//
|
||||
// valuesList
|
||||
//
|
||||
valuesList.Location = new Point(374, 12);
|
||||
valuesList.Name = "valuesList";
|
||||
valuesList.SelectedIndex = -1;
|
||||
valuesList.Size = new Size(298, 125);
|
||||
valuesList.TabIndex = 1;
|
||||
//
|
||||
// emailBox
|
||||
//
|
||||
emailBox.Location = new Point(12, 178);
|
||||
emailBox.Name = "emailBox";
|
||||
emailBox.Pattern = null;
|
||||
emailBox.Size = new Size(281, 62);
|
||||
emailBox.TabIndex = 2;
|
||||
//
|
||||
// buttonCheck
|
||||
//
|
||||
buttonCheck.Location = new Point(12, 246);
|
||||
buttonCheck.Name = "buttonCheck";
|
||||
buttonCheck.Size = new Size(281, 29);
|
||||
buttonCheck.TabIndex = 3;
|
||||
buttonCheck.Text = "Проверить";
|
||||
buttonCheck.UseVisualStyleBackColor = true;
|
||||
buttonCheck.Click += buttonCheck_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Segoe UI Black", 12F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
label1.ForeColor = Color.Chartreuse;
|
||||
label1.Location = new Point(295, 210);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(69, 28);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "label1";
|
||||
label1.Visible = false;
|
||||
//
|
||||
// buttonGet
|
||||
//
|
||||
buttonGet.Location = new Point(374, 143);
|
||||
buttonGet.Name = "buttonGet";
|
||||
buttonGet.Size = new Size(298, 29);
|
||||
buttonGet.TabIndex = 5;
|
||||
buttonGet.Text = "Получить значение";
|
||||
buttonGet.UseVisualStyleBackColor = true;
|
||||
buttonGet.Click += buttonGet_Click;
|
||||
//
|
||||
// textBoxShowItem
|
||||
//
|
||||
textBoxShowItem.Location = new Point(374, 180);
|
||||
textBoxShowItem.Name = "textBoxShowItem";
|
||||
textBoxShowItem.Size = new Size(297, 27);
|
||||
textBoxShowItem.TabIndex = 6;
|
||||
//
|
||||
// buttonGetDown
|
||||
//
|
||||
buttonGetDown.Location = new Point(12, 64);
|
||||
buttonGetDown.Name = "buttonGetDown";
|
||||
buttonGetDown.Size = new Size(139, 51);
|
||||
buttonGetDown.TabIndex = 7;
|
||||
buttonGetDown.Text = "Получить значение";
|
||||
buttonGetDown.UseVisualStyleBackColor = true;
|
||||
buttonGetDown.Click += buttonGetDown_Click;
|
||||
//
|
||||
// textBoxResult
|
||||
//
|
||||
textBoxResult.Location = new Point(12, 121);
|
||||
textBoxResult.Name = "textBoxResult";
|
||||
textBoxResult.Size = new Size(281, 27);
|
||||
textBoxResult.TabIndex = 8;
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(154, 64);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(139, 51);
|
||||
buttonClear.TabIndex = 9;
|
||||
buttonClear.Text = "Очистить";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClear_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(684, 286);
|
||||
Controls.Add(buttonClear);
|
||||
Controls.Add(textBoxResult);
|
||||
Controls.Add(buttonGetDown);
|
||||
Controls.Add(textBoxShowItem);
|
||||
Controls.Add(buttonGet);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCheck);
|
||||
Controls.Add(emailBox);
|
||||
Controls.Add(valuesList);
|
||||
Controls.Add(dropDownList);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private COP_1.DropDownList dropDownList;
|
||||
private COP_1.ValuesList valuesList;
|
||||
private COP_1.emailBox emailBox;
|
||||
private Button buttonCheck;
|
||||
private Label label1;
|
||||
private Button buttonGet;
|
||||
private TextBox textBoxShowItem;
|
||||
private Button buttonGetDown;
|
||||
private TextBox textBoxResult;
|
||||
private Button buttonClear;
|
||||
}
|
||||
}
|
88
COP_1Test/Form1.cs
Normal file
88
COP_1Test/Form1.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using COP_1;
|
||||
using System;
|
||||
|
||||
namespace COP_1Test
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.BackColor = GetRandomPastelColor();
|
||||
list = new List<string>();
|
||||
list.AddRange(new string[] { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5", "Çíà÷åíèå 6" });
|
||||
|
||||
Album album1 = new Album("Meds", "Placebo", "Alternative", "2006");
|
||||
Album album2 = new Album("Iowa", "Slipknot", "Nu-Metal", "2001");
|
||||
Album album3 = new Album("Showbiz", "Muse", "Alternative", "1999");
|
||||
Album album4 = new Album("Chocolate Starfish and the Hot Dog Flavored Water", "Limp Bizkit", "Nu-metal", "2011");
|
||||
|
||||
valuesList.SetLayoutInfo("Íàçâàíèå: {Title} Èñïîëíèòåëü: {Performer} Æàíð: {Genre} Ãîä: {Year}", "{", "}");
|
||||
valuesList.AddInListBox(album1, 0);
|
||||
valuesList.AddInListBox(album2, 1);
|
||||
valuesList.AddInListBox(album3, 2);
|
||||
valuesList.AddInListBox(album4, 3);
|
||||
|
||||
emailBox.Pattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";
|
||||
|
||||
dropDownList.AddingToList(new List<string>() { "Placebo", "Slipknot", "Blue October", "The Used", "Muse", "The Cure" });
|
||||
dropDownList.ExplicitEvent += Event_Handler;
|
||||
|
||||
emailBox.ExplicitEvent += Event_Handler;
|
||||
emailBox.SetExample("eeee@mail.ru");
|
||||
}
|
||||
private Color GetRandomPastelColor()
|
||||
{
|
||||
Random random = new Random();
|
||||
int red = random.Next(128, 256);
|
||||
int green = random.Next(128, 256);
|
||||
int blue = random.Next(128, 256);
|
||||
|
||||
return Color.FromArgb(red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
private void Event_Handler(object sender, EventArgs e)
|
||||
{
|
||||
this.BackColor = GetRandomPastelColor();
|
||||
}
|
||||
|
||||
|
||||
private void buttonGet_Click(object sender, EventArgs e)
|
||||
{
|
||||
string str = valuesList.GetObjectFromStr<Album>().Title + " " + valuesList.GetObjectFromStr<Album>().Performer + " " + valuesList.GetObjectFromStr<Album>().Genre + " " + valuesList.GetObjectFromStr<Album>().Year;
|
||||
textBoxShowItem.Text = str;
|
||||
}
|
||||
private void buttonCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (emailBox.TextBoxValue != null)
|
||||
{
|
||||
label1.Visible = true;
|
||||
label1.Text = "true";
|
||||
label1.ForeColor = Color.Green;
|
||||
}
|
||||
else
|
||||
{
|
||||
label1.Visible = true;
|
||||
label1.Text = "false";
|
||||
label1.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList.Clear();
|
||||
}
|
||||
private void buttonGetDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxResult.Text = dropDownList.Selected;
|
||||
}
|
||||
}
|
||||
}
|
120
COP_1Test/Form1.resx
Normal file
120
COP_1Test/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
141
COP_1Test/Form2.Designer.cs
generated
Normal file
141
COP_1Test/Form2.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
||||
namespace COP_1Test
|
||||
{
|
||||
partial class Form2
|
||||
{
|
||||
/// <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();
|
||||
groupBox2 = new GroupBox();
|
||||
button2 = new Button();
|
||||
groupBox3 = new GroupBox();
|
||||
button3 = new Button();
|
||||
groupBox1 = new GroupBox();
|
||||
button1 = new Button();
|
||||
wordText = new COP_1.cop_2.WordBigText(components);
|
||||
wordDiagram = new COP_1.cop_2.WordDiagram(components);
|
||||
wordTable = new COP_1.cop_2.WordTable(components);
|
||||
groupBox2.SuspendLayout();
|
||||
groupBox3.SuspendLayout();
|
||||
groupBox1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(button2);
|
||||
groupBox2.Dock = DockStyle.Top;
|
||||
groupBox2.Location = new Point(0, 154);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(294, 80);
|
||||
groupBox2.TabIndex = 4;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Таблица";
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Dock = DockStyle.Fill;
|
||||
button2.Location = new Point(3, 23);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(288, 54);
|
||||
button2.TabIndex = 0;
|
||||
button2.Text = "Создать";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += buttonTable_Click;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
groupBox3.Controls.Add(button3);
|
||||
groupBox3.Dock = DockStyle.Top;
|
||||
groupBox3.Location = new Point(0, 80);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Size = new Size(294, 74);
|
||||
groupBox3.TabIndex = 3;
|
||||
groupBox3.TabStop = false;
|
||||
groupBox3.Text = "Линейная диаграмма";
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Dock = DockStyle.Fill;
|
||||
button3.Location = new Point(3, 23);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(288, 48);
|
||||
button3.TabIndex = 0;
|
||||
button3.Text = "Создать";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += buttonDiagram_Click;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(button1);
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(0, 0);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(294, 80);
|
||||
groupBox1.TabIndex = 2;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Большой текст";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Dock = DockStyle.Fill;
|
||||
button1.Location = new Point(3, 23);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(288, 54);
|
||||
button1.TabIndex = 0;
|
||||
button1.Text = "Создать";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += buttonBigText_Click;
|
||||
//
|
||||
// Form2
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(294, 239);
|
||||
Controls.Add(groupBox2);
|
||||
Controls.Add(groupBox3);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "Form2";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "COP_2";
|
||||
groupBox2.ResumeLayout(false);
|
||||
groupBox3.ResumeLayout(false);
|
||||
groupBox1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBox2;
|
||||
private Button button2;
|
||||
private GroupBox groupBox3;
|
||||
private Button button3;
|
||||
private GroupBox groupBox1;
|
||||
private Button button1;
|
||||
private COP_1.cop_2.WordBigText wordText;
|
||||
private COP_1.cop_2.WordDiagram wordDiagram;
|
||||
private COP_1.cop_2.WordTable wordTable;
|
||||
}
|
||||
}
|
133
COP_1Test/Form2.cs
Normal file
133
COP_1Test/Form2.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using COP_1.cop_2.helpers.enums;
|
||||
using COP_1.cop_2.helpers;
|
||||
using COP_1.cop_2;
|
||||
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;
|
||||
using COP_1;
|
||||
|
||||
namespace COP_1Test
|
||||
{
|
||||
public partial class Form2 : Form
|
||||
{
|
||||
string[] testArray = { "«Да, здесь, в этом лесу был этот дуб, с которым мы были согласны», подумал князь Андрей. " +
|
||||
"«Да где он», подумал опять князь Андрей, глядя на левую сторону дороги и сам того не зная, не узнавая его, любовался тем дубом, которого он искал. " +
|
||||
"Старый дуб, весь преображенный, раскинувшись шатром сочной, темной зелени, млел, чуть колыхаясь в лучах вечернего солнца. Ни корявых пальцев, ни болячек, " +
|
||||
"ни старого недоверия и горя, – ничего не было видно. Сквозь жесткую, столетнюю кору пробились без сучков сочные, молодые листья, так что верить нельзя было, что " +
|
||||
"этот старик произвел их. «Да, это тот самый дуб», подумал князь Андрей, и на него вдруг нашло беспричинное, весеннее чувство радости и обновления. " +
|
||||
"Все лучшие минуты его жизни вдруг в одно и то же время вспомнились ему. И Аустерлиц с высоким небом, и мертвое, укоризненное лицо жены, и Пьер на пароме, " +
|
||||
"и девочка, взволнованная красотою ночи, и эта ночь, и луна, – и все это вдруг вспомнилось ему." + Environment.NewLine,
|
||||
"«Нет, жизнь не кончена в 31 год, вдруг окончательно, беспеременно " +
|
||||
"решил князь Андрей. Мало того, что я знаю все то, что есть во мне, надо, чтобы и все знали это: и Пьер, и эта девочка, которая хотела улететь в небо, надо, чтобы " +
|
||||
"все знали меня, чтобы не для одного меня шла моя жизнь, чтоб не жили они так независимо от моей жизни, чтоб на всех она отражалась и чтобы все они жили со мною вместе!»"};
|
||||
public Form2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonBigText_Click(object sender, EventArgs e)
|
||||
{
|
||||
//фильтрация файлов для диалогового окна
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
WordBigTextInfo largeText = new(dialog.FileName, "Встреча Болконского с дубом pt.2", testArray);
|
||||
wordText.CreateWordText(largeText);
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<int[]> mergedColumns = new()
|
||||
{
|
||||
new int[] { 2, 3 }
|
||||
};
|
||||
|
||||
var columns = new List<ColumnParams>
|
||||
{
|
||||
new() { FirstRowHeader = "Название", SecondRowHeader = "", PropertyName = "Title", Width = 1.3 },
|
||||
new() { FirstRowHeader = "Исполнитель", SecondRowHeader = "",PropertyName = "Performer", Width = 1.3 },
|
||||
new() { FirstRowHeader = "Общая информация", SecondRowHeader = "Жанр", PropertyName = "Genre", Width = 1.3 },
|
||||
new() { FirstRowHeader = "Общая информация", SecondRowHeader = "Год", PropertyName = "Year", Width = 1.3 },
|
||||
};
|
||||
|
||||
var albums = new List<Album>
|
||||
{
|
||||
new() {Title = "Battle For The Sun", Performer = "Placebo", Genre = "Alternative", Year = "2009"},
|
||||
new() {Title = "The Bastards", Performer = "Palaye Royale", Genre = "Glam Rock", Year = "2020"},
|
||||
new() {Title = "All Hope Is Gone", Performer = "Slipknot", Genre = "Nu-Metal", Year = "2008"},
|
||||
new() {Title = "Three Imaginary Boys", Performer = "The Cure", Genre = "Gothic Rock", Year = "1979"},
|
||||
new() {Title = "Black Holes and Revelations", Performer = "Muse", Genre = "Alternative", Year = "2006" }
|
||||
};
|
||||
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
WordTableInfo<Album> info = new(dialog.FileName, "Задание 2", columns, albums, mergedColumns);
|
||||
wordTable.CreateTable(info);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
//фильтрация файлов для диалогового окна
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] cathegories = { "Январь", "Февраль", "Март", "April", "May" };
|
||||
(string, double)[] alb1 = { ("January", 600), ("February", 500), ("March", 300) };
|
||||
(string, double)[] alb2 = { ("January", 300), ("February", 500), ("March", 700) };
|
||||
(string, double)[] alb3 = { ("January", 200), ("February", 300), ("March", 100) };
|
||||
|
||||
SimpleLineChart diagram = new(dialog.FileName, "Третье задание", "График популярности альбомов", EnumAreaLegend.Right, new List<DataLineChart> {
|
||||
new DataLineChart("Meds", alb1), new DataLineChart("Iowa", alb2), new DataLineChart("Regional At Best", alb3),
|
||||
});
|
||||
|
||||
wordDiagram.AddDiagram(diagram);
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
COP_1Test/Form2.resx
Normal file
129
COP_1Test/Form2.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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>
|
||||
<metadata name="wordText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>280, 17</value>
|
||||
</metadata>
|
||||
</root>
|
17
COP_1Test/Program.cs
Normal file
17
COP_1Test/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace COP_1Test
|
||||
{
|
||||
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 Form2());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user