Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3ab2a9278 | |||
| 04ec89337f | |||
| e1a78b2ddf | |||
| da2da98d11 |
31
Components/Components.sln
Normal file
31
Components/Components.sln
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35219.272
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "Components\Components.csproj", "{2CCE7E87-C678-473B-A49E-12D715DC1882}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "..\Test\Test.csproj", "{F498BD7C-5822-4357-B434-BC4756C46295}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{2CCE7E87-C678-473B-A49E-12D715DC1882}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2CCE7E87-C678-473B-A49E-12D715DC1882}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2CCE7E87-C678-473B-A49E-12D715DC1882}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2CCE7E87-C678-473B-A49E-12D715DC1882}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F498BD7C-5822-4357-B434-BC4756C46295}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F498BD7C-5822-4357-B434-BC4756C46295}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F498BD7C-5822-4357-B434-BC4756C46295}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F498BD7C-5822-4357-B434-BC4756C46295}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {DF71D288-1405-4811-A1C1-AB7A96E8AABA}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
14
Components/Components/Components.csproj
Normal file
14
Components/Components/Components.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
56
Components/Components/CustomComboBox.Designer.cs
generated
Normal file
56
Components/Components/CustomComboBox.Designer.cs
generated
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomComboBox
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
comboBox = new ComboBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBox
|
||||||
|
//
|
||||||
|
comboBox.FormattingEnabled = true;
|
||||||
|
comboBox.Location = new Point(22, 13);
|
||||||
|
comboBox.Name = "comboBox";
|
||||||
|
comboBox.Size = new Size(340, 23);
|
||||||
|
comboBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// CustomComboBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(comboBox);
|
||||||
|
Name = "CustomComboBox";
|
||||||
|
Size = new Size(399, 68);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
92
Components/Components/CustomComboBox.cs
Normal file
92
Components/Components/CustomComboBox.cs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
public partial class CustomComboBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomComboBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Очищение списка
|
||||||
|
/// </summary>
|
||||||
|
public void ComboBoxClear()
|
||||||
|
{
|
||||||
|
comboBox.Items.Clear();
|
||||||
|
comboBox.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выбранный элемент
|
||||||
|
/// </summary>
|
||||||
|
public string SelectedItem
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (comboBox.Items.Count == 0)
|
||||||
|
{
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
if (comboBox.SelectedItem == null)
|
||||||
|
{
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
return comboBox.SelectedItem.ToString()!;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (comboBox.Items.Contains(value))
|
||||||
|
{
|
||||||
|
comboBox.SelectedItem = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Публичное свойство
|
||||||
|
/// </summary>
|
||||||
|
public ComboBox.ObjectCollection ComboBoxItems
|
||||||
|
{
|
||||||
|
get { return comboBox.Items; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие, вызываемое при смене значения
|
||||||
|
/// </summary>
|
||||||
|
private EventHandler _onValueChangedEvent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие, вызываемое при смене значения
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler ValueChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
_onValueChangedEvent += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
_onValueChangedEvent -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Смена значения
|
||||||
|
/// </summary>
|
||||||
|
private void CustomComboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_onValueChangedEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Components/Components/CustomComboBox.resx
Normal file
120
Components/Components/CustomComboBox.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>
|
||||||
57
Components/Components/CustomListBox.Designer.cs
generated
Normal file
57
Components/Components/CustomListBox.Designer.cs
generated
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomListBox
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
listBox = new ListBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// listBox
|
||||||
|
//
|
||||||
|
listBox.FormattingEnabled = true;
|
||||||
|
listBox.ItemHeight = 15;
|
||||||
|
listBox.Location = new Point(21, 20);
|
||||||
|
listBox.Name = "listBox";
|
||||||
|
listBox.Size = new Size(296, 154);
|
||||||
|
listBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// CustomListBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(listBox);
|
||||||
|
Name = "CustomListBox";
|
||||||
|
Size = new Size(341, 201);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ListBox listBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
127
Components/Components/CustomListBox.cs
Normal file
127
Components/Components/CustomListBox.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
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 Components
|
||||||
|
{
|
||||||
|
public partial class CustomListBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomListBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Макет
|
||||||
|
/// </summary>
|
||||||
|
private string _templateString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Символ начала
|
||||||
|
/// </summary>
|
||||||
|
private string _startSymbol;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Символ конца
|
||||||
|
/// </summary>
|
||||||
|
private string _endSymbol;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Шаблон строки
|
||||||
|
/// </summary>
|
||||||
|
public void SetTemplateString(string templateString, string startSymbol, string endSymbol)
|
||||||
|
{
|
||||||
|
if (templateString != "" && startSymbol != "" && endSymbol != "")
|
||||||
|
{
|
||||||
|
_templateString = templateString;
|
||||||
|
_startSymbol = startSymbol;
|
||||||
|
_endSymbol = endSymbol;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Вы не ввели все значения");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выбранная строка
|
||||||
|
/// </summary>
|
||||||
|
public int SelectedIndex
|
||||||
|
{
|
||||||
|
get { return listBox.SelectedIndex; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (listBox.SelectedIndex != 0)
|
||||||
|
{
|
||||||
|
listBox.SelectedIndex = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение обхекта
|
||||||
|
/// </summary>
|
||||||
|
public T GetObjectFromStr<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
if (listBox.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
string row = listBox.SelectedItem.ToString();
|
||||||
|
T curObject = new T();
|
||||||
|
StringBuilder sb = new StringBuilder(row);
|
||||||
|
foreach (var property in typeof(T).GetProperties())
|
||||||
|
{
|
||||||
|
if (!property.CanWrite)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int borderOne = sb.ToString().IndexOf(_startSymbol);
|
||||||
|
if (borderOne == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int borderTwo = sb.ToString().IndexOf(_endSymbol, borderOne + 1);
|
||||||
|
if (borderTwo == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string propertyValue = sb.ToString(borderOne + 1, borderTwo - borderOne - 1);
|
||||||
|
sb.Remove(0, borderTwo + 1);
|
||||||
|
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||||
|
}
|
||||||
|
return curObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Заполнение
|
||||||
|
/// </summary>
|
||||||
|
public void FillProperty<T>(T dataObject, int rowIndex, string propertyName)
|
||||||
|
{
|
||||||
|
|
||||||
|
while (listBox.Items.Count <= rowIndex)
|
||||||
|
{
|
||||||
|
listBox.Items.Add(_templateString);
|
||||||
|
}
|
||||||
|
|
||||||
|
string row = listBox.Items[rowIndex].ToString();
|
||||||
|
PropertyInfo propertyInfo = dataObject.GetType().GetProperty(propertyName);
|
||||||
|
|
||||||
|
if (propertyInfo != null)
|
||||||
|
{
|
||||||
|
object propertyValue = propertyInfo.GetValue(dataObject);
|
||||||
|
row = row.Replace($"{_startSymbol}{propertyName}{_endSymbol}", propertyValue.ToString());
|
||||||
|
listBox.Items[rowIndex] = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Components/Components/CustomListBox.resx
Normal file
120
Components/Components/CustomListBox.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>
|
||||||
57
Components/Components/CustomTextBox.Designer.cs
generated
Normal file
57
Components/Components/CustomTextBox.Designer.cs
generated
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomTextBox
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
textBox = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBox
|
||||||
|
//
|
||||||
|
textBox.Location = new Point(18, 17);
|
||||||
|
textBox.Name = "textBox";
|
||||||
|
textBox.Size = new Size(288, 23);
|
||||||
|
textBox.TabIndex = 0;
|
||||||
|
textBox.Click += textBox_Enter;
|
||||||
|
//
|
||||||
|
// CustomTextBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(textBox);
|
||||||
|
Name = "CustomTextBox";
|
||||||
|
Size = new Size(327, 86);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
107
Components/Components/CustomTextBox.cs
Normal file
107
Components/Components/CustomTextBox.cs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
public partial class CustomTextBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomTextBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Шаблон вводимого значения
|
||||||
|
/// </summary>
|
||||||
|
private string? _numberPattern;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Шаблон вводимого значения
|
||||||
|
/// </summary>
|
||||||
|
public string? NumPattern
|
||||||
|
{
|
||||||
|
get { return _numberPattern; }
|
||||||
|
set { _numberPattern = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Введенное значение
|
||||||
|
/// </summary>
|
||||||
|
public string? TextBoxNumber
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (NumPattern == null)
|
||||||
|
{
|
||||||
|
throw new CustomException("Шаблон не заполнен!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Regex regex = new Regex(NumPattern);
|
||||||
|
if (regex.IsMatch(textBox.Text))
|
||||||
|
{
|
||||||
|
return textBox.Text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new CustomException(textBox.Text + " не соответствует шаблону!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Regex regex = new Regex(NumPattern!);
|
||||||
|
if (regex.IsMatch(value))
|
||||||
|
{
|
||||||
|
textBox.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие, вызываемое при смене значения
|
||||||
|
/// </summary>
|
||||||
|
private EventHandler _onValueChangedEvent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие, вызываемое при смене значения
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler ValueChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
_onValueChangedEvent += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
_onValueChangedEvent -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Смена значения
|
||||||
|
/// </summary>
|
||||||
|
private void CustomNumberBox_NumberChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_onValueChangedEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выведение подсказки на экран
|
||||||
|
/// </summary>
|
||||||
|
private void textBox_Enter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int visibleTime = 2000;
|
||||||
|
ToolTip tooltip = new ToolTip();
|
||||||
|
tooltip.Show("+79991144333", textBox, 30, -20, visibleTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Components/Components/CustomTextBox.resx
Normal file
120
Components/Components/CustomTextBox.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
Components/Components/DiagramComponent.Designer.cs
generated
Normal file
36
Components/Components/DiagramComponent.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class DiagramComponent
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
96
Components/Components/DiagramComponent.cs
Normal file
96
Components/Components/DiagramComponent.cs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
using Components.models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using PdfSharp.Charting;
|
||||||
|
using PdfSharp.Drawing;
|
||||||
|
using PdfSharp.Pdf;
|
||||||
|
using PdfSharp;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
public partial class DiagramComponent : Component
|
||||||
|
{
|
||||||
|
public DiagramComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiagramComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
public void CreateLineDiagram(string docPath, string title, string header, Dictionary<string, List<Double>> data, LegendAlign legendAlign = LegendAlign.top)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(docPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите путь до файла!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите заголовок");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(header))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите заголовок для диаграммы");
|
||||||
|
}
|
||||||
|
if (data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Нету данных");
|
||||||
|
}
|
||||||
|
|
||||||
|
Chart chart = new Chart(ChartType.Line);
|
||||||
|
|
||||||
|
chart.Legend.Docking = (DockingType)legendAlign;
|
||||||
|
chart.Legend.LineFormat.Visible = true;
|
||||||
|
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
Series series = chart.SeriesCollection.AddSeries();
|
||||||
|
series.Name = item.Key;
|
||||||
|
double[] vals = new double[item.Value.Count];
|
||||||
|
for (int i = 0; i < item.Value.Count; i++)
|
||||||
|
{
|
||||||
|
vals.SetValue(Convert.ToDouble(item.Value[i]), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
series.Add(vals);
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
chart.YAxis.HasMajorGridlines = true;
|
||||||
|
|
||||||
|
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
|
||||||
|
chart.PlotArea.LineFormat.Width = 1;
|
||||||
|
chart.PlotArea.LineFormat.Visible = true;
|
||||||
|
|
||||||
|
chart.Legend.LineFormat.Visible = true;
|
||||||
|
|
||||||
|
ChartFrame chartFrame = new ChartFrame();
|
||||||
|
chartFrame.Location = new XPoint(50, 70);
|
||||||
|
chartFrame.Size = new XSize(500, 400);
|
||||||
|
chartFrame.Add(chart);
|
||||||
|
|
||||||
|
PdfDocument document = new PdfDocument(docPath);
|
||||||
|
PdfPage page = document.AddPage();
|
||||||
|
page.Size = PageSize.A4;
|
||||||
|
XGraphics gfx = XGraphics.FromPdfPage(page);
|
||||||
|
XFont font = new XFont("Times New Roman", 14);
|
||||||
|
gfx.DrawString(title, font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.TopLeft);
|
||||||
|
gfx.DrawString(header, font, XBrushes.Black, new XRect(20, 40, page.Width, page.Height), XStringFormats.TopCenter);
|
||||||
|
|
||||||
|
chartFrame.Draw(gfx);
|
||||||
|
document.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Components/Components/Exceptions/CustomException.cs
Normal file
14
Components/Components/Exceptions/CustomException.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.Exceptions
|
||||||
|
{
|
||||||
|
public class CustomException : Exception
|
||||||
|
{
|
||||||
|
public CustomException() { }
|
||||||
|
public CustomException(string message) : base(message) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Components/Components/LargeTextComponent.Designer.cs
generated
Normal file
36
Components/Components/LargeTextComponent.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class LargeTextComponent
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
65
Components/Components/LargeTextComponent.cs
Normal file
65
Components/Components/LargeTextComponent.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
public partial class LargeTextComponent : Component
|
||||||
|
{
|
||||||
|
private Document? _document;
|
||||||
|
|
||||||
|
private Section? _section;
|
||||||
|
public LargeTextComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LargeTextComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
public void CreateDocument(string docPath, string title, string[] rows)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(docPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите путь до файла!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите заголовок");
|
||||||
|
}
|
||||||
|
if (rows.Length <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нету данных для сохранения");
|
||||||
|
}
|
||||||
|
|
||||||
|
_document = new Document();
|
||||||
|
var style = _document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
|
||||||
|
_section = _document.AddSection();
|
||||||
|
|
||||||
|
var paragraph = _section.AddParagraph(title);
|
||||||
|
paragraph.Format.SpaceAfter = "0.1cm";
|
||||||
|
paragraph.Format.Font.Bold = true;
|
||||||
|
foreach (var row in rows)
|
||||||
|
{
|
||||||
|
_section.AddParagraph(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
var renderer = new PdfDocumentRenderer(true);
|
||||||
|
renderer.Document = _document;
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(docPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Components/Components/TableComponent.Designer.cs
generated
Normal file
36
Components/Components/TableComponent.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class TableComponent
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
136
Components/Components/TableComponent.cs
Normal file
136
Components/Components/TableComponent.cs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
using Components.models;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
public partial class TableComponent : Component
|
||||||
|
{
|
||||||
|
private Document? _document;
|
||||||
|
|
||||||
|
private Section? _section;
|
||||||
|
public TableComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
public void CreateTable<T>(string docPath, string title, List<MergeCells>? mergeCells, List<ColumnInfo> colInfo, List<T> data) where T : class, new()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(docPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите путь до файла!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите заголовок");
|
||||||
|
}
|
||||||
|
if (colInfo == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Введите все заголовки");
|
||||||
|
}
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нету информации для вывода");
|
||||||
|
}
|
||||||
|
|
||||||
|
_document = new Document();
|
||||||
|
var style = _document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
|
||||||
|
_section = _document.AddSection();
|
||||||
|
|
||||||
|
var paragraph = _section.AddParagraph(title);
|
||||||
|
paragraph.Format.SpaceAfter = "0.3cm";
|
||||||
|
|
||||||
|
var table = _section.AddTable();
|
||||||
|
table.Borders.Visible = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < colInfo.Count; i++)
|
||||||
|
{
|
||||||
|
table.AddColumn(colInfo[i].Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mergeCells != null)
|
||||||
|
{
|
||||||
|
table.AddRow();
|
||||||
|
}
|
||||||
|
var row = table.AddRow();
|
||||||
|
|
||||||
|
for (int i = 0; i < colInfo.Count; i++)
|
||||||
|
{
|
||||||
|
row[i].AddParagraph(colInfo[i].Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> MergeColls = new List<int>();
|
||||||
|
|
||||||
|
if (mergeCells != null)
|
||||||
|
{
|
||||||
|
foreach (var cell in mergeCells)
|
||||||
|
{
|
||||||
|
MergeColls.AddRange(cell.Indexes[1..]);
|
||||||
|
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].MergeRight = cell.Indexes[2..].Length;
|
||||||
|
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].AddParagraph(cell.Header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cellsCount = table.Rows[1].Cells.Count;
|
||||||
|
|
||||||
|
if (MergeColls.Count != 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cellsCount; i++)
|
||||||
|
{
|
||||||
|
var cell = table.Rows[0].Cells[i];
|
||||||
|
if (!MergeColls.Contains(i + 1))
|
||||||
|
{
|
||||||
|
cell.MergeDown = 1;
|
||||||
|
cell.AddParagraph(colInfo[i].Header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowData = 2;
|
||||||
|
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
var properties = item.GetType().GetProperties();
|
||||||
|
if (properties.Count() != cellsCount)
|
||||||
|
{
|
||||||
|
throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < properties.Count(); i++)
|
||||||
|
{
|
||||||
|
var property = properties[i];
|
||||||
|
var propValue = property.GetValue(item);
|
||||||
|
if (propValue == null) throw new Exception("Пустое поле");
|
||||||
|
if (property.Name == colInfo[i].PropertyName)
|
||||||
|
{
|
||||||
|
if (table.Rows.Count <= rowData) table.AddRow();
|
||||||
|
table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()!);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rowData++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var renderer = new PdfDocumentRenderer(true);
|
||||||
|
renderer.Document = _document;
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(docPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Components/Components/docs/cat.jpg
Normal file
BIN
Components/Components/docs/cat.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 255 KiB |
BIN
Components/Components/docs/cat2.jpg
Normal file
BIN
Components/Components/docs/cat2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 117 KiB |
BIN
Components/Components/docs/diagram.pdf
Normal file
BIN
Components/Components/docs/diagram.pdf
Normal file
Binary file not shown.
BIN
Components/Components/docs/table.pdf
Normal file
BIN
Components/Components/docs/table.pdf
Normal file
Binary file not shown.
BIN
Components/Components/docs/text.pdf
Normal file
BIN
Components/Components/docs/text.pdf
Normal file
Binary file not shown.
22
Components/Components/models/ColumnInfo.cs
Normal file
22
Components/Components/models/ColumnInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.models
|
||||||
|
{
|
||||||
|
public class ColumnInfo
|
||||||
|
{
|
||||||
|
public string PropertyName;
|
||||||
|
public string Header;
|
||||||
|
public int Width;
|
||||||
|
|
||||||
|
public ColumnInfo(string propertyName, string header, int width)
|
||||||
|
{
|
||||||
|
PropertyName = propertyName;
|
||||||
|
Header = header;
|
||||||
|
Width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Components/Components/models/LegendAlign.cs
Normal file
16
Components/Components/models/LegendAlign.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.models
|
||||||
|
{
|
||||||
|
public enum LegendAlign
|
||||||
|
{
|
||||||
|
top,
|
||||||
|
bottom,
|
||||||
|
left,
|
||||||
|
right
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Components/Components/models/MergeCells.cs
Normal file
20
Components/Components/models/MergeCells.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.models
|
||||||
|
{
|
||||||
|
public class MergeCells
|
||||||
|
{
|
||||||
|
public string Header;
|
||||||
|
public int[] Indexes;
|
||||||
|
|
||||||
|
public MergeCells(string header, int[] indexes)
|
||||||
|
{
|
||||||
|
Header = header;
|
||||||
|
Indexes = indexes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
CustomListBox/CustomListBox.sln
Normal file
25
CustomListBox/CustomListBox.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35219.272
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomListBox", "CustomListBox\CustomListBox.csproj", "{40E6152B-37DF-4F81-AE29-286E819C3D48}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{40E6152B-37DF-4F81-AE29-286E819C3D48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{40E6152B-37DF-4F81-AE29-286E819C3D48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{40E6152B-37DF-4F81-AE29-286E819C3D48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{40E6152B-37DF-4F81-AE29-286E819C3D48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B593B78E-4310-492D-B3F5-1F7A0A90E5E5}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
10
CustomListBox/CustomListBox/CustomListBox.csproj
Normal file
10
CustomListBox/CustomListBox/CustomListBox.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
105
Test/Form1.Designer.cs
generated
Normal file
105
Test/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
buttonLargeText = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
customListBox1 = new Components.CustomListBox();
|
||||||
|
toolTip1 = new ToolTip(components);
|
||||||
|
diagramComponent1 = new Components.DiagramComponent(components);
|
||||||
|
largeTextComponent1 = new Components.LargeTextComponent(components);
|
||||||
|
tableComponent1 = new Components.TableComponent(components);
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonLargeText
|
||||||
|
//
|
||||||
|
buttonLargeText.Location = new Point(33, 39);
|
||||||
|
buttonLargeText.Name = "buttonLargeText";
|
||||||
|
buttonLargeText.Size = new Size(159, 23);
|
||||||
|
buttonLargeText.TabIndex = 0;
|
||||||
|
buttonLargeText.Text = "создать пдф с текстом";
|
||||||
|
buttonLargeText.UseVisualStyleBackColor = true;
|
||||||
|
buttonLargeText.Click += buttonLargeText_CLick;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(33, 105);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(159, 23);
|
||||||
|
button1.TabIndex = 1;
|
||||||
|
button1.Text = "создать пдф с таблицей";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += buttonCreateTable_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(33, 187);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(170, 23);
|
||||||
|
button2.TabIndex = 2;
|
||||||
|
button2.Text = "создать пдф с диаграммой";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += buttonDiagram_Click;
|
||||||
|
//
|
||||||
|
// customListBox1
|
||||||
|
//
|
||||||
|
customListBox1.Location = new Point(399, 30);
|
||||||
|
customListBox1.Name = "customListBox1";
|
||||||
|
customListBox1.SelectedIndex = -1;
|
||||||
|
customListBox1.Size = new Size(341, 201);
|
||||||
|
customListBox1.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 275);
|
||||||
|
Controls.Add(customListBox1);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(buttonLargeText);
|
||||||
|
Name = "Form1";
|
||||||
|
Text = "Form1";
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonLargeText;
|
||||||
|
private Button button1;
|
||||||
|
private Button button2;
|
||||||
|
private Components.CustomListBox customListBox1;
|
||||||
|
private ToolTip toolTip1;
|
||||||
|
private Components.DiagramComponent diagramComponent1;
|
||||||
|
private Components.LargeTextComponent largeTextComponent1;
|
||||||
|
private Components.TableComponent tableComponent1;
|
||||||
|
}
|
||||||
|
}
|
||||||
86
Test/Form1.cs
Normal file
86
Test/Form1.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
using Components.models;
|
||||||
|
using 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;
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
List<Person> people = new List<Person>()
|
||||||
|
{
|
||||||
|
new Person("labuba", "not labuba", "19"),
|
||||||
|
new Person("labuba2", "not labuba2", "25"),
|
||||||
|
new Person("labuba3", "not labuba3", "20"),
|
||||||
|
};
|
||||||
|
customListBox1.SetTemplateString("Дорогой дневник, мне не хватит слов чтобы описать всю {FirstName} {LastName} возраста {Age}", "{", "}");
|
||||||
|
|
||||||
|
customListBox1.FillProperty(people[0], 0, "FirstName");
|
||||||
|
customListBox1.FillProperty(people[0], 0, "LastName");
|
||||||
|
customListBox1.FillProperty(people[0], 0, "Age");
|
||||||
|
|
||||||
|
customListBox1.FillProperty(people[1], 1, "FirstName");
|
||||||
|
customListBox1.FillProperty(people[1], 1, "LastName");
|
||||||
|
customListBox1.FillProperty(people[1], 1, "Age");
|
||||||
|
|
||||||
|
customListBox1.FillProperty(people[2], 2, "FirstName");
|
||||||
|
customListBox1.FillProperty(people[2], 2, "LastName");
|
||||||
|
customListBox1.FillProperty(people[2], 2, "Age");
|
||||||
|
}
|
||||||
|
private void buttonLargeText_CLick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string[] strings = new string[] { "labuba",
|
||||||
|
"тут я пишу супер много текста( ну или не супер много ) для сдачи",
|
||||||
|
"best labuba",
|
||||||
|
"гружу сюда супер большой тексттттт" };
|
||||||
|
largeTextComponent1.CreateDocument("C:\\Users\\User\\source\\repos\\PIbd-31_Egorov_M.A._COP_34\\Components\\Components\\docs\\text.pdf",
|
||||||
|
"OMEGA LABA 2", strings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreateTable_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
List<ColumnInfo> columnInfos = new List<ColumnInfo>()
|
||||||
|
{
|
||||||
|
new ColumnInfo("FirstName","Имя",50),
|
||||||
|
new ColumnInfo("LastName","Фамилия",100),
|
||||||
|
new ColumnInfo("Age","Возраст",75),
|
||||||
|
};
|
||||||
|
|
||||||
|
List<MergeCells> mergeCells = new List<MergeCells>()
|
||||||
|
{
|
||||||
|
new MergeCells("Данные", new int[] {0,2,2})
|
||||||
|
};
|
||||||
|
|
||||||
|
List<Person> people = new List<Person>()
|
||||||
|
{
|
||||||
|
new Person("labuba", "not labuba", "19"),
|
||||||
|
new Person("labuba2", "not labuba2", "25"),
|
||||||
|
new Person("labuba3", "not labuba3", "20"),
|
||||||
|
};
|
||||||
|
|
||||||
|
tableComponent1.CreateTable("C:\\Users\\User\\source\\repos\\PIbd-31_Egorov_M.A._COP_34\\Components\\Components\\docs\\table.pdf",
|
||||||
|
"TABLE LUTI", mergeCells, columnInfos, people);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDiagram_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Dictionary<string, List<Double>> data = new Dictionary<string, List<Double>>();
|
||||||
|
data.Add("labuba1", new List<double> { 12, 1, 2, 5, 2 });
|
||||||
|
data.Add("labuba2", new List<double> { 3, 2, 1, 3, 6 });
|
||||||
|
data.Add("labuba3", new List<double> { 7, 3, 1, 2, 5 });
|
||||||
|
|
||||||
|
diagramComponent1.CreateLineDiagram("C:\\Users\\User\\source\\repos\\PIbd-31_Egorov_M.A._COP_34\\Components\\Components\\docs\\diagram.pdf",
|
||||||
|
"ZAGOLOVOK", "LINEYNAYA", data, LegendAlign.bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
132
Test/Form1.resx
Normal file
132
Test/Form1.resx
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<?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="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="diagramComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>114, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="largeTextComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>282, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="tableComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>453, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
22
Test/Person.cs
Normal file
22
Test/Person.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
public class Person
|
||||||
|
{
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string Age { get; set; }
|
||||||
|
public Person(string fn, string ln, string ag)
|
||||||
|
{
|
||||||
|
FirstName = fn;
|
||||||
|
LastName = ln;
|
||||||
|
Age = ag;
|
||||||
|
}
|
||||||
|
public Person() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Test/Program.cs
Normal file
17
Test/Program.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
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 Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Test/Test.csproj
Normal file
15
Test/Test.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="..\Components\Components\Components.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user