Что-то начало работать
This commit is contained in:
parent
17b1ec82f5
commit
7ac053add7
@ -1,15 +0,0 @@
|
||||
<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>
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
80
ExecForm/Form1.Designer.cs
generated
80
ExecForm/Form1.Designer.cs
generated
@ -1,80 +0,0 @@
|
||||
namespace ExecForm
|
||||
{
|
||||
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()
|
||||
{
|
||||
chooseList1 = new Library14Petrushin.ChooseList();
|
||||
hierarchicalTreeView1 = new Library14Petrushin.HierarchicalTreeView();
|
||||
textBoxRange1 = new Library14Petrushin.TextBoxRange();
|
||||
SuspendLayout();
|
||||
//
|
||||
// chooseList1
|
||||
//
|
||||
chooseList1.Location = new Point(12, 12);
|
||||
chooseList1.Name = "chooseList1";
|
||||
chooseList1.SelectedValue = "";
|
||||
chooseList1.Size = new Size(185, 190);
|
||||
chooseList1.TabIndex = 0;
|
||||
//
|
||||
// hierarchicalTreeView1
|
||||
//
|
||||
hierarchicalTreeView1.Location = new Point(567, 2);
|
||||
hierarchicalTreeView1.Name = "hierarchicalTreeView1";
|
||||
hierarchicalTreeView1.SelectedNodeIndex = -1;
|
||||
hierarchicalTreeView1.Size = new Size(266, 504);
|
||||
hierarchicalTreeView1.TabIndex = 2;
|
||||
//
|
||||
// textBoxRange1
|
||||
//
|
||||
textBoxRange1.Location = new Point(254, 21);
|
||||
textBoxRange1.MaxLength = null;
|
||||
textBoxRange1.MinLength = null;
|
||||
textBoxRange1.Name = "textBoxRange1";
|
||||
textBoxRange1.Size = new Size(259, 118);
|
||||
textBoxRange1.TabIndex = 3;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(834, 507);
|
||||
Controls.Add(textBoxRange1);
|
||||
Controls.Add(hierarchicalTreeView1);
|
||||
Controls.Add(chooseList1);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Library14Petrushin.ChooseList chooseList1;
|
||||
private Library14Petrushin.HierarchicalTreeView hierarchicalTreeView1;
|
||||
private Library14Petrushin.TextBoxRange textBoxRange1;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using Library14Petrushin.Classes;
|
||||
using Library14Petrushin;
|
||||
|
||||
namespace ExecForm
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
// Íàñòðîéêà êîìïîíåíòîâ
|
||||
chooseList1.AddItemToList("Item 1");
|
||||
chooseList1.AddItemToList("Item 2");
|
||||
chooseList1.AddItemToList("Item 3");
|
||||
|
||||
textBoxRange1.MinLength = 3;
|
||||
textBoxRange1.MaxLength = 10;
|
||||
|
||||
var hierarchy = new List<string> { "Department", "Position", "FullName" };
|
||||
var alwaysNewBranch = new Dictionary<string, bool> { { "FullName", true } };
|
||||
hierarchicalTreeView1.SetHierarchy(hierarchy, alwaysNewBranch);
|
||||
|
||||
var employees = new List<Employee>
|
||||
{
|
||||
new Employee { Department = "IT", Position = "Developer", FullName = "John Doe" },
|
||||
new Employee { Department = "HR", Position = "Manager", FullName = "Jane Smith" }
|
||||
};
|
||||
|
||||
// Çàïîëíåíèå äåðåâà ñ èñïîëüçîâàíèåì AddObjectToTree
|
||||
foreach (var employee in employees)
|
||||
{
|
||||
hierarchicalTreeView1.AddObjectToTree(employee, hierarchy.Last());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
@ -1,17 +0,0 @@
|
||||
namespace ExecForm
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<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>
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
152
ExexForm2/Form1.Designer.cs
generated
152
ExexForm2/Form1.Designer.cs
generated
@ -1,152 +0,0 @@
|
||||
namespace ExexForm2
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
pdfImg1 = new Library14Petrushin.PdfImg(components);
|
||||
btnSelectImages = new Button();
|
||||
btnSelectDirectory = new Button();
|
||||
btnCreatePdf = new Button();
|
||||
txtDocumentTitle = new TextBox();
|
||||
lstImages = new ListBox();
|
||||
lblDirectory = new Label();
|
||||
btnCrTb = new Button();
|
||||
pdfColGroupTable1 = new Library14Petrushin.PdfColGroupTable();
|
||||
pdfCirclDiagr1 = new Library14Petrushin.PdfCirclDiagr();
|
||||
btnCircl = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// btnSelectImages
|
||||
//
|
||||
btnSelectImages.Location = new Point(24, 28);
|
||||
btnSelectImages.Name = "btnSelectImages";
|
||||
btnSelectImages.Size = new Size(116, 50);
|
||||
btnSelectImages.TabIndex = 0;
|
||||
btnSelectImages.Text = "выбор изображения";
|
||||
btnSelectImages.UseVisualStyleBackColor = true;
|
||||
btnSelectImages.Click += btnSelectImages_Click;
|
||||
//
|
||||
// btnSelectDirectory
|
||||
//
|
||||
btnSelectDirectory.Location = new Point(24, 89);
|
||||
btnSelectDirectory.Name = "btnSelectDirectory";
|
||||
btnSelectDirectory.Size = new Size(116, 49);
|
||||
btnSelectDirectory.TabIndex = 1;
|
||||
btnSelectDirectory.Text = "выбор директории";
|
||||
btnSelectDirectory.UseVisualStyleBackColor = true;
|
||||
btnSelectDirectory.Click += btnSelectDirectory_Click;
|
||||
//
|
||||
// btnCreatePdf
|
||||
//
|
||||
btnCreatePdf.Location = new Point(24, 158);
|
||||
btnCreatePdf.Name = "btnCreatePdf";
|
||||
btnCreatePdf.Size = new Size(101, 48);
|
||||
btnCreatePdf.TabIndex = 2;
|
||||
btnCreatePdf.Text = "Создать";
|
||||
btnCreatePdf.UseVisualStyleBackColor = true;
|
||||
btnCreatePdf.Click += btnCreatePdf_Click;
|
||||
//
|
||||
// txtDocumentTitle
|
||||
//
|
||||
txtDocumentTitle.Location = new Point(24, 224);
|
||||
txtDocumentTitle.Name = "txtDocumentTitle";
|
||||
txtDocumentTitle.Size = new Size(101, 27);
|
||||
txtDocumentTitle.TabIndex = 3;
|
||||
//
|
||||
// lstImages
|
||||
//
|
||||
lstImages.FormattingEnabled = true;
|
||||
lstImages.Location = new Point(146, 28);
|
||||
lstImages.Name = "lstImages";
|
||||
lstImages.Size = new Size(179, 404);
|
||||
lstImages.TabIndex = 4;
|
||||
//
|
||||
// lblDirectory
|
||||
//
|
||||
lblDirectory.AutoSize = true;
|
||||
lblDirectory.Location = new Point(24, 280);
|
||||
lblDirectory.Name = "lblDirectory";
|
||||
lblDirectory.Size = new Size(50, 20);
|
||||
lblDirectory.TabIndex = 5;
|
||||
lblDirectory.Text = "label1";
|
||||
//
|
||||
// btnCrTb
|
||||
//
|
||||
btnCrTb.Location = new Point(349, 28);
|
||||
btnCrTb.Name = "btnCrTb";
|
||||
btnCrTb.Size = new Size(142, 29);
|
||||
btnCrTb.TabIndex = 6;
|
||||
btnCrTb.Text = "Создать таблицу";
|
||||
btnCrTb.UseVisualStyleBackColor = true;
|
||||
btnCrTb.Click += btnCreatePdfTable_Click;
|
||||
//
|
||||
// btnCircl
|
||||
//
|
||||
btnCircl.Location = new Point(606, 28);
|
||||
btnCircl.Name = "btnCircl";
|
||||
btnCircl.Size = new Size(161, 29);
|
||||
btnCircl.TabIndex = 7;
|
||||
btnCircl.Text = "Создать диаграмму";
|
||||
btnCircl.UseVisualStyleBackColor = true;
|
||||
btnCircl.Click += btnCreatePdfCircl_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(btnCircl);
|
||||
Controls.Add(btnCrTb);
|
||||
Controls.Add(lblDirectory);
|
||||
Controls.Add(lstImages);
|
||||
Controls.Add(txtDocumentTitle);
|
||||
Controls.Add(btnCreatePdf);
|
||||
Controls.Add(btnSelectDirectory);
|
||||
Controls.Add(btnSelectImages);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Library14Petrushin.PdfImg pdfImg1;
|
||||
private Button btnSelectImages;
|
||||
private Button btnSelectDirectory;
|
||||
private Button btnCreatePdf;
|
||||
private TextBox txtDocumentTitle;
|
||||
private ListBox lstImages;
|
||||
private Label lblDirectory;
|
||||
private Button btnCrTb;
|
||||
private Library14Petrushin.PdfColGroupTable pdfColGroupTable1;
|
||||
private Library14Petrushin.PdfCirclDiagr pdfCirclDiagr1;
|
||||
private Button btnCircl;
|
||||
}
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
using Library14Petrushin;
|
||||
using Library14Petrushin.Classes;
|
||||
|
||||
namespace ExexForm2
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private PdfImg pdfImg;
|
||||
private List<ImageData> selectedImages;
|
||||
private string selectedDirectory;
|
||||
private PdfColGroupTable pdfTable;
|
||||
private PdfCirclDiagr pdfCirclDiagr;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
pdfImg = new PdfImg();
|
||||
selectedImages = new List<ImageData>();
|
||||
pdfTable = new PdfColGroupTable();
|
||||
pdfCirclDiagr = new PdfCirclDiagr();
|
||||
}
|
||||
|
||||
private void btnSelectImages_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
|
||||
openFileDialog.Multiselect = true;
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
foreach (string fileName in openFileDialog.FileNames)
|
||||
{
|
||||
selectedImages.Add(new ImageData { ImagePath = fileName });
|
||||
lstImages.Items.Add(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSelectDirectory_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
||||
{
|
||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectedDirectory = folderBrowserDialog.SelectedPath;
|
||||
lblDirectory.Text = "Selected Directory: " + selectedDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCreatePdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtDocumentTitle.Text) || selectedImages.Count == 0 || string.IsNullOrEmpty(selectedDirectory))
|
||||
{
|
||||
MessageBox.Show("Please select images, directory, and enter a document title.");
|
||||
return;
|
||||
}
|
||||
|
||||
string fileName = Path.Combine(selectedDirectory, "output1.pdf");
|
||||
pdfImg.CreatePdfDocument(fileName, txtDocumentTitle.Text, selectedImages);
|
||||
MessageBox.Show("PDF document created successfully!");
|
||||
}
|
||||
|
||||
|
||||
// 2 -------------------------------------------
|
||||
|
||||
|
||||
private void btnCreatePdfTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
string selectDirTable = "";
|
||||
string fileName = "";
|
||||
|
||||
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
||||
{
|
||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectDirTable = folderBrowserDialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||
saveFileDialog.DefaultExt = "pdf";
|
||||
saveFileDialog.InitialDirectory = selectDirTable;
|
||||
saveFileDialog.FileName = "output2.pdf";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = saveFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
var generator = new PdfColGroupTable();
|
||||
|
||||
var data1 = new List<Person>
|
||||
{
|
||||
new Person { FirstName = "John", LastName = "Doe", Age = 30 },
|
||||
new Person { FirstName = "Jane", LastName = "Smith", Age = 25 }
|
||||
};
|
||||
|
||||
var commonHeaders = new List<string> { "Name", "", "" };
|
||||
var headersNames = new List<(string, string)> {
|
||||
("First Name","FirstName"),
|
||||
("Last Name", "LastName"),
|
||||
("Age", "Age")
|
||||
};
|
||||
var rowHeights = new List<double> { 20, 20 };
|
||||
var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)>
|
||||
{
|
||||
(0, 1, 0, 0), // 0 è 1 ÿ÷åéêè ïî âåðòèêàëè ïåðâîé êîëîíêè
|
||||
(2, 2, 0, 1)
|
||||
};
|
||||
|
||||
generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headersNames, commonHeaders, data1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 3 -------------------------------------------
|
||||
|
||||
|
||||
private void btnCreatePdfCircl_Click(object sender, EventArgs e)
|
||||
{
|
||||
string selectDir = "";
|
||||
string fileName = "";
|
||||
|
||||
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
||||
{
|
||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectDir = folderBrowserDialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||
saveFileDialog.DefaultExt = "pdf";
|
||||
saveFileDialog.InitialDirectory = selectDir;
|
||||
saveFileDialog.FileName = "output3.pdf";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = saveFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
var pdfCirclDiagr = new PdfCirclDiagr();
|
||||
|
||||
List<ChartData> chartData = new List<ChartData>
|
||||
{
|
||||
new ChartData { SeriesName = "Series 1", Value = 10 },
|
||||
new ChartData { SeriesName = "Series 2", Value = 20 },
|
||||
new ChartData { SeriesName = "Series 3", Value = 30 },
|
||||
new ChartData { SeriesName = "Series 4", Value = 40 }
|
||||
};
|
||||
|
||||
pdfCirclDiagr.GeneratePdf(fileName, "Document Title", "Chart Title", LegendPosition.Right, chartData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
<?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="pdfImg1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfColGroupTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>130, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfCirclDiagr1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>315, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,17 +0,0 @@
|
||||
namespace ExexForm2
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
173
Laba3/FormMain.Designer.cs
generated
Normal file
173
Laba3/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
using DocumentFormat.OpenXml.Office2010.CustomUI;
|
||||
using Microsoft.Vbe.Interop;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace View
|
||||
{
|
||||
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()
|
||||
{
|
||||
panelControl = new Panel();
|
||||
ControlsStripMenuItem = new ToolStripMenuItem();
|
||||
ActionsToolStripMenuItem = new ToolStripMenuItem();
|
||||
AddElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
UpdElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DelElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DocsToolStripMenuItem = new ToolStripMenuItem();
|
||||
WordDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
TableDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
ChartDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip = new MenuStrip();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
panelControl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
panelControl.BackColor = SystemColors.Info;
|
||||
panelControl.Location = new Point(14, 36);
|
||||
panelControl.Margin = new Padding(3, 4, 3, 4);
|
||||
panelControl.Name = "panelControl";
|
||||
panelControl.Size = new Size(1024, 236);
|
||||
panelControl.TabIndex = 2;
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
ControlsStripMenuItem.Size = new Size(113, 26);
|
||||
ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
|
||||
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
ActionsToolStripMenuItem.Size = new Size(88, 26);
|
||||
ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
AddElementToolStripMenuItem.Size = new Size(213, 26);
|
||||
AddElementToolStripMenuItem.Text = "Добавить";
|
||||
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
UpdElementToolStripMenuItem.Size = new Size(213, 26);
|
||||
UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
DelElementToolStripMenuItem.Size = new Size(213, 26);
|
||||
DelElementToolStripMenuItem.Text = "Удалить";
|
||||
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { WordDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
|
||||
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
DocsToolStripMenuItem.Size = new Size(101, 26);
|
||||
DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// WordDocToolStripMenuItem
|
||||
//
|
||||
WordDocToolStripMenuItem.Name = "WordDocToolStripMenuItem";
|
||||
WordDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
WordDocToolStripMenuItem.Size = new Size(291, 26);
|
||||
WordDocToolStripMenuItem.Text = "Диаграмма ворд";
|
||||
WordDocToolStripMenuItem.Click += WordDocToolStripMenuItem_Click;
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
TableDocToolStripMenuItem.Size = new Size(291, 26);
|
||||
TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
ChartDocToolStripMenuItem.Size = new Size(291, 26);
|
||||
ChartDocToolStripMenuItem.Text = "Текст пдф";
|
||||
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.AutoSize = false;
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||
menuStrip.Size = new Size(1051, 32);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1051, 288);
|
||||
Controls.Add(panelControl);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Главная форма";
|
||||
KeyDown += FormMain_KeyDown;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Panel panelControl;
|
||||
private ToolStripMenuItem ControlsStripMenuItem;
|
||||
private ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
private ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private ToolStripMenuItem WordDocToolStripMenuItem;
|
||||
private ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private MenuStrip menuStrip;
|
||||
private Library14Petrushin.PdfImg pdfImg;
|
||||
private Library15Gerimovich.WordDiagramComponent wordDiagramComponent;
|
||||
private WinFormsLibrary1.ComponentTable componentTable;
|
||||
}
|
||||
}
|
256
Laba3/FormMain.cs
Normal file
256
Laba3/FormMain.cs
Normal file
@ -0,0 +1,256 @@
|
||||
using Data.Models;
|
||||
using Library14Petrushin;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using Library15Gerimovich;
|
||||
using WinFormsLibrary1;
|
||||
using WinFormsLibrary1.Models;
|
||||
using View.ViewModels;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System.Reflection;
|
||||
|
||||
namespace View
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
private string _selectedPlugin;
|
||||
private ContextMenuStrip contextMenu = new ContextMenuStrip();
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_plugins = LoadPlugins();
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
|
||||
/*private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||
{
|
||||
PluginsManager manager = new PluginsManager();
|
||||
var plugins = manager.plugins_dictionary;
|
||||
|
||||
ToolStripItem[] toolStripItems = new ToolStripItem[plugins.Count];
|
||||
int i = 0;
|
||||
if (plugins.Count > 0)
|
||||
{
|
||||
foreach (var plugin in plugins)
|
||||
{
|
||||
ToolStripMenuItem itemMenu = new ToolStripMenuItem();
|
||||
itemMenu.Text = plugin.Value.PluginName;
|
||||
itemMenu.Click += (sender, e) =>
|
||||
{
|
||||
_selectedPlugin = plugin.Value.PluginName;
|
||||
panelControl.Controls.Clear();
|
||||
panelControl.Controls.Add(_plugins[_selectedPlugin].GetControl);
|
||||
panelControl.Controls[0].Dock = DockStyle.Fill;
|
||||
};
|
||||
toolStripItems[i] = itemMenu;
|
||||
i++;
|
||||
}
|
||||
ControlsStripMenuItem.DropDownItems.AddRange(toolStripItems);
|
||||
}
|
||||
return plugins;
|
||||
}*/
|
||||
|
||||
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 (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
AddNewElement();
|
||||
break;
|
||||
case Keys.U:
|
||||
UpdateElement();
|
||||
break;
|
||||
case Keys.D:
|
||||
DeleteElement();
|
||||
break;
|
||||
case Keys.S:
|
||||
CreateWord();
|
||||
break;
|
||||
case Keys.T:
|
||||
CreatePdf();
|
||||
break;
|
||||
case Keys.C:
|
||||
CreateExcel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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 CreateWord()
|
||||
{
|
||||
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateWord(new PluginsConventionSaveDocument { FileName = dialog.FileName }))
|
||||
{
|
||||
//MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CreateExcel()
|
||||
{
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateExcel(new PluginsConventionSaveDocument { FileName = dialog.FileName }))
|
||||
{
|
||||
//MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CreatePdf()
|
||||
{
|
||||
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreatePdf(new PluginsConventionSaveDocument { FileName = dialog.FileName }))
|
||||
{
|
||||
//MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 WordDocToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateWord();
|
||||
}
|
||||
|
||||
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateExcel();
|
||||
}
|
||||
|
||||
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreatePdf();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
178
Laba3/MainForm.Designer.cs
generated
178
Laba3/MainForm.Designer.cs
generated
@ -1,178 +0,0 @@
|
||||
namespace View
|
||||
{
|
||||
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();
|
||||
menuStrip1 = new MenuStrip();
|
||||
createToolStripMenuItem = new ToolStripMenuItem();
|
||||
updateToolStripMenuItem = new ToolStripMenuItem();
|
||||
deleteToolStripMenuItem = new ToolStripMenuItem();
|
||||
manufacturerToolStripMenuItem = new ToolStripMenuItem();
|
||||
documentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
pdfImageToolStripMenuItem = new ToolStripMenuItem();
|
||||
exelTableToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordGistToolStripMenuItem = new ToolStripMenuItem();
|
||||
outputTableResults = new Library15Gerimovich.OutputTableResults();
|
||||
pdfImg = new Library14Petrushin.PdfImg(components);
|
||||
wordDiagramComponent = new Library15Gerimovich.WordDiagramComponent(components);
|
||||
componentTable = new WinFormsLibrary1.ComponentTable(components);
|
||||
saveFileDialogPdf = new SaveFileDialog();
|
||||
saveFileDialogWord = new SaveFileDialog();
|
||||
saveFileDialogExel = new SaveFileDialog();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { createToolStripMenuItem, updateToolStripMenuItem, deleteToolStripMenuItem, manufacturerToolStripMenuItem, documentsToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(480, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// createToolStripMenuItem
|
||||
//
|
||||
createToolStripMenuItem.Name = "createToolStripMenuItem";
|
||||
createToolStripMenuItem.Size = new Size(66, 24);
|
||||
createToolStripMenuItem.Text = "Create";
|
||||
createToolStripMenuItem.Click += addToolStripMenuItem_Click;
|
||||
//
|
||||
// updateToolStripMenuItem
|
||||
//
|
||||
updateToolStripMenuItem.Name = "updateToolStripMenuItem";
|
||||
updateToolStripMenuItem.Size = new Size(72, 24);
|
||||
updateToolStripMenuItem.Text = "Update";
|
||||
updateToolStripMenuItem.Click += editToolStripMenuItem_Click;
|
||||
//
|
||||
// deleteToolStripMenuItem
|
||||
//
|
||||
deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||
deleteToolStripMenuItem.Size = new Size(67, 24);
|
||||
deleteToolStripMenuItem.Text = "Delete";
|
||||
deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click;
|
||||
//
|
||||
// manufacturerToolStripMenuItem
|
||||
//
|
||||
manufacturerToolStripMenuItem.Name = "manufacturerToolStripMenuItem";
|
||||
manufacturerToolStripMenuItem.Size = new Size(111, 24);
|
||||
manufacturerToolStripMenuItem.Text = "Manufacturer";
|
||||
manufacturerToolStripMenuItem.Click += manufacturersToolStripMenuItem_Click;
|
||||
//
|
||||
// documentsToolStripMenuItem
|
||||
//
|
||||
documentsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pdfImageToolStripMenuItem, exelTableToolStripMenuItem, wordGistToolStripMenuItem });
|
||||
documentsToolStripMenuItem.Name = "documentsToolStripMenuItem";
|
||||
documentsToolStripMenuItem.Size = new Size(98, 24);
|
||||
documentsToolStripMenuItem.Text = "Documents";
|
||||
//
|
||||
// pdfImageToolStripMenuItem
|
||||
//
|
||||
pdfImageToolStripMenuItem.Name = "pdfImageToolStripMenuItem";
|
||||
pdfImageToolStripMenuItem.Size = new Size(159, 26);
|
||||
pdfImageToolStripMenuItem.Text = "Pdf Image";
|
||||
pdfImageToolStripMenuItem.Click += createSimpleDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// exelTableToolStripMenuItem
|
||||
//
|
||||
exelTableToolStripMenuItem.Name = "exelTableToolStripMenuItem";
|
||||
exelTableToolStripMenuItem.Size = new Size(159, 26);
|
||||
exelTableToolStripMenuItem.Text = "Exel table";
|
||||
exelTableToolStripMenuItem.Click += createCustomTableDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// wordGistToolStripMenuItem
|
||||
//
|
||||
wordGistToolStripMenuItem.Name = "wordGistToolStripMenuItem";
|
||||
wordGistToolStripMenuItem.Size = new Size(159, 26);
|
||||
wordGistToolStripMenuItem.Text = "Word gist";
|
||||
wordGistToolStripMenuItem.Click += createChartDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// outputTableResults
|
||||
//
|
||||
outputTableResults.Location = new Point(12, 32);
|
||||
outputTableResults.Margin = new Padding(3, 4, 3, 4);
|
||||
outputTableResults.Name = "outputTableResults";
|
||||
outputTableResults.SelectedRow = -1;
|
||||
outputTableResults.Size = new Size(467, 308);
|
||||
outputTableResults.TabIndex = 1;
|
||||
//
|
||||
// saveFileDialogPdf
|
||||
//
|
||||
saveFileDialogPdf.FileName = "Products.pdf";
|
||||
saveFileDialogPdf.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||
saveFileDialogPdf.Title = "Save PDF Document";
|
||||
//
|
||||
// saveFileDialogWord
|
||||
//
|
||||
saveFileDialogWord.FileName = "Diagram.docx";
|
||||
saveFileDialogWord.Filter = "Word Files (*.docx)|*.docx";
|
||||
saveFileDialogWord.Title = "Save Word Document";
|
||||
//
|
||||
// saveFileDialogExel
|
||||
//
|
||||
saveFileDialogExel.FileName = "ProductReport.xlsx";
|
||||
saveFileDialogExel.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
||||
saveFileDialogExel.Title = "Save Excel Document";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(480, 351);
|
||||
Controls.Add(outputTableResults);
|
||||
Controls.Add(menuStrip1);
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Form1";
|
||||
KeyDown += MainForm_KeyDown;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem createToolStripMenuItem;
|
||||
private ToolStripMenuItem updateToolStripMenuItem;
|
||||
private Library15Gerimovich.OutputTableResults outputTableResults;
|
||||
private ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private ToolStripMenuItem manufacturerToolStripMenuItem;
|
||||
private ToolStripMenuItem documentsToolStripMenuItem;
|
||||
private ToolStripMenuItem pdfImageToolStripMenuItem;
|
||||
private ToolStripMenuItem exelTableToolStripMenuItem;
|
||||
private ToolStripMenuItem wordGistToolStripMenuItem;
|
||||
private Library14Petrushin.PdfImg pdfImg;
|
||||
private Library15Gerimovich.WordDiagramComponent wordDiagramComponent;
|
||||
private WinFormsLibrary1.ComponentTable componentTable;
|
||||
}
|
||||
}
|
@ -1,284 +0,0 @@
|
||||
using Data;
|
||||
using Data.Repositories;
|
||||
using View;
|
||||
using System.Windows.Forms;
|
||||
using Data.Models;
|
||||
using Library14Petrushin;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using Library15Gerimovich;
|
||||
using WinFormsLibrary1;
|
||||
using WinFormsLibrary1.Models;
|
||||
using View.ViewModels;
|
||||
|
||||
namespace View
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private SaveFileDialog saveFileDialogPdf;
|
||||
private SaveFileDialog saveFileDialogWord;
|
||||
private SaveFileDialog saveFileDialogExel;
|
||||
|
||||
public MainForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository;
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
InitializeOutputTableResults();
|
||||
LoadProducts();
|
||||
}
|
||||
|
||||
private void InitializeOutputTableResults()
|
||||
{
|
||||
outputTableResults.ConfigureColumns(new List<ColumnInfo>
|
||||
{
|
||||
new ColumnInfo("", 0, false, "Id"),
|
||||
new ColumnInfo("Name", 150, true, "Name"),
|
||||
new ColumnInfo("ManufacturerNameManufacturerName", 150, true, "ManufacturerName"),
|
||||
new ColumnInfo("DeliveryDate", 50, true, "DeliveryDate"),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void LoadProducts()
|
||||
{
|
||||
var products = _productRepository.GetAllProducts();
|
||||
outputTableResults.ClearGrid();
|
||||
foreach (var product in products)
|
||||
{
|
||||
outputTableResults.InsertValue(product);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void editToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
var selectedProduct = _productRepository.GetProductById(selectedProductId);
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository, selectedProduct);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
if (MessageBox.Show("Are you sure you want to delete this product?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_productRepository.DeleteProduct(selectedProductId);
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void manufacturersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var manufacturerForm = new ManufacturerForm(_manufacturerRepository);
|
||||
manufacturerForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void createSimpleDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем изображения из базы данных
|
||||
var images = GetImagesFromDatabase();
|
||||
|
||||
if (images.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogPdf.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
|
||||
// Путь для сохранения PDF-документа
|
||||
string fileName = saveFileDialogPdf.FileName;
|
||||
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No images found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createCustomTableDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем все продукты из базы данных
|
||||
var products = GetAllProducts();
|
||||
|
||||
if (products.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogExel.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объекты MergeCell и Column
|
||||
var mergeCells = new List<MergeCell>
|
||||
{
|
||||
new MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<Column>
|
||||
{
|
||||
new Column("Id", "Id", 10),
|
||||
new Column("Name", "Name", 20),
|
||||
new Column("ManufacturerName", "ManufacturerName", 20),
|
||||
new Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = ProductTableItem.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(saveFileDialogExel.FileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createChartDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем данные о количестве продукции каждого производителя
|
||||
var productCounts = GetProductCountsByManufacturer();
|
||||
|
||||
if (productCounts.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogWord.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
{
|
||||
FileName = saveFileDialogWord.FileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
// бизнес логика
|
||||
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
addToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.U:
|
||||
editToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.D:
|
||||
deleteToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.S:
|
||||
createSimpleDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.T:
|
||||
createCustomTableDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.C:
|
||||
createChartDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ImageData> GetImagesFromDatabase()
|
||||
{
|
||||
var images = new List<ImageData>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (product.Image != null)
|
||||
{
|
||||
// Создаем временный файл для сохранения изображения
|
||||
string tempFilePath = Path.GetTempFileName();
|
||||
File.WriteAllBytes(tempFilePath, product.Image);
|
||||
|
||||
// Добавляем путь к временному файлу в список
|
||||
images.Add(new ImageData { ImagePath = tempFilePath });
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
private Dictionary<string, double> GetProductCountsByManufacturer()
|
||||
{
|
||||
var productCounts = new Dictionary<string, double>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (productCounts.ContainsKey(product.ManufacturerName))
|
||||
{
|
||||
productCounts[product.ManufacturerName]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
productCounts[product.ManufacturerName] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return productCounts;
|
||||
}
|
||||
|
||||
private List<Product> GetAllProducts()
|
||||
{
|
||||
return _productRepository.GetAllProducts().ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>572, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfImg.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>708, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>813, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>1039, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>195, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogExel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>388, 17</value>
|
||||
</metadata>
|
||||
</root>
|
304
Laba3/MainPluginConvention.cs
Normal file
304
Laba3/MainPluginConvention.cs
Normal file
@ -0,0 +1,304 @@
|
||||
using Data;
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
using Library15Gerimovich;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using PluginsConvention14;
|
||||
using PluginsConvention14.MyPlugin;
|
||||
using System.Composition;
|
||||
using WinFormsLibrary1;
|
||||
|
||||
namespace View
|
||||
{
|
||||
[Export(typeof(IPluginsConvention))]
|
||||
public class MainPluginConvention : IPluginsConvention
|
||||
{
|
||||
|
||||
private OutputTableResults оutputTableResults;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
public string PluginName { get; set; } = "Products";
|
||||
|
||||
public MainPluginConvention()
|
||||
{
|
||||
var dbContext = new ApplicationDbContext();
|
||||
_productRepository = new ProductRepository(dbContext);
|
||||
_manufacturerRepository = new ManufacturerRepository(dbContext);
|
||||
|
||||
оutputTableResults = new OutputTableResults();
|
||||
var menu = new ContextMenuStrip();
|
||||
var skillMenuItem = new ToolStripMenuItem("Forms");
|
||||
menu.Items.Add(skillMenuItem);
|
||||
skillMenuItem.Click += (sender, e) =>
|
||||
{
|
||||
var formSkill = new ManufacturerForm(_manufacturerRepository);
|
||||
formSkill.ShowDialog();
|
||||
};
|
||||
оutputTableResults.ContextMenuStrip = menu;
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
/// Название плагина
|
||||
/*string IPluginsConvention.PluginName => PluginName();
|
||||
public string PluginName()
|
||||
{
|
||||
return "Products";
|
||||
}*/
|
||||
|
||||
public UserControl GetControl => оutputTableResults;
|
||||
|
||||
PluginsConventionElement IPluginsConvention.GetElement => GetElement();
|
||||
|
||||
public PluginsConventionElement GetElement()
|
||||
{
|
||||
var product = оutputTableResults.GetSelectedObject<MainPluginConventionElement>(); ;
|
||||
MainPluginConventionElement element = null;
|
||||
if (оutputTableResults != null)
|
||||
{
|
||||
element = new MainPluginConventionElement
|
||||
{
|
||||
Id = product.Id,
|
||||
Name = product.Name,
|
||||
ManufacturerName = product.ManufacturerName,
|
||||
DeliveryDate = product.DeliveryDate,
|
||||
};
|
||||
}
|
||||
return (new PluginsConventionElement { Id = element.Id });
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
var formOrder = new ProductForm(_productRepository, _manufacturerRepository, _productRepository.GetProductById(Convert.ToInt32(element.Id)));
|
||||
return formOrder;
|
||||
}
|
||||
else
|
||||
{
|
||||
var formOrder = new ProductForm(_productRepository, _manufacturerRepository);
|
||||
return formOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
_productRepository.DeleteProduct(Convert.ToInt32(element.Id));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
оutputTableResults.ClearGrid();
|
||||
foreach (var product in products)
|
||||
{
|
||||
оutputTableResults.InsertValue(product);
|
||||
}
|
||||
}
|
||||
public bool CreatePdf(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Получаем изображения из базы данных
|
||||
var images = GetImagesFromDatabase();
|
||||
|
||||
if (images.Count > 0)
|
||||
{
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
}
|
||||
}
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<Library14Petrushin.ImageData> GetImagesFromDatabase()
|
||||
{
|
||||
var images = new List<Library14Petrushin.ImageData>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (product.Image != null)
|
||||
{
|
||||
// Создаем временный файл для сохранения изображения
|
||||
string tempFilePath = Path.GetTempFileName();
|
||||
File.WriteAllBytes(tempFilePath, product.Image);
|
||||
|
||||
// Добавляем путь к временному файлу в список
|
||||
images.Add(new Library14Petrushin.ImageData { ImagePath = tempFilePath });
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
public bool CreateExcel(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// Получаем все продукты из базы данных
|
||||
var products = GetAllProducts();
|
||||
|
||||
if (products.Count > 0)
|
||||
{
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
}
|
||||
}
|
||||
// Создаем объекты MergeCell и Column
|
||||
var mergeCells = new List<WinFormsLibrary1.Models.MergeCell>
|
||||
{
|
||||
new WinFormsLibrary1.Models.MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<WinFormsLibrary1.Models.Column>
|
||||
{
|
||||
new WinFormsLibrary1.Models.Column("Id", "Id", 10),
|
||||
new WinFormsLibrary1.Models.Column("Name", "Name", 20),
|
||||
new WinFormsLibrary1.Models.Column("ManufacturerName", "ManufacturerName", 20),
|
||||
new WinFormsLibrary1.Models.Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = MainPluginConventionElement.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(fileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<Product> GetAllProducts()
|
||||
{
|
||||
return _productRepository.GetAllProducts().ToList();
|
||||
}
|
||||
|
||||
public bool CreateWord(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// Получаем данные о количестве продукции каждого производителя
|
||||
var productCounts = GetProductCountsByManufacturer();
|
||||
|
||||
if (productCounts.Count > 0)
|
||||
{
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
|
||||
var wordDiagramComponent = new WordDiagramComponent();
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Dictionary<string, double> GetProductCountsByManufacturer()
|
||||
{
|
||||
var productCounts = new Dictionary<string, double>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (productCounts.ContainsKey(product.ManufacturerName))
|
||||
{
|
||||
productCounts[product.ManufacturerName]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
productCounts[product.ManufacturerName] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return productCounts;
|
||||
}
|
||||
}
|
||||
}
|
64
Laba3/ManufacturerForm.Designer.cs
generated
64
Laba3/ManufacturerForm.Designer.cs
generated
@ -1,64 +0,0 @@
|
||||
namespace View
|
||||
{
|
||||
partial class ManufacturerForm
|
||||
{
|
||||
/// <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();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(711, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||
dataGridView.UserAddedRow += dataGridView_UserAddedRow;
|
||||
dataGridView.UserDeletingRow += dataGridView_UserDeletingRow;
|
||||
dataGridView.KeyDown += dataGridView_KeyDown;
|
||||
//
|
||||
// ManufacturerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(731, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ManufacturerForm";
|
||||
Text = "ManufacturerForm";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
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 View
|
||||
{
|
||||
public partial class ManufacturerForm : Form
|
||||
{
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
|
||||
public ManufacturerForm(IManufacturerRepository manufacturerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
LoadManufacturers();
|
||||
}
|
||||
|
||||
private void LoadManufacturers()
|
||||
{
|
||||
var manufacturers = _manufacturerRepository.GetAllManufacturers().ToList();
|
||||
dataGridView.DataSource = manufacturers;
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
var manufacturer = dataGridView.Rows[e.RowIndex].DataBoundItem as Manufacturer;
|
||||
if (manufacturer != null)
|
||||
{
|
||||
_manufacturerRepository.UpdateManufacturer(manufacturer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
var manufacturer = e.Row.DataBoundItem as Manufacturer;
|
||||
if (manufacturer != null)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete this manufacturer?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_manufacturerRepository.DeleteManufacturer(manufacturer.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserAddedRow(object sender, DataGridViewRowEventArgs e)
|
||||
{
|
||||
var manufacturer = new Manufacturer { Name = "" };
|
||||
_manufacturerRepository.AddManufacturer(manufacturer);
|
||||
LoadManufacturers();
|
||||
}
|
||||
|
||||
|
||||
// реализация через нажатие клавишь
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Insert)
|
||||
{
|
||||
var manufacturer = new Manufacturer { Name = "" };
|
||||
_manufacturerRepository.AddManufacturer(manufacturer);
|
||||
LoadManufacturers();
|
||||
}
|
||||
else if (e.KeyCode == Keys.Delete)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
var selectedManufacturer = dataGridView.SelectedRows[0].DataBoundItem as Manufacturer;
|
||||
if (selectedManufacturer != null)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete this manufacturer?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_manufacturerRepository.DeleteManufacturer(selectedManufacturer.Id);
|
||||
LoadManufacturers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
50
Laba3/PluginsManager.cs
Normal file
50
Laba3/PluginsManager.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.ComponentModel.Composition.Hosting;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace View
|
||||
{
|
||||
public class PluginsManager
|
||||
{
|
||||
//Тег, указывающий, что plugins должны быть заполнены CompositionContainer
|
||||
[ImportMany(typeof(IPluginsConvention))]
|
||||
IEnumerable<IPluginsConvention> Plugins { get; set; }
|
||||
|
||||
public readonly Dictionary<string, IPluginsConvention> plugins_dictionary = new Dictionary<string, IPluginsConvention>();
|
||||
|
||||
public PluginsManager()
|
||||
{
|
||||
AggregateCatalog catalog = new AggregateCatalog();
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins")));
|
||||
|
||||
|
||||
//Контейнер композиции
|
||||
|
||||
CompositionContainer container = new CompositionContainer(catalog);
|
||||
try
|
||||
{
|
||||
container.ComposeParts(this);
|
||||
}
|
||||
catch (CompositionException compositionException)
|
||||
{
|
||||
MessageBox.Show(compositionException.ToString());
|
||||
}
|
||||
if (Plugins.Any())
|
||||
{
|
||||
Plugins
|
||||
.ToList()
|
||||
.ForEach(p =>
|
||||
{
|
||||
if (!plugins_dictionary.Keys.Contains(p.PluginName))
|
||||
plugins_dictionary.Add(p.PluginName, p);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
Laba3/ProductForm.Designer.cs
generated
121
Laba3/ProductForm.Designer.cs
generated
@ -1,121 +0,0 @@
|
||||
namespace PluginsConvention14
|
||||
{
|
||||
partial class ProductForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dtpDeliveryDate = new WinFormsLibrary1.DateInputControl();
|
||||
cmbManufacturer = new WinFormsLibrary1.ComboBoxUserControl();
|
||||
txtName = new Library14Petrushin.TextBoxRange();
|
||||
pbImage = new PictureBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dtpDeliveryDate
|
||||
//
|
||||
dtpDeliveryDate.DateFormat = null;
|
||||
dtpDeliveryDate.Location = new Point(13, 137);
|
||||
dtpDeliveryDate.Margin = new Padding(4, 5, 4, 5);
|
||||
dtpDeliveryDate.Name = "dtpDeliveryDate";
|
||||
dtpDeliveryDate.Size = new Size(186, 110);
|
||||
dtpDeliveryDate.TabIndex = 0;
|
||||
//
|
||||
// cmbManufacturer
|
||||
//
|
||||
cmbManufacturer.Location = new Point(12, 218);
|
||||
cmbManufacturer.Margin = new Padding(4, 5, 4, 5);
|
||||
cmbManufacturer.Name = "cmbManufacturer";
|
||||
cmbManufacturer.SelectedValue = "";
|
||||
cmbManufacturer.Size = new Size(201, 40);
|
||||
cmbManufacturer.TabIndex = 1;
|
||||
//
|
||||
// txtName
|
||||
//
|
||||
txtName.Location = new Point(12, 12);
|
||||
txtName.MaxLength = null;
|
||||
txtName.MinLength = null;
|
||||
txtName.Name = "txtName";
|
||||
txtName.Size = new Size(315, 108);
|
||||
txtName.TabIndex = 2;
|
||||
//
|
||||
// pbImage
|
||||
//
|
||||
pbImage.Location = new Point(320, 32);
|
||||
pbImage.Name = "pbImage";
|
||||
pbImage.Size = new Size(451, 344);
|
||||
pbImage.TabIndex = 3;
|
||||
pbImage.TabStop = false;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(320, 399);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(110, 29);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Choose img";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += btnBrowse_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(12, 326);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(94, 29);
|
||||
button2.TabIndex = 5;
|
||||
button2.Text = "Save";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += btnSave_Click;
|
||||
//
|
||||
// ProductForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(pbImage);
|
||||
Controls.Add(txtName);
|
||||
Controls.Add(cmbManufacturer);
|
||||
Controls.Add(dtpDeliveryDate);
|
||||
Name = "ProductForm";
|
||||
Text = "ProductForm";
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private WinFormsLibrary1.DateInputControl dtpDeliveryDate;
|
||||
private WinFormsLibrary1.ComboBoxUserControl cmbManufacturer;
|
||||
private Library14Petrushin.TextBoxRange txtName;
|
||||
private PictureBox pbImage;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
using Data;
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace View
|
||||
{
|
||||
public partial class ProductForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private Product _product;
|
||||
private bool _isNewProduct;
|
||||
private const int MINL = 3;
|
||||
private const int MAXL= 10;
|
||||
|
||||
public ProductForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository, Product product = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
|
||||
_productRepository = productRepository;
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
|
||||
|
||||
var manufacturers = _manufacturerRepository.GetAllManufacturers().Select(m => m.Name).ToList();
|
||||
// cmbManufacturer.Data = manufacturers;
|
||||
foreach (var manufacturer in manufacturers)
|
||||
{
|
||||
cmbManufacturer.AddItem(manufacturer);
|
||||
}
|
||||
|
||||
_product = product;
|
||||
_isNewProduct = product == null;
|
||||
txtName.MinLength = MINL;
|
||||
txtName.MaxLength = MAXL;
|
||||
dtpDeliveryDate.DateFormat = "dd MMMM yyyy";
|
||||
|
||||
if (!_isNewProduct)
|
||||
{
|
||||
txtName.InputValue = _product.Name;
|
||||
cmbManufacturer.SelectedValue = _product.ManufacturerName;
|
||||
dtpDeliveryDate.Date = _product.DeliveryDate;
|
||||
|
||||
if (_product.Image != null)
|
||||
{
|
||||
using (var ms = new MemoryStream(_product.Image))
|
||||
{
|
||||
pbImage.Image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp";
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
pbImage.Image = Image.FromFile(openFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtName.InputValue))
|
||||
{
|
||||
MessageBox.Show("Name is required.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isNewProduct)
|
||||
{
|
||||
_product = new Product();
|
||||
}
|
||||
|
||||
_product.Name = txtName.InputValue;
|
||||
_product.ManufacturerName = cmbManufacturer.SelectedValue.ToString();
|
||||
_product.DeliveryDate = dtpDeliveryDate.Date;
|
||||
|
||||
if (pbImage.Image != null)
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
pbImage.Image.Save(ms, pbImage.Image.RawFormat);
|
||||
_product.Image = ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
if (_isNewProduct)
|
||||
{
|
||||
_productRepository.AddProduct(_product);
|
||||
}
|
||||
else
|
||||
{
|
||||
_productRepository.UpdateProduct(_product);
|
||||
}
|
||||
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -11,15 +11,9 @@ namespace View
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
// Ñîçäàíèå ýêçåìïëÿðîâ ðåïîçèòîðèåâ
|
||||
var dbContext = new ApplicationDbContext();
|
||||
var productRepository = new ProductRepository(dbContext);
|
||||
var manufacturerRepository = new ManufacturerRepository(dbContext);
|
||||
|
||||
// Ïåðåäà÷à ðåïîçèòîðèåâ â êîíñòðóêòîð MainForm
|
||||
Application.Run(new MainForm(productRepository, manufacturerRepository));
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,13 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="9.0.0" />
|
||||
<PackageReference Include="WinFormsLibrary1" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
<ProjectReference Include="..\PluginsConvention14\PluginsConvention14.csproj" />
|
||||
<ProjectReference Include="..\Models\Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "View", "..\Laba3\View.cspro
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Data", "..\Models\Data.csproj", "{DC70937E-903F-4BAA-A774-80D01EC5B75A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConvention14", "..\PluginsConvention14\PluginsConvention14.csproj", "{C6CB6D7F-9DCF-414B-8544-1AE4FDE373CD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConvention14", "..\PluginsConvention14\PluginsConvention14.csproj", "{C6CB6D7F-9DCF-414B-8544-1AE4FDE373CD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
BIN
Plugins/PluginsConvention14.dll
Normal file
BIN
Plugins/PluginsConvention14.dll
Normal file
Binary file not shown.
178
PluginsConvention14/Forms/MainForm.Designer.cs
generated
178
PluginsConvention14/Forms/MainForm.Designer.cs
generated
@ -1,178 +0,0 @@
|
||||
namespace PluginsConvention14
|
||||
{
|
||||
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();
|
||||
menuStrip1 = new MenuStrip();
|
||||
createToolStripMenuItem = new ToolStripMenuItem();
|
||||
updateToolStripMenuItem = new ToolStripMenuItem();
|
||||
deleteToolStripMenuItem = new ToolStripMenuItem();
|
||||
manufacturerToolStripMenuItem = new ToolStripMenuItem();
|
||||
documentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
pdfImageToolStripMenuItem = new ToolStripMenuItem();
|
||||
exelTableToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordGistToolStripMenuItem = new ToolStripMenuItem();
|
||||
outputTableResults = new Library15Gerimovich.OutputTableResults();
|
||||
pdfImg = new Library14Petrushin.PdfImg(components);
|
||||
wordDiagramComponent = new Library15Gerimovich.WordDiagramComponent(components);
|
||||
componentTable = new WinFormsLibrary1.ComponentTable(components);
|
||||
saveFileDialogPdf = new SaveFileDialog();
|
||||
saveFileDialogWord = new SaveFileDialog();
|
||||
saveFileDialogExel = new SaveFileDialog();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { createToolStripMenuItem, updateToolStripMenuItem, deleteToolStripMenuItem, manufacturerToolStripMenuItem, documentsToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(480, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// createToolStripMenuItem
|
||||
//
|
||||
createToolStripMenuItem.Name = "createToolStripMenuItem";
|
||||
createToolStripMenuItem.Size = new Size(66, 24);
|
||||
createToolStripMenuItem.Text = "Create";
|
||||
createToolStripMenuItem.Click += addToolStripMenuItem_Click;
|
||||
//
|
||||
// updateToolStripMenuItem
|
||||
//
|
||||
updateToolStripMenuItem.Name = "updateToolStripMenuItem";
|
||||
updateToolStripMenuItem.Size = new Size(72, 24);
|
||||
updateToolStripMenuItem.Text = "Update";
|
||||
updateToolStripMenuItem.Click += editToolStripMenuItem_Click;
|
||||
//
|
||||
// deleteToolStripMenuItem
|
||||
//
|
||||
deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||
deleteToolStripMenuItem.Size = new Size(67, 24);
|
||||
deleteToolStripMenuItem.Text = "Delete";
|
||||
deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click;
|
||||
//
|
||||
// manufacturerToolStripMenuItem
|
||||
//
|
||||
manufacturerToolStripMenuItem.Name = "manufacturerToolStripMenuItem";
|
||||
manufacturerToolStripMenuItem.Size = new Size(111, 24);
|
||||
manufacturerToolStripMenuItem.Text = "Manufacturer";
|
||||
manufacturerToolStripMenuItem.Click += manufacturersToolStripMenuItem_Click;
|
||||
//
|
||||
// documentsToolStripMenuItem
|
||||
//
|
||||
documentsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pdfImageToolStripMenuItem, exelTableToolStripMenuItem, wordGistToolStripMenuItem });
|
||||
documentsToolStripMenuItem.Name = "documentsToolStripMenuItem";
|
||||
documentsToolStripMenuItem.Size = new Size(98, 24);
|
||||
documentsToolStripMenuItem.Text = "Documents";
|
||||
//
|
||||
// pdfImageToolStripMenuItem
|
||||
//
|
||||
pdfImageToolStripMenuItem.Name = "pdfImageToolStripMenuItem";
|
||||
pdfImageToolStripMenuItem.Size = new Size(159, 26);
|
||||
pdfImageToolStripMenuItem.Text = "Pdf Image";
|
||||
pdfImageToolStripMenuItem.Click += createSimpleDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// exelTableToolStripMenuItem
|
||||
//
|
||||
exelTableToolStripMenuItem.Name = "exelTableToolStripMenuItem";
|
||||
exelTableToolStripMenuItem.Size = new Size(159, 26);
|
||||
exelTableToolStripMenuItem.Text = "Exel table";
|
||||
exelTableToolStripMenuItem.Click += createCustomTableDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// wordGistToolStripMenuItem
|
||||
//
|
||||
wordGistToolStripMenuItem.Name = "wordGistToolStripMenuItem";
|
||||
wordGistToolStripMenuItem.Size = new Size(159, 26);
|
||||
wordGistToolStripMenuItem.Text = "Word gist";
|
||||
wordGistToolStripMenuItem.Click += createChartDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// outputTableResults
|
||||
//
|
||||
outputTableResults.Location = new Point(12, 32);
|
||||
outputTableResults.Margin = new Padding(3, 4, 3, 4);
|
||||
outputTableResults.Name = "outputTableResults";
|
||||
outputTableResults.SelectedRow = -1;
|
||||
outputTableResults.Size = new Size(467, 308);
|
||||
outputTableResults.TabIndex = 1;
|
||||
//
|
||||
// saveFileDialogPdf
|
||||
//
|
||||
saveFileDialogPdf.FileName = "Products.pdf";
|
||||
saveFileDialogPdf.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||
saveFileDialogPdf.Title = "Save PDF Document";
|
||||
//
|
||||
// saveFileDialogWord
|
||||
//
|
||||
saveFileDialogWord.FileName = "Diagram.docx";
|
||||
saveFileDialogWord.Filter = "Word Files (*.docx)|*.docx";
|
||||
saveFileDialogWord.Title = "Save Word Document";
|
||||
//
|
||||
// saveFileDialogExel
|
||||
//
|
||||
saveFileDialogExel.FileName = "ProductReport.xlsx";
|
||||
saveFileDialogExel.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
||||
saveFileDialogExel.Title = "Save Excel Document";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(480, 351);
|
||||
Controls.Add(outputTableResults);
|
||||
Controls.Add(menuStrip1);
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Form1";
|
||||
KeyDown += MainForm_KeyDown;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem createToolStripMenuItem;
|
||||
private ToolStripMenuItem updateToolStripMenuItem;
|
||||
private Library15Gerimovich.OutputTableResults outputTableResults;
|
||||
private ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private ToolStripMenuItem manufacturerToolStripMenuItem;
|
||||
private ToolStripMenuItem documentsToolStripMenuItem;
|
||||
private ToolStripMenuItem pdfImageToolStripMenuItem;
|
||||
private ToolStripMenuItem exelTableToolStripMenuItem;
|
||||
private ToolStripMenuItem wordGistToolStripMenuItem;
|
||||
private Library14Petrushin.PdfImg pdfImg;
|
||||
private Library15Gerimovich.WordDiagramComponent wordDiagramComponent;
|
||||
private WinFormsLibrary1.ComponentTable componentTable;
|
||||
}
|
||||
}
|
@ -1,284 +0,0 @@
|
||||
using Data;
|
||||
using Data.Repositories;
|
||||
using View;
|
||||
using System.Windows.Forms;
|
||||
using Data.Models;
|
||||
using Library14Petrushin;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using Library15Gerimovich;
|
||||
using WinFormsLibrary1;
|
||||
using WinFormsLibrary1.Models;
|
||||
using View.ViewModels;
|
||||
|
||||
namespace PluginsConvention14
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private SaveFileDialog saveFileDialogPdf;
|
||||
private SaveFileDialog saveFileDialogWord;
|
||||
private SaveFileDialog saveFileDialogExel;
|
||||
|
||||
public MainForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository;
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
InitializeOutputTableResults();
|
||||
LoadProducts();
|
||||
}
|
||||
|
||||
private void InitializeOutputTableResults()
|
||||
{
|
||||
outputTableResults.ConfigureColumns(new List<ColumnInfo>
|
||||
{
|
||||
new ColumnInfo("", 0, false, "Id"),
|
||||
new ColumnInfo("Name", 150, true, "Name"),
|
||||
new ColumnInfo("ManufacturerNameManufacturerName", 150, true, "ManufacturerName"),
|
||||
new ColumnInfo("DeliveryDate", 50, true, "DeliveryDate"),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void LoadProducts()
|
||||
{
|
||||
var products = _productRepository.GetAllProducts();
|
||||
outputTableResults.ClearGrid();
|
||||
foreach (var product in products)
|
||||
{
|
||||
outputTableResults.InsertValue(product);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void editToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
var selectedProduct = _productRepository.GetProductById(selectedProductId);
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository, selectedProduct);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
if (MessageBox.Show("Are you sure you want to delete this product?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_productRepository.DeleteProduct(selectedProductId);
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void manufacturersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var manufacturerForm = new ManufacturerForm(_manufacturerRepository);
|
||||
manufacturerForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void createSimpleDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем изображения из базы данных
|
||||
var images = GetImagesFromDatabase();
|
||||
|
||||
if (images.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogPdf.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
|
||||
// Путь для сохранения PDF-документа
|
||||
string fileName = saveFileDialogPdf.FileName;
|
||||
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No images found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createCustomTableDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем все продукты из базы данных
|
||||
var products = GetAllProducts();
|
||||
|
||||
if (products.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogExel.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объекты MergeCell и Column
|
||||
var mergeCells = new List<MergeCell>
|
||||
{
|
||||
new MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<Column>
|
||||
{
|
||||
new Column("Id", "Id", 10),
|
||||
new Column("Name", "Name", 20),
|
||||
new Column("ManufacturerName", "ManufacturerName", 20),
|
||||
new Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = ProductTableItem.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(saveFileDialogExel.FileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createChartDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем данные о количестве продукции каждого производителя
|
||||
var productCounts = GetProductCountsByManufacturer();
|
||||
|
||||
if (productCounts.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogWord.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
{
|
||||
FileName = saveFileDialogWord.FileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
// бизнес логика
|
||||
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
addToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.U:
|
||||
editToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.D:
|
||||
deleteToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.S:
|
||||
createSimpleDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.T:
|
||||
createCustomTableDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.C:
|
||||
createChartDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ImageData> GetImagesFromDatabase()
|
||||
{
|
||||
var images = new List<ImageData>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (product.Image != null)
|
||||
{
|
||||
// Создаем временный файл для сохранения изображения
|
||||
string tempFilePath = Path.GetTempFileName();
|
||||
File.WriteAllBytes(tempFilePath, product.Image);
|
||||
|
||||
// Добавляем путь к временному файлу в список
|
||||
images.Add(new ImageData { ImagePath = tempFilePath });
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
private Dictionary<string, double> GetProductCountsByManufacturer()
|
||||
{
|
||||
var productCounts = new Dictionary<string, double>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (productCounts.ContainsKey(product.ManufacturerName))
|
||||
{
|
||||
productCounts[product.ManufacturerName]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
productCounts[product.ManufacturerName] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return productCounts;
|
||||
}
|
||||
|
||||
private List<Product> GetAllProducts()
|
||||
{
|
||||
return _productRepository.GetAllProducts().ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>572, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfImg.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>708, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>813, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>1039, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>195, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogExel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>388, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,4 +1,4 @@
|
||||
namespace ViewPluginsConvention14
|
||||
namespace PluginsConvention14
|
||||
{
|
||||
partial class ManufacturerForm
|
||||
{
|
||||
|
@ -1,14 +1,5 @@
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
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 PluginsConvention14
|
||||
{
|
||||
@ -63,7 +54,7 @@ namespace PluginsConvention14
|
||||
_manufacturerRepository.AddManufacturer(manufacturer);
|
||||
LoadManufacturers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// реализация через нажатие клавишь
|
||||
|
||||
|
@ -1,16 +1,7 @@
|
||||
using Data;
|
||||
using Data.Models;
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PluginsConvention14
|
||||
{
|
||||
@ -21,7 +12,7 @@ namespace PluginsConvention14
|
||||
private Product _product;
|
||||
private bool _isNewProduct;
|
||||
private const int MINL = 3;
|
||||
private const int MAXL= 10;
|
||||
private const int MAXL = 10;
|
||||
|
||||
public ProductForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository, Product product = null)
|
||||
{
|
||||
@ -108,7 +99,7 @@ namespace PluginsConvention14
|
||||
_productRepository.UpdateProduct(_product);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System.Composition;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Library15Gerimovich;
|
||||
using Data.Repositories;
|
||||
using Data;
|
||||
using Data.Models;
|
||||
using Data;
|
||||
using View.ViewModels;
|
||||
using WinFormsLibrary1;
|
||||
using Data.Repositories;
|
||||
using Library15Gerimovich;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System.Composition;
|
||||
using WinFormsLibrary1;
|
||||
|
||||
namespace PluginsConvention14.MyPlugin
|
||||
{
|
||||
@ -22,6 +16,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
private OutputTableResults оutputTableResults;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
public string PluginName { get; set; } = "Products";
|
||||
|
||||
public MainPluginConvention()
|
||||
{
|
||||
@ -31,7 +26,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
|
||||
оutputTableResults = new OutputTableResults();
|
||||
var menu = new ContextMenuStrip();
|
||||
var skillMenuItem = new ToolStripMenuItem("Формы");
|
||||
var skillMenuItem = new ToolStripMenuItem("Forms");
|
||||
menu.Items.Add(skillMenuItem);
|
||||
skillMenuItem.Click += (sender, e) =>
|
||||
{
|
||||
@ -39,15 +34,29 @@ namespace PluginsConvention14.MyPlugin
|
||||
formSkill.ShowDialog();
|
||||
};
|
||||
оutputTableResults.ContextMenuStrip = menu;
|
||||
|
||||
InitializeOutputTableResults();
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
private void InitializeOutputTableResults()
|
||||
{
|
||||
оutputTableResults.ConfigureColumns(new List<ColumnInfo>
|
||||
{
|
||||
new ColumnInfo("", 0, false, "Id"),
|
||||
new ColumnInfo("Name", 150, true, "Name"),
|
||||
new ColumnInfo("ManufacturerNameManufacturerName", 150, true, "ManufacturerName"),
|
||||
new ColumnInfo("DeliveryDate", 50, true, "DeliveryDate"),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// Название плагина
|
||||
string IPluginsConvention.PluginName => PluginName();
|
||||
/*string IPluginsConvention.PluginName => PluginName();
|
||||
public string PluginName()
|
||||
{
|
||||
return "Products";
|
||||
}
|
||||
}*/
|
||||
|
||||
public UserControl GetControl => оutputTableResults;
|
||||
|
||||
@ -74,7 +83,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
var formOrder = new ProductForm(_productRepository, _manufacturerRepository, _productRepository.GetProductById(element.Id));
|
||||
var formOrder = new ProductForm(_productRepository, _manufacturerRepository, _productRepository.GetProductById(Convert.ToInt32(element.Id)));
|
||||
return formOrder;
|
||||
}
|
||||
else
|
||||
@ -88,7 +97,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
_productRepository.DeleteProduct(element.Id);
|
||||
_productRepository.DeleteProduct(Convert.ToInt32(element.Id));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -125,18 +134,18 @@ namespace PluginsConvention14.MyPlugin
|
||||
fileName = dialog.FileName.ToString();
|
||||
}
|
||||
}
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@ -171,7 +180,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Получаем все продукты из базы данных
|
||||
var products = GetAllProducts();
|
||||
@ -192,7 +201,7 @@ namespace PluginsConvention14.MyPlugin
|
||||
new WinFormsLibrary1.Models.MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<WinFormsLibrary1.Models.Column>
|
||||
var columns = new List<WinFormsLibrary1.Models.Column>
|
||||
{
|
||||
new WinFormsLibrary1.Models.Column("Id", "Id", 10),
|
||||
new WinFormsLibrary1.Models.Column("Name", "Name", 20),
|
||||
@ -200,23 +209,24 @@ namespace PluginsConvention14.MyPlugin
|
||||
new WinFormsLibrary1.Models.Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = ProductTableItem.ConvertProductsToTableItems(products);
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = MainPluginConventionElement.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(fileName, "Product Report", mergeCells, columns, tableItems);
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(fileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}else
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
@ -248,27 +258,27 @@ namespace PluginsConvention14.MyPlugin
|
||||
|
||||
if (productCounts.Count > 0)
|
||||
{
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
FileName = fileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
|
||||
var wordDiagramComponent = new WordDiagramComponent();
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,11 +1,5 @@
|
||||
using Data.Models;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using View.ViewModels;
|
||||
|
||||
namespace PluginsConvention14.MyPlugin
|
||||
{
|
||||
@ -14,11 +8,11 @@ namespace PluginsConvention14.MyPlugin
|
||||
public string Name { get; set; }
|
||||
public string ManufacturerName { get; set; }
|
||||
public string DeliveryDate { get; set; }
|
||||
public static List<ProductTableItem> ConvertProductsToTableItems(List<Product> products)
|
||||
public static List<MainPluginConventionElement> ConvertProductsToTableItems(List<Product> products)
|
||||
{
|
||||
return products.Select(p => new ProductTableItem
|
||||
return products.Select(p => new MainPluginConventionElement
|
||||
{
|
||||
Id = p.Id.ToString(),
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
ManufacturerName = p.ManufacturerName,
|
||||
DeliveryDate = p.DeliveryDate.ToShortDateString()
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
|
@ -9,20 +9,17 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Library15Gerimovich" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
|
||||
<PackageReference Include="System.Composition" Version="9.0.0" />
|
||||
<PackageReference Include="WinFormsLibrary1" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Laba3\View.csproj" />
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
<ProjectReference Include="..\Models\Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Forms\MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Forms\ManufacturerForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
178
PluginsConventionLibrary/Forms/MainForm.Designer.cs
generated
178
PluginsConventionLibrary/Forms/MainForm.Designer.cs
generated
@ -1,178 +0,0 @@
|
||||
namespace Laba3
|
||||
{
|
||||
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();
|
||||
menuStrip1 = new MenuStrip();
|
||||
createToolStripMenuItem = new ToolStripMenuItem();
|
||||
updateToolStripMenuItem = new ToolStripMenuItem();
|
||||
deleteToolStripMenuItem = new ToolStripMenuItem();
|
||||
manufacturerToolStripMenuItem = new ToolStripMenuItem();
|
||||
documentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
pdfImageToolStripMenuItem = new ToolStripMenuItem();
|
||||
exelTableToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordGistToolStripMenuItem = new ToolStripMenuItem();
|
||||
outputTableResults = new Library15Gerimovich.OutputTableResults();
|
||||
pdfImg = new Library14Petrushin.PdfImg(components);
|
||||
wordDiagramComponent = new Library15Gerimovich.WordDiagramComponent(components);
|
||||
componentTable = new WinFormsLibrary1.ComponentTable(components);
|
||||
saveFileDialogPdf = new SaveFileDialog();
|
||||
saveFileDialogWord = new SaveFileDialog();
|
||||
saveFileDialogExel = new SaveFileDialog();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { createToolStripMenuItem, updateToolStripMenuItem, deleteToolStripMenuItem, manufacturerToolStripMenuItem, documentsToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(480, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// createToolStripMenuItem
|
||||
//
|
||||
createToolStripMenuItem.Name = "createToolStripMenuItem";
|
||||
createToolStripMenuItem.Size = new Size(66, 24);
|
||||
createToolStripMenuItem.Text = "Create";
|
||||
createToolStripMenuItem.Click += addToolStripMenuItem_Click;
|
||||
//
|
||||
// updateToolStripMenuItem
|
||||
//
|
||||
updateToolStripMenuItem.Name = "updateToolStripMenuItem";
|
||||
updateToolStripMenuItem.Size = new Size(72, 24);
|
||||
updateToolStripMenuItem.Text = "Update";
|
||||
updateToolStripMenuItem.Click += editToolStripMenuItem_Click;
|
||||
//
|
||||
// deleteToolStripMenuItem
|
||||
//
|
||||
deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||
deleteToolStripMenuItem.Size = new Size(67, 24);
|
||||
deleteToolStripMenuItem.Text = "Delete";
|
||||
deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click;
|
||||
//
|
||||
// manufacturerToolStripMenuItem
|
||||
//
|
||||
manufacturerToolStripMenuItem.Name = "manufacturerToolStripMenuItem";
|
||||
manufacturerToolStripMenuItem.Size = new Size(111, 24);
|
||||
manufacturerToolStripMenuItem.Text = "Manufacturer";
|
||||
manufacturerToolStripMenuItem.Click += manufacturersToolStripMenuItem_Click;
|
||||
//
|
||||
// documentsToolStripMenuItem
|
||||
//
|
||||
documentsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pdfImageToolStripMenuItem, exelTableToolStripMenuItem, wordGistToolStripMenuItem });
|
||||
documentsToolStripMenuItem.Name = "documentsToolStripMenuItem";
|
||||
documentsToolStripMenuItem.Size = new Size(98, 24);
|
||||
documentsToolStripMenuItem.Text = "Documents";
|
||||
//
|
||||
// pdfImageToolStripMenuItem
|
||||
//
|
||||
pdfImageToolStripMenuItem.Name = "pdfImageToolStripMenuItem";
|
||||
pdfImageToolStripMenuItem.Size = new Size(159, 26);
|
||||
pdfImageToolStripMenuItem.Text = "Pdf Image";
|
||||
pdfImageToolStripMenuItem.Click += createSimpleDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// exelTableToolStripMenuItem
|
||||
//
|
||||
exelTableToolStripMenuItem.Name = "exelTableToolStripMenuItem";
|
||||
exelTableToolStripMenuItem.Size = new Size(159, 26);
|
||||
exelTableToolStripMenuItem.Text = "Exel table";
|
||||
exelTableToolStripMenuItem.Click += createCustomTableDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// wordGistToolStripMenuItem
|
||||
//
|
||||
wordGistToolStripMenuItem.Name = "wordGistToolStripMenuItem";
|
||||
wordGistToolStripMenuItem.Size = new Size(159, 26);
|
||||
wordGistToolStripMenuItem.Text = "Word gist";
|
||||
wordGistToolStripMenuItem.Click += createChartDocumentToolStripMenuItem_Click;
|
||||
//
|
||||
// outputTableResults
|
||||
//
|
||||
outputTableResults.Location = new Point(12, 32);
|
||||
outputTableResults.Margin = new Padding(3, 4, 3, 4);
|
||||
outputTableResults.Name = "outputTableResults";
|
||||
outputTableResults.SelectedRow = -1;
|
||||
outputTableResults.Size = new Size(467, 308);
|
||||
outputTableResults.TabIndex = 1;
|
||||
//
|
||||
// saveFileDialogPdf
|
||||
//
|
||||
saveFileDialogPdf.FileName = "Products.pdf";
|
||||
saveFileDialogPdf.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||
saveFileDialogPdf.Title = "Save PDF Document";
|
||||
//
|
||||
// saveFileDialogWord
|
||||
//
|
||||
saveFileDialogWord.FileName = "Diagram.docx";
|
||||
saveFileDialogWord.Filter = "Word Files (*.docx)|*.docx";
|
||||
saveFileDialogWord.Title = "Save Word Document";
|
||||
//
|
||||
// saveFileDialogExel
|
||||
//
|
||||
saveFileDialogExel.FileName = "ProductReport.xlsx";
|
||||
saveFileDialogExel.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
||||
saveFileDialogExel.Title = "Save Excel Document";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(480, 351);
|
||||
Controls.Add(outputTableResults);
|
||||
Controls.Add(menuStrip1);
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Form1";
|
||||
KeyDown += MainForm_KeyDown;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem createToolStripMenuItem;
|
||||
private ToolStripMenuItem updateToolStripMenuItem;
|
||||
private Library15Gerimovich.OutputTableResults outputTableResults;
|
||||
private ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private ToolStripMenuItem manufacturerToolStripMenuItem;
|
||||
private ToolStripMenuItem documentsToolStripMenuItem;
|
||||
private ToolStripMenuItem pdfImageToolStripMenuItem;
|
||||
private ToolStripMenuItem exelTableToolStripMenuItem;
|
||||
private ToolStripMenuItem wordGistToolStripMenuItem;
|
||||
private Library14Petrushin.PdfImg pdfImg;
|
||||
private Library15Gerimovich.WordDiagramComponent wordDiagramComponent;
|
||||
private WinFormsLibrary1.ComponentTable componentTable;
|
||||
}
|
||||
}
|
@ -1,284 +0,0 @@
|
||||
using Data;
|
||||
using Data.Repositories;
|
||||
using View;
|
||||
using System.Windows.Forms;
|
||||
using Data.Models;
|
||||
using Library14Petrushin;
|
||||
using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using Library15Gerimovich;
|
||||
using WinFormsLibrary1;
|
||||
using WinFormsLibrary1.Models;
|
||||
using View.ViewModels;
|
||||
|
||||
namespace Laba3
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private SaveFileDialog saveFileDialogPdf;
|
||||
private SaveFileDialog saveFileDialogWord;
|
||||
private SaveFileDialog saveFileDialogExel;
|
||||
|
||||
public MainForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository;
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
InitializeOutputTableResults();
|
||||
LoadProducts();
|
||||
}
|
||||
|
||||
private void InitializeOutputTableResults()
|
||||
{
|
||||
outputTableResults.ConfigureColumns(new List<ColumnInfo>
|
||||
{
|
||||
new ColumnInfo("", 0, false, "Id"),
|
||||
new ColumnInfo("Name", 150, true, "Name"),
|
||||
new ColumnInfo("ManufacturerNameManufacturerName", 150, true, "ManufacturerName"),
|
||||
new ColumnInfo("DeliveryDate", 50, true, "DeliveryDate"),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void LoadProducts()
|
||||
{
|
||||
var products = _productRepository.GetAllProducts();
|
||||
outputTableResults.ClearGrid();
|
||||
foreach (var product in products)
|
||||
{
|
||||
outputTableResults.InsertValue(product);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void editToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
var selectedProduct = _productRepository.GetProductById(selectedProductId);
|
||||
var productForm = new ProductForm(_productRepository, _manufacturerRepository, selectedProduct);
|
||||
if (productForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedProductId = outputTableResults.GetSelectedObject<Product>().Id;
|
||||
if (MessageBox.Show("Are you sure you want to delete this product?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_productRepository.DeleteProduct(selectedProductId);
|
||||
LoadProducts();
|
||||
}
|
||||
}
|
||||
|
||||
private void manufacturersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var manufacturerForm = new ManufacturerForm(_manufacturerRepository);
|
||||
manufacturerForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void createSimpleDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем изображения из базы данных
|
||||
var images = GetImagesFromDatabase();
|
||||
|
||||
if (images.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogPdf.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем компонент PdfImg
|
||||
var pdfImg = new Library14Petrushin.PdfImg();
|
||||
|
||||
// Путь для сохранения PDF-документа
|
||||
string fileName = saveFileDialogPdf.FileName;
|
||||
|
||||
// Заголовок документа
|
||||
string documentTitle = "Product Images";
|
||||
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No images found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createCustomTableDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем все продукты из базы данных
|
||||
var products = GetAllProducts();
|
||||
|
||||
if (products.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogExel.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объекты MergeCell и Column
|
||||
var mergeCells = new List<MergeCell>
|
||||
{
|
||||
new MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<Column>
|
||||
{
|
||||
new Column("Id", "Id", 10),
|
||||
new Column("Name", "Name", 20),
|
||||
new Column("ManufacturerName", "ManufacturerName", 20),
|
||||
new Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = ProductTableItem.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(saveFileDialogExel.FileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
private void createChartDocumentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Получаем данные о количестве продукции каждого производителя
|
||||
var productCounts = GetProductCountsByManufacturer();
|
||||
|
||||
if (productCounts.Count > 0)
|
||||
{
|
||||
// Показываем диалоговое окно для выбора пути сохранения
|
||||
if (saveFileDialogWord.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Создаем объект WordDiagramInfo
|
||||
var diagramInfo = new WordDiagramInfo
|
||||
{
|
||||
FileName = saveFileDialogWord.FileName,
|
||||
Title = "Product Count by Manufacturer",
|
||||
ChartTitle = "Product Count",
|
||||
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Product Count",
|
||||
Data = productCounts
|
||||
}
|
||||
};
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No products found in the database.");
|
||||
}
|
||||
}
|
||||
|
||||
// бизнес логика
|
||||
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.A:
|
||||
addToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.U:
|
||||
editToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.D:
|
||||
deleteToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.S:
|
||||
createSimpleDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.T:
|
||||
createCustomTableDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
case Keys.C:
|
||||
createChartDocumentToolStripMenuItem_Click(null, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ImageData> GetImagesFromDatabase()
|
||||
{
|
||||
var images = new List<ImageData>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (product.Image != null)
|
||||
{
|
||||
// Создаем временный файл для сохранения изображения
|
||||
string tempFilePath = Path.GetTempFileName();
|
||||
File.WriteAllBytes(tempFilePath, product.Image);
|
||||
|
||||
// Добавляем путь к временному файлу в список
|
||||
images.Add(new ImageData { ImagePath = tempFilePath });
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
private Dictionary<string, double> GetProductCountsByManufacturer()
|
||||
{
|
||||
var productCounts = new Dictionary<string, double>();
|
||||
var products = _productRepository.GetAllProducts();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (productCounts.ContainsKey(product.ManufacturerName))
|
||||
{
|
||||
productCounts[product.ManufacturerName]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
productCounts[product.ManufacturerName] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return productCounts;
|
||||
}
|
||||
|
||||
private List<Product> GetAllProducts()
|
||||
{
|
||||
return _productRepository.GetAllProducts().ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>572, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfImg.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>708, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>813, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>1039, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>195, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialogExel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>388, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,64 +0,0 @@
|
||||
namespace View
|
||||
{
|
||||
partial class ManufacturerForm
|
||||
{
|
||||
/// <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();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(711, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||
dataGridView.UserAddedRow += dataGridView_UserAddedRow;
|
||||
dataGridView.UserDeletingRow += dataGridView_UserDeletingRow;
|
||||
dataGridView.KeyDown += dataGridView_KeyDown;
|
||||
//
|
||||
// ManufacturerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(731, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ManufacturerForm";
|
||||
Text = "ManufacturerForm";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
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 View
|
||||
{
|
||||
public partial class ManufacturerForm : Form
|
||||
{
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
|
||||
public ManufacturerForm(IManufacturerRepository manufacturerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
LoadManufacturers();
|
||||
}
|
||||
|
||||
private void LoadManufacturers()
|
||||
{
|
||||
var manufacturers = _manufacturerRepository.GetAllManufacturers().ToList();
|
||||
dataGridView.DataSource = manufacturers;
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
var manufacturer = dataGridView.Rows[e.RowIndex].DataBoundItem as Manufacturer;
|
||||
if (manufacturer != null)
|
||||
{
|
||||
_manufacturerRepository.UpdateManufacturer(manufacturer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
var manufacturer = e.Row.DataBoundItem as Manufacturer;
|
||||
if (manufacturer != null)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete this manufacturer?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_manufacturerRepository.DeleteManufacturer(manufacturer.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserAddedRow(object sender, DataGridViewRowEventArgs e)
|
||||
{
|
||||
var manufacturer = new Manufacturer { Name = "" };
|
||||
_manufacturerRepository.AddManufacturer(manufacturer);
|
||||
LoadManufacturers();
|
||||
}
|
||||
|
||||
|
||||
// реализация через нажатие клавишь
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Insert)
|
||||
{
|
||||
var manufacturer = new Manufacturer { Name = "" };
|
||||
_manufacturerRepository.AddManufacturer(manufacturer);
|
||||
LoadManufacturers();
|
||||
}
|
||||
else if (e.KeyCode == Keys.Delete)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
var selectedManufacturer = dataGridView.SelectedRows[0].DataBoundItem as Manufacturer;
|
||||
if (selectedManufacturer != null)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete this manufacturer?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
_manufacturerRepository.DeleteManufacturer(selectedManufacturer.Id);
|
||||
LoadManufacturers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
121
PluginsConventionLibrary/Forms/ProductForm.Designer.cs
generated
121
PluginsConventionLibrary/Forms/ProductForm.Designer.cs
generated
@ -1,121 +0,0 @@
|
||||
namespace Laba3
|
||||
{
|
||||
partial class ProductForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dtpDeliveryDate = new WinFormsLibrary1.DateInputControl();
|
||||
cmbManufacturer = new WinFormsLibrary1.ComboBoxUserControl();
|
||||
txtName = new Library14Petrushin.TextBoxRange();
|
||||
pbImage = new PictureBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dtpDeliveryDate
|
||||
//
|
||||
dtpDeliveryDate.DateFormat = null;
|
||||
dtpDeliveryDate.Location = new Point(13, 137);
|
||||
dtpDeliveryDate.Margin = new Padding(4, 5, 4, 5);
|
||||
dtpDeliveryDate.Name = "dtpDeliveryDate";
|
||||
dtpDeliveryDate.Size = new Size(186, 110);
|
||||
dtpDeliveryDate.TabIndex = 0;
|
||||
//
|
||||
// cmbManufacturer
|
||||
//
|
||||
cmbManufacturer.Location = new Point(12, 218);
|
||||
cmbManufacturer.Margin = new Padding(4, 5, 4, 5);
|
||||
cmbManufacturer.Name = "cmbManufacturer";
|
||||
cmbManufacturer.SelectedValue = "";
|
||||
cmbManufacturer.Size = new Size(201, 40);
|
||||
cmbManufacturer.TabIndex = 1;
|
||||
//
|
||||
// txtName
|
||||
//
|
||||
txtName.Location = new Point(12, 12);
|
||||
txtName.MaxLength = null;
|
||||
txtName.MinLength = null;
|
||||
txtName.Name = "txtName";
|
||||
txtName.Size = new Size(315, 108);
|
||||
txtName.TabIndex = 2;
|
||||
//
|
||||
// pbImage
|
||||
//
|
||||
pbImage.Location = new Point(320, 32);
|
||||
pbImage.Name = "pbImage";
|
||||
pbImage.Size = new Size(451, 344);
|
||||
pbImage.TabIndex = 3;
|
||||
pbImage.TabStop = false;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(320, 399);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(110, 29);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Choose img";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += btnBrowse_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(12, 326);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(94, 29);
|
||||
button2.TabIndex = 5;
|
||||
button2.Text = "Save";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += btnSave_Click;
|
||||
//
|
||||
// ProductForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(pbImage);
|
||||
Controls.Add(txtName);
|
||||
Controls.Add(cmbManufacturer);
|
||||
Controls.Add(dtpDeliveryDate);
|
||||
Name = "ProductForm";
|
||||
Text = "ProductForm";
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private WinFormsLibrary1.DateInputControl dtpDeliveryDate;
|
||||
private WinFormsLibrary1.ComboBoxUserControl cmbManufacturer;
|
||||
private Library14Petrushin.TextBoxRange txtName;
|
||||
private PictureBox pbImage;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
using Data;
|
||||
using Data.Models;
|
||||
using Data.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Laba3
|
||||
{
|
||||
public partial class ProductForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private Product _product;
|
||||
private bool _isNewProduct;
|
||||
private const int MINL = 3;
|
||||
private const int MAXL= 10;
|
||||
|
||||
public ProductForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository, Product product = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
|
||||
_productRepository = productRepository;
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
|
||||
|
||||
var manufacturers = _manufacturerRepository.GetAllManufacturers().Select(m => m.Name).ToList();
|
||||
// cmbManufacturer.Data = manufacturers;
|
||||
foreach (var manufacturer in manufacturers)
|
||||
{
|
||||
cmbManufacturer.AddItem(manufacturer);
|
||||
}
|
||||
|
||||
_product = product;
|
||||
_isNewProduct = product == null;
|
||||
txtName.MinLength = MINL;
|
||||
txtName.MaxLength = MAXL;
|
||||
dtpDeliveryDate.DateFormat = "dd MMMM yyyy";
|
||||
|
||||
if (!_isNewProduct)
|
||||
{
|
||||
txtName.InputValue = _product.Name;
|
||||
cmbManufacturer.SelectedValue = _product.ManufacturerName;
|
||||
dtpDeliveryDate.Date = _product.DeliveryDate;
|
||||
|
||||
if (_product.Image != null)
|
||||
{
|
||||
using (var ms = new MemoryStream(_product.Image))
|
||||
{
|
||||
pbImage.Image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp";
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
pbImage.Image = Image.FromFile(openFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtName.InputValue))
|
||||
{
|
||||
MessageBox.Show("Name is required.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isNewProduct)
|
||||
{
|
||||
_product = new Product();
|
||||
}
|
||||
|
||||
_product.Name = txtName.InputValue;
|
||||
_product.ManufacturerName = cmbManufacturer.SelectedValue.ToString();
|
||||
_product.DeliveryDate = dtpDeliveryDate.Date;
|
||||
|
||||
if (pbImage.Image != null)
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
pbImage.Image.Save(ms, pbImage.Image.RawFormat);
|
||||
_product.Image = ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
if (_isNewProduct)
|
||||
{
|
||||
_productRepository.AddProduct(_product);
|
||||
}
|
||||
else
|
||||
{
|
||||
_productRepository.UpdateProduct(_product);
|
||||
}
|
||||
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateWord(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateExcel(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreatePdf(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="MyPlugin\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
<ProjectReference Include="..\Models\Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Forms\MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Forms\ManufacturerForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Forms\ProductForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user