Compare commits
3 Commits
69b21488e6
...
454452c84b
Author | SHA1 | Date | |
---|---|---|---|
|
454452c84b | ||
|
f20d17f212 | ||
|
0b515dc8c4 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@
|
|||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
*.dll
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
@ -7,15 +7,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbazovAppView", "AbazovAppV
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbazovViewComponents", "AbazovViewComponents\AbazovViewComponents.csproj", "{070AAA71-3C9B-4E19-A89D-83372C630C6E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbazovViewComponents", "AbazovViewComponents\AbazovViewComponents.csproj", "{070AAA71-3C9B-4E19-A89D-83372C630C6E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountsApp", "AccountsApp\AccountsApp.csproj", "{AFCB57A0-4332-4C32-9FB1-60548F7D7276}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsApp", "AccountsApp\AccountsApp.csproj", "{AFCB57A0-4332-4C32-9FB1-60548F7D7276}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountsDataModels", "AccountsDataModels\AccountsDataModels.csproj", "{31DEDC68-889D-427B-ADDE-60F2ADE2C596}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsDataModels", "AccountsDataModels\AccountsDataModels.csproj", "{31DEDC68-889D-427B-ADDE-60F2ADE2C596}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountsContracts", "AccountsContracts\AccountsContracts.csproj", "{CDA8B86A-9645-4D83-92D0-C8D2D85B734F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsContracts", "AccountsContracts\AccountsContracts.csproj", "{CDA8B86A-9645-4D83-92D0-C8D2D85B734F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountsBusinessLogic", "AccountsBusinessLogic\AccountsBusinessLogic.csproj", "{D98A5D9F-A491-4A4B-A4A3-B1F388BAD18D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsBusinessLogic", "AccountsBusinessLogic\AccountsBusinessLogic.csproj", "{D98A5D9F-A491-4A4B-A4A3-B1F388BAD18D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountsDataBaseImplement", "AccountsDataBaseImplement\AccountsDataBaseImplement.csproj", "{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsDataBaseImplement", "AccountsDataBaseImplement\AccountsDataBaseImplement.csproj", "{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{B97362C6-7FB3-4696-BE00-7E42C4E40274}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountAppPlugins", "AccountAppPlugins\AccountAppPlugins.csproj", "{0FE49AC5-A83A-46D6-8590-DD06DC9E34A0}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -51,6 +55,14 @@ Global
|
|||||||
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{ACF95C0D-CEB3-41B9-8B7F-149BEEEE53CE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B97362C6-7FB3-4696-BE00-7E42C4E40274}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B97362C6-7FB3-4696-BE00-7E42C4E40274}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B97362C6-7FB3-4696-BE00-7E42C4E40274}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B97362C6-7FB3-4696-BE00-7E42C4E40274}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0FE49AC5-A83A-46D6-8590-DD06DC9E34A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0FE49AC5-A83A-46D6-8590-DD06DC9E34A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0FE49AC5-A83A-46D6-8590-DD06DC9E34A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0FE49AC5-A83A-46D6-8590-DD06DC9E34A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
21
AbazovApp/AccountAppPlugins/AccountAppPlugins.csproj
Normal file
21
AbazovApp/AccountAppPlugins/AccountAppPlugins.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<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>
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||||
|
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
||||||
|
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
176
AbazovApp/AccountAppPlugins/FormMain.Designer.cs
generated
Normal file
176
AbazovApp/AccountAppPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AccountAppPlugins
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
ControlsStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ActionsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ThesaurusToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AddElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
UpdElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DelElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DocsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SimpleDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
TableDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ChartDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
panelControl = new Panel();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Size = new Size(800, 24);
|
||||||
|
menuStrip.TabIndex = 0;
|
||||||
|
menuStrip.Text = "Меню";
|
||||||
|
//
|
||||||
|
// ControlsStripMenuItem
|
||||||
|
//
|
||||||
|
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||||
|
ControlsStripMenuItem.Size = new Size(90, 20);
|
||||||
|
ControlsStripMenuItem.Text = "Компоненты";
|
||||||
|
//
|
||||||
|
// ActionsToolStripMenuItem
|
||||||
|
//
|
||||||
|
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
|
||||||
|
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||||
|
ActionsToolStripMenuItem.Size = new Size(70, 20);
|
||||||
|
ActionsToolStripMenuItem.Text = "Действия";
|
||||||
|
//
|
||||||
|
// ThesaurusToolStripMenuItem
|
||||||
|
//
|
||||||
|
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||||
|
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
|
||||||
|
ThesaurusToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||||
|
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// AddElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||||
|
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||||
|
AddElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
AddElementToolStripMenuItem.Text = "Добавить";
|
||||||
|
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// UpdElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||||
|
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||||
|
UpdElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
UpdElementToolStripMenuItem.Text = "Изменить";
|
||||||
|
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// DelElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||||
|
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||||
|
DelElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
DelElementToolStripMenuItem.Text = "Удалить";
|
||||||
|
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// DocsToolStripMenuItem
|
||||||
|
//
|
||||||
|
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
|
||||||
|
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||||
|
DocsToolStripMenuItem.Size = new Size(82, 20);
|
||||||
|
DocsToolStripMenuItem.Text = "Документы";
|
||||||
|
//
|
||||||
|
// SimpleDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||||
|
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
|
SimpleDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||||
|
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// TableDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||||
|
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||||
|
TableDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||||
|
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ChartDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||||
|
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||||
|
ChartDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||||
|
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// panelControl
|
||||||
|
//
|
||||||
|
panelControl.Dock = DockStyle.Fill;
|
||||||
|
panelControl.Location = new Point(0, 24);
|
||||||
|
panelControl.Name = "panelControl";
|
||||||
|
panelControl.Size = new Size(800, 426);
|
||||||
|
panelControl.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(panelControl);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Name = "FormMain";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Главная форма";
|
||||||
|
WindowState = FormWindowState.Maximized;
|
||||||
|
KeyDown += FormMain_KeyDown;
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.Panel panelControl;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
236
AbazovApp/AccountAppPlugins/FormMain.cs
Normal file
236
AbazovApp/AccountAppPlugins/FormMain.cs
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
using PluginsConventionLibrary;
|
||||||
|
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 AccountAppPlugins
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||||
|
private string _selectedPlugin;
|
||||||
|
|
||||||
|
public FormMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_plugins = new();
|
||||||
|
LoadPlugins();
|
||||||
|
_selectedPlugin = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadPlugins()
|
||||||
|
{
|
||||||
|
List<IPluginsConvention> pluginsList = GetPlugins();
|
||||||
|
|
||||||
|
foreach (var plugin in pluginsList)
|
||||||
|
{
|
||||||
|
_plugins[plugin.PluginName] = plugin;
|
||||||
|
CreateMenuItem(plugin.PluginName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<IPluginsConvention> GetPlugins()
|
||||||
|
{
|
||||||
|
string currentDir = Environment.CurrentDirectory;
|
||||||
|
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
|
||||||
|
string[] dllFiles = Directory.GetFiles(
|
||||||
|
pluginsDir,
|
||||||
|
"*.dll",
|
||||||
|
SearchOption.AllDirectories
|
||||||
|
);
|
||||||
|
List<IPluginsConvention> plugins = new();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (Activator.CreateInstance(type) is IPluginsConvention plugin)
|
||||||
|
{
|
||||||
|
plugins.Add(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
ex.Message
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateMenuItem(string pluginName)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem menuItem = new(pluginName);
|
||||||
|
menuItem.Click += (object? sender, EventArgs e) =>
|
||||||
|
{
|
||||||
|
UserControl userControl = _plugins[pluginName].GetControl;
|
||||||
|
if (userControl != null)
|
||||||
|
{
|
||||||
|
panelControl.Controls.Clear();
|
||||||
|
userControl.Dock = DockStyle.Fill;
|
||||||
|
_plugins[pluginName].ReloadData();
|
||||||
|
_selectedPlugin = pluginName;
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files|*.xlsx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateTableDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Word Files|*.docx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateChartDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "PDF Files|*.pdf"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
63
AbazovApp/AccountAppPlugins/FormMain.resx
Normal file
63
AbazovApp/AccountAppPlugins/FormMain.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
17
AbazovApp/AccountAppPlugins/Program.cs
Normal file
17
AbazovApp/AccountAppPlugins/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace AccountAppPlugins
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new FormMain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,17 @@
|
|||||||
<ProjectReference Include="..\AbazovViewComponents\AbazovViewComponents.csproj" />
|
<ProjectReference Include="..\AbazovViewComponents\AbazovViewComponents.csproj" />
|
||||||
<ProjectReference Include="..\AccountsBusinessLogic\AccountsBusinessLogic.csproj" />
|
<ProjectReference Include="..\AccountsBusinessLogic\AccountsBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\AccountsDataBaseImplement\AccountsDataBaseImplement.csproj" />
|
<ProjectReference Include="..\AccountsDataBaseImplement\AccountsDataBaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CreatePluginsFolder" BeforeTargets="PreBuildEvent" Condition="!Exists('$(SolutionDir)Plugins')">
|
||||||
|
<MakeDir Directories="$(SolutionDir)Plugins" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyPlugins" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
@ -96,18 +96,28 @@ namespace AccountsApp
|
|||||||
|
|
||||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files|*.xlsx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
List<string> avatars = new List<string>();
|
List<string> avatars = new List<string>();
|
||||||
foreach (var account in _logic.ReadList(null))
|
foreach (var account in _logic.ReadList(null))
|
||||||
{
|
{
|
||||||
avatars.Add(account.Avatar);
|
avatars.Add(account.Avatar);
|
||||||
}
|
}
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "Аватары.xlsx";
|
string path = saveFileDialog.FileName;
|
||||||
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Аватары", avatars.ToArray()))) MessageBox.Show("Документ создан");
|
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Аватары", avatars.ToArray()))) MessageBox.Show("Документ создан");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "Интересы.pdf";
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "PDF Files|*.pdf"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
|
string path = saveFileDialog.FileName;
|
||||||
Dictionary<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
|
Dictionary<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
|
||||||
|
|
||||||
data = _logic
|
data = _logic
|
||||||
@ -129,7 +139,12 @@ namespace AccountsApp
|
|||||||
|
|
||||||
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory + "Аккаунты.docx";
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Word Files|*.docx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
|
string path = saveFileDialog.FileName;
|
||||||
List<(int, int)> merges = new List<(int, int)> { (1, 2) };
|
List<(int, int)> merges = new List<(int, int)> { (1, 2) };
|
||||||
List<int> widths = new List<int> { 100, 100, 100, 100 };
|
List<int> widths = new List<int> { 100, 100, 100, 100 };
|
||||||
List<(string, string)> headers = new List<(string, string)> {
|
List<(string, string)> headers = new List<(string, string)> {
|
||||||
@ -141,6 +156,7 @@ namespace AccountsApp
|
|||||||
};
|
};
|
||||||
|
|
||||||
wordTableComponentAccount.createWithTable(path, "Список аккаунтов", merges, widths, headers, _logic.ReadList(null));
|
wordTableComponentAccount.createWithTable(path, "Список аккаунтов", merges, widths, headers, _logic.ReadList(null));
|
||||||
|
MessageBox.Show("Успех");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,6 @@
|
|||||||
<value>639, 27</value>
|
<value>639, 27</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>90</value>
|
<value>137</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
175
AbazovApp/AccountsApp/PluginsConvention.cs
Normal file
175
AbazovApp/AccountsApp/PluginsConvention.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
using AbazovViewComponents.LogicalComponents;
|
||||||
|
using AccountsBusinessLogic.BusinessLogics;
|
||||||
|
using AccountsContracts.BusinessLogicContracts;
|
||||||
|
using AccountsContracts.StorageContracts;
|
||||||
|
using AccountsContracts.ViewModels;
|
||||||
|
using AccountsDataBaseImplement.Implements;
|
||||||
|
using ComponentsLibraryNet60.DocumentWithChart;
|
||||||
|
using ComponentsLibraryNet60.Models;
|
||||||
|
using ControlsLibraryNet60.Core;
|
||||||
|
using ControlsLibraryNet60.Data;
|
||||||
|
using ControlsLibraryNet60.Models;
|
||||||
|
using NevaevaLibrary.LogicalComponents;
|
||||||
|
using PluginsConventionLibrary;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AccountsApp
|
||||||
|
{
|
||||||
|
public class PluginsConvention : IPluginsConvention
|
||||||
|
{
|
||||||
|
private readonly IAccountLogic _accountLogic;
|
||||||
|
private readonly IInterestLogic _interestLogic;
|
||||||
|
private readonly ControlDataTableTable _controlDataTable;
|
||||||
|
private readonly ExcelImagesComponent _excelImagesComponent;
|
||||||
|
private readonly WordTableComponent _wordTableComponent;
|
||||||
|
private readonly ComponentDocumentWithChartBarPdf _chartBar;
|
||||||
|
public string PluginName { get; set; } = "LabWork_03_plugin";
|
||||||
|
|
||||||
|
public UserControl GetControl
|
||||||
|
{
|
||||||
|
get { return _controlDataTable; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginsConvention()
|
||||||
|
{
|
||||||
|
_accountLogic = new AccountLogic(new AccountStorage());
|
||||||
|
_interestLogic = new InterestLogic(new InterestStorage());
|
||||||
|
_excelImagesComponent = new();
|
||||||
|
_wordTableComponent = new();
|
||||||
|
_chartBar = new();
|
||||||
|
_controlDataTable = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginsConventionElement GetElement
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int Id = _controlDataTable.GetSelectedObject<AccountViewModel>()!.Id;
|
||||||
|
byte[] bytes = new byte[16];
|
||||||
|
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
|
||||||
|
Guid guid = new Guid(bytes);
|
||||||
|
return new PluginsConventionElement() { Id = guid };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Form GetForm(PluginsConventionElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return new FormAccount(_accountLogic, _interestLogic);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FormAccount form = new FormAccount(_accountLogic, _interestLogic);
|
||||||
|
form.Id = element.Id.GetHashCode();
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Form GetThesaurus()
|
||||||
|
{
|
||||||
|
return new FormInterests(_interestLogic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteElement(PluginsConventionElement element)
|
||||||
|
{
|
||||||
|
_accountLogic.Delete(
|
||||||
|
new AccountsContracts.BindingModels.AccountBindingModel { Id = element.Id.GetHashCode()}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReloadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var account = _accountLogic.ReadList(null);
|
||||||
|
if (account != null)
|
||||||
|
{
|
||||||
|
_controlDataTable.Clear();
|
||||||
|
|
||||||
|
_controlDataTable.LoadColumns(new List<DataTableColumnConfig> {
|
||||||
|
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
|
||||||
|
new DataTableColumnConfig { ColumnHeader = "Логин", PropertyName = "Login", Visible = true, Width = 200},
|
||||||
|
new DataTableColumnConfig { ColumnHeader = "Выбранный интерес", PropertyName = "InterestName", Visible = true, Width = 200},
|
||||||
|
new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200},
|
||||||
|
});
|
||||||
|
|
||||||
|
_controlDataTable.AddTable(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
ex.Message,
|
||||||
|
"Ошибка",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
List<string> avatars = new List<string>();
|
||||||
|
foreach (var account in _accountLogic.ReadList(null))
|
||||||
|
{
|
||||||
|
avatars.Add(account.Avatar);
|
||||||
|
}
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
if (_excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Аватары", avatars.ToArray())))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ создан");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
List<(int, int)> merges = new List<(int, int)> { (1, 2) };
|
||||||
|
List<int> widths = new List<int> { 100, 100, 100, 100 };
|
||||||
|
List<(string, string)> headers = new List<(string, string)> {
|
||||||
|
("Id", "Идентификатор"),
|
||||||
|
("", "Личные данные"),
|
||||||
|
("Login", "Логин"),
|
||||||
|
("Email", "Эл. почта"),
|
||||||
|
("InterestName", "Выбранный интерес")
|
||||||
|
};
|
||||||
|
|
||||||
|
_wordTableComponent.createWithTable(path, "Список аккаунтов", merges, widths, headers, _accountLogic.ReadList(null));
|
||||||
|
MessageBox.Show("Документ создан");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
Dictionary<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
|
||||||
|
|
||||||
|
data = _accountLogic
|
||||||
|
.ReadList(null)
|
||||||
|
.GroupBy(x => x.InterestName)
|
||||||
|
.ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count()) });
|
||||||
|
|
||||||
|
_chartBar.CreateDoc(new ComponentDocumentWithChartConfig
|
||||||
|
{
|
||||||
|
Header = "Интересы",
|
||||||
|
FilePath = path,
|
||||||
|
ChartTitle = "Интересы",
|
||||||
|
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||||
|
Data = data,
|
||||||
|
});
|
||||||
|
|
||||||
|
MessageBox.Show("Успех");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,6 @@ namespace AccountsContracts.BindingModels
|
|||||||
|
|
||||||
public int InterestId { get; set; }
|
public int InterestId { get; set; }
|
||||||
|
|
||||||
public string Avatar { get; set; }
|
public string Avatar { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
65
AbazovApp/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
65
AbazovApp/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public interface IPluginsConvention
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Название плагина
|
||||||
|
/// </summary>
|
||||||
|
string PluginName { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение контрола для вывода набора данных
|
||||||
|
/// </summary>
|
||||||
|
UserControl GetControl { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение элемента, выбранного в контроле
|
||||||
|
/// </summary>
|
||||||
|
PluginsConventionElement GetElement { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение формы для создания/редактирования объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Form GetForm(PluginsConventionElement element);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение формы для работы со справочником
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Form GetThesaurus();
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление элемента
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool DeleteElement(PluginsConventionElement element);
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление набора данных в контроле
|
||||||
|
/// </summary>
|
||||||
|
void ReloadData();
|
||||||
|
/// <summary>
|
||||||
|
/// Создание простого документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateSimpleDocument(PluginsConventionSaveDocument
|
||||||
|
saveDocument);
|
||||||
|
/// <summary>
|
||||||
|
/// Создание простого документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||||
|
/// <summary>
|
||||||
|
/// Создание документа с диаграммой
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public class PluginsConventionElement
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public class PluginsConventionSaveDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user