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(" ",