добавление функционала к элементу

This commit is contained in:
kotcheshir73 2021-04-08 10:37:47 +04:00
parent b86492fa1c
commit a5ac4947d0
27 changed files with 151 additions and 17 deletions

View File

@ -1,4 +1,6 @@
namespace DesktopTools.Interfaces
using DesktopTools.Models;
namespace DesktopTools.Interfaces
{
/// <summary>
/// Работа с generic-контролом элемента
@ -10,5 +12,11 @@
/// </summary>
/// <returns></returns>
IControl GetInstanceGenericControl();
/// <summary>
/// Получение настроек
/// </summary>
/// <returns></returns>
ControlViewEntityElementConfiguration GetConfigControl();
}
}

View File

@ -130,7 +130,7 @@ namespace DesktopTools.Controls
{
try
{
Configurate();
Configurate(GetConfig());
}
catch (Exception ex)
{
@ -192,8 +192,25 @@ namespace DesktopTools.Controls
};
}
private void Configurate()
private void Configurate(ControlViewEntityElementConfiguration config)
{
// Загрузка подпунктов в контекстное меню и в пункт меню "Действие"
if (config.ControlOnMoveElem != null)
{
foreach (var elem in config.ControlOnMoveElem)
{
ToolStripMenuItem item = new() { Text = elem.Value.Title, Name = elem.Key };
item.Click += elem.Value.Event;
toolStripSplitButtonActions.DropDownItems.Add(item);
contextMenuStripElement.Items.Add(item);
}
}
// либо скрытие пункта, если не предусмотренно подпунктов
else
{
toolStripSplitButtonActions.Visible = false;
toolStripSeparator1.Visible = false;
}
var attributeClass = typeof(E).GetCustomAttribute<ViewModelControlElementClassAttribute>();
if (attributeClass == null)
{
@ -368,5 +385,7 @@ namespace DesktopTools.Controls
return false;
}
private ControlViewEntityElementConfiguration GetConfig() => _genericControlViewEntityElement?.GetConfigControl();
}
}

View File

@ -3,10 +3,6 @@ namespace DesktopTools.Controls
{
partial class MainControlViewEntityElement
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
protected System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
@ -29,13 +25,18 @@ namespace DesktopTools.Controls
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainControlViewEntityElement));
this.toolStripActions = new System.Windows.Forms.ToolStrip();
this.toolStripButtonSave = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonReload = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonClose = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSplitButtonActions = new System.Windows.Forms.ToolStripSplitButton();
this.panelContainer = new System.Windows.Forms.Panel();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPageMain = new System.Windows.Forms.TabPage();
this.contextMenuStripElement = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripActions.SuspendLayout();
this.tabControl.SuspendLayout();
this.SuspendLayout();
@ -45,7 +46,9 @@ namespace DesktopTools.Controls
this.toolStripActions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButtonSave,
this.toolStripButtonReload,
this.toolStripButtonClose});
this.toolStripButtonClose,
this.toolStripSeparator1,
this.toolStripSplitButtonActions});
this.toolStripActions.Location = new System.Drawing.Point(0, 0);
this.toolStripActions.Name = "toolStripActions";
this.toolStripActions.Size = new System.Drawing.Size(594, 25);
@ -80,6 +83,20 @@ namespace DesktopTools.Controls
this.toolStripButtonClose.Size = new System.Drawing.Size(23, 22);
this.toolStripButtonClose.Text = "Закрыть";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// toolStripSplitButtonActions
//
this.toolStripSplitButtonActions.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripSplitButtonActions.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButtonActions.Image")));
this.toolStripSplitButtonActions.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripSplitButtonActions.Name = "toolStripSplitButtonActions";
this.toolStripSplitButtonActions.Size = new System.Drawing.Size(74, 22);
this.toolStripSplitButtonActions.Text = "Действия";
//
// panelContainer
//
this.panelContainer.AutoScroll = true;
@ -93,22 +110,27 @@ namespace DesktopTools.Controls
//
this.tabControl.Controls.Add(this.tabPageMain);
this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl.Location = new System.Drawing.Point(218, 141);
this.tabControl.Location = new System.Drawing.Point(0, 25);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(130, 127);
this.tabControl.Size = new System.Drawing.Size(594, 485);
this.tabControl.TabIndex = 0;
//
// tabPageMain
//
this.tabPageMain.ContextMenuStrip = this.contextMenuStripElement;
this.tabPageMain.Location = new System.Drawing.Point(4, 24);
this.tabPageMain.Name = "tabPageMain";
this.tabPageMain.Padding = new System.Windows.Forms.Padding(3);
this.tabPageMain.Size = new System.Drawing.Size(122, 99);
this.tabPageMain.Size = new System.Drawing.Size(586, 457);
this.tabPageMain.TabIndex = 0;
this.tabPageMain.Text = "Свойства элемента";
this.tabPageMain.UseVisualStyleBackColor = true;
//
// contextMenuStripElement
//
this.contextMenuStripElement.Name = "contextMenuStripElement";
//
// MainControlViewEntityElement
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -135,5 +157,9 @@ namespace DesktopTools.Controls
protected System.Windows.Forms.Panel panelContainer;
protected System.Windows.Forms.TabControl tabControl;
protected System.Windows.Forms.TabPage tabPageMain;
protected System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
protected System.Windows.Forms.ToolStripSplitButton toolStripSplitButtonActions;
protected System.Windows.Forms.ContextMenuStrip contextMenuStripElement;
protected System.ComponentModel.IContainer components;
}
}

View File

@ -57,4 +57,14 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing.Common" name="System.Drawing.Common, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<data name="toolStripSplitButtonActions.Image" type="System.Drawing.Bitmap, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb
J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj
CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN
AAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
namespace DesktopTools.Models
{
/// <summary>
/// Настройки для контрола вывода элемента сущности
/// </summary>
public class ControlViewEntityElementConfiguration
{
/// <summary>
/// Перечень действий для контектснго меню и выпадающего в верхнем меню пункта "Действия"
/// </summary>
public Dictionary<string, (string Title, EventHandler Event)> ControlOnMoveElem { get; set; } = null;
}
}

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace DesktopTools.Models
{
/// <summary>
/// Настройки для таблицы вывода списка записей сущности
/// Настройки для контрола вывода списка записей сущности
/// </summary>
public class ControlViewEntityListConfiguration
{

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlAcademicPlanElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlAcademicPlanRecordElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlAcademicPlanRecordTimeNormHourElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,11 +3,6 @@ namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlAcademicPlanRecordTimeNormHourList
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlClassroomElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlDisciplineElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlDisciplineBlockElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlEducationDirectionElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlEmployeeElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlEmployeePostElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -20,5 +21,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlLecturerElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlLecturerAcademicDegreeElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlLecturerAcademicRankElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlLecturerPostElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlPostElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -3,6 +3,7 @@ using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using System;
namespace DepartmentWindowsDesktop.EntityControls
@ -23,5 +24,7 @@ namespace DepartmentWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlTimeNormElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -1,5 +1,6 @@
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
@ -23,5 +24,7 @@ namespace SecurityWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlAccessElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -1,5 +1,6 @@
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
@ -23,5 +24,7 @@ namespace SecurityWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlEnviromentSettingElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -1,5 +1,6 @@
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
@ -23,5 +24,7 @@ namespace SecurityWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlRoleElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -1,5 +1,6 @@
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
@ -23,5 +24,7 @@ namespace SecurityWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlUserElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}

View File

@ -1,5 +1,6 @@
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using SecurityBusinessLogic.ViewModels;
@ -23,5 +24,7 @@ namespace SecurityWindowsDesktop.EntityControls
}
public IControl GetInstanceGenericControl() => new ControlUserRoleElement() { ControlId = Guid.NewGuid() };
public ControlViewEntityElementConfiguration GetConfigControl() => new();
}
}