Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
271e884511 | ||
|
de8ff2cfaf | ||
|
d9f159ae7b | ||
|
db32ab60ce | ||
|
1128ffdc1a |
36
FormLibrary/ComponentHistogramToPdf.Designer.cs
generated
Normal file
36
FormLibrary/ComponentHistogramToPdf.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
partial class ComponentHistogramToPdf
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
101
FormLibrary/ComponentHistogramToPdf.cs
Normal file
101
FormLibrary/ComponentHistogramToPdf.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using FormLibrary.HelperClasses;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using OxyPlot.Series;
|
||||
using OxyPlot;
|
||||
using System.ComponentModel;
|
||||
using OxyPlot.WindowsForms;
|
||||
using OxyPlot.Legends;
|
||||
|
||||
|
||||
namespace FormLibrary
|
||||
{
|
||||
public partial class ComponentHistogramToPdf : Component
|
||||
{
|
||||
public ComponentHistogramToPdf()
|
||||
{
|
||||
InitializeComponent();
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
public ComponentHistogramToPdf(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public void CreateHistogramPdf(string filePath, string documentTitle, string chartTitle, LegendPosition legendPosition, List<ChartData> chartData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
throw new ArgumentException("Путь к файлу не должен быть пустым.");
|
||||
if (string.IsNullOrEmpty(documentTitle))
|
||||
throw new ArgumentException("Название документа не должно быть пустым.");
|
||||
if (string.IsNullOrEmpty(chartTitle))
|
||||
throw new ArgumentException("Заголовок диаграммы не должен быть пустым.");
|
||||
if (chartData == null || chartData.Count == 0)
|
||||
throw new ArgumentException("Набор данных не должен быть пустым.");
|
||||
|
||||
foreach (var data in chartData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data.SeriesName) || data.Data == null || data.Data.Count == 0)
|
||||
throw new ArgumentException($"Набор данных для серии '{data.SeriesName}' некорректен.");
|
||||
}
|
||||
|
||||
// создание графика
|
||||
var plotModel = new PlotModel { Title = chartTitle };
|
||||
|
||||
foreach (var data in chartData)
|
||||
{
|
||||
var barSeries = new BarSeries { Title = data.SeriesName };
|
||||
foreach (var item in data.Data)
|
||||
{
|
||||
barSeries.Items.Add(new BarItem(item.Value));
|
||||
}
|
||||
plotModel.Series.Add(barSeries);
|
||||
}
|
||||
|
||||
// Добавление легенды
|
||||
AddLegend(plotModel, legendPosition);
|
||||
|
||||
// сохранение графика в изображение
|
||||
var pngExporter = new PngExporter { Width = 600, Height = 400 };
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
pngExporter.Export(plotModel, stream);
|
||||
File.WriteAllBytes("chart.png", stream.ToArray());
|
||||
}
|
||||
|
||||
// создание документа
|
||||
Document document = new Document();
|
||||
document.Info.Title = documentTitle;
|
||||
document.Info.Subject = "Гистограмма";
|
||||
|
||||
Section section = document.AddSection();
|
||||
section.AddParagraph(chartTitle, "Heading1");
|
||||
|
||||
// вставка изображения в PDF
|
||||
var image = section.AddImage("chart.png");
|
||||
image.Width = Unit.FromCentimeter(15);
|
||||
|
||||
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true) { Document = document };
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(filePath);
|
||||
|
||||
File.Delete("chart.png");
|
||||
}
|
||||
|
||||
//добавление легенды
|
||||
private void AddLegend(PlotModel plotModel, LegendPosition legendPosition)
|
||||
{
|
||||
// Создание легенды
|
||||
var legend = new OxyPlot.Legends.Legend
|
||||
{
|
||||
LegendPlacement = LegendPlacement.Outside,
|
||||
LegendPosition = legendPosition,
|
||||
LegendOrientation = LegendOrientation.Vertical
|
||||
};
|
||||
|
||||
plotModel.Legends.Add(legend);
|
||||
}
|
||||
}
|
||||
}
|
58
FormLibrary/CustomListBox.Designer.cs
generated
Normal file
58
FormLibrary/CustomListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
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()
|
||||
{
|
||||
listBox1 = new ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
listBox1.FormattingEnabled = true;
|
||||
listBox1.ItemHeight = 15;
|
||||
listBox1.Location = new Point(3, 3);
|
||||
listBox1.Name = "listBox1";
|
||||
listBox1.Size = new Size(231, 169);
|
||||
listBox1.TabIndex = 0;
|
||||
listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
|
||||
//
|
||||
// CustomListBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(listBox1);
|
||||
Name = "CustomListBox";
|
||||
Size = new Size(237, 179);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox1;
|
||||
}
|
||||
}
|
48
FormLibrary/CustomListBox.cs
Normal file
48
FormLibrary/CustomListBox.cs
Normal file
@ -0,0 +1,48 @@
|
||||
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.Header;
|
||||
|
||||
namespace FormLibrary
|
||||
{
|
||||
public partial class CustomListBox : UserControl
|
||||
{
|
||||
|
||||
public event EventHandler? SelectedItemChanged;
|
||||
public CustomListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string SelectedItem
|
||||
{
|
||||
get => listBox1.SelectedItem?.ToString() ?? string.Empty;
|
||||
set => listBox1.SelectedIndex = listBox1.Items.IndexOf(value);
|
||||
}
|
||||
|
||||
private void ListBox1_SelectedIndexChanged(object? sender, EventArgs e)
|
||||
{
|
||||
SelectedItemChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
public void PopulateListBox(List<string> items)
|
||||
{
|
||||
listBox1.Items.Clear();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
listBox1.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearListBox()
|
||||
{
|
||||
listBox1.Items.Clear();
|
||||
}
|
||||
}
|
||||
}
|
120
FormLibrary/CustomListBox.resx
Normal file
120
FormLibrary/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>
|
13
FormLibrary/Exceptions/EmptyValueException.cs
Normal file
13
FormLibrary/Exceptions/EmptyValueException.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.Exceptions
|
||||
{
|
||||
public class EmptyValueException : Exception
|
||||
{
|
||||
public EmptyValueException() : base("Значение не заполнено.") { }
|
||||
}
|
||||
}
|
13
FormLibrary/Exceptions/InvalidValueTypeException.cs
Normal file
13
FormLibrary/Exceptions/InvalidValueTypeException.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.Exceptions
|
||||
{
|
||||
public class InvalidValueTypeException : Exception
|
||||
{
|
||||
public InvalidValueTypeException() : base("Значение не соответствует требуемому типу.") { }
|
||||
}
|
||||
}
|
18
FormLibrary/FormLibrary.csproj
Normal file
18
FormLibrary/FormLibrary.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OxyPlot.Core" Version="2.2.0" />
|
||||
<PackageReference Include="OxyPlot.WindowsForms" Version="2.2.0" />
|
||||
<PackageReference Include="OxyPlot.Wpf" Version="2.2.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
FormLibrary/HelperClasses/ChartData.cs
Normal file
14
FormLibrary/HelperClasses/ChartData.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public class ChartData
|
||||
{
|
||||
public string SeriesName { get; set; }
|
||||
public Dictionary<string, double> Data { get; set; } // Ключ — категория, значение — значение для гистограммы
|
||||
}
|
||||
}
|
16
FormLibrary/HelperClasses/ColumnConfig.cs
Normal file
16
FormLibrary/HelperClasses/ColumnConfig.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public class ColumnConfig
|
||||
{
|
||||
public string HeaderText { get; set; }
|
||||
public int Width { get; set; }
|
||||
public bool IsVisible { get; set; }
|
||||
public string PropertyName { get; set; }
|
||||
}
|
||||
}
|
16
FormLibrary/HelperClasses/LegendPositions.cs
Normal file
16
FormLibrary/HelperClasses/LegendPositions.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public enum LegendPositions
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
19
FormLibrary/HelperClasses/PDFTableSettings.cs
Normal file
19
FormLibrary/HelperClasses/PDFTableSettings.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public class PDFTableSettings<T>
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public string DocumentTitle { get; set; }
|
||||
public List<(string HeaderTitle, float Width, string PropertyName, int ColumnIndex)> Columns { get; set; }
|
||||
public float HeaderRowHeight { get; set; }
|
||||
public float DataRowHeight { get; set; }
|
||||
public List<T> DataList { get; set; }
|
||||
}
|
||||
|
||||
}
|
23
FormLibrary/HelperClasses/PdfDocumentData.cs
Normal file
23
FormLibrary/HelperClasses/PdfDocumentData.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public class PdfDocumentData
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string DocumentTitle { get; set; }
|
||||
public List<string[,]> Tables { get; set; }
|
||||
|
||||
public PdfDocumentData(string fileName, string documentTitle, List<string[,]> tables)
|
||||
{
|
||||
FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
|
||||
DocumentTitle = documentTitle ?? throw new ArgumentNullException(nameof(documentTitle));
|
||||
Tables = tables ?? throw new ArgumentNullException(nameof(tables));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
16
FormLibrary/HelperClasses/Student.cs
Normal file
16
FormLibrary/HelperClasses/Student.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary.HelperClasses
|
||||
{
|
||||
public class Student
|
||||
{
|
||||
public int Number { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public int Course { get; set; }
|
||||
}
|
||||
}
|
68
FormLibrary/IntegerInputControl.Designer.cs
generated
Normal file
68
FormLibrary/IntegerInputControl.Designer.cs
generated
Normal file
@ -0,0 +1,68 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
partial class IntegerInputControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkBoxNull = new CheckBox();
|
||||
textBoxInput = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxNull
|
||||
//
|
||||
checkBoxNull.AutoSize = true;
|
||||
checkBoxNull.Location = new Point(13, 17);
|
||||
checkBoxNull.Name = "checkBoxNull";
|
||||
checkBoxNull.Size = new Size(15, 14);
|
||||
checkBoxNull.TabIndex = 0;
|
||||
checkBoxNull.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBoxInput
|
||||
//
|
||||
textBoxInput.Location = new Point(34, 13);
|
||||
textBoxInput.Name = "textBoxInput";
|
||||
textBoxInput.Size = new Size(100, 23);
|
||||
textBoxInput.TabIndex = 1;
|
||||
//
|
||||
// IntegerInputControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(textBoxInput);
|
||||
Controls.Add(checkBoxNull);
|
||||
Name = "IntegerInputControl";
|
||||
Size = new Size(146, 49);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxNull;
|
||||
private TextBox textBoxInput;
|
||||
}
|
||||
}
|
82
FormLibrary/IntegerInputControl.cs
Normal file
82
FormLibrary/IntegerInputControl.cs
Normal file
@ -0,0 +1,82 @@
|
||||
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 System;
|
||||
using System.Windows.Forms;
|
||||
using FormLibrary.Exceptions;
|
||||
|
||||
namespace FormLibrary
|
||||
{
|
||||
public partial class IntegerInputControl : UserControl
|
||||
{
|
||||
public event EventHandler? ValueChanged;
|
||||
|
||||
public event EventHandler? CheckBoxChanged;
|
||||
|
||||
public IntegerInputControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
checkBoxNull.CheckedChanged += CheckBoxNull_CheckedChanged;
|
||||
textBoxInput.TextChanged += TextBoxInput_TextChanged;
|
||||
}
|
||||
|
||||
public int? Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (checkBoxNull.Checked)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxInput.Text))
|
||||
{
|
||||
throw new EmptyValueException();
|
||||
}
|
||||
|
||||
if (int.TryParse(textBoxInput.Text, out int result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidValueTypeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value is not null)
|
||||
{
|
||||
textBoxInput.Text = value.ToString();
|
||||
}
|
||||
checkBoxNull.Checked = value is null;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckBoxNull_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
textBoxInput.Enabled = !checkBoxNull.Checked;
|
||||
if (checkBoxNull.Checked)
|
||||
{
|
||||
textBoxInput.Text = string.Empty;
|
||||
}
|
||||
CheckBoxChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void TextBoxInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
ValueChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
FormLibrary/IntegerInputControl.resx
Normal file
120
FormLibrary/IntegerInputControl.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
FormLibrary/PDFTable.Designer.cs
generated
Normal file
36
FormLibrary/PDFTable.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
partial class PDFTable
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
71
FormLibrary/PDFTable.cs
Normal file
71
FormLibrary/PDFTable.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using FormLibrary.HelperClasses;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using System.ComponentModel;
|
||||
using Document = MigraDoc.DocumentObjectModel.Document;
|
||||
|
||||
|
||||
namespace FormLibrary
|
||||
{
|
||||
public partial class PDFTable : Component
|
||||
{
|
||||
public PDFTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
|
||||
}
|
||||
|
||||
public PDFTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void GeneratePdf(PdfDocumentData pdfData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pdfData.FileName)) throw new ArgumentException("Имя файла не должно быть пустым.");
|
||||
if (string.IsNullOrWhiteSpace(pdfData.DocumentTitle)) throw new ArgumentException("Название документа не должно быть пустым.");
|
||||
if (pdfData.Tables == null || pdfData.Tables.Count == 0) throw new ArgumentException("Необходимо передать хотя бы одну таблицу.");
|
||||
|
||||
Document document = new Document();
|
||||
Section section = document.AddSection();
|
||||
|
||||
Paragraph title = section.AddParagraph();
|
||||
title.AddFormattedText(pdfData.DocumentTitle, TextFormat.Bold);
|
||||
title.Format.Alignment = ParagraphAlignment.Center;
|
||||
section.AddParagraph();
|
||||
|
||||
foreach (var tableData in pdfData.Tables)
|
||||
{
|
||||
Table table = section.AddTable();
|
||||
int columnsCount = tableData.GetLength(1);
|
||||
|
||||
for (int i = 0; i < columnsCount; i++)
|
||||
{
|
||||
Column column = table.AddColumn(Unit.FromCentimeter(3));
|
||||
}
|
||||
|
||||
table.Borders.Width = 0.75;
|
||||
table.Borders.Color = Colors.Black;
|
||||
|
||||
for (int i = 0; i < tableData.GetLength(0); i++)
|
||||
{
|
||||
Row row = table.AddRow();
|
||||
for (int j = 0; j < tableData.GetLength(1); j++)
|
||||
{
|
||||
row.Cells[j].AddParagraph(tableData[i, j]);
|
||||
}
|
||||
}
|
||||
|
||||
section.AddParagraph();
|
||||
}
|
||||
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
|
||||
pdfRenderer.Document = document;
|
||||
pdfRenderer.RenderDocument();
|
||||
pdfRenderer.PdfDocument.Save(pdfData.FileName);
|
||||
}
|
||||
}
|
||||
}
|
36
FormLibrary/PDFTableCustom.Designer.cs
generated
Normal file
36
FormLibrary/PDFTableCustom.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
partial class PDFTableCustom
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
95
FormLibrary/PDFTableCustom.cs
Normal file
95
FormLibrary/PDFTableCustom.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using FormLibrary.HelperClasses;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FormLibrary
|
||||
{
|
||||
public partial class PDFTableCustom : Component
|
||||
{
|
||||
public PDFTableCustom()
|
||||
{
|
||||
InitializeComponent();
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
public PDFTableCustom(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public void GeneratePDFWithHead<T>(PDFTableSettings<T> settings)
|
||||
{
|
||||
if (settings == null ||
|
||||
string.IsNullOrEmpty(settings.FilePath) ||
|
||||
string.IsNullOrEmpty(settings.DocumentTitle) ||
|
||||
settings.Columns == null || settings.Columns.Count == 0 ||
|
||||
settings.DataList == null)
|
||||
throw new ArgumentException("Заполнены не все необходимые данные для генерации документа.");
|
||||
|
||||
Document document = new Document();
|
||||
Section section = document.AddSection();
|
||||
section.AddParagraph(settings.DocumentTitle, "Heading1");
|
||||
|
||||
Table table = new Table();
|
||||
table.Borders.Width = 0.75;
|
||||
|
||||
// столбцы
|
||||
foreach (var (_, width, _, _) in settings.Columns)
|
||||
{
|
||||
Column column = table.AddColumn(Unit.FromCentimeter(width));
|
||||
column.Format.Alignment = ParagraphAlignment.Center;
|
||||
}
|
||||
|
||||
// заголовки
|
||||
Row headerRow = table.AddRow();
|
||||
headerRow.Height = Unit.FromCentimeter(settings.HeaderRowHeight);
|
||||
|
||||
for (int columnIndex = 0; columnIndex < settings.Columns.Count; columnIndex++)
|
||||
{
|
||||
var (headerTitle, _, _, _) = settings.Columns[columnIndex];
|
||||
headerRow.Cells[columnIndex].AddParagraph(headerTitle);
|
||||
headerRow.Cells[columnIndex].Format.Font.Bold = true;
|
||||
headerRow.Cells[columnIndex].Format.Alignment = ParagraphAlignment.Center;
|
||||
}
|
||||
|
||||
// данные
|
||||
foreach (var dataItem in settings.DataList)
|
||||
{
|
||||
Row row = table.AddRow();
|
||||
row.Height = Unit.FromCentimeter(settings.DataRowHeight);
|
||||
|
||||
for (int columnIndex = 0; columnIndex < settings.Columns.Count; columnIndex++)
|
||||
{
|
||||
var (_, _, propertyName, _) = settings.Columns[columnIndex];
|
||||
|
||||
PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName);
|
||||
if (propertyInfo == null)
|
||||
throw new ArgumentException($"Свойство {propertyName} не найдено в классе {typeof(T).Name}.");
|
||||
|
||||
object value = propertyInfo.GetValue(dataItem);
|
||||
if (columnIndex == 0)
|
||||
{
|
||||
row.Cells[columnIndex].Format.Font.Bold = true;
|
||||
}
|
||||
row.Cells[columnIndex].AddParagraph(value != null ? value.ToString() : "");
|
||||
}
|
||||
}
|
||||
|
||||
section.Add(table);
|
||||
|
||||
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true) { Document = document };
|
||||
renderer.RenderDocument();
|
||||
renderer.Save(settings.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
58
FormLibrary/ValueTableControl.Designer.cs
generated
Normal file
58
FormLibrary/ValueTableControl.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace FormLibrary
|
||||
{
|
||||
partial class ValueTableControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView1 = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Location = new Point(3, 3);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.Size = new Size(445, 363);
|
||||
dataGridView1.TabIndex = 0;
|
||||
//
|
||||
// ValueTableControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(dataGridView1);
|
||||
Name = "ValueTableControl";
|
||||
Size = new Size(451, 369);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView1;
|
||||
}
|
||||
}
|
103
FormLibrary/ValueTableControl.cs
Normal file
103
FormLibrary/ValueTableControl.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using FormLibrary.HelperClasses;
|
||||
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 FormLibrary
|
||||
{
|
||||
public partial class ValueTableControl : UserControl
|
||||
{
|
||||
public ValueTableControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
ConfigureDataGridView();
|
||||
}
|
||||
|
||||
private void ConfigureDataGridView()
|
||||
{
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.AllowUserToAddRows = false;
|
||||
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
}
|
||||
|
||||
public void ConfigureColumns(List<(string HeaderText, string DataPropertyName, float FillWeight)> columns)
|
||||
{
|
||||
dataGridView1.Columns.Clear();
|
||||
|
||||
foreach (var column in columns)
|
||||
{
|
||||
dataGridView1.Columns.Add(new DataGridViewTextBoxColumn
|
||||
{
|
||||
HeaderText = column.HeaderText,
|
||||
DataPropertyName = column.DataPropertyName,
|
||||
FillWeight = column.FillWeight
|
||||
});
|
||||
}
|
||||
}
|
||||
public void ClearRows()
|
||||
{
|
||||
dataGridView1.Rows.Clear();
|
||||
}
|
||||
|
||||
public int SelectedRowIndex
|
||||
{
|
||||
get => dataGridView1.SelectedRows[0].Index;
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value < dataGridView1.Rows.Count)
|
||||
{
|
||||
dataGridView1.ClearSelection();
|
||||
dataGridView1.Rows[value].Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T GetSelectedObject<T>() where T : new()
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 0)
|
||||
throw new InvalidOperationException("Нет выбранной строки.");
|
||||
|
||||
var selectedRow = dataGridView1.SelectedRows[0];
|
||||
var obj = new T();
|
||||
|
||||
foreach (DataGridViewColumn column in dataGridView1.Columns)
|
||||
{
|
||||
var prop = typeof(T).GetProperty(column.DataPropertyName);
|
||||
if (prop != null)
|
||||
{
|
||||
var value = selectedRow.Cells[column.Index].Value;
|
||||
prop.SetValue(obj, Convert.ChangeType(value, prop.PropertyType));
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void FillData<T>(List<T> objects)
|
||||
{
|
||||
dataGridView1.Rows.Clear();
|
||||
|
||||
if (objects == null || !objects.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var properties = typeof(T).GetProperties();
|
||||
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
var values = properties.Select(p => p.GetValue(obj, null)).ToArray();
|
||||
dataGridView1.Rows.Add(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
FormLibrary/ValueTableControl.resx
Normal file
120
FormLibrary/ValueTableControl.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>
|
15
Forms/Forms.csproj
Normal file
15
Forms/Forms.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="WinFormsLibraryZhirnova" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
225
Forms/MainForm.Designer.cs
generated
Normal file
225
Forms/MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,225 @@
|
||||
namespace Forms
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <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();
|
||||
customListBox1 = new FormLibrary.CustomListBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
integerInputControl1 = new FormLibrary.IntegerInputControl();
|
||||
button3 = new Button();
|
||||
button4 = new Button();
|
||||
textBox1 = new TextBox();
|
||||
valueTableControl1 = new FormLibrary.ValueTableControl();
|
||||
button5 = new Button();
|
||||
button6 = new Button();
|
||||
button7 = new Button();
|
||||
pdfTable1 = new FormLibrary.PDFTable(components);
|
||||
button8 = new Button();
|
||||
pdfTableCustom1 = new FormLibrary.PDFTableCustom(components);
|
||||
button9 = new Button();
|
||||
button11 = new Button();
|
||||
componentHistogramToPdf1 = new FormLibrary.ComponentHistogramToPdf(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// customListBox1
|
||||
//
|
||||
customListBox1.Location = new Point(12, 12);
|
||||
customListBox1.Name = "customListBox1";
|
||||
customListBox1.SelectedItem = "";
|
||||
customListBox1.Size = new Size(237, 176);
|
||||
customListBox1.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(12, 194);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(237, 34);
|
||||
button1.TabIndex = 1;
|
||||
button1.Text = "Заполнить список";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonLoad_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(12, 234);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(237, 34);
|
||||
button2.TabIndex = 2;
|
||||
button2.Text = "Очистить список";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += ButtonClear_Click;
|
||||
//
|
||||
// integerInputControl1
|
||||
//
|
||||
integerInputControl1.Location = new Point(329, 12);
|
||||
integerInputControl1.Name = "integerInputControl1";
|
||||
integerInputControl1.Size = new Size(146, 56);
|
||||
integerInputControl1.TabIndex = 3;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(361, 74);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(103, 23);
|
||||
button3.TabIndex = 4;
|
||||
button3.Text = "Set";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += buttonInput_Click;
|
||||
//
|
||||
// button4
|
||||
//
|
||||
button4.Location = new Point(361, 103);
|
||||
button4.Name = "button4";
|
||||
button4.Size = new Size(103, 23);
|
||||
button4.TabIndex = 5;
|
||||
button4.Text = "Get";
|
||||
button4.UseVisualStyleBackColor = true;
|
||||
button4.Click += buttonOutput_Click;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(329, 132);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(135, 23);
|
||||
textBox1.TabIndex = 6;
|
||||
//
|
||||
// valueTableControl1
|
||||
//
|
||||
valueTableControl1.Location = new Point(487, 12);
|
||||
valueTableControl1.Name = "valueTableControl1";
|
||||
valueTableControl1.Size = new Size(450, 369);
|
||||
valueTableControl1.TabIndex = 7;
|
||||
//
|
||||
// button5
|
||||
//
|
||||
button5.Location = new Point(487, 387);
|
||||
button5.Name = "button5";
|
||||
button5.Size = new Size(159, 51);
|
||||
button5.TabIndex = 8;
|
||||
button5.Text = "Заполнить таблицу";
|
||||
button5.UseVisualStyleBackColor = true;
|
||||
button5.Click += ButtonFillTable_Click;
|
||||
//
|
||||
// button6
|
||||
//
|
||||
button6.Location = new Point(652, 387);
|
||||
button6.Name = "button6";
|
||||
button6.Size = new Size(134, 51);
|
||||
button6.TabIndex = 9;
|
||||
button6.Text = "Очистить таблицу";
|
||||
button6.UseVisualStyleBackColor = true;
|
||||
button6.Click += ButtonClearTable_Click;
|
||||
//
|
||||
// button7
|
||||
//
|
||||
button7.Location = new Point(792, 387);
|
||||
button7.Name = "button7";
|
||||
button7.Size = new Size(148, 51);
|
||||
button7.TabIndex = 10;
|
||||
button7.Text = "Get";
|
||||
button7.UseVisualStyleBackColor = true;
|
||||
button7.Click += ButtonShowData_Click;
|
||||
//
|
||||
// button8
|
||||
//
|
||||
button8.Location = new Point(26, 481);
|
||||
button8.Name = "button8";
|
||||
button8.Size = new Size(139, 23);
|
||||
button8.TabIndex = 11;
|
||||
button8.Text = "Create PDF";
|
||||
button8.UseVisualStyleBackColor = true;
|
||||
button8.Click += GeneratePdfButton_Click;
|
||||
//
|
||||
// button9
|
||||
//
|
||||
button9.Location = new Point(189, 481);
|
||||
button9.Name = "button9";
|
||||
button9.Size = new Size(139, 23);
|
||||
button9.TabIndex = 12;
|
||||
button9.Text = "Create customPDF";
|
||||
button9.UseVisualStyleBackColor = true;
|
||||
button9.Click += btnGeneratePDF_Click;
|
||||
//
|
||||
// button11
|
||||
//
|
||||
button11.Location = new Point(347, 481);
|
||||
button11.Name = "button11";
|
||||
button11.Size = new Size(139, 23);
|
||||
button11.TabIndex = 13;
|
||||
button11.Text = "Create Histogram PDF";
|
||||
button11.UseVisualStyleBackColor = true;
|
||||
button11.Click += btnGenerateHistogrammPdf_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(944, 625);
|
||||
Controls.Add(button11);
|
||||
Controls.Add(button9);
|
||||
Controls.Add(button8);
|
||||
Controls.Add(button7);
|
||||
Controls.Add(button6);
|
||||
Controls.Add(button5);
|
||||
Controls.Add(valueTableControl1);
|
||||
Controls.Add(textBox1);
|
||||
Controls.Add(button4);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(integerInputControl1);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(customListBox1);
|
||||
Name = "MainForm";
|
||||
Text = "MainForm";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private FormLibrary.CustomListBox customListBox1;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private FormLibrary.IntegerInputControl integerInputControl1;
|
||||
private Button button3;
|
||||
private Button button4;
|
||||
private TextBox textBox1;
|
||||
private FormLibrary.ValueTableControl valueTableControl1;
|
||||
private Button button5;
|
||||
private Button button6;
|
||||
private Button button7;
|
||||
private FormLibrary.PDFTable pdfTable1;
|
||||
private Button button8;
|
||||
private FormLibrary.PDFTableCustom pdfTableCustom1;
|
||||
private Button button9;
|
||||
private Button button11;
|
||||
private FormLibrary.ComponentHistogramToPdf componentHistogramToPdf1;
|
||||
}
|
||||
}
|
219
Forms/MainForm.cs
Normal file
219
Forms/MainForm.cs
Normal file
@ -0,0 +1,219 @@
|
||||
using FormLibrary;
|
||||
using FormLibrary.Exceptions;
|
||||
using FormLibrary.HelperClasses;
|
||||
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 System.Windows.Forms.VisualStyles;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
|
||||
using OxyPlot.Legends;
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private int? savedValue;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
customListBox1.SelectedItemChanged += CustomListBox1_SelectedItemChanged;
|
||||
integerInputControl1.ValueChanged += IntegerInputControl1_ValueChanged;
|
||||
integerInputControl1.CheckBoxChanged += IntegerInputControl_CheckBoxChanged;
|
||||
}
|
||||
|
||||
private void CustomListBox1_SelectedItemChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is CustomListBox customListBox)
|
||||
{
|
||||
string selectedItem = customListBox.SelectedItem;
|
||||
MessageBox.Show($"Выбранный элемент: {selectedItem}", "Выбор элемента", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ButtonLoad_Click(object? sender, EventArgs e)
|
||||
{
|
||||
List<string> items = new List<string>();
|
||||
for (int i = 0; i <= 5; i++)
|
||||
{
|
||||
items.Add("Item " + i.ToString());
|
||||
}
|
||||
|
||||
customListBox1.PopulateListBox(items);
|
||||
}
|
||||
|
||||
private void ButtonClear_Click(object? sender, EventArgs e)
|
||||
{
|
||||
customListBox1.ClearListBox();
|
||||
}
|
||||
private void buttonInput_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
savedValue = integerInputControl1.Value;
|
||||
MessageBox.Show("Значение успешно сохранено.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (EmptyValueException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (InvalidValueTypeException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOutput_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (savedValue.HasValue)
|
||||
{
|
||||
MessageBox.Show($"Сохраненное значение: {savedValue}", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Сохраненное значение: null", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void IntegerInputControl1_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = "Textbox changed";
|
||||
}
|
||||
|
||||
private void IntegerInputControl_CheckBoxChanged(object? sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = "Checkbox changed";
|
||||
}
|
||||
private void ButtonFillTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
var columns = new List<(string HeaderText, string DataPropertyName, float FillWeight)>
|
||||
{
|
||||
("Группа", "Group", 30),
|
||||
("ФИО", "FullName", 50),
|
||||
("Курс", "Course", 20)
|
||||
};
|
||||
valueTableControl1.ConfigureColumns(columns);
|
||||
|
||||
var students = new List<Student>
|
||||
{
|
||||
new Student { Group = "Пибд-31", FullName = "Алексеев Иван Сергеевич", Course = 3 },
|
||||
new Student { Group = "Пибд-31", FullName = "Анисин Руслан Сергеевич", Course = 3 },
|
||||
new Student { Group = "Пибд-31", FullName = "Афанасьев Степан Сергеевич", Course = 3 }
|
||||
};
|
||||
|
||||
valueTableControl1.FillData(students);
|
||||
}
|
||||
|
||||
private void ButtonClearTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
valueTableControl1.ClearRows();
|
||||
}
|
||||
|
||||
private void ButtonShowData_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectedStudent = valueTableControl1.GetSelectedObject<Student>();
|
||||
MessageBox.Show($"Группа: {selectedStudent.Group}, ФИО: {selectedStudent.FullName}, Курс: {selectedStudent.Course}",
|
||||
"Выбранный студент",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void GeneratePdfButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pdfData = new PdfDocumentData(
|
||||
"C:\\Users\\Admin\\Downloads\\Отчёт.pdf",
|
||||
"Название документа",
|
||||
new List<string[,]>
|
||||
{
|
||||
new string[,]
|
||||
{
|
||||
{ "Ячейка 1", "Ячейка 2", "Ячейка 3" },
|
||||
{ "Ячейка 4", "Ячейка 5", "Ячейка 6" }
|
||||
},
|
||||
new string[,]
|
||||
{
|
||||
{ "Ячейка 1", "Ячейка 2" },
|
||||
{ "Ячейка 1", "Ячейка 2" }
|
||||
}
|
||||
});
|
||||
|
||||
var documentGenerator = new PDFTable();
|
||||
documentGenerator.GeneratePdf(pdfData);
|
||||
|
||||
MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Произошла ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void btnGeneratePDF_Click(object sender, EventArgs e)
|
||||
{
|
||||
var settings = new PDFTableSettings<Student>
|
||||
{
|
||||
FilePath = "C:\\Users\\Admin\\Downloads\\Отчет2.pdf",
|
||||
DocumentTitle = "Отчет по студентам",
|
||||
HeaderRowHeight = 1.0f,
|
||||
DataRowHeight = 1.0f,
|
||||
DataList = new List<Student>
|
||||
{
|
||||
new Student { Number = 1, Group = "Пибд-31", FullName = "Алексеев Иван", Course = 3 },
|
||||
new Student { Number = 2, Group = "Пибд-31", FullName = "Анисин Руслан", Course = 3 },
|
||||
new Student { Number = 3, Group = "Пибд-31", FullName = "Афанасьев Степан", Course = 3 }
|
||||
},
|
||||
Columns = new List<(string, float, string, int)>
|
||||
{
|
||||
("№", 1.0f, nameof(Student.Number), 0),
|
||||
("Группа", 4.0f, nameof(Student.Group), 1),
|
||||
("ФИО", 6.0f, nameof(Student.FullName), 2),
|
||||
("Курс", 2.0f, nameof(Student.Course), 3)
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
pdfTableCustom1.GeneratePDFWithHead(settings);
|
||||
MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}");
|
||||
}
|
||||
}
|
||||
private void btnGenerateHistogrammPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var histogramGenerator = new ComponentHistogramToPdf();
|
||||
|
||||
var chartData = new List<ChartData>
|
||||
{
|
||||
new ChartData { SeriesName = "Серияd 1", Data = new Dictionary<string, double> { { "Категорияz 1", 2 }, { "Категорияx 2", 10 } } },
|
||||
new ChartData { SeriesName = "Серияs 2", Data = new Dictionary<string, double> { { "Категорияa 1", 3 }, { "Категорияs 2", 5 } } },
|
||||
new ChartData { SeriesName = "Серияs 3", Data = new Dictionary<string, double> { { "Категорияa 1", 3 }, { "Категорияs 2", 8 } } }
|
||||
};
|
||||
|
||||
string filePath = "C:\\Users\\Admin\\Downloads\\Гистограмма.pdf";
|
||||
|
||||
histogramGenerator.CreateHistogramPdf(filePath, "Название документа", "Заголовок гистограммы", LegendPosition.BottomCenter, chartData);
|
||||
|
||||
MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
Forms/MainForm.resx
Normal file
129
Forms/MainForm.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="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfTableCustom1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>122, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentHistogramToPdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>269, 17</value>
|
||||
</metadata>
|
||||
</root>
|
19
Forms/Program.cs
Normal file
19
Forms/Program.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Text;
|
||||
namespace Forms
|
||||
{
|
||||
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.
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
61
KopLab1.sln
Normal file
61
KopLab1.sln
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StudentPerformanceBusinessLogic", "StudentPerformanceBusinessLogic\StudentPerformanceBusinessLogic.csproj", "{0A1F54AD-49A1-420C-B8D1-049D8DA1E0D7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StudentPerformanceDataModels", "StudentPerformanceDataModels\StudentPerformanceDataModels.csproj", "{632322C2-D69C-40AD-A503-E85326249916}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StudentPerformanceContracts", "StudentPerformanceContracts\StudentPerformanceContracts.csproj", "{3BD4CC4F-A1BB-42BE-87AE-1D1E17AE165D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StudentPerformanceDatabaseImplement", "StudentPerformanceDatabaseImplement\StudentPerformanceDatabaseImplement.csproj", "{D894595F-CBC4-4D43-8E81-0A2B5B43FCF5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab3Form", "..\..\..\Downloads\KOP_PIbd-33_Volkov_N.A._Tikhonenkov_A.E.-Lab3_Tikhonenkov\kop_pibd-33_volkov_n.a._tikhonenkov_a.e\KopLab1\Lab3Form\Lab3Form.csproj", "{015AA962-A1EB-4EC0-9585-3AE294E62953}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{D6605228-5D19-48D0-BA7D-2A69C0C7B8B2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentPerformanceAppPlugins", "StudentPerformanceAppPlugins\StudentPerformanceAppPlugins.csproj", "{F63290DE-3E70-4EF4-9D84-DA6027635D15}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0A1F54AD-49A1-420C-B8D1-049D8DA1E0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A1F54AD-49A1-420C-B8D1-049D8DA1E0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A1F54AD-49A1-420C-B8D1-049D8DA1E0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A1F54AD-49A1-420C-B8D1-049D8DA1E0D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{632322C2-D69C-40AD-A503-E85326249916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{632322C2-D69C-40AD-A503-E85326249916}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{632322C2-D69C-40AD-A503-E85326249916}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{632322C2-D69C-40AD-A503-E85326249916}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3BD4CC4F-A1BB-42BE-87AE-1D1E17AE165D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BD4CC4F-A1BB-42BE-87AE-1D1E17AE165D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BD4CC4F-A1BB-42BE-87AE-1D1E17AE165D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BD4CC4F-A1BB-42BE-87AE-1D1E17AE165D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D894595F-CBC4-4D43-8E81-0A2B5B43FCF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D894595F-CBC4-4D43-8E81-0A2B5B43FCF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D894595F-CBC4-4D43-8E81-0A2B5B43FCF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D894595F-CBC4-4D43-8E81-0A2B5B43FCF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{015AA962-A1EB-4EC0-9585-3AE294E62953}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{015AA962-A1EB-4EC0-9585-3AE294E62953}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{015AA962-A1EB-4EC0-9585-3AE294E62953}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{015AA962-A1EB-4EC0-9585-3AE294E62953}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6605228-5D19-48D0-BA7D-2A69C0C7B8B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6605228-5D19-48D0-BA7D-2A69C0C7B8B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6605228-5D19-48D0-BA7D-2A69C0C7B8B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D6605228-5D19-48D0-BA7D-2A69C0C7B8B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F63290DE-3E70-4EF4-9D84-DA6027635D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F63290DE-3E70-4EF4-9D84-DA6027635D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F63290DE-3E70-4EF4-9D84-DA6027635D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F63290DE-3E70-4EF4-9D84-DA6027635D15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C6DEED66-161D-4CE7-B327-9DB0A6D32439}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
39
Lab3Form/Form1.Designer.cs
generated
Normal file
39
Lab3Form/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace Lab3Form
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
30
Lab3Form/Form1.cs
Normal file
30
Lab3Form/Form1.cs
Normal file
@ -0,0 +1,30 @@
|
||||
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 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 Lab3Form
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
Lab3Form/Form1.resx
Normal file
120
Lab3Form/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>
|
84
Lab3Form/FormFormats.Designer.cs
generated
Normal file
84
Lab3Form/FormFormats.Designer.cs
generated
Normal file
@ -0,0 +1,84 @@
|
||||
namespace Lab3Form
|
||||
{
|
||||
partial class FormFormats
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
NameCol = new DataGridViewTextBoxColumn();
|
||||
Id = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { NameCol, Id });
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 47;
|
||||
dataGridView.Size = new Size(800, 356);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||
dataGridView.UserDeletingRow += dataGridView_UserDeletingRow;
|
||||
dataGridView.KeyUp += dataGridView_KeyUp;
|
||||
//
|
||||
// NameCol
|
||||
//
|
||||
NameCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
NameCol.HeaderText = "Название товара";
|
||||
NameCol.MinimumWidth = 6;
|
||||
NameCol.Name = "NameCol";
|
||||
//
|
||||
// Id
|
||||
//
|
||||
Id.HeaderText = "Id";
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
Id.Width = 125;
|
||||
//
|
||||
// Formcitys
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 356);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "Formcitys";
|
||||
Text = "Выбранные товары";
|
||||
Load += Formcitys_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn NameCol;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
}
|
||||
}
|
106
Lab3Form/FormFormats.cs
Normal file
106
Lab3Form/FormFormats.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using StudentPerformanceContracts.BindingModels;
|
||||
using StudentPerformanceContracts.BusinessLogicContracts;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
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 Lab3Form
|
||||
{
|
||||
public partial class FormFormats : Form
|
||||
{
|
||||
private readonly IFormatLogic _logic;
|
||||
private bool loading = false;
|
||||
|
||||
public FormFormats(IFormatLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
loading = true;
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var city in list)
|
||||
{
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
dataGridView.Rows[rowIndex].Cells[0].Value = city.Name;
|
||||
dataGridView.Rows[rowIndex].Cells[1].Value = city.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Formcitys_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Update(new FormatBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Create(new FormatBindingModel { Id = 0, Name = name.ToString() });
|
||||
int newInterestId = _logic.ReadList(null).ToList().Last().Id;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newInterestId;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
dataGridView.Rows.Add();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRows(DataGridViewSelectedRowCollection rows)
|
||||
{
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
DataGridViewRow row = rows[i];
|
||||
if (!_logic.Delete(new FormatBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
|
||||
}
|
||||
dataGridView.Rows.Clear();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
if (dataGridView.SelectedRows == null) return;
|
||||
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
deleteRows(dataGridView.SelectedRows);
|
||||
}
|
||||
}
|
||||
}
|
126
Lab3Form/FormFormats.resx
Normal file
126
Lab3Form/FormFormats.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?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="NameCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
175
Lab3Form/FormMain.Designer.cs
generated
Normal file
175
Lab3Form/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,175 @@
|
||||
namespace Lab3Form
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <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();
|
||||
menuStrip = new MenuStrip();
|
||||
заказыToolStripMenuItem = new ToolStripMenuItem();
|
||||
создатьToolStripMenuItem = new ToolStripMenuItem();
|
||||
редактироватьToolStripMenuItem = new ToolStripMenuItem();
|
||||
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
документToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСТаблицейToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСДиаграммойToolStripMenuItem = new ToolStripMenuItem();
|
||||
выбранныеТоварыToolStripMenuItem = new ToolStripMenuItem();
|
||||
/* controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();*/
|
||||
pdfTable1 = new FormLibrary.PDFTable(components);
|
||||
excelTableComponent1 = new WinFormsLibraryVolkov.NonVisualComponents.ExcelTableComponent(components);
|
||||
/*componentDocumentWithChartLineWord1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartLineWord(components);*/
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(18, 18);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, отчётыToolStripMenuItem, выбранныеТоварыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
menuStrip.Size = new Size(853, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// заказыToolStripMenuItem
|
||||
//
|
||||
заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem });
|
||||
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||
заказыToolStripMenuItem.Size = new Size(58, 20);
|
||||
заказыToolStripMenuItem.Text = "Заказы";
|
||||
//
|
||||
// создатьToolStripMenuItem
|
||||
//
|
||||
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||
создатьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
создатьToolStripMenuItem.Size = new Size(196, 22);
|
||||
создатьToolStripMenuItem.Text = "Создать";
|
||||
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
|
||||
//
|
||||
// редактироватьToolStripMenuItem
|
||||
//
|
||||
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
|
||||
редактироватьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
редактироватьToolStripMenuItem.Size = new Size(196, 22);
|
||||
редактироватьToolStripMenuItem.Text = "Редактировать";
|
||||
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
удалитьToolStripMenuItem.Size = new Size(196, 22);
|
||||
удалитьToolStripMenuItem.Text = "Удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документToolStripMenuItem, документСТаблицейToolStripMenuItem, документСДиаграммойToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(60, 20);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// документToolStripMenuItem
|
||||
//
|
||||
документToolStripMenuItem.Name = "документToolStripMenuItem";
|
||||
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
документToolStripMenuItem.Size = new Size(309, 22);
|
||||
документToolStripMenuItem.Text = "Документ с простой таблицей";
|
||||
документToolStripMenuItem.Click += GeneratePdfButton_Click;
|
||||
//
|
||||
// документСТаблицейToolStripMenuItem
|
||||
//
|
||||
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
|
||||
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
документСТаблицейToolStripMenuItem.Size = new Size(309, 22);
|
||||
документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам Excel";
|
||||
документСТаблицейToolStripMenuItem.Click += buttonCreateOrderReport_Click;
|
||||
//
|
||||
// документСДиаграммойToolStripMenuItem
|
||||
//
|
||||
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
|
||||
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
документСДиаграммойToolStripMenuItem.Size = new Size(309, 22);
|
||||
документСДиаграммойToolStripMenuItem.Text = "Документ с линейной диаграммой";
|
||||
документСДиаграммойToolStripMenuItem.Click += CreateDocumentButton_Click;
|
||||
//
|
||||
// выбранныеТоварыToolStripMenuItem
|
||||
//
|
||||
выбранныеТоварыToolStripMenuItem.Name = "выбранныеТоварыToolStripMenuItem";
|
||||
выбранныеТоварыToolStripMenuItem.Size = new Size(125, 20);
|
||||
выбранныеТоварыToolStripMenuItem.Text = "Города назначения";
|
||||
выбранныеТоварыToolStripMenuItem.Click += выбранныеТоварыToolStripMenuItem_Click;
|
||||
//
|
||||
// controlDataTable
|
||||
//
|
||||
controlDataTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlDataTable.AutoSize = true;
|
||||
controlDataTable.Location = new Point(0, 24);
|
||||
controlDataTable.Margin = new Padding(4, 3, 4, 3);
|
||||
controlDataTable.Name = "controlDataTable";
|
||||
controlDataTable.SelectedRowIndex = -1;
|
||||
controlDataTable.Size = new Size(853, 419);
|
||||
controlDataTable.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(853, 442);
|
||||
Controls.Add(controlDataTable);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormMain";
|
||||
Text = "Заказы";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem заказыToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||
private ToolStripMenuItem редактироватьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem документToolStripMenuItem;
|
||||
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
|
||||
private ToolStripMenuItem выбранныеТоварыToolStripMenuItem;
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
|
||||
private FormLibrary.PDFTable pdfTable1;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelTableComponent excelTableComponent1;
|
||||
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartLineWord componentDocumentWithChartLineWord1;
|
||||
}
|
||||
}
|
338
Lab3Form/FormMain.cs
Normal file
338
Lab3Form/FormMain.cs
Normal file
@ -0,0 +1,338 @@
|
||||
using StudentPerformanceBusinessLogic.BusinessLogics;
|
||||
using StudentPerformanceContracts.BusinessLogicContracts;
|
||||
using StudentPerformanceContracts.ViewModels;
|
||||
using StudentPerformanceContracts.BindingModels;
|
||||
using StudentPerformanceContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using WinFormsLibraryZhirnova.NonVisualComponents;
|
||||
using ComponentsLibraryNet60.Core;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using FormLibrary.HelperClasses;
|
||||
using FormLibrary;
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
using System.Text;
|
||||
|
||||
namespace Lab3Form
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private IStudentLogic _logic;
|
||||
|
||||
public FormMain(IStudentLogic logic)
|
||||
{
|
||||
controlDataTable.LoadColumns(new List<DataTableColumnConfig>
|
||||
{
|
||||
new DataTableColumnConfig { ColumnHeader = "Идентификатор", PropertyName = "Id", Visible = true, Width = 100 },
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО заказчика", PropertyName = "Fullname", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Город назначения", PropertyName = "DestinationCityName", Visible = true, Width = 150 },
|
||||
new DataTableColumnConfig { ColumnHeader = "История передвижения", PropertyName = "OrderStatusHistory", Visible = true, Width = 250 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Дата выдачи", PropertyName = "ExpectedDeliveryDate", Visible = true, Width = 125 },
|
||||
});
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
controlDataTable.Clear();
|
||||
var orders = _logic.ReadList(null);
|
||||
if (orders != null)
|
||||
{
|
||||
var displayOrders = orders.Select(order => new
|
||||
{
|
||||
order.Id,
|
||||
order.Fullname,
|
||||
order.Format,
|
||||
AverageScore = string.Join(", ", order.AverageScore),
|
||||
order.AdmissionDate
|
||||
}).ToList();
|
||||
controlDataTable.AddTable(displayOrders);
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||
if (service is FormStudent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||
if (service is FormStudent form)
|
||||
{
|
||||
form._id = controlDataTable.GetSelectedObject<StudentSearchModel>().Id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedOrder = controlDataTable.GetSelectedObject<StudentSearchModel>();
|
||||
if (selectedOrder == null)
|
||||
{
|
||||
MessageBox.Show("Не выбрана запись для удаления.");
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
var isDeleted = _logic.Delete(new StudentBindingModel { Id = selectedOrder.Id ?? 0 });
|
||||
if (isDeleted)
|
||||
{
|
||||
LoadData();
|
||||
MessageBox.Show("Запись успешно удалена.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при удалении записи.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GeneratePdfButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var orders = _logic.ReadList(null);
|
||||
|
||||
|
||||
var orderTables = new List<string[,]>();
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
|
||||
int rowCount = order.AverageScore.Count;
|
||||
|
||||
|
||||
string[,] orderTable = new string[rowCount+1, 4];
|
||||
|
||||
|
||||
orderTable[0, 0] = "Средний балл по сессии";
|
||||
orderTable[0, 1] = "Идентификатор студента";
|
||||
orderTable[0, 2] = "Форма обучения";
|
||||
orderTable[0, 3] = "Дата поступления";
|
||||
|
||||
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
{
|
||||
orderTable[i+1, 0] = order.AverageScore[i];
|
||||
orderTable[i+1, 1] = order.Id.ToString();
|
||||
orderTable[i+1, 2] = order.Format;
|
||||
orderTable[i+1, 3] = order.AdmissionDate.ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
|
||||
orderTables.Add(orderTable);
|
||||
}
|
||||
|
||||
|
||||
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
|
||||
saveFileDialog.Title = "Сохранить PDF-документ";
|
||||
saveFileDialog.FileName = "Отчет1.pdf";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
var pdfData = new PdfDocumentData(
|
||||
saveFileDialog.FileName,
|
||||
"Отчет по студентам",
|
||||
orderTables
|
||||
);
|
||||
|
||||
var documentGenerator = new PDFTable();
|
||||
documentGenerator.GeneratePdf(pdfData);
|
||||
|
||||
MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Произошла ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateOrderReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var orders = _logic.ReadList(null);
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Нет заказов для отчета.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var tableData = new List<StudentExcelViewModel>();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (order != null)
|
||||
{
|
||||
tableData.Add(new StudentExcelViewModel(
|
||||
order.Id,
|
||||
order.Fullname,
|
||||
order.Format,
|
||||
order.AdmissionDate
|
||||
));
|
||||
}
|
||||
}
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "OrderReport.xlsx";
|
||||
|
||||
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Title = "Сохранить Excel-документ";
|
||||
saveFileDialog.FileName = "Отчет2.xlsx";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
path = saveFileDialog.FileName;
|
||||
|
||||
MessageBox.Show("Excel-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<(int, int)> merges = new List<(int, int)>
|
||||
{
|
||||
(0,1),
|
||||
(2, 3)
|
||||
};
|
||||
|
||||
List<int> heights = Enumerable.Repeat(20, 4).ToList();
|
||||
|
||||
|
||||
List<(string, string)> headers = new List<(string, string)>
|
||||
{
|
||||
|
||||
("","Данные"),
|
||||
("Id", "Идентификатор"),
|
||||
("Fullname", "ФИО студента"),
|
||||
("", "Студент"),
|
||||
("Format", "Форма обучения"),
|
||||
("AdmissionDate", "Дата поступления")
|
||||
};
|
||||
|
||||
if (merges.Count == 0 || heights.Count == 0 || headers.Count == 0 || tableData.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Недостаточно данных для создания отчета.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"Merges Count: {merges.Count}");
|
||||
Console.WriteLine($"Heights Count: {heights.Count}");
|
||||
Console.WriteLine($"Headers Count: {headers.Count}");
|
||||
Console.WriteLine($"TableData Count: {tableData.Count}");
|
||||
if (excelTableComponent1.createWithTable(path, "Отчет по студентам", merges, heights, headers, tableData))
|
||||
{
|
||||
MessageBox.Show("Отчет успешно создан!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании отчета.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CreateDocumentButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var orders = _logic.ReadList(null).Cast<StudentViewModel>().ToList();
|
||||
|
||||
|
||||
var chartData = new Dictionary<string, List<(DateTime Date, int Count)>>();
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (!chartData.ContainsKey(order.Format))
|
||||
{
|
||||
chartData[order.Format] = new List<(DateTime Date, int Count)>();
|
||||
}
|
||||
|
||||
|
||||
var existingData = chartData[order.Format]
|
||||
.FirstOrDefault(d => d.Date.Date == order.AdmissionDate.Date);
|
||||
|
||||
if (existingData.Date == default)
|
||||
{
|
||||
chartData[order.Format].Add((order.AdmissionDate.Date, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int index = chartData[order.Format].FindIndex(d => d.Date.Date == order.AdmissionDate.Date);
|
||||
var updatedValue = chartData[order.Format][index];
|
||||
chartData[order.Format][index] = (updatedValue.Date, updatedValue.Count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
string filePath = "Отчет3.docx";
|
||||
|
||||
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Title = "Сохранить Word-документ";
|
||||
saveFileDialog.FileName = "Отчет3.docx";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
filePath = saveFileDialog.FileName;
|
||||
|
||||
MessageBox.Show("Docx-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
var config = new ComponentDocumentWithChartConfig
|
||||
{
|
||||
ChartTitle = "Отчет по заказам",
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||
Data = chartData.ToDictionary(
|
||||
entry => entry.Key,
|
||||
entry => entry.Value.Select(d => (DateTimeToInt(d.Date), (double)d.Count)).ToList()),
|
||||
FilePath = filePath,
|
||||
Header = "Заголовок отчета"
|
||||
|
||||
};
|
||||
|
||||
|
||||
var documentComponent = new ComponentDocumentWithChartLineWord();
|
||||
|
||||
|
||||
documentComponent.CreateDoc(config);
|
||||
|
||||
MessageBox.Show("Документ создан успешно!");
|
||||
}
|
||||
private int DateTimeToInt(DateTime date)
|
||||
{
|
||||
return date.Day;
|
||||
}
|
||||
|
||||
|
||||
private void выбранныеТоварыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFormats));
|
||||
if (service is FormFormats form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
135
Lab3Form/FormMain.resx
Normal file
135
Lab3Form/FormMain.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>126, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelTableComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>231, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithChartLineWord1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>409, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>177</value>
|
||||
</metadata>
|
||||
</root>
|
177
Lab3Form/FormStudent.Designer.cs
generated
Normal file
177
Lab3Form/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,177 @@
|
||||
namespace Lab3Form
|
||||
{
|
||||
partial class FormStudent
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelFIO = new Label();
|
||||
textBoxFIO = new TextBox();
|
||||
labelcity = new Label();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
customListBox1 = new FormLibrary.CustomListBox();
|
||||
customInputRangeDate1 = new WinFormsLibraryVolkov.CustomInputRangeDate();
|
||||
listBox1 = new ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(10, 7);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(91, 15);
|
||||
labelFIO.TabIndex = 0;
|
||||
labelFIO.Text = "ФИО заказчика";
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(10, 24);
|
||||
textBoxFIO.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(241, 23);
|
||||
textBoxFIO.TabIndex = 1;
|
||||
//
|
||||
// labelcity
|
||||
//
|
||||
labelcity.AutoSize = true;
|
||||
labelcity.Location = new Point(10, 62);
|
||||
labelcity.Name = "labelcity";
|
||||
labelcity.Size = new Size(107, 15);
|
||||
labelcity.TabIndex = 4;
|
||||
labelcity.Text = "Город назначения";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(161, 414);
|
||||
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(83, 21);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(7, 414);
|
||||
buttonSave.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 21);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Multiselect = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(10, 360);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(132, 15);
|
||||
label1.TabIndex = 10;
|
||||
label1.Text = "Дата получения заказа";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(10, 264);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(123, 15);
|
||||
label2.TabIndex = 12;
|
||||
label2.Text = "Точки передвижения";
|
||||
//
|
||||
// customListBox1
|
||||
//
|
||||
customListBox1.Location = new Point(10, 80);
|
||||
customListBox1.Name = "customListBox1";
|
||||
customListBox1.SelectedItem = "";
|
||||
customListBox1.Size = new Size(237, 179);
|
||||
customListBox1.TabIndex = 17;
|
||||
//
|
||||
// customInputRangeDate1
|
||||
//
|
||||
customInputRangeDate1.Location = new Point(10, 378);
|
||||
customInputRangeDate1.MaxDate = new DateTime(0L);
|
||||
customInputRangeDate1.MinDate = new DateTime(0L);
|
||||
customInputRangeDate1.Name = "customInputRangeDate1";
|
||||
customInputRangeDate1.Size = new Size(199, 31);
|
||||
customInputRangeDate1.TabIndex = 18;
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
listBox1.FormattingEnabled = true;
|
||||
listBox1.ItemHeight = 15;
|
||||
listBox1.Location = new Point(13, 282);
|
||||
listBox1.Name = "listBox1";
|
||||
listBox1.SelectionMode = SelectionMode.MultiExtended;
|
||||
listBox1.Size = new Size(231, 64);
|
||||
listBox1.TabIndex = 19;
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(256, 459);
|
||||
Controls.Add(listBox1);
|
||||
Controls.Add(customInputRangeDate1);
|
||||
Controls.Add(customListBox1);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(labelcity);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(labelFIO);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormOrder";
|
||||
Text = "Заказ";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelcity;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private FormLibrary.CustomListBox customListBox1;
|
||||
private WinFormsLibraryZhirnova.CustomInputRangeDate customInputRangeDate1;
|
||||
private ListBox listBox1;
|
||||
}
|
||||
}
|
120
Lab3Form/FormStudent.cs
Normal file
120
Lab3Form/FormStudent.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using StudentPerformanceContracts.BindingModels;
|
||||
using StudentPerformanceContracts.BusinessLogicContracts;
|
||||
using StudentPerformanceContracts.SearchModels;
|
||||
using StudentPerformanceContracts.ViewModels;
|
||||
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 Lab3Form
|
||||
{
|
||||
public partial class FormStudent : Form
|
||||
{
|
||||
public int? _id;
|
||||
private readonly IStudentLogic _logic;
|
||||
private readonly IFormatLogic _formatLogic;
|
||||
private List<FormatViewModel> _Formats;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormStudent(IStudentLogic logic, IFormatLogic formatLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logic = logic;
|
||||
_formatLogic = formatLogic;
|
||||
_Formats = new List<FormatViewModel>();
|
||||
_Formats = _formatLogic.ReadList(null);
|
||||
var cityNames = _Formats.Select(city => city.Name).ToList();
|
||||
customListBox1.PopulateListBox(cityNames);
|
||||
var orderStatuses = new List<string> { "Очное", "Заочное", "Очно-заочное", "Дистанционное" };
|
||||
listBox1.Items.AddRange(orderStatuses.ToArray());
|
||||
DateTime now = DateTime.Now;
|
||||
customInputRangeDate1.MinDate = now.AddYears(-6);
|
||||
customInputRangeDate1.MaxDate = now;
|
||||
this.Load += FormOrder_Load;
|
||||
}
|
||||
|
||||
private void FormOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
StudentSearchModel searchModel = new StudentSearchModel { Id = _id.Value };
|
||||
StudentViewModel orderViewModel = _logic.ReadElement(searchModel);
|
||||
|
||||
if (orderViewModel != null)
|
||||
{
|
||||
textBoxFIO.Text = orderViewModel.Fullname;
|
||||
|
||||
FormatViewModel selectedCity = _Formats.FirstOrDefault(city => city.Id == orderViewModel.FormatId);
|
||||
if (selectedCity != null)
|
||||
{
|
||||
customListBox1.SelectedItem = selectedCity.Name;
|
||||
}
|
||||
|
||||
customInputRangeDate1.Date = orderViewModel.AdmissionDate;
|
||||
|
||||
foreach (string status in orderViewModel.AverageScore)
|
||||
{
|
||||
int index = listBox1.Items.IndexOf(status);
|
||||
if (index != -1)
|
||||
{
|
||||
listBox1.SetSelected(index, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Студент с указанным ID не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО студента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (customListBox1.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Укажите форму обучения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new StudentBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fullname = textBoxFIO.Text,
|
||||
FormatId = _Formats.First(x => x.Name == customListBox1.SelectedItem).Id,
|
||||
AdmissionDate = customInputRangeDate1.Date,
|
||||
AverageScore = listBox1.SelectedItems.Cast<string>().ToList(),
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Возникла ошибка при сохранении. Дополнительная информация в логах");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Успешное сохранение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
Lab3Form/FormStudent.resx
Normal file
126
Lab3Form/FormStudent.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?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="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>90</value>
|
||||
</metadata>
|
||||
</root>
|
27
Lab3Form/Lab3Form.csproj
Normal file
27
Lab3Form/Lab3Form.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="WinFormsLibraryZhirnova" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FormLibrary\FormLibrary.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceBusinessLogic\StudentPerformanceBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceContracts\StudentPerformanceContracts.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceDatabaseImplement\StudentPerformanceDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceDataModels\StudentPerformanceDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
38
Lab3Form/Program.cs
Normal file
38
Lab3Form/Program.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StudentPerformanceBusinessLogic.BusinessLogics;
|
||||
using StudentPerformanceContracts.BusinessLogicContracts;
|
||||
using StudentPerformanceContracts.StorageContracts;
|
||||
using StudentPerformanceDatabaseImplement.Implements;
|
||||
|
||||
namespace Lab3Form
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <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();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IFormatStorage, FormatStorage>();
|
||||
services.AddTransient<IStudentStorage, StudentStorage>();
|
||||
services.AddTransient<IFormatLogic, FormatLogic>();
|
||||
services.AddTransient<IStudentLogic, StudentLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormStudent>();
|
||||
services.AddTransient<FormFormats>();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Plugins/ComponentsLibraryNet60.dll
Normal file
BIN
Plugins/ComponentsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
Plugins/ControlsLibraryNet60.dll
Normal file
BIN
Plugins/ControlsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
Plugins/DocumentFormat.OpenXml.dll
Normal file
BIN
Plugins/DocumentFormat.OpenXml.dll
Normal file
Binary file not shown.
BIN
Plugins/FormLibrary.dll
Normal file
BIN
Plugins/FormLibrary.dll
Normal file
Binary file not shown.
BIN
Plugins/Humanizer.dll
Normal file
BIN
Plugins/Humanizer.dll
Normal file
Binary file not shown.
BIN
Plugins/Lab3Form.dll
Normal file
BIN
Plugins/Lab3Form.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
BIN
Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
BIN
Plugins/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.CodeAnalysis.CSharp.dll
Normal file
BIN
Plugins/Microsoft.CodeAnalysis.CSharp.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
BIN
Plugins/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.CodeAnalysis.dll
Normal file
BIN
Plugins/Microsoft.CodeAnalysis.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
BIN
Plugins/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Configuration.Abstractions.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Configuration.Abstractions.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Logging.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Options.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
Plugins/Microsoft.Extensions.Primitives.dll
Normal file
BIN
Plugins/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
BIN
Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
Binary file not shown.
BIN
Plugins/MigraDoc.Rendering.dll
Normal file
BIN
Plugins/MigraDoc.Rendering.dll
Normal file
Binary file not shown.
BIN
Plugins/Mono.TextTemplating.dll
Normal file
BIN
Plugins/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
BIN
Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
Binary file not shown.
BIN
Plugins/Npgsql.dll
Normal file
BIN
Plugins/Npgsql.dll
Normal file
Binary file not shown.
BIN
Plugins/OxyPlot.WindowsForms.dll
Normal file
BIN
Plugins/OxyPlot.WindowsForms.dll
Normal file
Binary file not shown.
BIN
Plugins/OxyPlot.Wpf.Shared.dll
Normal file
BIN
Plugins/OxyPlot.Wpf.Shared.dll
Normal file
Binary file not shown.
BIN
Plugins/OxyPlot.Wpf.dll
Normal file
BIN
Plugins/OxyPlot.Wpf.dll
Normal file
Binary file not shown.
BIN
Plugins/OxyPlot.dll
Normal file
BIN
Plugins/OxyPlot.dll
Normal file
Binary file not shown.
BIN
Plugins/PdfSharp.Charting.dll
Normal file
BIN
Plugins/PdfSharp.Charting.dll
Normal file
Binary file not shown.
BIN
Plugins/PdfSharp.dll
Normal file
BIN
Plugins/PdfSharp.dll
Normal file
Binary file not shown.
BIN
Plugins/PluginsConventionLibrary.dll
Normal file
BIN
Plugins/PluginsConventionLibrary.dll
Normal file
Binary file not shown.
BIN
Plugins/StudentPerformanceBusinessLogic.dll
Normal file
BIN
Plugins/StudentPerformanceBusinessLogic.dll
Normal file
Binary file not shown.
BIN
Plugins/StudentPerformanceContracts.dll
Normal file
BIN
Plugins/StudentPerformanceContracts.dll
Normal file
Binary file not shown.
BIN
Plugins/StudentPerformanceDataModels.dll
Normal file
BIN
Plugins/StudentPerformanceDataModels.dll
Normal file
Binary file not shown.
BIN
Plugins/StudentPerformanceDatabaseImplement.dll
Normal file
BIN
Plugins/StudentPerformanceDatabaseImplement.dll
Normal file
Binary file not shown.
BIN
Plugins/System.ComponentModel.Composition.dll
Normal file
BIN
Plugins/System.ComponentModel.Composition.dll
Normal file
Binary file not shown.
BIN
Plugins/System.Composition.AttributedModel.dll
Normal file
BIN
Plugins/System.Composition.AttributedModel.dll
Normal file
Binary file not shown.
BIN
Plugins/System.Composition.Convention.dll
Normal file
BIN
Plugins/System.Composition.Convention.dll
Normal file
Binary file not shown.
BIN
Plugins/System.Composition.Hosting.dll
Normal file
BIN
Plugins/System.Composition.Hosting.dll
Normal file
Binary file not shown.
BIN
Plugins/System.Composition.Runtime.dll
Normal file
BIN
Plugins/System.Composition.Runtime.dll
Normal file
Binary file not shown.
BIN
Plugins/System.Composition.TypedParts.dll
Normal file
BIN
Plugins/System.Composition.TypedParts.dll
Normal file
Binary file not shown.
BIN
Plugins/System.IO.Pipelines.dll
Normal file
BIN
Plugins/System.IO.Pipelines.dll
Normal file
Binary file not shown.
BIN
Plugins/WinFormsLibraryVolkov.dll
Normal file
BIN
Plugins/WinFormsLibraryVolkov.dll
Normal file
Binary file not shown.
20
PluginsConventionLibrary/MainPluginConventionElement.cs
Normal file
20
PluginsConventionLibrary/MainPluginConventionElement.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class MainPluginConventionElement : PluginsConventionElement
|
||||
{
|
||||
public string ProductCategoryName { get; set; }
|
||||
|
||||
public string PhotoFilePath { get; set; }
|
||||
|
||||
public string FIO { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
65
PluginsConventionLibrary/Plugins/IPluginsConvention.cs
Normal file
65
PluginsConventionLibrary/Plugins/IPluginsConvention.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
/// <summary>
|
||||
/// Название плагина
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
/// <summary>
|
||||
/// Получение контрола для вывода набора данных
|
||||
/// </summary>
|
||||
UserControl GetControl { get; }
|
||||
/// <summary>
|
||||
/// Получение элемента, выбранного в контроле
|
||||
/// </summary>
|
||||
PluginsConventionElement GetElement { get; }
|
||||
/// <summary>
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Получение формы для работы со справочником
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Form GetThesaurus();
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument
|
||||
saveDocument);
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
13
PluginsConventionLibrary/Plugins/PluginsConventionElement.cs
Normal file
13
PluginsConventionLibrary/Plugins/PluginsConventionElement.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
22
PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
22
PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StudentPerformanceBusinessLogic\StudentPerformanceBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceContracts\StudentPerformanceContracts.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceDatabaseImplement\StudentPerformanceDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\StudentPerformanceDataModels\StudentPerformanceDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
191
StudentPerformanceAppPlugins/FormMain.Designer.cs
generated
Normal file
191
StudentPerformanceAppPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StudentPerformanceAppPlugins
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.panelControl = new System.Windows.Forms.Panel();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ControlsStripMenuItem,
|
||||
this.ActionsToolStripMenuItem,
|
||||
this.DocsToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||
this.menuStrip.Size = new System.Drawing.Size(914, 30);
|
||||
this.menuStrip.TabIndex = 0;
|
||||
this.menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
this.ControlsStripMenuItem.Size = new System.Drawing.Size(113, 24);
|
||||
this.ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ThesaurusToolStripMenuItem,
|
||||
this.AddElementToolStripMenuItem,
|
||||
this.UpdElementToolStripMenuItem,
|
||||
this.DelElementToolStripMenuItem});
|
||||
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
|
||||
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
|
||||
this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
this.ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||
this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.AddElementToolStripMenuItem.Text = "Добавить";
|
||||
this.AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||
this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
this.UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||
this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||
this.DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SimpleDocToolStripMenuItem,
|
||||
this.TableDocToolStripMenuItem,
|
||||
this.ChartDocToolStripMenuItem});
|
||||
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
|
||||
this.DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
this.SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||
this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.TableDocToolStripMenuItem.Text = "Документ с таблицей";
|
||||
this.TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
this.ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelControl.Location = new System.Drawing.Point(0, 30);
|
||||
this.panelControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelControl.Name = "panelControl";
|
||||
this.panelControl.Size = new System.Drawing.Size(914, 570);
|
||||
this.panelControl.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(914, 600);
|
||||
this.Controls.Add(this.panelControl);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Главная форма";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panelControl;
|
||||
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
}
|
||||
}
|
227
StudentPerformanceAppPlugins/FormMain.cs
Normal file
227
StudentPerformanceAppPlugins/FormMain.cs
Normal file
@ -0,0 +1,227 @@
|
||||
using PluginsConventionLibrary;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
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 StudentPerformanceAppPlugins
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
private string _selectedPlugin;
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
_plugins = LoadPlugins();
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
|
||||
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||
{
|
||||
var plugins = new Dictionary<string, IPluginsConvention>();
|
||||
|
||||
string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.Parent!.FullName + "\\Plugins";
|
||||
|
||||
string[] dllFiles = Directory.GetFiles(pluginsDir, "*.dll", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string dllFile in dllFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||
{
|
||||
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||
plugins.Add(plugin.PluginName, plugin);
|
||||
CreateMenuItem(plugin.PluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при загрузке сборки {dllFile}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private void CreateMenuItem(string pluginName)
|
||||
{
|
||||
ToolStripMenuItem menuItem = new(pluginName);
|
||||
menuItem.Click += (object? sender, EventArgs e) =>
|
||||
{
|
||||
UserControl userControl = _plugins[pluginName].GetControl;
|
||||
if (userControl != null)
|
||||
{
|
||||
panelControl.Controls.Clear();
|
||||
userControl.Dock = DockStyle.Fill;
|
||||
_plugins[pluginName].ReloadData();
|
||||
_selectedPlugin = pluginName;
|
||||
panelControl.Controls.Add(userControl);
|
||||
}
|
||||
};
|
||||
ControlsStripMenuItem.DropDownItems.Add(menuItem);
|
||||
}
|
||||
|
||||
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_selectedPlugin) ||
|
||||
!_plugins.ContainsKey(_selectedPlugin))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.I:
|
||||
ShowThesaurus();
|
||||
break;
|
||||
case Keys.A:
|
||||
AddNewElement();
|
||||
break;
|
||||
case Keys.U:
|
||||
UpdateElement();
|
||||
break;
|
||||
case Keys.D:
|
||||
DeleteElement();
|
||||
break;
|
||||
case Keys.S:
|
||||
CreateSimpleDoc();
|
||||
break;
|
||||
case Keys.T:
|
||||
CreateTableDoc();
|
||||
break;
|
||||
case Keys.C:
|
||||
CreateChartDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowThesaurus()
|
||||
{
|
||||
_plugins[_selectedPlugin].GetThesaurus()?.Show();
|
||||
}
|
||||
|
||||
private void AddNewElement()
|
||||
{
|
||||
var form = _plugins[_selectedPlugin].GetForm(null);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElement()
|
||||
{
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для обновления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
var form = _plugins[_selectedPlugin].GetForm(element);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteElement()
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Удалить выбранный элемент?",
|
||||
"Удаление",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для удаления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (_plugins[_selectedPlugin].DeleteElement(element))
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSimpleDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
}
|
||||
}
|
||||
|
||||
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
|
||||
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
|
||||
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
|
||||
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
|
||||
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
|
||||
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
|
||||
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user