4 лаба готова
This commit is contained in:
parent
5a6d37dfba
commit
dbe12624a3
26
COP_5/AppByPlugins/AppByPlugins.csproj
Normal file
26
COP_5/AppByPlugins/AppByPlugins.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LibraryAccountingApp_lab3\LibraryAccountingApp_lab3.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
174
COP_5/AppByPlugins/FormMain.Designer.cs
generated
Normal file
174
COP_5/AppByPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,174 @@
|
||||
namespace AppByPlugins
|
||||
{
|
||||
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()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
ControlsStripMenuItem = new ToolStripMenuItem();
|
||||
ActionsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ThesaurusToolStripMenuItem = new ToolStripMenuItem();
|
||||
AddElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
UpdElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DelElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DocsToolStripMenuItem = new ToolStripMenuItem();
|
||||
SimpleDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
TableDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
ChartDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
panelControl = new Panel();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
ControlsStripMenuItem.Size = new Size(90, 20);
|
||||
ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
|
||||
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
ActionsToolStripMenuItem.Size = new Size(70, 20);
|
||||
ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
|
||||
ThesaurusToolStripMenuItem.Size = new Size(179, 22);
|
||||
ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
AddElementToolStripMenuItem.Size = new Size(179, 22);
|
||||
AddElementToolStripMenuItem.Text = "Добавить";
|
||||
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
UpdElementToolStripMenuItem.Size = new Size(179, 22);
|
||||
UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
DelElementToolStripMenuItem.Size = new Size(179, 22);
|
||||
DelElementToolStripMenuItem.Text = "Удалить";
|
||||
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
|
||||
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
DocsToolStripMenuItem.Size = new Size(82, 20);
|
||||
DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
SimpleDocToolStripMenuItem.Size = new Size(251, 22);
|
||||
SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
TableDocToolStripMenuItem.Size = new Size(251, 22);
|
||||
TableDocToolStripMenuItem.Text = "Документ с таблицей";
|
||||
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
ChartDocToolStripMenuItem.Size = new Size(251, 22);
|
||||
ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
panelControl.Dock = DockStyle.Fill;
|
||||
panelControl.Location = new Point(0, 24);
|
||||
panelControl.Name = "panelControl";
|
||||
panelControl.Size = new Size(800, 426);
|
||||
panelControl.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(panelControl);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Главная форма";
|
||||
WindowState = FormWindowState.Maximized;
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem ControlsStripMenuItem;
|
||||
private ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||
private ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private Panel panelControl;
|
||||
private ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||
private ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
}
|
||||
}
|
217
COP_5/AppByPlugins/FormMain.cs
Normal file
217
COP_5/AppByPlugins/FormMain.cs
Normal file
@ -0,0 +1,217 @@
|
||||
using PluginsConventionLibrary;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AppByPlugins
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
private string _selectedPlugin;
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
_plugins = LoadPlugins();
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
|
||||
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||
{
|
||||
var plugins = new Dictionary<string, IPluginsConvention>();
|
||||
|
||||
string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.Parent!.FullName + "\\Plugins";
|
||||
|
||||
string[] dllFiles = Directory.GetFiles(pluginsDir, "*.dll", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string dllFile in dllFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||
{
|
||||
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||
plugins.Add(plugin.PluginName, plugin);
|
||||
CreateMenuItem(plugin.PluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при загрузке сборки {dllFile}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private void CreateMenuItem(string pluginName)
|
||||
{
|
||||
ToolStripMenuItem menuItem = new(pluginName);
|
||||
menuItem.Click += (object? sender, EventArgs e) =>
|
||||
{
|
||||
UserControl userControl = _plugins[pluginName].GetControl;
|
||||
if (userControl != null)
|
||||
{
|
||||
panelControl.Controls.Clear();
|
||||
userControl.Dock = DockStyle.Fill;
|
||||
_plugins[pluginName].ReloadData();
|
||||
_selectedPlugin = pluginName;
|
||||
panelControl.Controls.Add(userControl);
|
||||
}
|
||||
};
|
||||
ControlsStripMenuItem.DropDownItems.Add(menuItem);
|
||||
}
|
||||
|
||||
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_selectedPlugin) ||
|
||||
!_plugins.ContainsKey(_selectedPlugin))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.I:
|
||||
ShowThesaurus();
|
||||
break;
|
||||
case Keys.A:
|
||||
AddNewElement();
|
||||
break;
|
||||
case Keys.U:
|
||||
UpdateElement();
|
||||
break;
|
||||
case Keys.D:
|
||||
DeleteElement();
|
||||
break;
|
||||
case Keys.S:
|
||||
CreateSimpleDoc();
|
||||
break;
|
||||
case Keys.T:
|
||||
CreateTableDoc();
|
||||
break;
|
||||
case Keys.C:
|
||||
CreateChartDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowThesaurus()
|
||||
{
|
||||
_plugins[_selectedPlugin].GetThesaurus()?.Show();
|
||||
}
|
||||
|
||||
private void AddNewElement()
|
||||
{
|
||||
var form = _plugins[_selectedPlugin].GetForm(null);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElement()
|
||||
{
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для обновления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
var form = _plugins[_selectedPlugin].GetForm(element);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteElement()
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Удалить выбранный элемент?",
|
||||
"Удаление",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для удаления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (_plugins[_selectedPlugin].DeleteElement(element))
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSimpleDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
}
|
||||
}
|
||||
|
||||
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
|
||||
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
|
||||
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
|
||||
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
|
||||
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
|
||||
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
|
||||
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -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.
|
||||
-->
|
||||
@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,4 +1,4 @@
|
||||
namespace PluginsConventionLibrary
|
||||
namespace AppByPlugins
|
||||
{
|
||||
internal static class Program
|
||||
{
|
@ -9,7 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsApp", "WinFormsApp\
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryAccountingApp_lab3", "LibraryAccountingApp_lab3\LibraryAccountingApp_lab3.csproj", "{6B665435-1A86-44B4-B4C9-B0F29559314D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{546EACBF-3463-4F53-B1DE-86141E8B3BCA}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{8FC0A55F-9949-4F12-852C-0A9E78652188}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppByPlugins", "AppByPlugins\AppByPlugins.csproj", "{8EB82929-920E-44C7-BA26-6C5E91AC9B67}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -29,10 +31,14 @@ Global
|
||||
{6B665435-1A86-44B4-B4C9-B0F29559314D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B665435-1A86-44B4-B4C9-B0F29559314D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B665435-1A86-44B4-B4C9-B0F29559314D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{546EACBF-3463-4F53-B1DE-86141E8B3BCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{546EACBF-3463-4F53-B1DE-86141E8B3BCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{546EACBF-3463-4F53-B1DE-86141E8B3BCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{546EACBF-3463-4F53-B1DE-86141E8B3BCA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8FC0A55F-9949-4F12-852C-0A9E78652188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8FC0A55F-9949-4F12-852C-0A9E78652188}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8FC0A55F-9949-4F12-852C-0A9E78652188}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8FC0A55F-9949-4F12-852C-0A9E78652188}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8EB82929-920E-44C7-BA26-6C5E91AC9B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8EB82929-920E-44C7-BA26-6C5E91AC9B67}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8EB82929-920E-44C7-BA26-6C5E91AC9B67}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8EB82929-920E-44C7-BA26-6C5E91AC9B67}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -37,6 +37,7 @@ namespace LibraryAccountingApp_lab3
|
||||
textBoxTitle.Text = view.Title;
|
||||
dateTextBoxDate.TextBoxValue = view.Date;
|
||||
textBoxImage.Text = "Обложка выбрана";
|
||||
selectedImage = view.Image;
|
||||
|
||||
controlSelectedComboBoxSingleAuthor.SelectedElement = view.AuthorName;
|
||||
}
|
||||
|
@ -23,6 +23,15 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COP_5\COP_5.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CreatePluginsFolder" BeforeTargets="PreBuildEvent" Condition="!Exists('$(SolutionDir)Plugins')">
|
||||
<MakeDir Directories="$(SolutionDir)Plugins" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CopyPlugins" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
251
COP_5/LibraryAccountingApp_lab3/PluginsConvention.cs
Normal file
251
COP_5/LibraryAccountingApp_lab3/PluginsConvention.cs
Normal file
@ -0,0 +1,251 @@
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using COP_5;
|
||||
using COP_5.PdfHelper;
|
||||
using FedComponentLib.NonVisualComponents;
|
||||
using FedComponentLib.NonVisualComponents.HelperModels;
|
||||
using LibraryAccountingApp_lab3.BusinessLogic;
|
||||
using LibraryAccountingApp_lab3.Contracts.BusinessLogicsContracts;
|
||||
using LibraryAccountingApp_lab3.Contracts.StorageContracts;
|
||||
using LibraryAccountingApp_lab3.Contracts.ViewModels;
|
||||
using LibraryAccountingApp_lab3.DatabaseImplement.Implements;
|
||||
using LibraryAccountingApp_lab3.DatabaseImplement.Models;
|
||||
using PluginsConventionLibrary;
|
||||
|
||||
namespace LibraryAccountingApp_lab3
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private readonly IBookLogic _bookLogic;
|
||||
private readonly IAuthorLogic _authorLogic;
|
||||
private readonly IAuthorStorage _authorStorage;
|
||||
private readonly ControlDataTableCell _controlDataTable;
|
||||
private readonly TableComponent _excelComponent;
|
||||
private readonly ComponentDocumentWithChartBarWord _wordComponent;
|
||||
private readonly PdfForImages _pdfComponent;
|
||||
public string PluginName { get; set; } = "Lab3_plugin";
|
||||
|
||||
public UserControl GetControl
|
||||
{
|
||||
get { return _controlDataTable; }
|
||||
}
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_bookLogic = new BookLogic(new BookStorage());
|
||||
_authorLogic = new AuthorLogic(new AuthorStorage());
|
||||
_excelComponent = new();
|
||||
_wordComponent = new();
|
||||
_pdfComponent = new();
|
||||
_controlDataTable = new();
|
||||
}
|
||||
|
||||
public PluginsConventionElement GetElement
|
||||
{
|
||||
get
|
||||
{
|
||||
int Id = _controlDataTable.GetSelectedObject<BookViewModel>()!.Id;
|
||||
byte[] bytes = new byte[16];
|
||||
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
|
||||
Guid guid = new Guid(bytes);
|
||||
return new PluginsConventionElement() { Id = guid };
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return new FormBook(_bookLogic, _authorLogic);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormBook form = new FormBook(_bookLogic, _authorLogic);
|
||||
form.Id = element.Id.GetHashCode();
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormAuthor(_authorLogic, _authorStorage);
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
_bookLogic.Delete(
|
||||
new Contracts.BindingModels.BookBindingModel { Id = element.Id.GetHashCode() }
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var book = _bookLogic.ReadList(null);
|
||||
if (book != null)
|
||||
{
|
||||
_controlDataTable.Clear();
|
||||
|
||||
_controlDataTable.LoadColumns(new List<DataTableColumnConfig> {
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
|
||||
new DataTableColumnConfig { ColumnHeader = "Название", PropertyName = "Title", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Автор", PropertyName = "AuthorName", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Дата издания", PropertyName = "Date", Visible = true, Width = 200},
|
||||
});
|
||||
|
||||
LoadDataInTable();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ex.Message,
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBook(int rowIndex, BookViewModel book)
|
||||
{
|
||||
_controlDataTable.AddCell(rowIndex, 0, book);
|
||||
_controlDataTable.AddCell(rowIndex, 1, book);
|
||||
_controlDataTable.AddCell(rowIndex, 2, book);
|
||||
_controlDataTable.AddCell(rowIndex, 3, book);
|
||||
}
|
||||
|
||||
public void LoadDataInTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
_controlDataTable.Clear();
|
||||
|
||||
var list = _bookLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
int rowIndex = 0;
|
||||
foreach (var book in list)
|
||||
{
|
||||
AddBook(rowIndex, book);
|
||||
rowIndex++;
|
||||
}
|
||||
_controlDataTable.Update();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка загрузки данных: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<byte[]> images = new List<byte[]>();
|
||||
var list = _bookLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var book in list)
|
||||
{
|
||||
images.Add(book.Image);
|
||||
}
|
||||
}
|
||||
|
||||
var config = new ImagePdfInfo
|
||||
{
|
||||
FilePath = saveDocument.FileName,
|
||||
Header = "Документ с обложками книг",
|
||||
Images = images
|
||||
};
|
||||
|
||||
_pdfComponent.CreatePdf(config);
|
||||
MessageBox.Show($"Сохранение прошло успешно", "Cохранение");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
string filepath = saveDocument.FileName;
|
||||
string title = "Таблица с книгами библиотеки";
|
||||
List<MergeCells> mergeCells = new List<MergeCells>()
|
||||
{
|
||||
new MergeCells("Книга", new int[] { 1, 2 }),
|
||||
};
|
||||
List<ColumnInfo> columns = new List<ColumnInfo>()
|
||||
{
|
||||
new ColumnInfo("Id", "Id", 10),
|
||||
new ColumnInfo("Title", "Название", 30),
|
||||
new ColumnInfo("AuthorName", "Автор", 30),
|
||||
new ColumnInfo("Date", "Дата", 20),
|
||||
};
|
||||
|
||||
var list = _bookLogic.ReadList(null);
|
||||
List<BookForExcel> data = new List<BookForExcel>();
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var book in list)
|
||||
{
|
||||
data.Add(new BookForExcel
|
||||
{
|
||||
Id = book.Id,
|
||||
Title = book.Title,
|
||||
AuthorName = book.AuthorName,
|
||||
Date = book.Date
|
||||
});
|
||||
}
|
||||
_controlDataTable.Update();
|
||||
}
|
||||
|
||||
_excelComponent.CreateDocument(filepath, title, mergeCells, columns, data);
|
||||
MessageBox.Show($"Сохранение прошло успешно", "Cохранение");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<(int AuthorId, double Value)> listData = new List<(int AuthorId, double Value)>();
|
||||
(int AuthorId, double Value) item = default;
|
||||
|
||||
// Получение списка авторов
|
||||
var authors = _authorLogic.ReadList(null);
|
||||
if (authors != null)
|
||||
{
|
||||
// Получение списка книг
|
||||
var books = _bookLogic.ReadList(null);
|
||||
if (books != null)
|
||||
{
|
||||
// Подсчет количества книг для каждого автора
|
||||
foreach (var author in authors)
|
||||
{
|
||||
int bookCount = books.Count(book => book.AuthorName == author.Name);
|
||||
listData.Add((author.Id, bookCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, List<(int AuthorId, double Value)>> data = new()
|
||||
{
|
||||
{ "Авторы", listData }
|
||||
};
|
||||
|
||||
var config = new ComponentDocumentWithChartConfig
|
||||
{
|
||||
ChartTitle = "Сколько книг написали авторы",
|
||||
FilePath = saveDocument.FileName,
|
||||
Header = "Гистограмма в Word",
|
||||
Data = data,
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Rigth,
|
||||
};
|
||||
|
||||
_wordComponent.CreateDoc(config);
|
||||
MessageBox.Show($"Сохранение прошло успешно", "Cохранение");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
BIN
COP_5/Plugins/Azure.Core.dll
Normal file
BIN
COP_5/Plugins/Azure.Core.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Azure.Identity.dll
Normal file
BIN
COP_5/Plugins/Azure.Identity.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/COP_5.dll
Normal file
BIN
COP_5/Plugins/COP_5.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/ComponentsLibraryNet60.dll
Normal file
BIN
COP_5/Plugins/ComponentsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/ControlsLibraryNet60.dll
Normal file
BIN
COP_5/Plugins/ControlsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/DocumentFormat.OpenXml.dll
Normal file
BIN
COP_5/Plugins/DocumentFormat.OpenXml.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/FedComponentLib.dll
Normal file
BIN
COP_5/Plugins/FedComponentLib.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Humanizer.dll
Normal file
BIN
COP_5/Plugins/Humanizer.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/LibraryAccountingApp_lab3.dll
Normal file
BIN
COP_5/Plugins/LibraryAccountingApp_lab3.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Data.SqlClient.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Data.SqlClient.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
COP_5/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Logging.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Options.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Identity.Client.Extensions.Msal.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Identity.Client.Extensions.Msal.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Identity.Client.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Identity.Client.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.IdentityModel.Abstractions.dll
Normal file
BIN
COP_5/Plugins/Microsoft.IdentityModel.Abstractions.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
BIN
COP_5/Plugins/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.IdentityModel.Logging.dll
Normal file
BIN
COP_5/Plugins/Microsoft.IdentityModel.Logging.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.IdentityModel.Protocols.dll
Normal file
BIN
COP_5/Plugins/Microsoft.IdentityModel.Protocols.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.IdentityModel.Tokens.dll
Normal file
BIN
COP_5/Plugins/Microsoft.IdentityModel.Tokens.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Office.Interop.Excel.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Office.Interop.Excel.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.SqlServer.Server.dll
Normal file
BIN
COP_5/Plugins/Microsoft.SqlServer.Server.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Microsoft.Vbe.Interop.dll
Normal file
BIN
COP_5/Plugins/Microsoft.Vbe.Interop.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
BIN
COP_5/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/MigraDoc.Rendering.dll
Normal file
BIN
COP_5/Plugins/MigraDoc.Rendering.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Mono.TextTemplating.dll
Normal file
BIN
COP_5/Plugins/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
BIN
COP_5/Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Npgsql.dll
Normal file
BIN
COP_5/Plugins/Npgsql.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/Office.dll
Normal file
BIN
COP_5/Plugins/Office.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/PdfSharp.Charting.dll
Normal file
BIN
COP_5/Plugins/PdfSharp.Charting.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/PdfSharp.dll
Normal file
BIN
COP_5/Plugins/PdfSharp.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/PluginsConventionLibrary.dll
Normal file
BIN
COP_5/Plugins/PluginsConventionLibrary.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.Configuration.ConfigurationManager.dll
Normal file
BIN
COP_5/Plugins/System.Configuration.ConfigurationManager.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.IdentityModel.Tokens.Jwt.dll
Normal file
BIN
COP_5/Plugins/System.IdentityModel.Tokens.Jwt.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.Memory.Data.dll
Normal file
BIN
COP_5/Plugins/System.Memory.Data.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.Runtime.Caching.dll
Normal file
BIN
COP_5/Plugins/System.Runtime.Caching.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.Text.Encodings.Web.dll
Normal file
BIN
COP_5/Plugins/System.Text.Encodings.Web.dll
Normal file
Binary file not shown.
BIN
COP_5/Plugins/System.Text.Json.dll
Normal file
BIN
COP_5/Plugins/System.Text.Json.dll
Normal file
Binary file not shown.
246
COP_5/PluginsConventionLibrary/FormMain.Designer.cs
generated
246
COP_5/PluginsConventionLibrary/FormMain.Designer.cs
generated
@ -1,246 +0,0 @@
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,227 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
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);
|
||||
if (!Directory.Exists(currentDirectory))
|
||||
{
|
||||
MessageBox.Show($"Ошибка получения плагинов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return plugins;
|
||||
}
|
||||
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 new Dictionary<string, IPluginsConvention>();
|
||||
}
|
||||
|
||||
private void CreateMenuItem(string pluginName)
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem(pluginName);
|
||||
menuItem.Click += (s, e) =>
|
||||
{
|
||||
_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 = "Документ Word";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument()))
|
||||
{
|
||||
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()))
|
||||
{
|
||||
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()))
|
||||
{
|
||||
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,66 +0,0 @@
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
/// <summary>
|
||||
/// Название плагина
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение контрола для вывода набора данных
|
||||
/// </summary>
|
||||
UserControl GetControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента, выбранного в контроле
|
||||
/// </summary>
|
||||
PluginsConventionElement GetElement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Получение формы для работы со справочником
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Form GetThesaurus();
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
58
COP_5/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
58
COP_5/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
@ -0,0 +1,58 @@
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
/// <summary>
|
||||
/// Название плагина
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
/// <summary>
|
||||
/// Получение контрола для вывода набора данных
|
||||
/// </summary>
|
||||
UserControl GetControl { get; }
|
||||
/// <summary>
|
||||
/// Получение элемента, выбранного в контроле
|
||||
/// </summary>
|
||||
PluginsConventionElement GetElement { get; }
|
||||
/// <summary>
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Получение формы для работы со справочником
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Form GetThesaurus();
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument
|
||||
saveDocument);
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user