diff --git a/.gitignore b/.gitignore
index ca1c7a3..99b8a56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+*.dll
+
# User-specific files
*.rsuser
*.suo
diff --git a/COP/AppByPlugins/AppByPlugins.csproj b/COP/AppByPlugins/AppByPlugins.csproj
new file mode 100644
index 0000000..8c2f882
--- /dev/null
+++ b/COP/AppByPlugins/AppByPlugins.csproj
@@ -0,0 +1,15 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COP/AppByPlugins/FormMain.Designer.cs b/COP/AppByPlugins/FormMain.Designer.cs
new file mode 100644
index 0000000..d736550
--- /dev/null
+++ b/COP/AppByPlugins/FormMain.Designer.cs
@@ -0,0 +1,181 @@
+namespace AppByPlugins
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.panelControl = new System.Windows.Forms.Panel();
+ this.menuStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip
+ //
+ this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ControlsStripMenuItem,
+ this.ActionsToolStripMenuItem,
+ this.DocsToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
+ this.menuStrip.Size = new System.Drawing.Size(914, 30);
+ this.menuStrip.TabIndex = 0;
+ this.menuStrip.Text = "Меню";
+ //
+ // ControlsStripMenuItem
+ //
+ this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
+ this.ControlsStripMenuItem.Size = new System.Drawing.Size(113, 24);
+ this.ControlsStripMenuItem.Text = "Компоненты";
+ //
+ // ActionsToolStripMenuItem
+ //
+ this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ThesaurusToolStripMenuItem,
+ this.AddElementToolStripMenuItem,
+ this.UpdElementToolStripMenuItem,
+ this.DelElementToolStripMenuItem});
+ this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
+ this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
+ this.ActionsToolStripMenuItem.Text = "Действия";
+ //
+ // ThesaurusToolStripMenuItem
+ //
+ this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
+ this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
+ this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
+ this.ThesaurusToolStripMenuItem.Text = "Справочник";
+ //
+ // AddElementToolStripMenuItem
+ //
+ this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
+ this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
+ this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
+ this.AddElementToolStripMenuItem.Text = "Добавить";
+ //
+ // UpdElementToolStripMenuItem
+ //
+ this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
+ this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
+ this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
+ this.UpdElementToolStripMenuItem.Text = "Изменить";
+ //
+ // DelElementToolStripMenuItem
+ //
+ this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
+ this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
+ this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
+ this.DelElementToolStripMenuItem.Text = "Удалить";
+ //
+ // DocsToolStripMenuItem
+ //
+ this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.SimpleDocToolStripMenuItem,
+ this.TableDocToolStripMenuItem,
+ this.ChartDocToolStripMenuItem});
+ this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
+ this.DocsToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
+ this.DocsToolStripMenuItem.Text = "Документы";
+ //
+ // SimpleDocToolStripMenuItem
+ //
+ this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
+ this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
+ this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
+ this.SimpleDocToolStripMenuItem.Text = "Простой документ";
+ //
+ // TableDocToolStripMenuItem
+ //
+ this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
+ this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
+ this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
+ this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
+ //
+ // ChartDocToolStripMenuItem
+ //
+ this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
+ this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
+ this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
+ this.ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
+ //
+ // panelControl
+ //
+ this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panelControl.Location = new System.Drawing.Point(0, 30);
+ this.panelControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.panelControl.Name = "panelControl";
+ this.panelControl.Size = new System.Drawing.Size(914, 570);
+ this.panelControl.TabIndex = 1;
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(914, 600);
+ this.Controls.Add(this.panelControl);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "FormMain";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Главная форма";
+ this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip menuStrip;
+ private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
+ private System.Windows.Forms.Panel panelControl;
+ private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/COP/AppByPlugins/FormMain.cs b/COP/AppByPlugins/FormMain.cs
new file mode 100644
index 0000000..098b013
--- /dev/null
+++ b/COP/AppByPlugins/FormMain.cs
@@ -0,0 +1,241 @@
+using PluginsConventionLibrary;
+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 AppByPlugins
+{
+ public partial class FormMain : Form
+ {
+ private readonly Dictionary _plugins;
+ private string _selectedPlugin;
+
+ public FormMain()
+ {
+ InitializeComponent();
+ _plugins = new();
+ LoadPlugins();
+ _selectedPlugin = string.Empty;
+ }
+
+ private void LoadPlugins()
+ {
+ List pluginsList = GetPlugins();
+
+ foreach (var plugin in pluginsList)
+ {
+ _plugins[plugin.PluginName] = plugin;
+ CreateMenuItem(plugin.PluginName);
+ }
+ }
+
+ private List GetPlugins()
+ {
+ string currentDir = Environment.CurrentDirectory;
+ string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
+ string[] dllFiles = Directory.GetFiles(
+ pluginsDir,
+ "*.dll",
+ SearchOption.AllDirectories
+ );
+ List plugins = new();
+ 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)
+ {
+ if (Activator.CreateInstance(type) is IPluginsConvention plugin)
+ {
+ plugins.Add(plugin);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(
+ 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 = "Excel Files|*.xlsx"
+ };
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ _plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
+
+ }
+ }
+ private void CreateTableDoc()
+ {
+ SaveFileDialog saveFileDialog = new()
+ {
+ Filter = "Word Files|*.docx"
+ };
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ _plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
+
+ }
+ }
+ private void CreateChartDoc()
+ {
+ SaveFileDialog saveFileDialog = new()
+ {
+ Filter = "PDF Files|*.pdf"
+ };
+ 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)
+ {
+
+ }
+ }
+}
diff --git a/COP/AppByPlugins/FormMain.resx b/COP/AppByPlugins/FormMain.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/COP/AppByPlugins/FormMain.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/COP/AppByPlugins/Program.cs b/COP/AppByPlugins/Program.cs
new file mode 100644
index 0000000..a783345
--- /dev/null
+++ b/COP/AppByPlugins/Program.cs
@@ -0,0 +1,17 @@
+namespace AppByPlugins
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new FormMain());
+ }
+ }
+}
\ No newline at end of file
diff --git a/COP/COP.sln b/COP/COP.sln
index 17e749e..aac846f 100644
--- a/COP/COP.sln
+++ b/COP/COP.sln
@@ -15,7 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsContracts", "Clients
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientDataBaseImplement", "ClientDataBaseImplement\ClientDataBaseImplement.csproj", "{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChubykinaComponents", "ChubykinaComponents\ChubykinaComponents.csproj", "{335CABB5-5AC4-4688-92DD-5B91FEB16192}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChubykinaComponents", "ChubykinaComponents\ChubykinaComponents.csproj", "{335CABB5-5AC4-4688-92DD-5B91FEB16192}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppByPlugins", "AppByPlugins\AppByPlugins.csproj", "{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -51,6 +55,14 @@ Global
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Debug|Any CPU.Build.0 = Debug|Any CPU
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Release|Any CPU.ActiveCfg = Release|Any CPU
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/COP/PluginsConventionLibrary/IPluginsConvention.cs b/COP/PluginsConventionLibrary/IPluginsConvention.cs
new file mode 100644
index 0000000..b25facd
--- /dev/null
+++ b/COP/PluginsConventionLibrary/IPluginsConvention.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace PluginsConventionLibrary
+{
+ public interface IPluginsConvention
+ {
+ ///
+ /// Название плагина
+ ///
+ string PluginName { get; }
+ ///
+ /// Получение контрола для вывода набора данных
+ ///
+ UserControl GetControl { get; }
+ ///
+ /// Получение элемента, выбранного в контроле
+ ///
+ PluginsConventionElement GetElement { get; }
+ ///
+ /// Получение формы для создания/редактирования объекта
+ ///
+ ///
+ ///
+ Form GetForm(PluginsConventionElement element);
+ ///
+ /// Получение формы для работы со справочником
+ ///
+ ///
+ Form GetThesaurus();
+ ///
+ /// Удаление элемента
+ ///
+ ///
+ ///
+ bool DeleteElement(PluginsConventionElement element);
+ ///
+ /// Обновление набора данных в контроле
+ ///
+ void ReloadData();
+ ///
+ /// Создание простого документа
+ ///
+ ///
+ ///
+ bool CreateSimpleDocument(PluginsConventionSaveDocument
+ saveDocument);
+ ///
+ /// Создание простого документа
+ ///
+ ///
+ ///
+ bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
+ ///
+ /// Создание документа с диаграммой
+ ///
+ ///
+ ///
+ bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
+ }
+}
diff --git a/COP/PluginsConventionLibrary/PluginsConventionElement.cs b/COP/PluginsConventionLibrary/PluginsConventionElement.cs
new file mode 100644
index 0000000..775c74a
--- /dev/null
+++ b/COP/PluginsConventionLibrary/PluginsConventionElement.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PluginsConventionLibrary
+{
+ public class PluginsConventionElement
+ {
+ public Guid Id { get; set; }
+ }
+}
diff --git a/COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj b/COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
new file mode 100644
index 0000000..aefee8c
--- /dev/null
+++ b/COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
@@ -0,0 +1,10 @@
+
+
+
+ net6.0-windows
+ enable
+ enable
+ true
+
+
+
diff --git a/COP/PluginsConventionLibrary/PluginsConventionSaveDocument.cs b/COP/PluginsConventionLibrary/PluginsConventionSaveDocument.cs
new file mode 100644
index 0000000..f902bc6
--- /dev/null
+++ b/COP/PluginsConventionLibrary/PluginsConventionSaveDocument.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PluginsConventionLibrary
+{
+ public class PluginsConventionSaveDocument
+ {
+ public string FileName { get; set; }
+ }
+}
diff --git a/COP/WinFormsTest/PluginsConvention.cs b/COP/WinFormsTest/PluginsConvention.cs
new file mode 100644
index 0000000..ffb3aca
--- /dev/null
+++ b/COP/WinFormsTest/PluginsConvention.cs
@@ -0,0 +1,175 @@
+using ClientsBusinessLogics.BusinessLogics;
+using ClientsContracts.BusinessLogicContracts;
+using ClientsContracts.StorageContracts;
+using ClientsContracts.ViewModels;
+using ClientDataBaseImplement.Implements;
+using BulatovaComponents.NonVisualComponents;
+using ChubykinaComponents.LogicalComponents;
+using ComponentsLibraryNet60.DocumentWithChart;
+using ComponentsLibraryNet60.Models;
+using ControlsLibraryNet60.Core;
+using ControlsLibraryNet60.Data;
+using ControlsLibraryNet60.Models;
+using PluginsConventionLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinFormsTest
+{
+ public class PluginsConvention : IPluginsConvention
+ {
+ private readonly IClientLogic _clientLogic;
+ private readonly ICategoryLogic _categoryLogic;
+ private readonly ControlDataTableTable _controlDataTable;
+ private readonly ExcelImagesComponent _excelImagesComponent;
+ private readonly WordTableComponent _wordTableComponent;
+ private readonly ComponentDocumentWithChartBarPdf _chartBar;
+ public string PluginName { get; set; } = "LabWork_03_plugin";
+
+ public UserControl GetControl
+ {
+ get { return _controlDataTable; }
+ }
+
+ public PluginsConvention()
+ {
+ _clientLogic = new ClientLogic(new ClientStorage());
+ _categoryLogic = new CategoryLogic(new CategoryStorage());
+ _excelImagesComponent = new();
+ _wordTableComponent = new();
+ _chartBar = new();
+ _controlDataTable = new();
+ }
+
+ public PluginsConventionElement GetElement
+ {
+ get
+ {
+ int Id = _controlDataTable.GetSelectedObject()!.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 FormClient(_clientLogic, _categoryLogic);
+ }
+ else
+ {
+ FormClient form = new FormClient(_clientLogic, _categoryLogic);
+ form.Id = element.Id.GetHashCode();
+ return form;
+ }
+ }
+
+ public Form GetThesaurus()
+ {
+ return new FormCategories(_categoryLogic);
+ }
+
+ public bool DeleteElement(PluginsConventionElement element)
+ {
+ _clientLogic.Delete(
+ new ClientsContracts.BindingModels.ClientBindingModel { Id = element.Id.GetHashCode() }
+ );
+ return true;
+ }
+
+ public void ReloadData()
+ {
+ try
+ {
+ var client = _clientLogic.ReadList(null);
+ if (client != null)
+ {
+ _controlDataTable.Clear();
+
+ _controlDataTable.LoadColumns(new List {
+ new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
+ new DataTableColumnConfig { ColumnHeader = "ФИО", PropertyName = "Fio", Visible = true, Width = 200},
+ new DataTableColumnConfig { ColumnHeader = "Выбранная категория", PropertyName = "CategoryName", Visible = true, Width = 200},
+ new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200},
+ });
+
+ _controlDataTable.AddTable(client);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(
+ ex.Message,
+ "Ошибка",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Error
+ );
+ }
+ }
+
+ public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ List photos = new List();
+ foreach (var client in _clientLogic.ReadList(null))
+ {
+ photos.Add(client.Photo);
+ }
+ string path = saveDocument.FileName;
+ if (_excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотографии", photos.ToArray())))
+ {
+ MessageBox.Show("Документ создан");
+ return true;
+ }
+ return false;
+ }
+
+ public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ string path = saveDocument.FileName;
+ List<(int, int)> merges = new List<(int, int)> { (1, 2) };
+ List widths = new List { 100, 100, 100, 100 };
+ List<(string, string)> headers = new List<(string, string)> {
+ ("Id", "Идентификатор"),
+ ("", "Личные данные"),
+ ("Fio", "ФИО"),
+ ("Email", "Эл. почта"),
+ ("CategoryName", "Выбранная категория")
+ };
+
+ _wordTableComponent.createWithTable(path, "Список аккаунтов", merges, widths, headers, _clientLogic.ReadList(null));
+ MessageBox.Show("Документ создан");
+ return true;
+ }
+
+ public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+
+ string path = saveDocument.FileName;
+ Dictionary> data = new Dictionary>();
+
+ data = _clientLogic
+ .ReadList(null)
+ .GroupBy(x => x.CategoryName)
+ .ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count()) });
+
+ _chartBar.CreateDoc(new ComponentDocumentWithChartConfig
+ {
+ Header = "Категории",
+ FilePath = path,
+ ChartTitle = "Категории",
+ LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
+ Data = data,
+ });
+
+ MessageBox.Show("Документ создан");
+ return false;
+ }
+ }
+}
diff --git a/COP/WinFormsTest/WinFormsTest.csproj b/COP/WinFormsTest/WinFormsTest.csproj
index 8829709..f1a1107 100644
--- a/COP/WinFormsTest/WinFormsTest.csproj
+++ b/COP/WinFormsTest/WinFormsTest.csproj
@@ -22,6 +22,7 @@
+
\ No newline at end of file