From d9dea309c59bc97611e3ef242e9d60ea9ee45ea4 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Mon, 25 Nov 2024 21:07:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cop.Borovkov.Var3/Lab4/Extensions/DiExtensions.cs | 4 ++-- Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs | 12 +++++++++++- .../Lab4/Implementations/PluginsConvention.cs | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cop.Borovkov.Var3/Lab4/Extensions/DiExtensions.cs b/Cop.Borovkov.Var3/Lab4/Extensions/DiExtensions.cs index ec824e1..129b87a 100644 --- a/Cop.Borovkov.Var3/Lab4/Extensions/DiExtensions.cs +++ b/Cop.Borovkov.Var3/Lab4/Extensions/DiExtensions.cs @@ -12,14 +12,14 @@ namespace Lab4.Extensions { services.AddScoped(); - services.AddScoped(); - return services; } public static IServiceCollection AddScopes( this IServiceCollection services) { + services.AddScoped(); + services.AddScoped>(sp => (type) => (sp.GetRequiredService(type) as IPluginsConvention)!); diff --git a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs index e2b5c8e..bc5a9c1 100644 --- a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs +++ b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs @@ -42,7 +42,13 @@ namespace Lab4.Forms _selectedPlugin = key; panelControl.Controls.Clear(); - panelControl.Controls.Add(_plugins[key].GetControl); + + _plugins[_selectedPlugin].ReloadData(); + var control = _plugins[key].GetControl; + control.Parent = panelControl; + control.Dock = DockStyle.Fill; + + panelControl.Controls.Add(control); }; ControlsStripMenuItem.DropDownItems!.Add(item); } @@ -121,6 +127,7 @@ namespace Lab4.Forms _plugins[_selectedPlugin].ReloadData(); } } + private void DeleteElement() { if (MessageBox.Show("Удалить выбранный элемент", "Удаление", @@ -170,6 +177,7 @@ namespace Lab4.Forms _ = MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void CreateTableDoc() { using var saveFileDialog = new SaveFileDialog @@ -198,6 +206,7 @@ namespace Lab4.Forms _ = MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void CreateChartDoc() { using var saveFileDialog = new SaveFileDialog @@ -225,6 +234,7 @@ namespace Lab4.Forms _ = MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus(); private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement(); diff --git a/Cop.Borovkov.Var3/Lab4/Implementations/PluginsConvention.cs b/Cop.Borovkov.Var3/Lab4/Implementations/PluginsConvention.cs index e2683c5..9f1253b 100644 --- a/Cop.Borovkov.Var3/Lab4/Implementations/PluginsConvention.cs +++ b/Cop.Borovkov.Var3/Lab4/Implementations/PluginsConvention.cs @@ -177,11 +177,11 @@ namespace Lab4.Implementations public Form GetThesaurus() => new CatalogForm(_educationFormRepository); - public void ReloadData() + public async void ReloadData() { try { - var students = _mapper.Map>(_studentRepository.GetAsync().Result); + var students = _mapper.Map>(await _studentRepository.GetAsync()); _control.FillValues( students.Select(s => string.Join(" ",