diff --git a/WinForms/Plugins/IPluginsConvention.cs b/WinForms/Plugins/IPluginsConvention.cs new file mode 100644 index 0000000..441f29e --- /dev/null +++ b/WinForms/Plugins/IPluginsConvention.cs @@ -0,0 +1,16 @@ +namespace Plugins +{ + 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); + } +} \ No newline at end of file diff --git a/WinForms/Plugins/Plugins.csproj b/WinForms/Plugins/Plugins.csproj new file mode 100644 index 0000000..060aa1c --- /dev/null +++ b/WinForms/Plugins/Plugins.csproj @@ -0,0 +1,10 @@ + + + + net6.0-windows + enable + true + enable + + + diff --git a/WinForms/Plugins/PluginsConventionElement.cs b/WinForms/Plugins/PluginsConventionElement.cs new file mode 100644 index 0000000..87075a0 --- /dev/null +++ b/WinForms/Plugins/PluginsConventionElement.cs @@ -0,0 +1,7 @@ +namespace Plugins +{ + public class PluginsConventionElement + { + public Guid Id { get; set; } + } +} diff --git a/WinForms/Plugins/PluginsConventionSaveDocument.cs b/WinForms/Plugins/PluginsConventionSaveDocument.cs new file mode 100644 index 0000000..03feec4 --- /dev/null +++ b/WinForms/Plugins/PluginsConventionSaveDocument.cs @@ -0,0 +1,7 @@ +namespace Plugins +{ + public class PluginsConventionSaveDocument + { + public string FileName { get; set; } + } +} diff --git a/WinForms/WinForms.sln b/WinForms/WinForms.sln index 61e9640..9a59482 100644 --- a/WinForms/WinForms.sln +++ b/WinForms/WinForms.sln @@ -16,6 +16,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrderBusinessLogic", "Order EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrdersDatabaseImplement", "OrdersDatabaseImplement\OrdersDatabaseImplement.csproj", "{00C86B65-4E95-4917-B348-398DCF0885C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins", "Plugins\Plugins.csproj", "{1BC56C34-8890-4E7D-954E-DB8C968B5FD3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsByPlugins", "WinFormsByPlugins\WinFormsByPlugins.csproj", "{D7DE576D-9EF9-454D-AE41-7C541431E391}" + ProjectSection(ProjectDependencies) = postProject + {10D1B0BE-6B52-41E6-8B57-4AFC49A26F17} = {10D1B0BE-6B52-41E6-8B57-4AFC49A26F17} + {1BC56C34-8890-4E7D-954E-DB8C968B5FD3} = {1BC56C34-8890-4E7D-954E-DB8C968B5FD3} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -42,6 +50,14 @@ Global {00C86B65-4E95-4917-B348-398DCF0885C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {00C86B65-4E95-4917-B348-398DCF0885C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {00C86B65-4E95-4917-B348-398DCF0885C3}.Release|Any CPU.Build.0 = Release|Any CPU + {1BC56C34-8890-4E7D-954E-DB8C968B5FD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BC56C34-8890-4E7D-954E-DB8C968B5FD3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BC56C34-8890-4E7D-954E-DB8C968B5FD3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BC56C34-8890-4E7D-954E-DB8C968B5FD3}.Release|Any CPU.Build.0 = Release|Any CPU + {D7DE576D-9EF9-454D-AE41-7C541431E391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7DE576D-9EF9-454D-AE41-7C541431E391}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7DE576D-9EF9-454D-AE41-7C541431E391}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7DE576D-9EF9-454D-AE41-7C541431E391}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WinForms/WinForms/PluginsConvention.cs b/WinForms/WinForms/PluginsConvention.cs new file mode 100644 index 0000000..8aae995 --- /dev/null +++ b/WinForms/WinForms/PluginsConvention.cs @@ -0,0 +1,235 @@ +using ComponentsLibraryNet60.DocumentWithChart; +using ComponentsLibraryNet60.DocumentWithTable; +using ComponentsLibraryNet60.Models; +using ControlsLibraryNet60.Data; +using ControlsLibraryNet60.Models; +using OfficeOpenXml.Drawing.Chart; +using OrderBusinessLogic; +using OrdersContracts.BindingModels; +using OrdersContracts.BusinessLogicContracts; +using OrdersContracts.ViewModels; +using OrdersDatabaseImplement.Implements; +using Plugins; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnvisableComponents; +using VisableComponents; +using VisualCompLib.Components; + +namespace WinForms +{ + public class PluginsConvention : IPluginsConvention + { + public string PluginName { get; } = "Дерево"; + private MyTreeView myTreeView1 = new MyTreeView(); + + private IOrderLogic _orderLogic = new OrderLogic(new OrderStorage()); + private IStatusLogic _statusLogic = new StatusLogic(new StatusStorage()); + + public PluginsConvention() + { + List stringToHierachy = new List() { "Status", "Amount", "Id", "Name" }; + myTreeView1.addToHierarchy(stringToHierachy); + } + + public UserControl GetControl + { + get + { + ReloadData(); + return myTreeView1; + } + } + + public PluginsConventionElement GetElement + { + get + { + var order = myTreeView1.GetNode(typeof(OrderViewModel)); + int id = -1; + if (order != null) + { + id = Convert.ToInt32((order as OrderViewModel).Id); + } + + byte[] bytes = new byte[16]; + + BitConverter.GetBytes(id).CopyTo(bytes, 0); + + return new() + { + Id = new Guid(bytes) + }; + } + } + + public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument) + { + try + { + + var statuses = _statusLogic.Read(null); + var orders = _orderLogic.Read(null); + List<(string, int)> dates = new List<(string, int)>(); + for (int i = 0; i < statuses.Count; i++) + { + int counter = 0; + for (int j = 0; j < orders.Count; j++) + { + if (orders[j].Status == statuses[i].Name && orders[j].Amount != null) counter++; + } + dates.Add((statuses[i].Name, counter)); + } + UnvisableComponents.ExcelChart excelChart = new UnvisableComponents.ExcelChart(); + + excelChart.Load(new ChartInfo + { + Path = saveDocument.FileName, + Title = "Статусы заказов", + DiagrammTitle = "Круговая диаграмма", + Dates = dates, + DirLegend = DirectionLegend.Right + }); + + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument) + { + try + { + List textList = new List(); + var list = _orderLogic.Read(null); + if (list != null) + { + foreach (var item in list) + { + if (item.Amount == null || item.Amount == "") + { + string orders = string.Concat("ФИО заказчика: ", item.Name, " Описание: ", item.Info); + textList.Add(orders); + } + } + string[] textArray = textList.ToArray(); + WordText wordText1 = new WordText(); + wordText1.CreateWordText(new(saveDocument.FileName, "Заказы, которые были оплачены скидками", textArray)); + } + + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument) + { + try + { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + + var orders = _orderLogic.Read(null); + for (int i = 0; i < orders.Count; i++) + { + if (orders[i].Amount == null || orders[i].Amount == "") { orders[i].Amount = "Заказы оплачен скидками"; } + } + ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf1 = new ComponentDocumentWithTableMultiHeaderPdf(); + componentDocumentWithTableMultiHeaderPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig + { + FilePath = saveDocument.FileName, + Header = "Отчет по заказам", + ColumnsRowsWidth = new List<(int, int)> { (5, 5), (10, 5), (15, 0), (15, 0) }, + Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> + { + (0, 0, "Id", "Id"), + (1, 0, "ФИО", "Name"), + (2, 0, "Статус", "Status"), + (3, 0, "Сумма заказа", "Amount") + }, + Data = orders + }); + + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + public bool DeleteElement(PluginsConventionElement element) + { + byte[] bytes = element.Id.ToByteArray(); + int Id = BitConverter.ToInt32(bytes, 0); + + if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return false; + + try + { + _orderLogic.Delete(new OrderBindingModel() { Id = Id }); + ReloadData(); + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + public Form GetForm(PluginsConventionElement element) + { + if (element == null) + { + return new FormOrder(_orderLogic, _statusLogic); + } + if (element.Id.GetHashCode() >= 0) + { + byte[] bytes = element.Id.ToByteArray(); + int Id = BitConverter.ToInt32(bytes, 0); + + FormOrder form = new FormOrder(_orderLogic, _statusLogic); + form.Id = Id; + return form; + } + return null; + } + + public Form GetThesaurus() + { + return new FormStatus(_statusLogic); + } + + public void ReloadData() + { + var list = _orderLogic.Read(null); + + try + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].Amount == null || list[i].Amount == "") { list[i].Amount = "нет"; } + } + myTreeView1.LoadTree(list); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + } +} diff --git a/WinForms/WinForms/WinForms.csproj b/WinForms/WinForms/WinForms.csproj index b7e53b0..ea0e5a1 100644 --- a/WinForms/WinForms/WinForms.csproj +++ b/WinForms/WinForms/WinForms.csproj @@ -23,6 +23,7 @@ + diff --git a/WinForms/WinFormsByPlugins/FormMain.Designer.cs b/WinForms/WinFormsByPlugins/FormMain.Designer.cs new file mode 100644 index 0000000..eb50eb1 --- /dev/null +++ b/WinForms/WinFormsByPlugins/FormMain.Designer.cs @@ -0,0 +1,233 @@ +namespace WinFormsByPlugins +{ + 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.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; + } +} \ No newline at end of file diff --git a/WinForms/WinFormsByPlugins/FormMain.cs b/WinForms/WinFormsByPlugins/FormMain.cs new file mode 100644 index 0000000..b459690 --- /dev/null +++ b/WinForms/WinFormsByPlugins/FormMain.cs @@ -0,0 +1,222 @@ +using Plugins; +using System.Reflection; +using WinForms; + +namespace WinFormsByPlugins +{ + public partial class FormMain : Form + { + private readonly Dictionary _plugins; + private string _selectedPlugin; + public FormMain() + { + InitializeComponent(); + _plugins = LoadPlugins(); + _selectedPlugin = string.Empty; + } + private Dictionary LoadPlugins() + { + Dictionary 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(); + } +} \ No newline at end of file diff --git a/WinForms/WinFormsByPlugins/FormMain.resx b/WinForms/WinFormsByPlugins/FormMain.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/WinForms/WinFormsByPlugins/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/WinForms/WinFormsByPlugins/Program.cs b/WinForms/WinFormsByPlugins/Program.cs new file mode 100644 index 0000000..a9d7c3b --- /dev/null +++ b/WinForms/WinFormsByPlugins/Program.cs @@ -0,0 +1,17 @@ +namespace WinFormsByPlugins +{ + 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/WinForms/WinFormsByPlugins/WinFormsByPlugins.csproj b/WinForms/WinFormsByPlugins/WinFormsByPlugins.csproj new file mode 100644 index 0000000..cda85db --- /dev/null +++ b/WinForms/WinFormsByPlugins/WinFormsByPlugins.csproj @@ -0,0 +1,18 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + \ No newline at end of file diff --git a/WinForms/plugin/Aspose.Words.Pdf2Word.dll b/WinForms/plugin/Aspose.Words.Pdf2Word.dll new file mode 100644 index 0000000..72d08f0 Binary files /dev/null and b/WinForms/plugin/Aspose.Words.Pdf2Word.dll differ diff --git a/WinForms/plugin/Aspose.Words.dll b/WinForms/plugin/Aspose.Words.dll new file mode 100644 index 0000000..10946f7 Binary files /dev/null and b/WinForms/plugin/Aspose.Words.dll differ diff --git a/WinForms/plugin/ComponentsLibraryNet60.dll b/WinForms/plugin/ComponentsLibraryNet60.dll new file mode 100644 index 0000000..9807306 Binary files /dev/null and b/WinForms/plugin/ComponentsLibraryNet60.dll differ diff --git a/WinForms/plugin/ControlsLibraryNet60.dll b/WinForms/plugin/ControlsLibraryNet60.dll new file mode 100644 index 0000000..3d14013 Binary files /dev/null and b/WinForms/plugin/ControlsLibraryNet60.dll differ diff --git a/WinForms/plugin/DocumentFormat.OpenXml.dll b/WinForms/plugin/DocumentFormat.OpenXml.dll new file mode 100644 index 0000000..ccdb81c Binary files /dev/null and b/WinForms/plugin/DocumentFormat.OpenXml.dll differ diff --git a/WinForms/plugin/EPPlus.Interfaces.dll b/WinForms/plugin/EPPlus.Interfaces.dll new file mode 100644 index 0000000..588ea51 Binary files /dev/null and b/WinForms/plugin/EPPlus.Interfaces.dll differ diff --git a/WinForms/plugin/EPPlus.System.Drawing.dll b/WinForms/plugin/EPPlus.System.Drawing.dll new file mode 100644 index 0000000..cea9325 Binary files /dev/null and b/WinForms/plugin/EPPlus.System.Drawing.dll differ diff --git a/WinForms/plugin/EPPlus.dll b/WinForms/plugin/EPPlus.dll new file mode 100644 index 0000000..475b7a2 Binary files /dev/null and b/WinForms/plugin/EPPlus.dll differ diff --git a/WinForms/plugin/Humanizer.dll b/WinForms/plugin/Humanizer.dll new file mode 100644 index 0000000..c9a7ef8 Binary files /dev/null and b/WinForms/plugin/Humanizer.dll differ diff --git a/WinForms/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll b/WinForms/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll new file mode 100644 index 0000000..96ea845 Binary files /dev/null and b/WinForms/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.EntityFrameworkCore.Design.dll b/WinForms/plugin/Microsoft.EntityFrameworkCore.Design.dll new file mode 100644 index 0000000..44b215b Binary files /dev/null and b/WinForms/plugin/Microsoft.EntityFrameworkCore.Design.dll differ diff --git a/WinForms/plugin/Microsoft.EntityFrameworkCore.Relational.dll b/WinForms/plugin/Microsoft.EntityFrameworkCore.Relational.dll new file mode 100644 index 0000000..ca681c4 Binary files /dev/null and b/WinForms/plugin/Microsoft.EntityFrameworkCore.Relational.dll differ diff --git a/WinForms/plugin/Microsoft.EntityFrameworkCore.dll b/WinForms/plugin/Microsoft.EntityFrameworkCore.dll new file mode 100644 index 0000000..37ace74 Binary files /dev/null and b/WinForms/plugin/Microsoft.EntityFrameworkCore.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Caching.Abstractions.dll b/WinForms/plugin/Microsoft.Extensions.Caching.Abstractions.dll new file mode 100644 index 0000000..be73869 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Caching.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Caching.Memory.dll b/WinForms/plugin/Microsoft.Extensions.Caching.Memory.dll new file mode 100644 index 0000000..561804a Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Caching.Memory.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Configuration.Abstractions.dll b/WinForms/plugin/Microsoft.Extensions.Configuration.Abstractions.dll new file mode 100644 index 0000000..3a12ec4 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Configuration.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Configuration.FileExtensions.dll b/WinForms/plugin/Microsoft.Extensions.Configuration.FileExtensions.dll new file mode 100644 index 0000000..160814d Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Configuration.FileExtensions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Configuration.Json.dll b/WinForms/plugin/Microsoft.Extensions.Configuration.Json.dll new file mode 100644 index 0000000..1c9ba24 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Configuration.Json.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Configuration.dll b/WinForms/plugin/Microsoft.Extensions.Configuration.dll new file mode 100644 index 0000000..4c0a93b Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Configuration.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll b/WinForms/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll new file mode 100644 index 0000000..11e5f2e Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.DependencyInjection.dll b/WinForms/plugin/Microsoft.Extensions.DependencyInjection.dll new file mode 100644 index 0000000..2c64257 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.DependencyInjection.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.DependencyModel.dll b/WinForms/plugin/Microsoft.Extensions.DependencyModel.dll new file mode 100644 index 0000000..072af1f Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.DependencyModel.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.FileProviders.Abstractions.dll b/WinForms/plugin/Microsoft.Extensions.FileProviders.Abstractions.dll new file mode 100644 index 0000000..d1045b6 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.FileProviders.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.FileProviders.Physical.dll b/WinForms/plugin/Microsoft.Extensions.FileProviders.Physical.dll new file mode 100644 index 0000000..e712dbe Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.FileProviders.Physical.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.FileSystemGlobbing.dll b/WinForms/plugin/Microsoft.Extensions.FileSystemGlobbing.dll new file mode 100644 index 0000000..61c4e0c Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.FileSystemGlobbing.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Logging.Abstractions.dll b/WinForms/plugin/Microsoft.Extensions.Logging.Abstractions.dll new file mode 100644 index 0000000..03edd8f Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Logging.Abstractions.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Logging.dll b/WinForms/plugin/Microsoft.Extensions.Logging.dll new file mode 100644 index 0000000..c53f5d2 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Logging.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Options.dll b/WinForms/plugin/Microsoft.Extensions.Options.dll new file mode 100644 index 0000000..3987d66 Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Options.dll differ diff --git a/WinForms/plugin/Microsoft.Extensions.Primitives.dll b/WinForms/plugin/Microsoft.Extensions.Primitives.dll new file mode 100644 index 0000000..081abea Binary files /dev/null and b/WinForms/plugin/Microsoft.Extensions.Primitives.dll differ diff --git a/WinForms/plugin/Microsoft.IO.RecyclableMemoryStream.dll b/WinForms/plugin/Microsoft.IO.RecyclableMemoryStream.dll new file mode 100644 index 0000000..5de0c12 Binary files /dev/null and b/WinForms/plugin/Microsoft.IO.RecyclableMemoryStream.dll differ diff --git a/WinForms/plugin/MigraDoc.DocumentObjectModel.dll b/WinForms/plugin/MigraDoc.DocumentObjectModel.dll new file mode 100644 index 0000000..2bf457c Binary files /dev/null and b/WinForms/plugin/MigraDoc.DocumentObjectModel.dll differ diff --git a/WinForms/plugin/MigraDoc.Rendering.dll b/WinForms/plugin/MigraDoc.Rendering.dll new file mode 100644 index 0000000..9c14fbe Binary files /dev/null and b/WinForms/plugin/MigraDoc.Rendering.dll differ diff --git a/WinForms/plugin/Mono.TextTemplating.dll b/WinForms/plugin/Mono.TextTemplating.dll new file mode 100644 index 0000000..d5a4b3c Binary files /dev/null and b/WinForms/plugin/Mono.TextTemplating.dll differ diff --git a/WinForms/plugin/Npgsql.EntityFrameworkCore.PostgreSQL.dll b/WinForms/plugin/Npgsql.EntityFrameworkCore.PostgreSQL.dll new file mode 100644 index 0000000..bd22f65 Binary files /dev/null and b/WinForms/plugin/Npgsql.EntityFrameworkCore.PostgreSQL.dll differ diff --git a/WinForms/plugin/Npgsql.dll b/WinForms/plugin/Npgsql.dll new file mode 100644 index 0000000..4a8471b Binary files /dev/null and b/WinForms/plugin/Npgsql.dll differ diff --git a/WinForms/plugin/OrderBusinessLogic.dll b/WinForms/plugin/OrderBusinessLogic.dll new file mode 100644 index 0000000..6e597f0 Binary files /dev/null and b/WinForms/plugin/OrderBusinessLogic.dll differ diff --git a/WinForms/plugin/OrdersContracts.dll b/WinForms/plugin/OrdersContracts.dll new file mode 100644 index 0000000..16bc851 Binary files /dev/null and b/WinForms/plugin/OrdersContracts.dll differ diff --git a/WinForms/plugin/OrdersDatabaseImplement.dll b/WinForms/plugin/OrdersDatabaseImplement.dll new file mode 100644 index 0000000..5072b50 Binary files /dev/null and b/WinForms/plugin/OrdersDatabaseImplement.dll differ diff --git a/WinForms/plugin/PdfSharp.Charting.dll b/WinForms/plugin/PdfSharp.Charting.dll new file mode 100644 index 0000000..384a0f0 Binary files /dev/null and b/WinForms/plugin/PdfSharp.Charting.dll differ diff --git a/WinForms/plugin/PdfSharp.dll b/WinForms/plugin/PdfSharp.dll new file mode 100644 index 0000000..aa564e1 Binary files /dev/null and b/WinForms/plugin/PdfSharp.dll differ diff --git a/WinForms/plugin/Plugins.dll b/WinForms/plugin/Plugins.dll new file mode 100644 index 0000000..94b50f3 Binary files /dev/null and b/WinForms/plugin/Plugins.dll differ diff --git a/WinForms/plugin/SkiaSharp.dll b/WinForms/plugin/SkiaSharp.dll new file mode 100644 index 0000000..518648c Binary files /dev/null and b/WinForms/plugin/SkiaSharp.dll differ diff --git a/WinForms/plugin/Spire.Doc.dll b/WinForms/plugin/Spire.Doc.dll new file mode 100644 index 0000000..cf34ba5 Binary files /dev/null and b/WinForms/plugin/Spire.Doc.dll differ diff --git a/WinForms/plugin/System.Security.Cryptography.Pkcs.dll b/WinForms/plugin/System.Security.Cryptography.Pkcs.dll new file mode 100644 index 0000000..eedf8e6 Binary files /dev/null and b/WinForms/plugin/System.Security.Cryptography.Pkcs.dll differ diff --git a/WinForms/plugin/System.Text.Encodings.Web.dll b/WinForms/plugin/System.Text.Encodings.Web.dll new file mode 100644 index 0000000..13a219a Binary files /dev/null and b/WinForms/plugin/System.Text.Encodings.Web.dll differ diff --git a/WinForms/plugin/System.Text.Json.dll b/WinForms/plugin/System.Text.Json.dll new file mode 100644 index 0000000..2078226 Binary files /dev/null and b/WinForms/plugin/System.Text.Json.dll differ diff --git a/WinForms/plugin/UnvisableComponents.dll b/WinForms/plugin/UnvisableComponents.dll new file mode 100644 index 0000000..7c2d2be Binary files /dev/null and b/WinForms/plugin/UnvisableComponents.dll differ diff --git a/WinForms/plugin/VisableComponents.dll b/WinForms/plugin/VisableComponents.dll new file mode 100644 index 0000000..c1611e4 Binary files /dev/null and b/WinForms/plugin/VisableComponents.dll differ diff --git a/WinForms/plugin/VisualCompLib.dll b/WinForms/plugin/VisualCompLib.dll new file mode 100644 index 0000000..09416ea Binary files /dev/null and b/WinForms/plugin/VisualCompLib.dll differ diff --git a/WinForms/plugin/VisualComponentsLib.dll b/WinForms/plugin/VisualComponentsLib.dll new file mode 100644 index 0000000..0aed699 Binary files /dev/null and b/WinForms/plugin/VisualComponentsLib.dll differ diff --git a/WinForms/plugin/WinForms.dll b/WinForms/plugin/WinForms.dll new file mode 100644 index 0000000..bfebd85 Binary files /dev/null and b/WinForms/plugin/WinForms.dll differ