diff --git a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.Designer.cs b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.Designer.cs
new file mode 100644
index 0000000..4951763
--- /dev/null
+++ b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.Designer.cs
@@ -0,0 +1,188 @@
+using System.ComponentModel;
+
+namespace Lab4.Forms
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private 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 MenuStrip();
+ this.ControlsStripMenuItem = new ToolStripMenuItem();
+ this.ActionsToolStripMenuItem = new ToolStripMenuItem();
+ this.DocsToolStripMenuItem = new ToolStripMenuItem();
+ this.SimpleDocToolStripMenuItem = new ToolStripMenuItem();
+ this.TableDocToolStripMenuItem = new ToolStripMenuItem();
+ this.ChartDocToolStripMenuItem = new ToolStripMenuItem();
+ this.panelControl = new Panel();
+ this.ThesaurusToolStripMenuItem = new ToolStripMenuItem();
+ this.AddElementToolStripMenuItem = new ToolStripMenuItem();
+ this.UpdElementToolStripMenuItem = new ToolStripMenuItem();
+ this.DelElementToolStripMenuItem = new ToolStripMenuItem();
+ this.menuStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip
+ //
+ this.menuStrip.Items.AddRange(new ToolStripItem[] {
+ this.ControlsStripMenuItem,
+ this.ActionsToolStripMenuItem,
+ this.DocsToolStripMenuItem});
+ this.menuStrip.Location = new Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new Size(800, 24);
+ this.menuStrip.TabIndex = 0;
+ this.menuStrip.Text = "Меню";
+ //
+ // ControlsStripMenuItem
+ //
+ this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
+ this.ControlsStripMenuItem.Size = new Size(94, 20);
+ this.ControlsStripMenuItem.Text = "Компоненты";
+ //
+ // ActionsToolStripMenuItem
+ //
+ this.ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {
+ this.ThesaurusToolStripMenuItem,
+ this.AddElementToolStripMenuItem,
+ this.UpdElementToolStripMenuItem,
+ this.DelElementToolStripMenuItem});
+ this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
+ this.ActionsToolStripMenuItem.Size = new Size(70, 20);
+ this.ActionsToolStripMenuItem.Text = "Действия";
+ //
+ // DocsToolStripMenuItem
+ //
+ this.DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {
+ this.SimpleDocToolStripMenuItem,
+ this.TableDocToolStripMenuItem,
+ this.ChartDocToolStripMenuItem});
+ this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
+ this.DocsToolStripMenuItem.Size = new Size(82, 20);
+ this.DocsToolStripMenuItem.Text = "Документы";
+ //
+ // SimpleDocToolStripMenuItem
+ //
+ this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
+ this.SimpleDocToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.S)));
+ this.SimpleDocToolStripMenuItem.Size = new Size(233, 22);
+ this.SimpleDocToolStripMenuItem.Text = "Простой документ";
+ this.SimpleDocToolStripMenuItem.Click += new EventHandler(this.SimpleDocToolStripMenuItem_Click);
+ //
+ // TableDocToolStripMenuItem
+ //
+ this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
+ this.TableDocToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.T)));
+ this.TableDocToolStripMenuItem.Size = new Size(233, 22);
+ this.TableDocToolStripMenuItem.Text = "Документ с таблицей";
+ this.TableDocToolStripMenuItem.Click += new EventHandler(this.TableDocToolStripMenuItem_Click);
+ //
+ // ChartDocToolStripMenuItem
+ //
+ this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
+ this.ChartDocToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.C)));
+ this.ChartDocToolStripMenuItem.Size = new Size(233, 22);
+ this.ChartDocToolStripMenuItem.Text = "Диаграмма";
+ this.ChartDocToolStripMenuItem.Click += new EventHandler(this.ChartDocToolStripMenuItem_Click);
+ //
+ // panelControl
+ //
+ this.panelControl.Dock = DockStyle.Fill;
+ this.panelControl.Location = new Point(0, 24);
+ this.panelControl.Name = "panelControl";
+ this.panelControl.Size = new Size(800, 426);
+ this.panelControl.TabIndex = 1;
+ //
+ // ThesaurusToolStripMenuItem
+ //
+ this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
+ this.ThesaurusToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.I)));
+ this.ThesaurusToolStripMenuItem.Size = new Size(180, 22);
+ this.ThesaurusToolStripMenuItem.Text = "Справочник";
+ this.ThesaurusToolStripMenuItem.Click += new EventHandler(this.ThesaurusToolStripMenuItem_Click);
+ //
+ // AddElementToolStripMenuItem
+ //
+ this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
+ this.AddElementToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.A)));
+ this.AddElementToolStripMenuItem.Size = new Size(180, 22);
+ this.AddElementToolStripMenuItem.Text = "Добавить";
+ this.AddElementToolStripMenuItem.Click += new EventHandler(this.AddElementToolStripMenuItem_Click);
+ //
+ // UpdElementToolStripMenuItem
+ //
+ this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
+ this.UpdElementToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.U)));
+ this.UpdElementToolStripMenuItem.Size = new Size(180, 22);
+ this.UpdElementToolStripMenuItem.Text = "Изменить";
+ this.UpdElementToolStripMenuItem.Click += new EventHandler(this.UpdElementToolStripMenuItem_Click);
+ //
+ // DelElementToolStripMenuItem
+ //
+ this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
+ this.DelElementToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.D)));
+ this.DelElementToolStripMenuItem.Size = new Size(180, 22);
+ this.DelElementToolStripMenuItem.Text = "Удалить";
+ this.DelElementToolStripMenuItem.Click += new EventHandler(this.DelElementToolStripMenuItem_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new SizeF(7F, 15F);
+ this.AutoScaleMode = AutoScaleMode.Font;
+ this.ClientSize = new Size(800, 450);
+ this.Controls.Add(this.panelControl);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Name = "FormMain";
+ this.StartPosition =
+ FormStartPosition.CenterScreen;
+ this.Text = "Главная форма";
+ this.WindowState =
+ FormWindowState.Maximized;
+ this.KeyDown += new
+ KeyEventHandler(this.FormMain_KeyDown);
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem ControlsStripMenuItem;
+ private ToolStripMenuItem DocsToolStripMenuItem;
+ private ToolStripMenuItem SimpleDocToolStripMenuItem;
+ private ToolStripMenuItem TableDocToolStripMenuItem;
+ private ToolStripMenuItem ChartDocToolStripMenuItem;
+ private Panel panelControl;
+ private ToolStripMenuItem ActionsToolStripMenuItem;
+ private ToolStripMenuItem ThesaurusToolStripMenuItem;
+ private ToolStripMenuItem AddElementToolStripMenuItem;
+ private ToolStripMenuItem UpdElementToolStripMenuItem;
+ private ToolStripMenuItem DelElementToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs
new file mode 100644
index 0000000..87a0204
--- /dev/null
+++ b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.cs
@@ -0,0 +1,186 @@
+using Lab4.Interfaces;
+using Lab4.Models;
+
+namespace Lab4.Forms
+{
+ public partial class FormMain : Form
+ {
+ private readonly Dictionary _plugins;
+ private string _selectedPlugin;
+
+ public FormMain()
+ {
+ InitializeComponent();
+
+ _plugins = LoadPlugins();
+ _selectedPlugin = string.Empty;
+ }
+
+ private Dictionary LoadPlugins()
+ {
+ // TODO Заполнить IPluginsConvention
+ // TODO Заполнить пункт меню "Компоненты" на основе IPluginsConvention.PluginName
+ // TODO Например, создавать ToolStripMenuItem, привязывать к ним обработку событий и добавлять в menuStrip
+ // TODO При выборе пункта меню получать UserControl и заполнять элемент panelControl этим контролом на всю площадь
+ // Пример: panelControl.Controls.Clear();
+ // panelControl.Controls.Add(ctrl);
+ return [];
+ }
+
+ 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();
+
+ 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()
+ {
+ // TODO узнать где сохранять
+ if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument()))
+ {
+ _ = MessageBox.Show("Документ сохранен",
+ "Создание документа",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ else
+ {
+ _ = MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void CreateTableDoc()
+ {
+ // TODO узнать где сохранять
+ if (_plugins[_selectedPlugin].CreateTableDocument(new
+ PluginsConventionSaveDocument()))
+ {
+ _ = MessageBox.Show("Документ сохранен",
+ "Создание документа",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ else
+ {
+ _ = MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void CreateChartDoc()
+ {
+ // TODO узнать где сохранять
+ if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument()))
+ {
+ _ = 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();
+
+ }
+}
diff --git a/Cop.Borovkov.Var3/Lab4/Forms/FormMain.resx b/Cop.Borovkov.Var3/Lab4/Forms/FormMain.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Cop.Borovkov.Var3/Lab4/Forms/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/Cop.Borovkov.Var3/Lab4/Forms/Interfaces/IPluginsConvention.cs b/Cop.Borovkov.Var3/Lab4/Interfaces/IPluginsConvention.cs
similarity index 94%
rename from Cop.Borovkov.Var3/Lab4/Forms/Interfaces/IPluginsConvention.cs
rename to Cop.Borovkov.Var3/Lab4/Interfaces/IPluginsConvention.cs
index 5046865..52dda70 100644
--- a/Cop.Borovkov.Var3/Lab4/Forms/Interfaces/IPluginsConvention.cs
+++ b/Cop.Borovkov.Var3/Lab4/Interfaces/IPluginsConvention.cs
@@ -1,4 +1,6 @@
-namespace Lab4.Forms.Interfaces
+using Lab4.Models;
+
+namespace Lab4.Interfaces
{
public interface IPluginsConvention
{
@@ -16,12 +18,14 @@
/// Получение элемента, выбранного в контроле
///
PluginsConventionElement GetElement { get; }
+
///
/// Получение формы для создания/редактирования объекта
///
///
///
- Form GetForm(PluginsConventionElement element);
+ Form GetForm(PluginsConventionElement? element = null);
+
///
/// Получение формы для работы со справочником
///
@@ -61,5 +65,4 @@
///
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
}
-
}
diff --git a/Cop.Borovkov.Var3/Lab4/Models/PluginsConventionSaveDocument.cs b/Cop.Borovkov.Var3/Lab4/Models/PluginsConventionSaveDocument.cs
new file mode 100644
index 0000000..d5e4fc7
--- /dev/null
+++ b/Cop.Borovkov.Var3/Lab4/Models/PluginsConventionSaveDocument.cs
@@ -0,0 +1,7 @@
+namespace Lab4.Models
+{
+ public class PluginsConventionSaveDocument
+ {
+ public string FileName { get; set; } = null!;
+ }
+}