diff --git a/WinFormsLibrary1/Plugins/IPluginsConvention.cs b/WinFormsLibrary1/Plugins/IPluginsConvention.cs new file mode 100644 index 0000000..0639b62 --- /dev/null +++ b/WinFormsLibrary1/Plugins/IPluginsConvention.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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/WinFormsLibrary1/Plugins/Plugins.csproj b/WinFormsLibrary1/Plugins/Plugins.csproj new file mode 100644 index 0000000..3e210aa --- /dev/null +++ b/WinFormsLibrary1/Plugins/Plugins.csproj @@ -0,0 +1,10 @@ + + + + net8.0-windows + enable + true + enable + + + diff --git a/WinFormsLibrary1/Plugins/PluginsConventionElement.cs b/WinFormsLibrary1/Plugins/PluginsConventionElement.cs new file mode 100644 index 0000000..e92a0b6 --- /dev/null +++ b/WinFormsLibrary1/Plugins/PluginsConventionElement.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plugins +{ + public class PluginsConventionElement + { + public Guid Id { get; set; } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/Plugins/PluginsConventionSaveDocument.cs b/WinFormsLibrary1/Plugins/PluginsConventionSaveDocument.cs new file mode 100644 index 0000000..7f92194 --- /dev/null +++ b/WinFormsLibrary1/Plugins/PluginsConventionSaveDocument.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plugins +{ + public class PluginsConventionSaveDocument + { + public string FileName { get; set; } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/PluginsP/Aspose.Words.Pdf2Word.dll b/WinFormsLibrary1/PluginsP/Aspose.Words.Pdf2Word.dll new file mode 100644 index 0000000..49383f8 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Aspose.Words.Pdf2Word.dll differ diff --git a/WinFormsLibrary1/PluginsP/Aspose.Words.dll b/WinFormsLibrary1/PluginsP/Aspose.Words.dll new file mode 100644 index 0000000..9a58544 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Aspose.Words.dll differ diff --git a/WinFormsLibrary1/PluginsP/BusinessLogics.dll b/WinFormsLibrary1/PluginsP/BusinessLogics.dll new file mode 100644 index 0000000..4c64c79 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/BusinessLogics.dll differ diff --git a/WinFormsLibrary1/PluginsP/Contracts.dll b/WinFormsLibrary1/PluginsP/Contracts.dll new file mode 100644 index 0000000..a040611 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Contracts.dll differ diff --git a/WinFormsLibrary1/PluginsP/DatabaseImplement.dll b/WinFormsLibrary1/PluginsP/DatabaseImplement.dll new file mode 100644 index 0000000..4cd1771 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/DatabaseImplement.dll differ diff --git a/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.Framework.dll b/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.Framework.dll new file mode 100644 index 0000000..3e59803 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.Framework.dll differ diff --git a/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.dll b/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.dll new file mode 100644 index 0000000..7a58eb6 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/DocumentFormat.OpenXml.dll differ diff --git a/WinFormsLibrary1/PluginsP/Forms.dll b/WinFormsLibrary1/PluginsP/Forms.dll new file mode 100644 index 0000000..ffbd6ec Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Forms.dll differ diff --git a/WinFormsLibrary1/PluginsP/Humanizer.dll b/WinFormsLibrary1/PluginsP/Humanizer.dll new file mode 100644 index 0000000..c9a7ef8 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Humanizer.dll differ diff --git a/WinFormsLibrary1/PluginsP/Library14Petrushin.dll b/WinFormsLibrary1/PluginsP/Library14Petrushin.dll new file mode 100644 index 0000000..1ba7e5c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Library14Petrushin.dll differ diff --git a/WinFormsLibrary1/PluginsP/Library15Gerimovich.dll b/WinFormsLibrary1/PluginsP/Library15Gerimovich.dll new file mode 100644 index 0000000..8eab6c9 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Library15Gerimovich.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Bcl.AsyncInterfaces.dll b/WinFormsLibrary1/PluginsP/Microsoft.Bcl.AsyncInterfaces.dll new file mode 100644 index 0000000..fe6ba4c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Bcl.AsyncInterfaces.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.Workspaces.dll b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.Workspaces.dll new file mode 100644 index 0000000..dc218f9 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.Workspaces.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.dll b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.dll new file mode 100644 index 0000000..412e7ed Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.CSharp.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.Workspaces.dll b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.Workspaces.dll new file mode 100644 index 0000000..8dec441 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.Workspaces.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.dll b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.dll new file mode 100644 index 0000000..79e9046 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.CodeAnalysis.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Abstractions.dll b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Abstractions.dll new file mode 100644 index 0000000..2169cf8 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Abstractions.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Design.dll b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Design.dll new file mode 100644 index 0000000..7ba3d94 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Design.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Relational.dll b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Relational.dll new file mode 100644 index 0000000..f8c58d0 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.Relational.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.dll b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.dll new file mode 100644 index 0000000..b628ed6 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.EntityFrameworkCore.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Abstractions.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Abstractions.dll new file mode 100644 index 0000000..99aac98 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Abstractions.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Memory.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Memory.dll new file mode 100644 index 0000000..077b1b6 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Caching.Memory.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Configuration.Abstractions.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Configuration.Abstractions.dll new file mode 100644 index 0000000..a5ab313 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Configuration.Abstractions.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.Abstractions.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.Abstractions.dll new file mode 100644 index 0000000..81ed3de Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.Abstractions.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.dll new file mode 100644 index 0000000..bd71a2b Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyInjection.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyModel.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyModel.dll new file mode 100644 index 0000000..8905537 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.DependencyModel.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.Abstractions.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.Abstractions.dll new file mode 100644 index 0000000..f9d1dc6 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.Abstractions.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.dll new file mode 100644 index 0000000..35905b6 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Logging.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Options.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Options.dll new file mode 100644 index 0000000..a7b3f21 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Options.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Primitives.dll b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Primitives.dll new file mode 100644 index 0000000..c24f2a0 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Extensions.Primitives.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Excel.dll b/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Excel.dll new file mode 100644 index 0000000..4ab081c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Excel.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Word.dll b/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Word.dll new file mode 100644 index 0000000..119bd10 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Office.Interop.Word.dll differ diff --git a/WinFormsLibrary1/PluginsP/Microsoft.Vbe.Interop.dll b/WinFormsLibrary1/PluginsP/Microsoft.Vbe.Interop.dll new file mode 100644 index 0000000..d8c4b64 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Microsoft.Vbe.Interop.dll differ diff --git a/WinFormsLibrary1/PluginsP/Models.dll b/WinFormsLibrary1/PluginsP/Models.dll new file mode 100644 index 0000000..c21e6fb Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Models.dll differ diff --git a/WinFormsLibrary1/PluginsP/Mono.TextTemplating.dll b/WinFormsLibrary1/PluginsP/Mono.TextTemplating.dll new file mode 100644 index 0000000..d5a4b3c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Mono.TextTemplating.dll differ diff --git a/WinFormsLibrary1/PluginsP/Npgsql.EntityFrameworkCore.PostgreSQL.dll b/WinFormsLibrary1/PluginsP/Npgsql.EntityFrameworkCore.PostgreSQL.dll new file mode 100644 index 0000000..4b4f0fc Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Npgsql.EntityFrameworkCore.PostgreSQL.dll differ diff --git a/WinFormsLibrary1/PluginsP/Npgsql.dll b/WinFormsLibrary1/PluginsP/Npgsql.dll new file mode 100644 index 0000000..fde1387 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Npgsql.dll differ diff --git a/WinFormsLibrary1/PluginsP/Office.dll b/WinFormsLibrary1/PluginsP/Office.dll new file mode 100644 index 0000000..447c580 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Office.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.Charting.dll b/WinFormsLibrary1/PluginsP/PdfSharp.Charting.dll new file mode 100644 index 0000000..5c61b17 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.Charting.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.Quality.dll b/WinFormsLibrary1/PluginsP/PdfSharp.Quality.dll new file mode 100644 index 0000000..72e514c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.Quality.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.Snippets.dll b/WinFormsLibrary1/PluginsP/PdfSharp.Snippets.dll new file mode 100644 index 0000000..266cdad Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.Snippets.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.System.dll b/WinFormsLibrary1/PluginsP/PdfSharp.System.dll new file mode 100644 index 0000000..e8dded5 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.System.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.WPFonts.dll b/WinFormsLibrary1/PluginsP/PdfSharp.WPFonts.dll new file mode 100644 index 0000000..9a7c2ca Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.WPFonts.dll differ diff --git a/WinFormsLibrary1/PluginsP/PdfSharp.dll b/WinFormsLibrary1/PluginsP/PdfSharp.dll new file mode 100644 index 0000000..61b8fde Binary files /dev/null and b/WinFormsLibrary1/PluginsP/PdfSharp.dll differ diff --git a/WinFormsLibrary1/PluginsP/Plugins.dll b/WinFormsLibrary1/PluginsP/Plugins.dll new file mode 100644 index 0000000..a58d6d4 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/Plugins.dll differ diff --git a/WinFormsLibrary1/PluginsP/SkiaSharp.dll b/WinFormsLibrary1/PluginsP/SkiaSharp.dll new file mode 100644 index 0000000..6e8e7ca Binary files /dev/null and b/WinFormsLibrary1/PluginsP/SkiaSharp.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.Composition.AttributedModel.dll b/WinFormsLibrary1/PluginsP/System.Composition.AttributedModel.dll new file mode 100644 index 0000000..d37283b Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.Composition.AttributedModel.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.Composition.Convention.dll b/WinFormsLibrary1/PluginsP/System.Composition.Convention.dll new file mode 100644 index 0000000..b6fa4ab Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.Composition.Convention.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.Composition.Hosting.dll b/WinFormsLibrary1/PluginsP/System.Composition.Hosting.dll new file mode 100644 index 0000000..c67f1c0 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.Composition.Hosting.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.Composition.Runtime.dll b/WinFormsLibrary1/PluginsP/System.Composition.Runtime.dll new file mode 100644 index 0000000..2a4b38c Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.Composition.Runtime.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.Composition.TypedParts.dll b/WinFormsLibrary1/PluginsP/System.Composition.TypedParts.dll new file mode 100644 index 0000000..7c0c780 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.Composition.TypedParts.dll differ diff --git a/WinFormsLibrary1/PluginsP/System.IO.Pipelines.dll b/WinFormsLibrary1/PluginsP/System.IO.Pipelines.dll new file mode 100644 index 0000000..8ee4dfd Binary files /dev/null and b/WinFormsLibrary1/PluginsP/System.IO.Pipelines.dll differ diff --git a/WinFormsLibrary1/PluginsP/WinFormsApp1.dll b/WinFormsLibrary1/PluginsP/WinFormsApp1.dll new file mode 100644 index 0000000..2a8f3c4 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/WinFormsApp1.dll differ diff --git a/WinFormsLibrary1/PluginsP/WinFormsLibrary1.dll b/WinFormsLibrary1/PluginsP/WinFormsLibrary1.dll new file mode 100644 index 0000000..7b99477 Binary files /dev/null and b/WinFormsLibrary1/PluginsP/WinFormsLibrary1.dll differ diff --git a/WinFormsLibrary1/WinFormsApp1/Forms.csproj b/WinFormsLibrary1/WinFormsApp1/Forms.csproj index 400d512..7b07e75 100644 --- a/WinFormsLibrary1/WinFormsApp1/Forms.csproj +++ b/WinFormsLibrary1/WinFormsApp1/Forms.csproj @@ -22,6 +22,7 @@ + diff --git a/WinFormsLibrary1/WinFormsApp1/PluginsConvention.cs b/WinFormsLibrary1/WinFormsApp1/PluginsConvention.cs new file mode 100644 index 0000000..3ab99e2 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/PluginsConvention.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Plugins; +using Contracts.BusinessLogicContracts; +using Library14Petrushin; +using WinFormsLibrary1; +using Library15Gerimovich.OfficePackage.HelperModels; +using Contracts.ViewModels; +using BusinessLogics.BusinessLogics; +using DatabaseImplement.Implements; +using Contracts.BindingModels; +using DatabaseImplement.Models; +using Library15Gerimovich; +using Library14Petrushin.Classes; + +namespace Forms +{ + public class PluginsConvention : IPluginsConvention + { + private readonly IProductLogic _productLogic; + private readonly ICategoryLogic _categoryLogic; + private readonly HierarchicalTreeView _myTreeView; + private readonly ComponentWithBigText wordLongTextComponent; + private readonly WordTablesComponent excelDiagramComponent; + private readonly PdfCirclDiagr componentDocumentWithTableMultiHeaderPdf; + public string PluginName { get; set; } = "Products"; + + public UserControl GetControl + { + get { return _myTreeView; } + } + + public PluginsConvention() + { + _productLogic = new ProductLogic(new ProductStorage()); + _categoryLogic = new CategoryLogic(new CategoryStorage()); + wordLongTextComponent = new(); + excelDiagramComponent = new(); + componentDocumentWithTableMultiHeaderPdf = new(); + _myTreeView = new(); + } + + public PluginsConventionElement GetElement + { + get + { + int Id = int.Parse(_myTreeView.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 ProductForm(_productLogic, _categoryLogic); + } + else + { + int id = element.Id.GetHashCode(); + int? idl = id; + ProductViewModel model = _productLogic.ReadElement(new Contracts.SearchModels.ProductSearchModel { Id = idl }); + ProductForm form = new ProductForm(_productLogic, _categoryLogic, model); + // form.Id = element.Id.GetHashCode(); + return form; + } + } + + public Form GetThesaurus() + { + return new CategoryForm(_categoryLogic); + } + + public bool DeleteElement(PluginsConventionElement element) + { + _productLogic.Delete( + new ProductBindingModel { Id = element.Id.GetHashCode() } + ); + return true; + } + + public void ReloadData() + { + try + { + var products = _productLogic.ReadList(null); + var hierarchy = new List { "Category", "CountOnStorageS", "Id", "Name" }; + var alwaysNewBranch = new Dictionary { { "Name", true } }; + _myTreeView.SetHierarchy(hierarchy, alwaysNewBranch); + + foreach (var product in products) + { + _myTreeView.AddObjectToTree(product, "Name"); + } + } + catch (Exception ex) + { + MessageBox.Show( + ex.Message, + "Ошибка", + MessageBoxButtons.OK, + MessageBoxIcon.Error + ); + } + } + + public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument) + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + var rows = products.Select(p => $"{p.Name} - {p.Description}").ToArray(); + var component = new ComponentWithBigText(); + component.CreateDocument(saveFileDialog.FileName, "Список продуктов", rows); + MessageBox.Show("Документ успешно создан."); + } + return true; + } + } + + public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument) + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Word files (*.docx)|*.docx|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + if (products == null || products.Count == 0) + { + MessageBox.Show("Нет данных для создания документа."); + return false; + } + var headers = new List<(int, int, string, string)> + { + (0, 0, "Id", "Id"), + (1, 0, "Name", "Name"), + (2, 0, "Category", "Category"), + (3, 0, "CountOnStorage", "CountOnStorage") + }; + + var columnsRowsWidth = new List<(int Column, int Row)> + { + (100, 0), + (200, 1), + (150, 2), + (150, 3) + }; + + var config = new WordTableWithData + { + FileName = saveFileDialog.FileName, + Title = "Список продуктов", + Headers = headers, + Data = products, + ColumnsRowsWidth = columnsRowsWidth, + NullReplace = "-", + }; + var wordTables = new WordTablesComponent(); + + wordTables.CreateTable(config); + MessageBox.Show("Документ успешно создан."); + } + return true; + } + } + + public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument) + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + var categories = products.Where(p => p.CountOnStorage == 0).GroupBy(p => p.Category) + .Select(g => new ChartData + { + SeriesName = g.Key, + Value = g.Count(p => p.CountOnStorage == 0) + }).ToList(); + + if (categories.Count == 0) + { + MessageBox.Show("Нет данных для создания диаграммы."); + return false; + } + + + var component = new PdfCirclDiagr(); + component.GeneratePdf(saveFileDialog.FileName, + "Диаграмма продуктов", "Продукты без наличия", + LegendPosition.Right, + categories); + MessageBox.Show("Документ успешно создан."); + } + return true; + } + } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/PluginsForm.Designer.cs b/WinFormsLibrary1/WinFormsApp1/PluginsForm.Designer.cs new file mode 100644 index 0000000..c746c5e --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/PluginsForm.Designer.cs @@ -0,0 +1,175 @@ +using DocumentFormat.OpenXml.Spreadsheet; + +namespace Forms +{ + partial class PluginsForm + { + /// + /// 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() + { + 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.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(180, 22); + ThesaurusToolStripMenuItem.Text = "Справочник"; + ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click; + // + // AddElementToolStripMenuItem + // + AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem"; + AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A; + AddElementToolStripMenuItem.Size = new Size(180, 22); + AddElementToolStripMenuItem.Text = "Добавить"; + AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click; + // + // UpdElementToolStripMenuItem + // + UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem"; + UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U; + UpdElementToolStripMenuItem.Size = new Size(180, 22); + UpdElementToolStripMenuItem.Text = "Изменить"; + UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click; + // + // DelElementToolStripMenuItem + // + DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem"; + DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D; + DelElementToolStripMenuItem.Size = new Size(180, 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(233, 22); + SimpleDocToolStripMenuItem.Text = "Простой документ"; + SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click; + // + // TableDocToolStripMenuItem + // + TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem"; + TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; + TableDocToolStripMenuItem.Size = new Size(233, 22); + TableDocToolStripMenuItem.Text = "Документ с таблицой"; + TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click; + // + // ChartDocToolStripMenuItem + // + ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem"; + ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; + ChartDocToolStripMenuItem.Size = new Size(233, 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; + KeyDown += FormMain_KeyDown; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + 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/WinFormsLibrary1/WinFormsApp1/PluginsForm.cs b/WinFormsLibrary1/WinFormsApp1/PluginsForm.cs new file mode 100644 index 0000000..5de3613 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/PluginsForm.cs @@ -0,0 +1,226 @@ +using DocumentFormat.OpenXml.Office2010.CustomUI; +using Plugins; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Forms +{ + public partial class PluginsForm : Form + { + private readonly Dictionary _plugins; + private string _selectedPlugin; + + public PluginsForm() + { + InitializeComponent(); + _plugins = LoadPlugins(); + _selectedPlugin = string.Empty; + } + + private Dictionary LoadPlugins() + { + var plugins = new Dictionary(); + + string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.Parent!.FullName + "\\PluginsP"; + + 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 = "Word Files|*.docx" + }; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + _plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + + } + } + private void CreateTableDoc() + { + SaveFileDialog saveFileDialog = new() + { + Filter = "PDF Files|*.pdf" + }; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + _plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + + } + } + private void CreateChartDoc() + { + SaveFileDialog saveFileDialog = new() + { + Filter = "Excel Files|*.xlsx" + }; + 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(); + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/PluginsForm.resx b/WinFormsLibrary1/WinFormsApp1/PluginsForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/PluginsForm.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/WinFormsLibrary1/WinFormsApp1/Program.cs b/WinFormsLibrary1/WinFormsApp1/Program.cs index 5ce4621..effc1e0 100644 --- a/WinFormsLibrary1/WinFormsApp1/Program.cs +++ b/WinFormsLibrary1/WinFormsApp1/Program.cs @@ -28,7 +28,7 @@ namespace WinFormsApp1 ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); - Application.Run(_serviceProvider.GetRequiredService()); + Application.Run(_serviceProvider.GetRequiredService()); } private static void ConfigureServices(ServiceCollection services) @@ -48,6 +48,7 @@ namespace WinFormsApp1 services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsLibrary1.sln b/WinFormsLibrary1/WinFormsLibrary1.sln index 0dd272b..6377826 100644 --- a/WinFormsLibrary1/WinFormsLibrary1.sln +++ b/WinFormsLibrary1/WinFormsLibrary1.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Cont EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{02E84641-9C21-43C3-99CD-765878F8C8F6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins", "Plugins\Plugins.csproj", "{1E1177E8-5664-4A09-AE2A-1C58F3A7CADD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {02E84641-9C21-43C3-99CD-765878F8C8F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {02E84641-9C21-43C3-99CD-765878F8C8F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {02E84641-9C21-43C3-99CD-765878F8C8F6}.Release|Any CPU.Build.0 = Release|Any CPU + {1E1177E8-5664-4A09-AE2A-1C58F3A7CADD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E1177E8-5664-4A09-AE2A-1C58F3A7CADD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E1177E8-5664-4A09-AE2A-1C58F3A7CADD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E1177E8-5664-4A09-AE2A-1C58F3A7CADD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WinFormsLibrary1/WinFormsLibrary1/ListBox.cs b/WinFormsLibrary1/WinFormsLibrary1/ListBox.cs index d71b09f..5b79910 100644 --- a/WinFormsLibrary1/WinFormsLibrary1/ListBox.cs +++ b/WinFormsLibrary1/WinFormsLibrary1/ListBox.cs @@ -31,6 +31,11 @@ namespace WinFormsLibrary1 InitializeComponent(); } + public void Clear() + { + listBox.Items.Clear(); + } + public void SetParams(string template, char? fromChar, char? toChar) { _template = template; @@ -40,57 +45,54 @@ namespace WinFormsLibrary1 public T? GetObject() where T : class, new() { - if (listBox.SelectedIndex == -1 || string.IsNullOrEmpty(_template) || !_startSymbol.HasValue || !_endSymbol.HasValue) - throw new ArgumentException("Не хватает данных"); - - var type = typeof(T); - var fields = type.GetFields(); - var properties = type.GetProperties(); - var members = fields.Cast().Concat(properties.Cast()).ToArray(); - - var curObject = new T(); - string text = listBox.SelectedItem?.ToString() ?? ""; - - var words = Regex.Split(_template, $@"\{_startSymbol.Value}.*?\{_endSymbol.Value}"); - - int firstWordStart = text.IndexOf(words[0], 0); - if (firstWordStart == -1) - throw new Exception("Не найден элемент шаблона"); - if (firstWordStart != 0) + if (listBox.SelectedIndex == -1) { - string beginning = text[..firstWordStart]; - FillMember(_template.Substring(1, firstWordStart - 2), curObject, beginning, members); + return null; } - int start = 0; - - for (int i = 0; i < words.Length - 1; i++) + string value = listBox.SelectedItem.ToString(); + StringBuilder stringBuilder = new StringBuilder(value); + T val = new T(); + PropertyInfo[] properties = val.GetType().GetProperties(); + foreach (PropertyInfo propertyInfo in properties) { - start = text.IndexOf(words[i], start); - if (start == -1) - throw new Exception("Не найден элемент шаблона"); - start += words[i].Length; + if (propertyInfo.CanWrite) + { + int num = stringBuilder.ToString().IndexOf(_startSymbol.Value); + if (num == -1) + { + break; + } - int nextWordIndex = text.IndexOf(words[i + 1], start); - if (nextWordIndex == -1) - throw new Exception("Не найден следующий элемент шаблона"); + int num2 = stringBuilder.ToString().IndexOf(_endSymbol.Value, num + 1); + if (num2 == -1) + { + break; + } - string valueBetween = text[start..nextWordIndex]; + string value2 = stringBuilder.ToString(num + 1, num2 - num - 1); + stringBuilder.Remove(0, num2 + 1); - string layoutPart = _template.Substring(_template.IndexOf(words[i]) + words[i].Length); - int startCharIndex = layoutPart.IndexOf(_startSymbol.Value); - int endCharIndex = layoutPart.IndexOf(_endSymbol.Value); - string memberName = layoutPart.Substring(startCharIndex + 1, endCharIndex - startCharIndex - 1); - - FillMember(memberName, curObject, valueBetween, members); - - start = nextWordIndex; + try + { + propertyInfo.SetValue(val, Convert.ChangeType(value2, propertyInfo.PropertyType)); + } + catch (FormatException) + { + // Обработка ошибки преобразования формата + // Можно либо пропустить это поле, либо установить значение по умолчанию + // Например: + // propertyInfo.SetValue(val, default); + // Или вывести сообщение об ошибке + MessageBox.Show($"Не удалось преобразовать значение '{value2}' в тип {propertyInfo.PropertyType} для поля {propertyInfo.Name}."); + } + } } - return (T?)curObject; - + return val; } + private void SetMemberValue(object obj, MemberInfo member, object value) { if (member is PropertyInfo property) diff --git a/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj b/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj index 13121d5..f4c6eb5 100644 --- a/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj +++ b/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj @@ -6,7 +6,7 @@ true enable True - 1.0.3 + 1.0.6 Library13StroevV diff --git a/reports/diagrams.vpp b/reports/diagrams.vpp new file mode 100644 index 0000000..85cdbf4 Binary files /dev/null and b/reports/diagrams.vpp differ diff --git a/reports/diagrams.vpp.bak_000f b/reports/diagrams.vpp.bak_000f new file mode 100644 index 0000000..85cdbf4 Binary files /dev/null and b/reports/diagrams.vpp.bak_000f differ diff --git a/reports/Лаб5/Adapter.jpg b/reports/Лаб5/Adapter.jpg new file mode 100644 index 0000000..09d6aa2 Binary files /dev/null and b/reports/Лаб5/Adapter.jpg differ diff --git a/reports/Лаб5/Bridge.jpg b/reports/Лаб5/Bridge.jpg new file mode 100644 index 0000000..cfa9f8f Binary files /dev/null and b/reports/Лаб5/Bridge.jpg differ diff --git a/reports/Лаб5/Facade.jpg b/reports/Лаб5/Facade.jpg new file mode 100644 index 0000000..1fa1bfb Binary files /dev/null and b/reports/Лаб5/Facade.jpg differ diff --git a/reports/Лаб5/Лаб5.docx b/reports/Лаб5/Лаб5.docx new file mode 100644 index 0000000..c999138 Binary files /dev/null and b/reports/Лаб5/Лаб5.docx differ diff --git a/reports/Лаб6/Builder1.jpg b/reports/Лаб6/Builder1.jpg new file mode 100644 index 0000000..270bd96 Binary files /dev/null and b/reports/Лаб6/Builder1.jpg differ diff --git a/reports/Лаб6/Builder2.jpg b/reports/Лаб6/Builder2.jpg new file mode 100644 index 0000000..c685705 Binary files /dev/null and b/reports/Лаб6/Builder2.jpg differ diff --git a/reports/Лаб6/Prototype.jpg b/reports/Лаб6/Prototype.jpg new file mode 100644 index 0000000..c685705 Binary files /dev/null and b/reports/Лаб6/Prototype.jpg differ diff --git a/reports/Лаб6/Лаб6.docx b/reports/Лаб6/Лаб6.docx new file mode 100644 index 0000000..cee1105 Binary files /dev/null and b/reports/Лаб6/Лаб6.docx differ diff --git a/reports/Лаб7/ChainOfResppnsobility.jpg b/reports/Лаб7/ChainOfResppnsobility.jpg new file mode 100644 index 0000000..5abfc2a Binary files /dev/null and b/reports/Лаб7/ChainOfResppnsobility.jpg differ diff --git a/reports/Лаб7/Mediator.jpg b/reports/Лаб7/Mediator.jpg new file mode 100644 index 0000000..f877286 Binary files /dev/null and b/reports/Лаб7/Mediator.jpg differ diff --git a/reports/Лаб7/Observer.jpg b/reports/Лаб7/Observer.jpg new file mode 100644 index 0000000..cf7b52d Binary files /dev/null and b/reports/Лаб7/Observer.jpg differ diff --git a/reports/Лаб7/Лаб7.docx b/reports/Лаб7/Лаб7.docx new file mode 100644 index 0000000..fd0ad6b Binary files /dev/null and b/reports/Лаб7/Лаб7.docx differ