Create FormMain
This commit is contained in:
parent
c5b14425b0
commit
549daa26b1
@ -5,12 +5,6 @@ VisualStudioVersion = 17.9.34723.18
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryWinFormsApp", "LibraryWinFormsApp\LibraryWinFormsApp.csproj", "{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryWinFormsApp", "LibraryWinFormsApp\LibraryWinFormsApp.csproj", "{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryContracts", "LibraryContracts\LibraryContracts.csproj", "{70D8ED64-2FC3-40DB-8C27-324439B590AA}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryDataModels", "LibraryDataModels\LibraryDataModels.csproj", "{37477D2C-F5EB-418D-A9FA-135A71B430E1}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryDatabase", "LibraryDatabase\LibraryDatabase.csproj", "{4F0EC406-67F6-49C1-97C8-F553455780FB}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,18 +15,6 @@ Global
|
|||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{70D8ED64-2FC3-40DB-8C27-324439B590AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{70D8ED64-2FC3-40DB-8C27-324439B590AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{70D8ED64-2FC3-40DB-8C27-324439B590AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{70D8ED64-2FC3-40DB-8C27-324439B590AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{37477D2C-F5EB-418D-A9FA-135A71B430E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{37477D2C-F5EB-418D-A9FA-135A71B430E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{37477D2C-F5EB-418D-A9FA-135A71B430E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{37477D2C-F5EB-418D-A9FA-135A71B430E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{4F0EC406-67F6-49C1-97C8-F553455780FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{4F0EC406-67F6-49C1-97C8-F553455780FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{4F0EC406-67F6-49C1-97C8-F553455780FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{4F0EC406-67F6-49C1-97C8-F553455780FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
public enum DocType
|
|
||||||
{
|
|
||||||
Excel,
|
|
||||||
Word,
|
|
||||||
Pdf
|
|
||||||
}
|
|
||||||
}
|
|
66
LibraryWinFormsApp/FormAuthors.Designer.cs
generated
66
LibraryWinFormsApp/FormAuthors.Designer.cs
generated
@ -1,66 +0,0 @@
|
|||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
partial class FormAuthors
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
authorsTable = new DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)authorsTable).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// authorsTable
|
|
||||||
//
|
|
||||||
authorsTable.AllowUserToAddRows = false;
|
|
||||||
authorsTable.AllowUserToDeleteRows = false;
|
|
||||||
authorsTable.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
authorsTable.Dock = DockStyle.Fill;
|
|
||||||
authorsTable.Location = new Point(0, 0);
|
|
||||||
authorsTable.Name = "authorsTable";
|
|
||||||
authorsTable.RowTemplate.Height = 25;
|
|
||||||
authorsTable.Size = new Size(800, 450);
|
|
||||||
authorsTable.TabIndex = 0;
|
|
||||||
authorsTable.CellEndEdit += authorsTable_CellEndEdit;
|
|
||||||
authorsTable.KeyDown += authorsTable_KeyDown;
|
|
||||||
//
|
|
||||||
// FormAuthors
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(authorsTable);
|
|
||||||
Name = "FormAuthors";
|
|
||||||
Text = "Авторы";
|
|
||||||
Load += FormAuthors_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)authorsTable).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView authorsTable;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using LibraryContracts.StorageContracts;
|
|
||||||
using LibraryDataModels.Dtos;
|
|
||||||
using LibraryDataModels.Views;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
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 LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
public partial class FormAuthors : Form
|
|
||||||
{
|
|
||||||
private IAuthorStorage _authorStorage;
|
|
||||||
private List<AuthorView> _authors;
|
|
||||||
public FormAuthors(IAuthorStorage authorStorage)
|
|
||||||
{
|
|
||||||
_authorStorage = authorStorage;
|
|
||||||
_authors = new List<AuthorView>();
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormAuthors_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_authors = _authorStorage.GetFullList();
|
|
||||||
if (_authors != null)
|
|
||||||
{
|
|
||||||
authorsTable.DataSource = _authors;
|
|
||||||
authorsTable.Columns[0].Visible = false;
|
|
||||||
authorsTable.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void authorsTable_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
||||||
{
|
|
||||||
var cellValue = (string)authorsTable.CurrentRow.Cells[1].EditedFormattedValue;
|
|
||||||
if (!string.IsNullOrEmpty(cellValue))
|
|
||||||
{
|
|
||||||
var keyValue = Convert.ToInt32(authorsTable.CurrentRow.Cells[0].Value);
|
|
||||||
if (keyValue != -1)
|
|
||||||
{
|
|
||||||
_authorStorage.Update(new AuthorDto()
|
|
||||||
{
|
|
||||||
Id = keyValue,
|
|
||||||
Name = cellValue,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_authorStorage.Insert(new AuthorDto()
|
|
||||||
{
|
|
||||||
Name = cellValue,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void authorsTable_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyData == Keys.Insert)
|
|
||||||
{
|
|
||||||
if (authorsTable.Rows.Count == 0)
|
|
||||||
{
|
|
||||||
_authors.Add(new AuthorView());
|
|
||||||
authorsTable.DataSource = new BindingList<AuthorView>(_authors);
|
|
||||||
authorsTable.CurrentCell = authorsTable.Rows[0].Cells[1];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (authorsTable.Rows[authorsTable.Rows.Count - 1].Cells[1].Value != null)
|
|
||||||
{
|
|
||||||
_authors.Add(new AuthorView());
|
|
||||||
authorsTable.DataSource = new BindingList<AuthorView>(_authors);
|
|
||||||
authorsTable.CurrentCell = authorsTable.Rows[authorsTable.Rows.Count - 1].Cells[1];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.KeyData == Keys.Delete)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить выбранный элемент?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_authorStorage.Delete(new AuthorDto()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(authorsTable.CurrentRow.Cells[0].Value),
|
|
||||||
});
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
180
LibraryWinFormsApp/FormBook.Designer.cs
generated
180
LibraryWinFormsApp/FormBook.Designer.cs
generated
@ -1,180 +0,0 @@
|
|||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
partial class FormBook
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
releaseDateField = new Library_var_4_lab_1.DateInputBox();
|
|
||||||
nameField = new TextBox();
|
|
||||||
coverLabel = new Label();
|
|
||||||
nameLabel = new Label();
|
|
||||||
releaseDateLabel = new Label();
|
|
||||||
authorLabel = new Label();
|
|
||||||
authorField = new YunusovComponentsLibrary.SelectedComponent();
|
|
||||||
saveButton = new Button();
|
|
||||||
pictureBox = new PictureBox();
|
|
||||||
changeCoverButton = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// releaseDateField
|
|
||||||
//
|
|
||||||
releaseDateField.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
releaseDateField.Location = new Point(8, 67);
|
|
||||||
releaseDateField.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
releaseDateField.Name = "releaseDateField";
|
|
||||||
releaseDateField.Size = new Size(215, 61);
|
|
||||||
releaseDateField.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// nameField
|
|
||||||
//
|
|
||||||
nameField.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
nameField.Location = new Point(8, 24);
|
|
||||||
nameField.Name = "nameField";
|
|
||||||
nameField.Size = new Size(215, 23);
|
|
||||||
nameField.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// coverLabel
|
|
||||||
//
|
|
||||||
coverLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
coverLabel.AutoSize = true;
|
|
||||||
coverLabel.Location = new Point(229, 4);
|
|
||||||
coverLabel.Name = "coverLabel";
|
|
||||||
coverLabel.Size = new Size(58, 15);
|
|
||||||
coverLabel.TabIndex = 3;
|
|
||||||
coverLabel.Text = "Обложка";
|
|
||||||
//
|
|
||||||
// nameLabel
|
|
||||||
//
|
|
||||||
nameLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
nameLabel.AutoSize = true;
|
|
||||||
nameLabel.Location = new Point(8, 4);
|
|
||||||
nameLabel.Name = "nameLabel";
|
|
||||||
nameLabel.Size = new Size(59, 15);
|
|
||||||
nameLabel.TabIndex = 4;
|
|
||||||
nameLabel.Text = "Название";
|
|
||||||
//
|
|
||||||
// releaseDateLabel
|
|
||||||
//
|
|
||||||
releaseDateLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
releaseDateLabel.AutoSize = true;
|
|
||||||
releaseDateLabel.Location = new Point(8, 50);
|
|
||||||
releaseDateLabel.Name = "releaseDateLabel";
|
|
||||||
releaseDateLabel.Size = new Size(79, 15);
|
|
||||||
releaseDateLabel.TabIndex = 5;
|
|
||||||
releaseDateLabel.Text = "Дата издания";
|
|
||||||
//
|
|
||||||
// authorLabel
|
|
||||||
//
|
|
||||||
authorLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
authorLabel.AutoSize = true;
|
|
||||||
authorLabel.Location = new Point(8, 97);
|
|
||||||
authorLabel.Name = "authorLabel";
|
|
||||||
authorLabel.Size = new Size(40, 15);
|
|
||||||
authorLabel.TabIndex = 6;
|
|
||||||
authorLabel.Text = "Автор";
|
|
||||||
//
|
|
||||||
// authorField
|
|
||||||
//
|
|
||||||
authorField.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
authorField.Location = new Point(8, 114);
|
|
||||||
authorField.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
authorField.Name = "authorField";
|
|
||||||
authorField.SelectedItem = "";
|
|
||||||
authorField.Size = new Size(215, 208);
|
|
||||||
authorField.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// saveButton
|
|
||||||
//
|
|
||||||
saveButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
saveButton.Location = new Point(8, 330);
|
|
||||||
saveButton.Name = "saveButton";
|
|
||||||
saveButton.Size = new Size(215, 30);
|
|
||||||
saveButton.TabIndex = 8;
|
|
||||||
saveButton.Text = "Сохранить";
|
|
||||||
saveButton.UseVisualStyleBackColor = true;
|
|
||||||
saveButton.Click += saveButton_Click;
|
|
||||||
//
|
|
||||||
// pictureBox
|
|
||||||
//
|
|
||||||
pictureBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
pictureBox.Location = new Point(229, 24);
|
|
||||||
pictureBox.Name = "pictureBox";
|
|
||||||
pictureBox.Size = new Size(400, 276);
|
|
||||||
pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
|
|
||||||
pictureBox.TabIndex = 9;
|
|
||||||
pictureBox.TabStop = false;
|
|
||||||
//
|
|
||||||
// changeCoverButton
|
|
||||||
//
|
|
||||||
changeCoverButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
changeCoverButton.Location = new Point(229, 330);
|
|
||||||
changeCoverButton.Name = "changeCoverButton";
|
|
||||||
changeCoverButton.Size = new Size(402, 30);
|
|
||||||
changeCoverButton.TabIndex = 10;
|
|
||||||
changeCoverButton.Text = "Изменить обложку";
|
|
||||||
changeCoverButton.UseVisualStyleBackColor = true;
|
|
||||||
changeCoverButton.Click += changeCoverButton_Click;
|
|
||||||
//
|
|
||||||
// FormBook
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(639, 364);
|
|
||||||
Controls.Add(changeCoverButton);
|
|
||||||
Controls.Add(pictureBox);
|
|
||||||
Controls.Add(saveButton);
|
|
||||||
Controls.Add(authorField);
|
|
||||||
Controls.Add(authorLabel);
|
|
||||||
Controls.Add(releaseDateLabel);
|
|
||||||
Controls.Add(nameLabel);
|
|
||||||
Controls.Add(coverLabel);
|
|
||||||
Controls.Add(nameField);
|
|
||||||
Controls.Add(releaseDateField);
|
|
||||||
Name = "FormBook";
|
|
||||||
Text = "Kнигa";
|
|
||||||
FormClosing += FormBook_FormClosing;
|
|
||||||
Load += FormBook_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Library_var_4_lab_1.DateInputBox releaseDateField;
|
|
||||||
private TextBox nameField;
|
|
||||||
private Label coverLabel;
|
|
||||||
private Label nameLabel;
|
|
||||||
private Label releaseDateLabel;
|
|
||||||
private Label authorLabel;
|
|
||||||
private YunusovComponentsLibrary.SelectedComponent authorField;
|
|
||||||
private Button saveButton;
|
|
||||||
private PictureBox pictureBox;
|
|
||||||
private Button changeCoverButton;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
||||||
using Library_var_4_lab_1;
|
|
||||||
using LibraryContracts.StorageContracts;
|
|
||||||
using LibraryDatabase.Models;
|
|
||||||
using LibraryDatabase.Storages;
|
|
||||||
using LibraryDataModels.Dtos;
|
|
||||||
using LibraryDataModels.Views;
|
|
||||||
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.Controls.Primitives;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
public partial class FormBook : Form
|
|
||||||
{
|
|
||||||
public int _id { get; set; } = -1;
|
|
||||||
private string _cover { get; set; } = string.Empty;
|
|
||||||
private BookView? _book = null;
|
|
||||||
private IBookStorage _bookStorage;
|
|
||||||
private IAuthorStorage _authorStorage;
|
|
||||||
private ImageConverter _imageConverter = new ImageConverter();
|
|
||||||
public FormBook(IBookStorage bookStorage, IAuthorStorage authorStorage)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_bookStorage = bookStorage;
|
|
||||||
_authorStorage = authorStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormBook_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
releaseDateField.Template = @"^([1-9]|[12][0-9]|3[01]) (января|февраля|марта|апреля|мая|июня|июля|августа|сентября|октября|ноября|декабря) [0-9]{4}$";
|
|
||||||
var authors = _authorStorage.GetFullList();
|
|
||||||
if (authors != null)
|
|
||||||
{
|
|
||||||
foreach (var author in authors)
|
|
||||||
{
|
|
||||||
authorField.Input(author.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_id != -1)
|
|
||||||
{
|
|
||||||
_book = _bookStorage.GetElement(new BookDto()
|
|
||||||
{
|
|
||||||
Id = _id,
|
|
||||||
});
|
|
||||||
if (_book != null)
|
|
||||||
{
|
|
||||||
_cover = _book.BookCover;
|
|
||||||
nameField.Text = _book.Name;
|
|
||||||
releaseDateField.Date = _book.ReleaseDate;
|
|
||||||
authorField.SelectedItem = _book.Author;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pictureBox.Image = _imageConverter.StringToImage(_cover);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormBook_FormClosing(object sender, FormClosingEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
bool Changed = false;
|
|
||||||
if (_book == null)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(_cover))
|
|
||||||
Changed = true;
|
|
||||||
if (!string.IsNullOrEmpty(nameField.Text))
|
|
||||||
Changed = true;
|
|
||||||
if (!string.IsNullOrEmpty(releaseDateField.Text))
|
|
||||||
Changed = true;
|
|
||||||
if (!string.IsNullOrEmpty(authorField.Text))
|
|
||||||
Changed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_cover != _book.BookCover)
|
|
||||||
Changed = true;
|
|
||||||
if (nameField.Text != _book.Name)
|
|
||||||
Changed = true;
|
|
||||||
if (releaseDateField.Date != _book.ReleaseDate)
|
|
||||||
Changed = true;
|
|
||||||
if (authorField.SelectedItem != _book.Author)
|
|
||||||
Changed = true;
|
|
||||||
}
|
|
||||||
if (Changed)
|
|
||||||
{
|
|
||||||
DialogResult dialogResult = MessageBox.Show("Изменения не были сохранены. Всё равно выйти?", "Внимание!", MessageBoxButtons.YesNo);
|
|
||||||
if (dialogResult == DialogResult.No)
|
|
||||||
{
|
|
||||||
e.Cancel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_cover))
|
|
||||||
{
|
|
||||||
throw new Exception("Выберите обложку");
|
|
||||||
}
|
|
||||||
var book = new BookDto()
|
|
||||||
{
|
|
||||||
Name = nameField.Text,
|
|
||||||
BookCover = _cover,
|
|
||||||
Author = authorField.SelectedItem,
|
|
||||||
ReleaseDate = releaseDateField.Date,
|
|
||||||
};
|
|
||||||
if (_id != -1)
|
|
||||||
{
|
|
||||||
book.Id = _id;
|
|
||||||
_book = _bookStorage.Update(book);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_book = _bookStorage.Insert(book);
|
|
||||||
}
|
|
||||||
_id = _book?.Id ?? -1;
|
|
||||||
_cover = _book?.BookCover ?? string.Empty;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeCoverButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
var dialog = new OpenFileDialog();
|
|
||||||
|
|
||||||
dialog.Title = "Выберите изображение";
|
|
||||||
dialog.Filter = "Изображения|*.jpg;*.jpeg;*.png;*.bmp";
|
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
var image_new = new Bitmap(dialog.FileName);
|
|
||||||
pictureBox.Image = image_new;
|
|
||||||
_cover = _imageConverter.ImageToString(image_new);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
145
LibraryWinFormsApp/FormBooks.Designer.cs
generated
145
LibraryWinFormsApp/FormBooks.Designer.cs
generated
@ -1,145 +0,0 @@
|
|||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
partial class FormBooks
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
bookTable = new YunusovComponentsLibrary.ListOutputComponent();
|
|
||||||
bookTableContextMenuStrip = new ContextMenuStrip(components);
|
|
||||||
changeAuthorsToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
createBookToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
updateBookToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
deleteBookToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
createPdfToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
createExcellToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
createWordToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
pdfImage = new ComponentLibrary1.pdf_image.PdfImage(components);
|
|
||||||
configurableTable = new Library_var_4_lab_1.ConfigurableTable(components);
|
|
||||||
wordDiagram = new YunusovComponentsLibrary.WordDiagram(components);
|
|
||||||
bookTableContextMenuStrip.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// bookTable
|
|
||||||
//
|
|
||||||
bookTable.AutoSize = true;
|
|
||||||
bookTable.ContextMenuStrip = bookTableContextMenuStrip;
|
|
||||||
bookTable.Dock = DockStyle.Fill;
|
|
||||||
bookTable.Location = new Point(0, 0);
|
|
||||||
bookTable.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
bookTable.Name = "bookTable";
|
|
||||||
bookTable.SelectedRow = -1;
|
|
||||||
bookTable.Size = new Size(827, 493);
|
|
||||||
bookTable.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// bookTableContextMenuStrip
|
|
||||||
//
|
|
||||||
bookTableContextMenuStrip.Items.AddRange(new ToolStripItem[] { changeAuthorsToolStripMenuItem, createBookToolStripMenuItem, updateBookToolStripMenuItem, deleteBookToolStripMenuItem, createPdfToolStripMenuItem, createExcellToolStripMenuItem, createWordToolStripMenuItem });
|
|
||||||
bookTableContextMenuStrip.Name = "bookTableContextMenuStrip";
|
|
||||||
bookTableContextMenuStrip.Size = new Size(202, 158);
|
|
||||||
//
|
|
||||||
// changeAuthorsToolStripMenuItem
|
|
||||||
//
|
|
||||||
changeAuthorsToolStripMenuItem.Name = "changeAuthorsToolStripMenuItem";
|
|
||||||
changeAuthorsToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
changeAuthorsToolStripMenuItem.Text = "Редактировать авторов";
|
|
||||||
changeAuthorsToolStripMenuItem.Click += changeAuthorsToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// createBookToolStripMenuItem
|
|
||||||
//
|
|
||||||
createBookToolStripMenuItem.Name = "createBookToolStripMenuItem";
|
|
||||||
createBookToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
createBookToolStripMenuItem.Text = "Добавить книгу";
|
|
||||||
createBookToolStripMenuItem.Click += createBookToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// updateBookToolStripMenuItem
|
|
||||||
//
|
|
||||||
updateBookToolStripMenuItem.Name = "updateBookToolStripMenuItem";
|
|
||||||
updateBookToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
updateBookToolStripMenuItem.Text = "Редактировать книгу";
|
|
||||||
updateBookToolStripMenuItem.Click += updateBookToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// deleteBookToolStripMenuItem
|
|
||||||
//
|
|
||||||
deleteBookToolStripMenuItem.Name = "deleteBookToolStripMenuItem";
|
|
||||||
deleteBookToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
deleteBookToolStripMenuItem.Text = "Удалить книгу";
|
|
||||||
deleteBookToolStripMenuItem.Click += deleteBookToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// createPdfToolStripMenuItem
|
|
||||||
//
|
|
||||||
createPdfToolStripMenuItem.Name = "createPdfToolStripMenuItem";
|
|
||||||
createPdfToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
createPdfToolStripMenuItem.Text = "Создать pdf";
|
|
||||||
createPdfToolStripMenuItem.Click += createPdfToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// createExcellToolStripMenuItem
|
|
||||||
//
|
|
||||||
createExcellToolStripMenuItem.Name = "createExcellToolStripMenuItem";
|
|
||||||
createExcellToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
createExcellToolStripMenuItem.Text = "Создать excell";
|
|
||||||
createExcellToolStripMenuItem.Click += createExcellToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// createWordToolStripMenuItem
|
|
||||||
//
|
|
||||||
createWordToolStripMenuItem.Name = "createWordToolStripMenuItem";
|
|
||||||
createWordToolStripMenuItem.Size = new Size(201, 22);
|
|
||||||
createWordToolStripMenuItem.Text = "Создать word";
|
|
||||||
createWordToolStripMenuItem.Click += createWordToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// FormBooks
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(827, 493);
|
|
||||||
Controls.Add(bookTable);
|
|
||||||
KeyPreview = true;
|
|
||||||
Name = "FormBooks";
|
|
||||||
Text = "Книги";
|
|
||||||
Load += FormBooks_Load;
|
|
||||||
KeyDown += booksTable_KeyDown;
|
|
||||||
bookTableContextMenuStrip.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private YunusovComponentsLibrary.ListOutputComponent bookTable;
|
|
||||||
private ContextMenuStrip bookTableContextMenuStrip;
|
|
||||||
private ToolStripMenuItem changeAuthorsToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem createBookToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem updateBookToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem deleteBookToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem createPdfToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem createExcellToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem createWordToolStripMenuItem;
|
|
||||||
private ComponentLibrary1.pdf_image.PdfImage pdfImage;
|
|
||||||
private Library_var_4_lab_1.ConfigurableTable configurableTable;
|
|
||||||
private YunusovComponentsLibrary.WordDiagram wordDiagram;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,357 +0,0 @@
|
|||||||
using ComponentLibrary1.pdf_image;
|
|
||||||
using LibraryContracts.StorageContracts;
|
|
||||||
using LibraryDataModels.Dtos;
|
|
||||||
using LibraryDataModels.Views;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using YunusovComponentsLibrary;
|
|
||||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
|
||||||
|
|
||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
public partial class FormBooks : Form
|
|
||||||
{
|
|
||||||
private IBookStorage _bookStorage;
|
|
||||||
private IAuthorStorage _authorStorage;
|
|
||||||
private List<BookView> _books = new List<BookView>();
|
|
||||||
private ImageConverter _converter = new ImageConverter();
|
|
||||||
public FormBooks(IBookStorage bookStorage, IAuthorStorage authorStorage)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_bookStorage = bookStorage;
|
|
||||||
_authorStorage = authorStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region event-handler-methods
|
|
||||||
private void FormBooks_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeAuthorsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormAuthors));
|
|
||||||
if (service is FormAuthors form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createBookToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CreateBook();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBookToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
UpdateBook();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteBookToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DeleteBook();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPdfToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CreatePdf();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createExcellToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CreateExcell();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createWordToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CreateWord();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void booksTable_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!e.Control) { return; }
|
|
||||||
switch (e.KeyCode)
|
|
||||||
{
|
|
||||||
case Keys.A:
|
|
||||||
CreateBook();
|
|
||||||
break;
|
|
||||||
case Keys.U:
|
|
||||||
UpdateBook();
|
|
||||||
break;
|
|
||||||
case Keys.D:
|
|
||||||
DeleteBook();
|
|
||||||
break;
|
|
||||||
case Keys.S:
|
|
||||||
CreatePdf();
|
|
||||||
break;
|
|
||||||
case Keys.T:
|
|
||||||
CreateExcell();
|
|
||||||
break;
|
|
||||||
case Keys.C:
|
|
||||||
CreateWord();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_books = _bookStorage.GetFullList();
|
|
||||||
List<ColumnInfo> parameters = new List<ColumnInfo>()
|
|
||||||
{
|
|
||||||
new ColumnInfo("", 0, false, "Id"),
|
|
||||||
new ColumnInfo("Íàçâàíèå", 258, true, "Name"),
|
|
||||||
new ColumnInfo("", 0, false, "BookCover"),
|
|
||||||
new ColumnInfo("ÔÈÎ àâòîðà", 258, true, "Author"),
|
|
||||||
new ColumnInfo("Äàòà èçäàíèÿ", 258, true, "ReleaseDate"),
|
|
||||||
};
|
|
||||||
bookTable.ConfigColumn(parameters);
|
|
||||||
if (_books == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach (var book in _books)
|
|
||||||
{
|
|
||||||
bookTable.AddItem(book);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateBook()
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormBook));
|
|
||||||
if (service is FormBook form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateBook()
|
|
||||||
{
|
|
||||||
int selectedRow = bookTable.SelectedRow;
|
|
||||||
if (selectedRow == -1)
|
|
||||||
{
|
|
||||||
throw new Exception("Âûáåðèòå êíèãó äëÿ ðåäàêòèðîâàíèÿ äàííûõ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(bookTable.Rows[selectedRow].Cells[0].Value);
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormBook));
|
|
||||||
if (service is FormBook form)
|
|
||||||
{
|
|
||||||
form._id = id;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DeleteBook()
|
|
||||||
{
|
|
||||||
int selectedRow = bookTable.SelectedRow;
|
|
||||||
if (selectedRow == -1)
|
|
||||||
{
|
|
||||||
throw new Exception("Âûáåðèòå êíèãó äëÿ óäàëåíèÿ");
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Óäàëèòü çàïèñü?", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(bookTable.Rows[selectedRow].Cells[0].Value);
|
|
||||||
_bookStorage.Delete(new BookDto()
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetFileExtension(DocType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DocType.Excel:
|
|
||||||
return ".xlsx";
|
|
||||||
case DocType.Word:
|
|
||||||
return ".docx";
|
|
||||||
case DocType.Pdf:
|
|
||||||
return ".pdf";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetFileFullName(DocType type)
|
|
||||||
{
|
|
||||||
string extension = GetFileExtension(type);
|
|
||||||
if (string.IsNullOrEmpty(extension))
|
|
||||||
{
|
|
||||||
throw new Exception("Invalid file extension");
|
|
||||||
}
|
|
||||||
using SaveFileDialog fileDialog = new SaveFileDialog
|
|
||||||
{
|
|
||||||
Filter = $"Ôàéëû|*{extension}"
|
|
||||||
};
|
|
||||||
if (fileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
return fileDialog.FileName;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreatePdf()
|
|
||||||
{
|
|
||||||
string fileName = GetFileFullName(DocType.Pdf);
|
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_books = _bookStorage.GetFullList();
|
|
||||||
List<byte[]> selectedImages = new List<byte[]>();
|
|
||||||
foreach (var book in _books)
|
|
||||||
{
|
|
||||||
selectedImages.Add(_converter.StringToByteArray(book.BookCover));
|
|
||||||
}
|
|
||||||
var info = new PdfImageInfo
|
|
||||||
{
|
|
||||||
FileName = fileName,
|
|
||||||
Title = "Îáëîæêè",
|
|
||||||
Images = selectedImages,
|
|
||||||
};
|
|
||||||
pdfImage.CreatePdf(info);
|
|
||||||
MessageBox.Show("PDF óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateExcell()
|
|
||||||
{
|
|
||||||
string fileName = GetFileFullName(DocType.Excel);
|
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<TreeNode> headers = new List<TreeNode>
|
|
||||||
{
|
|
||||||
new TreeNode
|
|
||||||
{
|
|
||||||
Text = "Èäåíòèôèêàòîð",
|
|
||||||
Tag = "Id",
|
|
||||||
Name = "40",
|
|
||||||
},
|
|
||||||
new TreeNode("Êíèãà", new TreeNode[]
|
|
||||||
{
|
|
||||||
new TreeNode
|
|
||||||
{
|
|
||||||
Text = "Íàçâàíèå",
|
|
||||||
Tag = "Name",
|
|
||||||
Name = "40",
|
|
||||||
},
|
|
||||||
new TreeNode
|
|
||||||
{
|
|
||||||
Text = "Àâòîð",
|
|
||||||
Tag = "Author",
|
|
||||||
Name = "40",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new TreeNode
|
|
||||||
{
|
|
||||||
Text = "Äàòà",
|
|
||||||
Tag = "ReleaseDate",
|
|
||||||
Name = "40",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
_books = _bookStorage.GetFullList();
|
|
||||||
configurableTable.CreateTable(
|
|
||||||
fileName,
|
|
||||||
"Êíèãè",
|
|
||||||
headers,
|
|
||||||
_books);
|
|
||||||
MessageBox.Show("Excell óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateWord()
|
|
||||||
{
|
|
||||||
string fileName = GetFileFullName(DocType.Word);
|
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_books = _bookStorage.GetFullList();
|
|
||||||
var authors = _authorStorage.GetFullList();
|
|
||||||
WordDiagramSeries series = new WordDiagramSeries();
|
|
||||||
series.SeriesName = "Àâòîðû";
|
|
||||||
foreach (var author in authors)
|
|
||||||
{
|
|
||||||
double sum = 0.0;
|
|
||||||
foreach (var book in _books)
|
|
||||||
{
|
|
||||||
if (string.Equals(book.Author, author.Name))
|
|
||||||
{
|
|
||||||
sum++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
series.Data.Add(author.Name, sum);
|
|
||||||
}
|
|
||||||
wordDiagram.CreateDiagram(new WordDiagramInfo()
|
|
||||||
{
|
|
||||||
FileName = fileName,
|
|
||||||
Title = "Àâòîðû",
|
|
||||||
ChartTitle = "Àâòîðû",
|
|
||||||
Series = series,
|
|
||||||
});
|
|
||||||
MessageBox.Show("Word óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +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="bookTableContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="pdfImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>222, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="configurableTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>327, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="wordDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>475, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
233
LibraryWinFormsApp/FormMain.Designer.cs
generated
Normal file
233
LibraryWinFormsApp/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
namespace LibraryWinFormsApp
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.ControlsStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ActionsToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.DocsToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.SimpleDocToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.TableDocToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ChartDocToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.panelControl = new System.Windows.Forms.Panel();
|
||||||
|
this.ThesaurusToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.AddElementToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.UpdElementToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.DelElementToolStripMenuItem = new
|
||||||
|
System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.Items.AddRange(new
|
||||||
|
System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ControlsStripMenuItem,
|
||||||
|
this.ActionsToolStripMenuItem,
|
||||||
|
this.DocsToolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(800, 24);
|
||||||
|
this.menuStrip.TabIndex = 0;
|
||||||
|
this.menuStrip.Text = "Меню";
|
||||||
|
//
|
||||||
|
// ControlsStripMenuItem
|
||||||
|
//
|
||||||
|
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||||
|
this.ControlsStripMenuItem.Size = new System.Drawing.Size(94,
|
||||||
|
20);
|
||||||
|
this.ControlsStripMenuItem.Text = "Компоненты";
|
||||||
|
//
|
||||||
|
// ActionsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new
|
||||||
|
System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ThesaurusToolStripMenuItem,
|
||||||
|
this.AddElementToolStripMenuItem,
|
||||||
|
this.UpdElementToolStripMenuItem,
|
||||||
|
this.DelElementToolStripMenuItem});
|
||||||
|
this.ActionsToolStripMenuItem.Name =
|
||||||
|
"ActionsToolStripMenuItem";
|
||||||
|
this.ActionsToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(70, 20);
|
||||||
|
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||||
|
//
|
||||||
|
// DocsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.DocsToolStripMenuItem.DropDownItems.AddRange(new
|
||||||
|
System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.SimpleDocToolStripMenuItem,
|
||||||
|
this.TableDocToolStripMenuItem,
|
||||||
|
this.ChartDocToolStripMenuItem});
|
||||||
|
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||||
|
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.DocsToolStripMenuItem.Text = "Документы";
|
||||||
|
//
|
||||||
|
// SimpleDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||||
|
this.SimpleDocToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.S)));
|
||||||
|
this.SimpleDocToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(233, 22);
|
||||||
|
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||||
|
this.SimpleDocToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// TableDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.TableDocToolStripMenuItem.Name =
|
||||||
|
"TableDocToolStripMenuItem";
|
||||||
|
this.TableDocToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.T)));
|
||||||
|
this.TableDocToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(233, 22);
|
||||||
|
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||||
|
this.TableDocToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.TableDocToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// ChartDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ChartDocToolStripMenuItem.Name =
|
||||||
|
"ChartDocToolStripMenuItem";
|
||||||
|
this.ChartDocToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.C)));
|
||||||
|
this.ChartDocToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(233, 22);
|
||||||
|
this.ChartDocToolStripMenuItem.Text = "Диаграмма";
|
||||||
|
this.ChartDocToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.ChartDocToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// panelControl
|
||||||
|
//
|
||||||
|
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panelControl.Location = new System.Drawing.Point(0, 24);
|
||||||
|
this.panelControl.Name = "panelControl";
|
||||||
|
this.panelControl.Size = new System.Drawing.Size(800, 426);
|
||||||
|
this.panelControl.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// ThesaurusToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ThesaurusToolStripMenuItem.Name =
|
||||||
|
"ThesaurusToolStripMenuItem";
|
||||||
|
this.ThesaurusToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.I)));
|
||||||
|
this.ThesaurusToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(180, 22);
|
||||||
|
this.ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||||
|
this.ThesaurusToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// AddElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.AddElementToolStripMenuItem.Name =
|
||||||
|
"AddElementToolStripMenuItem";
|
||||||
|
this.AddElementToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.A)));
|
||||||
|
this.AddElementToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(180, 22);
|
||||||
|
this.AddElementToolStripMenuItem.Text = "Добавить";
|
||||||
|
this.AddElementToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.AddElementToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// UpdElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||||
|
this.UpdElementToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.U)));
|
||||||
|
this.UpdElementToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(180, 22);
|
||||||
|
this.UpdElementToolStripMenuItem.Text = "Изменить";
|
||||||
|
this.UpdElementToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.UpdElementToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// DelElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.DelElementToolStripMenuItem.Name =
|
||||||
|
"DelElementToolStripMenuItem";
|
||||||
|
this.DelElementToolStripMenuItem.ShortcutKeys =
|
||||||
|
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
|
||||||
|
System.Windows.Forms.Keys.D)));
|
||||||
|
this.DelElementToolStripMenuItem.Size = new
|
||||||
|
System.Drawing.Size(180, 22);
|
||||||
|
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||||
|
this.DelElementToolStripMenuItem.Click += new
|
||||||
|
System.EventHandler(this.DelElementToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.panelControl);
|
||||||
|
this.Controls.Add(this.menuStrip);
|
||||||
|
this.MainMenuStrip = this.menuStrip;
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.StartPosition =
|
||||||
|
System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Главная форма";
|
||||||
|
this.WindowState =
|
||||||
|
System.Windows.Forms.FormWindowState.Maximized;
|
||||||
|
this.KeyDown += new
|
||||||
|
System.Windows.Forms.KeyEventHandler(this.FormMain_KeyDown);
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.Panel panelControl;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
253
LibraryWinFormsApp/FormMain.cs
Normal file
253
LibraryWinFormsApp/FormMain.cs
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
using NPOI.HPSF;
|
||||||
|
using Plugins;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace LibraryWinFormsApp
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||||
|
private string _selectedPlugin;
|
||||||
|
public FormMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_plugins = LoadPlugins();
|
||||||
|
_selectedPlugin = string.Empty;
|
||||||
|
}
|
||||||
|
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||||
|
{
|
||||||
|
Dictionary<string, IPluginsConvention> plugins = new();
|
||||||
|
string currentDirectory = Directory
|
||||||
|
.GetParent(Environment.CurrentDirectory)!
|
||||||
|
.Parent!
|
||||||
|
.Parent!
|
||||||
|
.Parent!
|
||||||
|
.FullName + "\\plugin";
|
||||||
|
string[] dllFiles = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);
|
||||||
|
foreach (string dllFile in dllFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||||
|
|
||||||
|
Type[] types = assembly.GetTypes();
|
||||||
|
|
||||||
|
foreach (Type type in types)
|
||||||
|
{
|
||||||
|
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||||
|
{
|
||||||
|
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||||
|
|
||||||
|
plugins.Add(plugin.PluginName, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Не удалось загрузить плагин {dllFile}: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var plugin in plugins)
|
||||||
|
{
|
||||||
|
CreateMenuItem(plugin.Value.PluginName);
|
||||||
|
}
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
private void CreateMenuItem(string pluginName)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem menuItem = new ToolStripMenuItem(pluginName);
|
||||||
|
menuItem.Click += (object? sender, EventArgs a) =>
|
||||||
|
{
|
||||||
|
_selectedPlugin = pluginName;
|
||||||
|
IPluginsConvention plugin = _plugins[pluginName];
|
||||||
|
UserControl userControl = plugin.GetControl;
|
||||||
|
if (userControl != null)
|
||||||
|
{
|
||||||
|
panelControl.Controls.Clear();
|
||||||
|
plugin.ReloadData();
|
||||||
|
userControl.Dock = DockStyle.Fill;
|
||||||
|
panelControl.Controls.Add(userControl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ControlsStripMenuItem.DropDownItems.Add(menuItem);
|
||||||
|
}
|
||||||
|
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_selectedPlugin) ||
|
||||||
|
!_plugins.ContainsKey(_selectedPlugin))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!e.Control)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.I:
|
||||||
|
ShowThesaurus();
|
||||||
|
break;
|
||||||
|
case Keys.A:
|
||||||
|
AddNewElement();
|
||||||
|
break;
|
||||||
|
case Keys.U:
|
||||||
|
UpdateElement();
|
||||||
|
break;
|
||||||
|
case Keys.D:
|
||||||
|
DeleteElement();
|
||||||
|
break;
|
||||||
|
case Keys.S:
|
||||||
|
CreateSimpleDoc();
|
||||||
|
break;
|
||||||
|
case Keys.T:
|
||||||
|
CreateTableDoc();
|
||||||
|
break;
|
||||||
|
case Keys.C:
|
||||||
|
CreateChartDoc();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ShowThesaurus()
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].GetThesaurus()?.Show();
|
||||||
|
}
|
||||||
|
private void AddNewElement()
|
||||||
|
{
|
||||||
|
var form = _plugins[_selectedPlugin].GetForm(null);
|
||||||
|
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].ReloadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void UpdateElement()
|
||||||
|
{
|
||||||
|
var element = _plugins[_selectedPlugin].GetElement;
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранного элемента", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var form = _plugins[_selectedPlugin].GetForm(element);
|
||||||
|
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].ReloadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DeleteElement()
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var element = _plugins[_selectedPlugin].GetElement;
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранного элемента", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_plugins[_selectedPlugin].DeleteElement(element))
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].ReloadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateSimpleDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.Filter = "Word Documents (*.docx)|*.docx";
|
||||||
|
saveFileDialog.Title = "Сохранить простой документ";
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_plugins[_selectedPlugin].CreateSimpleDocument(
|
||||||
|
new PluginsConventionSaveDocument()
|
||||||
|
{
|
||||||
|
FileName = saveFileDialog.FileName
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сохранен", "Создание" +
|
||||||
|
" документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ошибка при создании документа",
|
||||||
|
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateTableDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||||
|
saveFileDialog.Title = "Сохранить таблицу";
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_plugins[_selectedPlugin].CreateTableDocument(
|
||||||
|
new PluginsConventionSaveDocument()
|
||||||
|
{
|
||||||
|
FileName = saveFileDialog.FileName
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сохранен", "Создание" +
|
||||||
|
" документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ошибка при создании документа",
|
||||||
|
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateChartDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
||||||
|
saveFileDialog.Title = "Сохранить диаграмму";
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_plugins[_selectedPlugin].CreateChartDocument(
|
||||||
|
new PluginsConventionSaveDocument()
|
||||||
|
{
|
||||||
|
FileName = saveFileDialog.FileName
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сохранен", "Создание" +
|
||||||
|
" документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ошибка при создании документа",
|
||||||
|
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ThesaurusToolStripMenuItem_Click(object sender,
|
||||||
|
EventArgs e) => ShowThesaurus();
|
||||||
|
private void AddElementToolStripMenuItem_Click(object sender,
|
||||||
|
EventArgs e) => AddNewElement();
|
||||||
|
private void UpdElementToolStripMenuItem_Click(object sender,
|
||||||
|
EventArgs e) => UpdateElement();
|
||||||
|
private void DelElementToolStripMenuItem_Click(object sender,
|
||||||
|
EventArgs e) => DeleteElement();
|
||||||
|
private void SimpleDocToolStripMenuItem_Click(object sender,
|
||||||
|
EventArgs e) => CreateSimpleDoc();
|
||||||
|
private void TableDocToolStripMenuItem_Click(object sender, EventArgs
|
||||||
|
e) => CreateTableDoc();
|
||||||
|
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs
|
||||||
|
e) => CreateChartDoc();
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
internal class ImageConverter
|
|
||||||
{
|
|
||||||
public Image StringToImage(string bytes)
|
|
||||||
{
|
|
||||||
byte[] arrayimg = Convert.FromBase64String(bytes);
|
|
||||||
Image imageStr = Image.FromStream(new MemoryStream(arrayimg));
|
|
||||||
return imageStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ImageToString(Image image)
|
|
||||||
{
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
image.Save(ms, image.RawFormat);
|
|
||||||
byte[] imageBytes = ms.ToArray();
|
|
||||||
string base64String = Convert.ToBase64String(imageBytes);
|
|
||||||
return base64String;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public byte[] StringToByteArray(string bytes)
|
|
||||||
{
|
|
||||||
return Convert.FromBase64String(bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,8 +15,4 @@
|
|||||||
<PackageReference Include="YunusovComponentsLibrary" Version="1.0.1" />
|
<PackageReference Include="YunusovComponentsLibrary" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\LibraryDatabase\LibraryDatabase.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,14 +1,7 @@
|
|||||||
using System;
|
|
||||||
using LibraryContracts.StorageContracts;
|
|
||||||
using LibraryDatabase.Storages;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace LibraryWinFormsApp
|
namespace LibraryWinFormsApp
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,19 +11,7 @@ namespace LibraryWinFormsApp
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
Application.Run(new FormMain());
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormBooks>());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddTransient<IAuthorStorage, AuthorStorage>();
|
|
||||||
services.AddTransient<IBookStorage, BookStorage>();
|
|
||||||
services.AddTransient<FormBooks>();
|
|
||||||
services.AddTransient<FormBook>();
|
|
||||||
services.AddTransient<FormAuthors>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user