From a474bd8bbba1029333e37480bb3b7e07a5033225 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Sun, 24 Nov 2024 17:58:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=B3=D0=B8=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs index 87a0204..83fc957 100644 --- a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs +++ b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs @@ -8,19 +8,32 @@ namespace Lab4.Forms private readonly Dictionary _plugins; private string _selectedPlugin; - public FormMain() + private readonly Func _pluginsConventionFunc; + + public FormMain(Func pluginsConventionFunc) { InitializeComponent(); + _pluginsConventionFunc = pluginsConventionFunc; + _plugins = LoadPlugins(); _selectedPlugin = string.Empty; } private Dictionary LoadPlugins() { - // TODO Заполнить IPluginsConvention - // TODO Заполнить пункт меню "Компоненты" на основе IPluginsConvention.PluginName - // TODO Например, создавать ToolStripMenuItem, привязывать к ним обработку событий и добавлять в menuStrip + Dictionary result = []; + + List keys = ["Успеваемость"]; + result = keys.Select(k => KeyValuePair.Create(k, _pluginsConventionFunc(k))).ToDictionary(); + foreach (string key in keys) + { + var item = new ToolStripMenuItem(key); + item.Click += (s, e) => _selectedPlugin = key; + + ControlsStripMenuItem.Container!.Add(item); + } + // TODO При выборе пункта меню получать UserControl и заполнять элемент panelControl этим контролом на всю площадь // Пример: panelControl.Controls.Clear(); // panelControl.Controls.Add(ctrl);