some fixes
This commit is contained in:
parent
549daa26b1
commit
529eb62a76
@ -1,4 +1,4 @@
|
|||||||
namespace LibraryWinFormsApp
|
namespace LibraryPluginWinFormsApp
|
||||||
{
|
{
|
||||||
partial class FormMain
|
partial class FormMain
|
||||||
{
|
{
|
253
LibraryPluginWinFormsApp/FormMain.cs
Normal file
253
LibraryPluginWinFormsApp/FormMain.cs
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
//using NPOI.HPSF;
|
||||||
|
//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 LibraryPluginWinFormsApp
|
||||||
|
//{
|
||||||
|
// public partial class FormMain : Form
|
||||||
|
// {
|
||||||
|
// private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||||
|
// private string _selectedPlugin;
|
||||||
|
// public FormMain()
|
||||||
|
// {
|
||||||
|
// InitializeComponent();
|
||||||
|
// _plugins = LoadPlugins();
|
||||||
|
// _selectedPlugin = string.Empty;
|
||||||
|
// }
|
||||||
|
// private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||||
|
// {
|
||||||
|
// Dictionary<string, IPluginsConvention> plugins = new();
|
||||||
|
// string currentDirectory = Directory
|
||||||
|
// .GetParent(Environment.CurrentDirectory)!
|
||||||
|
// .Parent!
|
||||||
|
// .Parent!
|
||||||
|
// .Parent!
|
||||||
|
// .FullName + "\\plugin";
|
||||||
|
// string[] dllFiles = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);
|
||||||
|
// foreach (string dllFile in dllFiles)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||||
|
|
||||||
|
// Type[] types = assembly.GetTypes();
|
||||||
|
|
||||||
|
// foreach (Type type in types)
|
||||||
|
// {
|
||||||
|
// if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||||
|
// {
|
||||||
|
// var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||||
|
|
||||||
|
// plugins.Add(plugin.PluginName, plugin);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"Не удалось загрузить плагин {dllFile}: {ex.Message}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// foreach (var plugin in plugins)
|
||||||
|
// {
|
||||||
|
// CreateMenuItem(plugin.Value.PluginName);
|
||||||
|
// }
|
||||||
|
// return plugins;
|
||||||
|
// }
|
||||||
|
// private void CreateMenuItem(string pluginName)
|
||||||
|
// {
|
||||||
|
// ToolStripMenuItem menuItem = new ToolStripMenuItem(pluginName);
|
||||||
|
// menuItem.Click += (object? sender, EventArgs a) =>
|
||||||
|
// {
|
||||||
|
// _selectedPlugin = pluginName;
|
||||||
|
// IPluginsConvention plugin = _plugins[pluginName];
|
||||||
|
// UserControl userControl = plugin.GetControl;
|
||||||
|
// if (userControl != null)
|
||||||
|
// {
|
||||||
|
// panelControl.Controls.Clear();
|
||||||
|
// plugin.ReloadData();
|
||||||
|
// userControl.Dock = DockStyle.Fill;
|
||||||
|
// 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 SaveFileDialog();
|
||||||
|
// saveFileDialog.Filter = "Word Documents (*.docx)|*.docx";
|
||||||
|
// saveFileDialog.Title = "Сохранить простой документ";
|
||||||
|
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
// {
|
||||||
|
// if (_plugins[_selectedPlugin].CreateSimpleDocument(
|
||||||
|
// new PluginsConventionSaveDocument()
|
||||||
|
// {
|
||||||
|
// FileName = saveFileDialog.FileName
|
||||||
|
// }))
|
||||||
|
// {
|
||||||
|
// MessageBox.Show("Документ сохранен", "Создание" +
|
||||||
|
// " документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// MessageBox.Show("Ошибка при создании документа",
|
||||||
|
// "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// private void CreateTableDoc()
|
||||||
|
// {
|
||||||
|
// SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
// saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
||||||
|
// saveFileDialog.Title = "Сохранить таблицу";
|
||||||
|
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
// {
|
||||||
|
// if (_plugins[_selectedPlugin].CreateTableDocument(
|
||||||
|
// new PluginsConventionSaveDocument()
|
||||||
|
// {
|
||||||
|
// FileName = saveFileDialog.FileName
|
||||||
|
// }))
|
||||||
|
// {
|
||||||
|
// MessageBox.Show("Документ сохранен", "Создание" +
|
||||||
|
// " документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// MessageBox.Show("Ошибка при создании документа",
|
||||||
|
// "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// private void CreateChartDoc()
|
||||||
|
// {
|
||||||
|
// SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
// saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
||||||
|
// saveFileDialog.Title = "Сохранить диаграмму";
|
||||||
|
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
// {
|
||||||
|
// if (_plugins[_selectedPlugin].CreateChartDocument(
|
||||||
|
// new PluginsConventionSaveDocument()
|
||||||
|
// {
|
||||||
|
// FileName = saveFileDialog.FileName
|
||||||
|
// }))
|
||||||
|
// {
|
||||||
|
// 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();
|
||||||
|
// }
|
||||||
|
//}
|
15
LibraryPluginWinFormsApp/LibraryPluginWinFormsApp.csproj
Normal file
15
LibraryPluginWinFormsApp/LibraryPluginWinFormsApp.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="FormMain.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,4 +1,4 @@
|
|||||||
namespace LibraryWinFormsApp
|
namespace LibraryPluginWinFormsApp
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.9.34723.18
|
VisualStudioVersion = 17.9.34723.18
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryWinFormsApp", "LibraryWinFormsApp\LibraryWinFormsApp.csproj", "{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryPluginWinFormsApp", "LibraryPluginWinFormsApp\LibraryPluginWinFormsApp.csproj", "{EDA20922-AD39-42EA-B126-81DCBF6458DF}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -11,10 +11,10 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{EDA20922-AD39-42EA-B126-81DCBF6458DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EDA20922-AD39-42EA-B126-81DCBF6458DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EDA20922-AD39-42EA-B126-81DCBF6458DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E8BD6D99-6C63-42E4-8BBC-6FF8419C7C9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EDA20922-AD39-42EA-B126-81DCBF6458DF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,253 +0,0 @@
|
|||||||
using NPOI.HPSF;
|
|
||||||
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 LibraryWinFormsApp
|
|
||||||
{
|
|
||||||
public partial class FormMain : Form
|
|
||||||
{
|
|
||||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
|
||||||
private string _selectedPlugin;
|
|
||||||
public FormMain()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_plugins = LoadPlugins();
|
|
||||||
_selectedPlugin = string.Empty;
|
|
||||||
}
|
|
||||||
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
|
||||||
{
|
|
||||||
Dictionary<string, IPluginsConvention> plugins = new();
|
|
||||||
string currentDirectory = Directory
|
|
||||||
.GetParent(Environment.CurrentDirectory)!
|
|
||||||
.Parent!
|
|
||||||
.Parent!
|
|
||||||
.Parent!
|
|
||||||
.FullName + "\\plugin";
|
|
||||||
string[] dllFiles = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);
|
|
||||||
foreach (string dllFile in dllFiles)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
|
||||||
|
|
||||||
Type[] types = assembly.GetTypes();
|
|
||||||
|
|
||||||
foreach (Type type in types)
|
|
||||||
{
|
|
||||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
|
||||||
{
|
|
||||||
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
|
||||||
|
|
||||||
plugins.Add(plugin.PluginName, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Не удалось загрузить плагин {dllFile}: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var plugin in plugins)
|
|
||||||
{
|
|
||||||
CreateMenuItem(plugin.Value.PluginName);
|
|
||||||
}
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
private void CreateMenuItem(string pluginName)
|
|
||||||
{
|
|
||||||
ToolStripMenuItem menuItem = new ToolStripMenuItem(pluginName);
|
|
||||||
menuItem.Click += (object? sender, EventArgs a) =>
|
|
||||||
{
|
|
||||||
_selectedPlugin = pluginName;
|
|
||||||
IPluginsConvention plugin = _plugins[pluginName];
|
|
||||||
UserControl userControl = plugin.GetControl;
|
|
||||||
if (userControl != null)
|
|
||||||
{
|
|
||||||
panelControl.Controls.Clear();
|
|
||||||
plugin.ReloadData();
|
|
||||||
userControl.Dock = DockStyle.Fill;
|
|
||||||
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 SaveFileDialog();
|
|
||||||
saveFileDialog.Filter = "Word Documents (*.docx)|*.docx";
|
|
||||||
saveFileDialog.Title = "Сохранить простой документ";
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (_plugins[_selectedPlugin].CreateSimpleDocument(
|
|
||||||
new PluginsConventionSaveDocument()
|
|
||||||
{
|
|
||||||
FileName = saveFileDialog.FileName
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сохранен", "Создание" +
|
|
||||||
" документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Ошибка при создании документа",
|
|
||||||
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CreateTableDoc()
|
|
||||||
{
|
|
||||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
||||||
saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
|
||||||
saveFileDialog.Title = "Сохранить таблицу";
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (_plugins[_selectedPlugin].CreateTableDocument(
|
|
||||||
new PluginsConventionSaveDocument()
|
|
||||||
{
|
|
||||||
FileName = saveFileDialog.FileName
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сохранен", "Создание" +
|
|
||||||
" документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Ошибка при создании документа",
|
|
||||||
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CreateChartDoc()
|
|
||||||
{
|
|
||||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
||||||
saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
|
||||||
saveFileDialog.Title = "Сохранить диаграмму";
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (_plugins[_selectedPlugin].CreateChartDocument(
|
|
||||||
new PluginsConventionSaveDocument()
|
|
||||||
{
|
|
||||||
FileName = saveFileDialog.FileName
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user