Работа с элементом

This commit is contained in:
kotcheshir73 2021-03-30 22:34:31 +04:00
parent da3e126579
commit 1df43b5105
55 changed files with 2143 additions and 181 deletions

View File

@ -21,18 +21,6 @@ namespace DatabaseCore.Models.Security
[MapConfiguration("Password")]
public string PasswordHash { get; set; }
[DataMember]
[MapConfiguration("StudentId")]
public Guid? StudentId { get; set; }
[DataMember]
[MapConfiguration("LecturerId")]
public Guid? LecturerId { get; set; }
[DataMember]
[MapConfiguration("EmployeeId")]
public Guid? EmployeeId { get; set; }
[DataMember]
[MapConfiguration("Avatar")]
public byte[] Avatar { get; set; }

View File

@ -51,13 +51,13 @@ namespace DesktopTools.BaseControls
this.panelControl.Size = new System.Drawing.Size(407, 25);
this.panelControl.TabIndex = 1;
//
// BaseControl
// AbstractBaseControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panelControl);
this.Controls.Add(this.labelTitle);
this.Name = "BaseControl";
this.Name = "AbstractBaseControl";
this.Size = new System.Drawing.Size(500, 25);
this.ResumeLayout(false);

View File

@ -4,6 +4,9 @@ using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Описание контрола для работы со значением свойства класса
/// </summary>
public abstract partial class AbstractBaseControl : UserControl
{
/// <summary>
@ -14,17 +17,18 @@ namespace DesktopTools.BaseControls
/// <summary>
/// Необходимость проверки при получении данных
/// </summary>
protected bool _mustCheckValue;
protected bool _mustFilling;
/// <summary>
/// Название свойства, по которму идет отображение
/// </summary>
protected string PropertyName { get; private set; }
protected string _propertyName;
#region Событие изменения значения
/// <summary>
/// Событие изменения значения в контроле
/// </summary>
protected event Action OnValueChange;
private event Action OnValueChange;
/// <summary>
/// Событие изменения значения в контроле
@ -35,14 +39,28 @@ namespace DesktopTools.BaseControls
/// Вызов события в дочерних контролах
/// </summary>
protected void CallOnValueChangeEvent() => OnValueChange?.Invoke();
#endregion
public AbstractBaseControl(string propertyName)
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName">Название свойства</param
/// <param name="mustFilling">Должно ли оно быть заполненным обязательно</param>
/// <param name="readOnly">Устанвока контрола в режим только просмотра</param>
public AbstractBaseControl(string propertyName, bool mustFilling, bool readOnly)
{
InitializeComponent();
PropertyName = propertyName;
_propertyName = propertyName;
_mustFilling = mustFilling;
panelControl.Enabled = !readOnly;
SetDefaultValue();
}
/// <summary>
/// Установка _originalValue в значение по умолчанию
/// </summary>
protected abstract void SetDefaultValue();
#region Работа с заголовком
/// <summary>
/// Установка заголовка
@ -67,29 +85,35 @@ namespace DesktopTools.BaseControls
}
#endregion
#region Работа со значением
/// <summary>
/// Устанвока контрола в режим только просмотра
/// Извлечение значения из свойства объекта
/// </summary>
/// <param name="readOnly"></param>
public abstract void SetReadOnly(bool readOnly);
/// <param name="obj"></param>
public void SetValue(object obj)
{
if (obj != null && _propertyName.IsNotEmpty())
{
var property = obj.GetType().GetProperty(_propertyName);
if (property != null)
{
_originalValue = property.GetValue(obj);
SetValueToControl(_originalValue);
}
}
}
/// <summary>
/// Установка значения
/// Установка значения в контрол
/// </summary>
/// <param name="value"></param>
public virtual void SetValueToControl(object value) => _originalValue = value;
protected abstract void SetValueToControl(object value);
/// <summary>
/// Сброс значения
/// </summary>
public abstract void DropValue();
/// <summary>
/// Установка флага необхоидмости проверки
/// </summary>
/// <param name="mustCheckValue"></param>
public void SetMustCheckValue(bool mustCheckValue) => _mustCheckValue = mustCheckValue;
/// <summary>
/// Проверка на заполненность
/// </summary>
@ -106,16 +130,17 @@ namespace DesktopTools.BaseControls
/// Заполнение свойства объекта значением из контрола
/// </summary>
/// <param name="obj"></param>
public void FillPropertyToObject(object obj)
public void GetValue(object obj)
{
if (obj != null && PropertyName.IsNotEmpty())
if (obj != null && _propertyName.IsNotEmpty())
{
var property = obj.GetType().GetProperty(PropertyName);
var property = obj.GetType().GetProperty(_propertyName);
if (property != null)
{
property.SetValue(obj, GetValueFromControl());
}
}
}
#endregion
}
}

View File

@ -0,0 +1,57 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlBool
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.checkBoxNullable = new System.Windows.Forms.CheckBox();
this.checkBox = new System.Windows.Forms.CheckBox();
//
// checkBoxNullable
//
this.checkBoxNullable.AutoSize = true;
this.checkBoxNullable.Location = new System.Drawing.Point(41, 14);
this.checkBoxNullable.Name = "checkBoxNullable";
this.checkBoxNullable.Size = new System.Drawing.Size(83, 19);
this.checkBoxNullable.TabIndex = 1;
this.checkBoxNullable.UseVisualStyleBackColor = true;
this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left;
//
// checkBox
//
this.checkBox.AutoSize = true;
this.checkBox.Location = new System.Drawing.Point(148, 9);
this.checkBox.Name = "checkBox";
this.checkBox.Size = new System.Drawing.Size(83, 19);
this.checkBox.TabIndex = 1;
this.checkBox.UseVisualStyleBackColor = true;
}
#endregion
private System.Windows.Forms.CheckBox checkBoxNullable;
private System.Windows.Forms.CheckBox checkBox;
}
}

View File

@ -0,0 +1,65 @@
using System;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с bool-полем
/// </summary>
public partial class BaseControlBool : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
public BaseControlBool(string propertyName, bool mustFilling, bool readOnly) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (!_mustFilling)
{
checkBoxNullable.CheckedChanged += (object sender, EventArgs e) =>
{
checkBox.Enabled = !(sender as CheckBox).Checked;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(checkBoxNullable);
}
checkBox.CheckedChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(checkBox);
}
protected override void SetDefaultValue() => _originalValue = _mustFilling ? false : null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
checkBox.Checked = Convert.ToBoolean(value);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
checkBox.Checked = Convert.ToBoolean(_originalValue);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override bool CheckValue() => true;
protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : checkBox.Checked;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -0,0 +1,56 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlDateTime
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.checkBoxNullable = new System.Windows.Forms.CheckBox();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
//
// checkBoxNullable
//
this.checkBoxNullable.AutoSize = true;
this.checkBoxNullable.Location = new System.Drawing.Point(41, 14);
this.checkBoxNullable.Name = "checkBoxNullable";
this.checkBoxNullable.Size = new System.Drawing.Size(83, 19);
this.checkBoxNullable.TabIndex = 1;
this.checkBoxNullable.UseVisualStyleBackColor = true;
this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left;
//
// dateTimePicker
//
this.dateTimePicker.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateTimePicker.Location = new System.Drawing.Point(123, 16);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(200, 23);
this.dateTimePicker.TabIndex = 0;
}
#endregion
private System.Windows.Forms.CheckBox checkBoxNullable;
private System.Windows.Forms.DateTimePicker dateTimePicker;
}
}

View File

@ -0,0 +1,81 @@
using ModuleTools.Extensions;
using System;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с датой
/// </summary>
public partial class BaseControlDateTime : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="minDate"></param>
/// <param name="maxDate"></param>
/// <param name="customDateFormat"></param>
public BaseControlDateTime(string propertyName, bool mustFilling, bool readOnly, DateTime? minDate, DateTime? maxDate, string customDateFormat) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (!_mustFilling)
{
checkBoxNullable.CheckedChanged += (object sender, EventArgs e) =>
{
dateTimePicker.Enabled = !(sender as CheckBox).Checked;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(checkBoxNullable);
}
dateTimePicker.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
if (minDate.HasValue)
{
dateTimePicker.MinDate = minDate.Value;
}
if (maxDate.HasValue)
{
dateTimePicker.MaxDate = maxDate.Value;
}
if(customDateFormat.IsNotEmpty())
{
dateTimePicker.CustomFormat = customDateFormat;
}
panelControl.Controls.Add(dateTimePicker);
}
protected override void SetDefaultValue() => _originalValue = _mustFilling ? DateTime.Now : null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
dateTimePicker.Value = Convert.ToDateTime(value);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
dateTimePicker.Value = Convert.ToDateTime(_originalValue);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override bool CheckValue() => true;
protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToDateTime(dateTimePicker.Value);
}
}

View File

@ -0,0 +1,58 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlDecimal
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.checkBoxNullable = new System.Windows.Forms.CheckBox();
this.numericUpDown = new System.Windows.Forms.NumericUpDown();
//
// checkBoxNullable
//
this.checkBoxNullable.AutoSize = true;
this.checkBoxNullable.Location = new System.Drawing.Point(41, 14);
this.checkBoxNullable.Name = "checkBoxNullable";
this.checkBoxNullable.Size = new System.Drawing.Size(83, 19);
this.checkBoxNullable.TabIndex = 1;
this.checkBoxNullable.UseVisualStyleBackColor = true;
this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left;
//
// numericUpDown
//
this.numericUpDown.Dock = System.Windows.Forms.DockStyle.Fill;
this.numericUpDown.Location = new System.Drawing.Point(148, 9);
this.numericUpDown.Name = "numericUpDown";
this.numericUpDown.Size = new System.Drawing.Size(120, 23);
this.numericUpDown.TabIndex = 2;
this.numericUpDown.Minimum = decimal.MinValue;
this.numericUpDown.Maximum = decimal.MaxValue;
}
#endregion
private System.Windows.Forms.CheckBox checkBoxNullable;
private System.Windows.Forms.NumericUpDown numericUpDown;
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с вещественным полем
/// </summary>
public partial class BaseControlDecimal : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="minValue"></param>
/// <param name="maxValue"></param>
/// <param name="decimalPlaces"></param>
public BaseControlDecimal(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue, int? decimalPlaces) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (!_mustFilling)
{
checkBoxNullable.CheckedChanged += (object sender, EventArgs e) =>
{
numericUpDown.Enabled = !(sender as CheckBox).Checked;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(checkBoxNullable);
}
numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
if (minValue.HasValue)
{
numericUpDown.Minimum = minValue.Value;
}
if (maxValue.HasValue)
{
numericUpDown.Maximum = maxValue.Value;
}
if (decimalPlaces.HasValue)
{
numericUpDown.DecimalPlaces = decimalPlaces.Value;
}
panelControl.Controls.Add(numericUpDown);
}
protected override void SetDefaultValue() => _originalValue = _mustFilling ? 0 : null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
numericUpDown.Value = Convert.ToDecimal(value);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
numericUpDown.Value = Convert.ToDecimal(_originalValue);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override bool CheckValue() => true;
protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToDouble(numericUpDown.Value);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -0,0 +1,59 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlEnum
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.checkBoxNullable = new System.Windows.Forms.CheckBox();
this.comboBox = new System.Windows.Forms.ComboBox();
//
// checkBoxNullable
//
this.checkBoxNullable.AutoSize = true;
this.checkBoxNullable.Location = new System.Drawing.Point(41, 14);
this.checkBoxNullable.Name = "checkBoxNullable";
this.checkBoxNullable.Size = new System.Drawing.Size(83, 19);
this.checkBoxNullable.TabIndex = 1;
this.checkBoxNullable.UseVisualStyleBackColor = true;
this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left;
//
// comboBox
//
this.comboBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox.FormattingEnabled = true;
this.comboBox.Location = new System.Drawing.Point(100, 10);
this.comboBox.Name = "comboBox";
this.comboBox.Size = new System.Drawing.Size(121, 23);
this.comboBox.TabIndex = 0;
this.comboBox.Dock = System.Windows.Forms.DockStyle.Fill;
}
#endregion
private System.Windows.Forms.CheckBox checkBoxNullable;
private System.Windows.Forms.ComboBox comboBox;
}
}

View File

@ -0,0 +1,86 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с перечислениями
/// </summary>
public partial class BaseControlEnum : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="enumType"></param>
public BaseControlEnum(string propertyName, bool mustFilling, bool readOnly, Type enumType) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (!_mustFilling)
{
checkBoxNullable.CheckedChanged += (object sender, EventArgs e) =>
{
comboBox.Enabled = !(sender as CheckBox).Checked;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(checkBoxNullable);
}
comboBox.Items.Clear();
foreach (var val in Enum.GetValues(enumType))
{
comboBox.Items.Add(val);
}
comboBox.SelectedIndexChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(comboBox);
}
protected override void SetDefaultValue() => _originalValue = null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
comboBox.SelectedIndex = comboBox.Items.IndexOf(value);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
comboBox.SelectedIndex = comboBox.Items.IndexOf(_originalValue);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override bool CheckValue()
{
if (_mustFilling && comboBox.SelectedIndex == -1)
{
BackColor = Color.OrangeRed;
return false;
}
return true;
}
protected override object GetValueFromControl()
{
if (_mustFilling && comboBox.SelectedIndex == -1)
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}
return checkBoxNullable.Checked ? null : comboBox.SelectedItem;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -0,0 +1,70 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlGuid
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.buttonClear = new System.Windows.Forms.Button();
this.buttonSelect = new System.Windows.Forms.Button();
this.textBox = new System.Windows.Forms.TextBox();
//
// buttonClear
//
this.buttonClear.BackgroundImage = global::DesktopTools.Properties.Resources.Clear;
this.buttonClear.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonClear.Dock = System.Windows.Forms.DockStyle.Right;
this.buttonClear.Location = new System.Drawing.Point(74, 12);
this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(25, 25);
this.buttonClear.TabIndex = 0;
this.buttonClear.Text = "...";
this.buttonClear.UseVisualStyleBackColor = true;
//
// buttonSelect
//
this.buttonSelect.Dock = System.Windows.Forms.DockStyle.Right;
this.buttonSelect.Location = new System.Drawing.Point(74, 12);
this.buttonSelect.Name = "buttonSelect";
this.buttonSelect.Size = new System.Drawing.Size(25, 25);
this.buttonSelect.TabIndex = 0;
this.buttonSelect.Text = "...";
this.buttonSelect.UseVisualStyleBackColor = true;
//
// textBox
//
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox.Location = new System.Drawing.Point(0, 0);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(1000, 1000);
this.textBox.TabIndex = 1;
}
#endregion
private System.Windows.Forms.Button buttonSelect;
private System.Windows.Forms.Button buttonClear;
private System.Windows.Forms.TextBox textBox;
}
}

View File

@ -0,0 +1,106 @@
using DesktopTools.Controls;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
public partial class BaseControlGuid : AbstractBaseControl
{
private AbstractControlViewEntityList _control;
public BaseControlGuid(string propertyName, bool mustFilling, bool readOnly, AbstractControlViewEntityList controlType) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
_control = controlType;
panelControl.Controls.Add(textBox);
if (!_mustFilling)
{
buttonClear.Click += (object sender, EventArgs e) =>
{
textBox.Text = string.Empty;
textBox.Tag = null;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(buttonClear);
}
buttonSelect.Click += (object sender, EventArgs e) =>
{
var form = new Form
{
Height = controlType.Height,
Width = controlType.Width,
Text = $"{controlType.Title}. Выбор",
StartPosition = FormStartPosition.CenterParent,
ControlBox = false
};
var clone = controlType.Clone();
form.Controls.Add(clone);
clone.Dock = DockStyle.Fill;
clone.FormForSelected = form;
clone.Open();
if (form.ShowDialog() == DialogResult.OK)
{
textBox.Tag = clone.SelectedId;
textBox.Text = clone.SelectedText;
CallOnValueChangeEvent();
}
};
panelControl.Controls.Add(buttonSelect);
}
protected override void SetDefaultValue() => _originalValue = null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
var id = new Guid(value.ToString());
textBox.Tag = id;
textBox.Text = _control?.GetTitleFromId(id);
}
else if (!_mustFilling)
{
textBox.Tag = null;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
var id = new Guid(_originalValue.ToString());
textBox.Tag = id;
textBox.Text = _control?.GetTitleFromId(id);
}
else if (!_mustFilling)
{
textBox.Tag = null;
textBox.Text = string.Empty;
}
}
public override bool CheckValue()
{
if (_mustFilling && textBox.Tag == null)
{
BackColor = Color.OrangeRed;
return false;
}
return true;
}
protected override object GetValueFromControl()
{
if (_mustFilling && textBox.Tag == null)
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}
return textBox.Tag == null ? null : new Guid(textBox.Tag.ToString());
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -0,0 +1,60 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlImage
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.pictureBox = new System.Windows.Forms.PictureBox();
this.buttonLoad = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
//
// buttonLoad
//
this.buttonLoad.Dock = System.Windows.Forms.DockStyle.Bottom;
this.buttonLoad.Location = new System.Drawing.Point(74, 12);
this.buttonLoad.Name = "buttonLoad";
this.buttonLoad.Size = new System.Drawing.Size(25, 25);
this.buttonLoad.TabIndex = 0;
this.buttonLoad.Text = "Загрузить";
this.buttonLoad.UseVisualStyleBackColor = true;
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(111, 19);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(100, 50);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
}
#endregion
private System.Windows.Forms.Button buttonLoad;
private System.Windows.Forms.PictureBox pictureBox;
}
}

View File

@ -0,0 +1,101 @@
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с изображением
/// </summary>
public partial class BaseControlImage : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="width"></param>
/// <param name="height"></param>
public BaseControlImage(string propertyName, bool mustFilling, bool readOnly, int? width, int? height) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (width.HasValue)
{
Width = width.Value;
}
if (height.HasValue)
{
Height = height.Value;
}
buttonLoad.Click += (object sender, EventArgs e) =>
{
var dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
pictureBox.ClientSize = new Size(150, 150);
pictureBox.Image = new Bitmap(dialog.FileName);
CallOnValueChangeEvent();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке файла", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
};
panelControl.Controls.Add(pictureBox);
}
protected override void SetDefaultValue() => _originalValue = null;
protected override void SetValueToControl(object value)
{
if (value != null)
{
using MemoryStream mStream = new(value as byte[]);
pictureBox.Image = Image.FromStream(mStream);
}
else if (!_mustFilling)
{
pictureBox.Image = null;
}
}
public override void DropValue()
{
if (_originalValue != null)
{
using MemoryStream mStream = new(_originalValue as byte[]);
pictureBox.Image = Image.FromStream(mStream);
}
else if (!_mustFilling)
{
pictureBox.Image = null;
}
}
public override bool CheckValue()
{
if (_mustFilling && pictureBox.Image == null)
{
BackColor = Color.OrangeRed;
return false;
}
return true;
}
protected override object GetValueFromControl()
{
if (_mustFilling && pictureBox.Image == null)
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}
var converter = new ImageConverter();
return (byte[])converter.ConvertTo(pictureBox.Image, typeof(byte[]));
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -1,64 +1,75 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с целочисленным полем
/// </summary>
public partial class BaseControlInt : AbstractBaseControl
{
public BaseControlInt(string propertyName) : base(propertyName)
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="minValue"></param>
/// <param name="maxValue"></param>
public BaseControlInt(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
checkBoxNullable.Visible = false;
panelControl.Controls.Add(checkBoxNullable);
if (!_mustFilling)
{
checkBoxNullable.CheckedChanged += (object sender, EventArgs e) =>
{
numericUpDown.Enabled = !(sender as CheckBox).Checked;
CallOnValueChangeEvent();
};
panelControl.Controls.Add(checkBoxNullable);
}
panelControl.Controls.Add(numericUpDown);
numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
_originalValue = 0;
if (minValue.HasValue)
{
numericUpDown.Minimum = minValue.Value;
}
if (maxValue.HasValue)
{
numericUpDown.Maximum = maxValue.Value;
}
panelControl.Controls.Add(numericUpDown);
}
public override void SetReadOnly(bool readOnly)
{
numericUpDown.Enabled = !readOnly;
checkBoxNullable.Enabled = !readOnly;
}
protected override void SetDefaultValue() => _originalValue = _mustFilling ? 0 : null;
public override void SetValueToControl(object value)
protected override void SetValueToControl(object value)
{
base.SetValueToControl(value);
if (value != null)
{
numericUpDown.Value = Convert.ToInt32(value);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override void DropValue()
{
numericUpDown.Value = _originalValue != null ? Convert.ToInt32(_originalValue) : 0;
if (_originalValue != null)
{
numericUpDown.Value = Convert.ToInt32(_originalValue);
}
else if (!_mustFilling)
{
checkBoxNullable.Checked = true;
}
}
public override bool CheckValue()
{
if (_mustCheckValue && checkBoxNullable.Checked)
{
BackColor = Color.OrangeRed;
return false;
}
return true;
}
public override bool CheckValue() => true;
protected override object GetValueFromControl()
{
if (_mustCheckValue && checkBoxNullable.Checked)
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}
return checkBoxNullable.Checked? null : Convert.ToInt32(numericUpDown.Value);
}
protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToInt32(numericUpDown.Value);
}
}

View File

@ -0,0 +1,44 @@

namespace DesktopTools.BaseControls
{
partial class BaseControlString
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.textBox = new System.Windows.Forms.TextBox();
//
// textBox
//
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox.Location = new System.Drawing.Point(0, 0);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(1000, 1000);
this.textBox.TabIndex = 0;
}
#endregion
private System.Windows.Forms.TextBox textBox;
}
}

View File

@ -0,0 +1,55 @@
using ModuleTools.Extensions;
using System;
using System.Drawing;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с однострочным текстовым полем
/// </summary>
public partial class BaseControlString : AbstractBaseControl
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="maxLength"></param>
public BaseControlString(string propertyName, bool mustFilling, bool readOnly, int? maxLength) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
if (maxLength.HasValue)
{
textBox.MaxLength = maxLength.Value;
}
textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(textBox);
}
protected override void SetDefaultValue() => _originalValue = string.Empty;
protected override void SetValueToControl(object value) => textBox.Text = value?.ToString();
public override void DropValue() => textBox.Text = _originalValue?.ToString();
public override bool CheckValue()
{
if (_mustFilling && textBox.Text.IsEmpty())
{
BackColor = Color.OrangeRed;
return false;
}
return true;
}
protected override object GetValueFromControl()
{
if (_mustFilling && textBox.Text.IsEmpty())
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}
return textBox.Text;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>
</root>

View File

@ -24,6 +24,8 @@ namespace DesktopTools.BaseControls
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.textBox = new System.Windows.Forms.TextBox();
//
// textBox
@ -32,7 +34,8 @@ namespace DesktopTools.BaseControls
this.textBox.Location = new System.Drawing.Point(0, 0);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(1000, 1000);
this.textBox.TabIndex = 1;
this.textBox.Multiline = true;
this.textBox.TabIndex = 0;
}
#endregion

View File

@ -4,29 +4,43 @@ using System.Drawing;
namespace DesktopTools.BaseControls
{
/// <summary>
/// Контрол, предоставляющий работу с текстовым полем на несколько строк
/// </summary>
public partial class BaseControlText : AbstractBaseControl
{
public BaseControlText(string propertyName) : base(propertyName)
/// <summary>
/// Конструктор
/// </summary>
/// <param name="propertyName"></param>
/// <param name="mustFilling"></param>
/// <param name="readOnly"></param>
/// <param name="maxLength"></param>
/// <param name="height"></param>
public BaseControlText(string propertyName, bool mustFilling, bool readOnly, int? maxLength, int? height) : base(propertyName, mustFilling, readOnly)
{
InitializeComponent();
panelControl.Controls.Add(textBox);
textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
_originalValue = string.Empty;
}
public override void SetReadOnly(bool readOnly) => textBox.Enabled = !readOnly;
public override void SetValueToControl(object value)
if (maxLength.HasValue)
{
base.SetValueToControl(value);
textBox.Text = value.ToString();
textBox.MaxLength = maxLength.Value;
}
if (height.HasValue)
{
textBox.Height = height.Value;
}
textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(textBox);
}
public override void DropValue() => textBox.Text = _originalValue.ToString();
protected override void SetDefaultValue() => _originalValue = string.Empty;
protected override void SetValueToControl(object value) => textBox.Text = value?.ToString();
public override void DropValue() => textBox.Text = _originalValue?.ToString();
public override bool CheckValue()
{
if(_mustCheckValue && textBox.Text.IsEmpty())
if(_mustFilling && textBox.Text.IsEmpty())
{
BackColor = Color.OrangeRed;
return false;
@ -36,7 +50,7 @@ namespace DesktopTools.BaseControls
protected override object GetValueFromControl()
{
if (_mustCheckValue && textBox.Text.IsEmpty())
if (_mustFilling && textBox.Text.IsEmpty())
{
throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено");
}

View File

@ -1,7 +1,7 @@

namespace DesktopTools.Controls
{
partial class BaseControlViewEntityElement
partial class AbstractControlViewEntityElement
{
/// <summary>
/// Обязательная переменная конструктора.

View File

@ -5,7 +5,7 @@ using System.Windows.Forms;
namespace DesktopTools.Controls
{
public partial class BaseControlViewEntityElement : UserControl
public abstract partial class AbstractControlViewEntityElement : UserControl
{
/// <summary>
/// Признак налиичия изменений
@ -25,12 +25,12 @@ namespace DesktopTools.Controls
/// <summary>
/// Открытие формы
/// </summary>
public virtual void Open() { }
public abstract void Open(Guid? id);
/// <summary>
/// Закрытие формы
/// </summary>
public virtual void Close()
public void Close()
{
if(_haveChages && DialogHelper.MessageQuestion("Имеется несохраненные данные, вы действительно хотите закрыть элемент?", "Закрытие элемента") ==
DialogResult.Yes)
@ -45,13 +45,7 @@ namespace DesktopTools.Controls
Dispose();
}
protected virtual bool Save() { return true; }
/// <summary>
/// Дубликат контрола
/// </summary>
/// <returns></returns>
public virtual BaseControlViewEntityElement Clone() { return null; }
protected abstract bool Save();
/// <summary>
/// Установка флага, что есть изменения
@ -96,7 +90,7 @@ namespace DesktopTools.Controls
/// <summary>
/// Констркутор
/// </summary>
public BaseControlViewEntityElement()
public AbstractControlViewEntityElement()
{
InitializeComponent();
}

View File

@ -1,7 +1,7 @@

namespace DesktopTools.Controls
{
partial class BaseControlViewEntityList
partial class AbstractControlViewEntityList
{
/// <summary>
/// Обязательная переменная конструктора.

View File

@ -4,7 +4,7 @@ using System.Windows.Forms;
namespace DesktopTools.Controls
{
public partial class BaseControlViewEntityList : UserControl
public abstract partial class AbstractControlViewEntityList : UserControl
{
/// <summary>
/// Событие, вызываемое при закрытии контрола
@ -19,14 +19,19 @@ namespace DesktopTools.Controls
/// <summary>
/// Открытие формы
/// </summary>
public virtual void Open() { }
public abstract void Open();
/// <summary>
/// Закрытие формы
/// </summary>
public virtual void Close()
public void Close()
{
CloseEvent?.Invoke(ControlId);
if (FormForSelected != null)
{
FormForSelected.DialogResult = DialogResult.Cancel;
FormForSelected.Close();
}
Dispose();
}
@ -34,7 +39,7 @@ namespace DesktopTools.Controls
/// Дубликат контрола
/// </summary>
/// <returns></returns>
public virtual BaseControlViewEntityList Clone() { return null; }
public abstract AbstractControlViewEntityList Clone();
/// <summary>
/// Идентификатор контрола
@ -56,11 +61,31 @@ namespace DesktopTools.Controls
/// </summary>
public AccessOperation AccessOperation { get; protected set; }
/// <summary>
/// Идентификатор выбранной записи
/// </summary>
public Guid? SelectedId { get; set; }
/// <summary>
/// Название выбранной записи
/// </summary>
public string SelectedText { get; set; }
/// <summary>
/// Ссылка на форму, в который открыевается контрол для выбора значения
/// </summary>
public Form FormForSelected { get; set; }
/// <summary>
/// Получение названиия объекта по его идентификатору
/// </summary>
/// <param name="id"></param>
public abstract string GetTitleFromId(Guid id);
/// <summary>
/// Констркутор
/// </summary>
public BaseControlViewEntityList()
public AbstractControlViewEntityList()
{
InitializeComponent();
}

View File

@ -1,6 +1,6 @@
namespace DesktopTools.Controls
{
partial class GenericControlEntityList<G, S, L, E, BL>
partial class AbstractGenericControlEntityList<G, S, L, E, BL>
{
/// <summary>
/// Освободить все используемые ресурсы.

View File

@ -13,7 +13,7 @@ using System.Windows.Forms;
namespace DesktopTools.Controls
{
public partial class GenericControlEntityList<G, S, L, E, BL> : BaseControlViewEntityList
public abstract partial class AbstractGenericControlEntityList<G, S, L, E, BL> : AbstractControlViewEntityList
where G : GetBindingModel, new()
where S : SetBindingModel, new()
where L : ListViewModel<E>
@ -28,7 +28,7 @@ namespace DesktopTools.Controls
/// <summary>
/// Констркутор
/// </summary>
public GenericControlEntityList()
public AbstractGenericControlEntityList()
{
InitializeComponent();
InitEvents();
@ -37,7 +37,6 @@ namespace DesktopTools.Controls
public override async void Open()
{
base.Open();
if (dataGridViewList.Columns.Count == 0)
{
Configurate(GetConfig());
@ -45,10 +44,7 @@ namespace DesktopTools.Controls
await LoadListAsync();
}
public override void Close()
{
base.Close();
}
public override string GetTitleFromId(Guid id) => _businessLogic.GetElement(new G { Id = id })?.ToString();
/// <summary>
/// Конфигуратор контрола
@ -150,6 +146,9 @@ namespace DesktopTools.Controls
{
toolStripFooter.Visible = false;
}
// при вызове контрола для выбора элемента, делаем возможность выбора только одной записи
dataGridViewList.MultiSelect = FormForSelected == null;
}
/// <summary>
@ -184,6 +183,14 @@ namespace DesktopTools.Controls
};
dataGridViewList.CellDoubleClick += (object sender, DataGridViewCellEventArgs e) =>
{
if (FormForSelected != null && dataGridViewList.SelectedRows.Count > 0)
{
SelectedId = new Guid(dataGridViewList.SelectedRows[0].Cells[0].Value.ToString());
SelectedText = _businessLogic.GetElement(new G { Id = SelectedId })?.ToString();
FormForSelected.DialogResult = DialogResult.OK;
FormForSelected.Close();
return;
}
CallUpdElementEvent();
};
@ -343,8 +350,8 @@ namespace DesktopTools.Controls
{
try
{
var control = new GenericControlEntityElement<G, S, L, E, BL>(id);
control.Open();
var control = new GenericControlEntityElement<G, S, L, E, BL>();
control.Open(id);
var form = new Form
{
Height = control.Height,
@ -364,12 +371,12 @@ namespace DesktopTools.Controls
}
}
protected virtual ControlViewEntityListConfiguration GetConfig() => new();
protected abstract ControlViewEntityListConfiguration GetConfig();
protected virtual L GetData() { return null; }
protected abstract L GetData();
protected virtual L GetDataWithPageName(string key) { return null; }
protected abstract L GetDataWithPageName(string key);
protected virtual L GetDataWithPageNumber(int page, int count) { return null; }
protected abstract L GetDataWithPageNumber(int page, int count);
}
}

View File

@ -2,6 +2,8 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using ModuleTools.Extensions;
using ModuleTools.ViewModels;
using System;
using System.Linq;
@ -10,7 +12,7 @@ using System.Windows.Forms;
namespace DesktopTools.Controls
{
public partial class GenericControlEntityElement<G, S, L, E, BL> : BaseControlViewEntityElement
public partial class GenericControlEntityElement<G, S, L, E, BL> : AbstractControlViewEntityElement
where G : GetBindingModel, new()
where S : SetBindingModel, new()
where L : ListViewModel<E>
@ -24,30 +26,31 @@ namespace DesktopTools.Controls
private event Action<int> SetTitleWidth;
private event Action<object> SetValues;
private event Action DropValues;
private event Func<bool> CheckValues;
private event Action<object> GetValues;
private E Element { get; set; }
public GenericControlEntityElement(Guid? id)
private E _element = null;
private E Element { get { return _element; } set { _element = value; SetValues?.Invoke(_element); _haveChages = false; } }
public GenericControlEntityElement()
{
InitializeComponent();
InitEvents();
_businessLogic = DependencyManager.Instance.Resolve<BL>();
Element = _businessLogic.GetElement(new G { Id = id });
}
public override void Open()
public override void Open(Guid? id)
{
base.Open();
if (panelContainer.Controls.Count == 0)
{
Configurate();
}
//LoadList();
Element = _businessLogic.GetElement(new G { Id = id });
}
private void InitEvents()
@ -71,23 +74,46 @@ namespace DesktopTools.Controls
if (attribute != null)
{
AbstractBaseControl control = null;
switch (property.PropertyType.Name.ToLower())
switch (attribute.ControlType)
{
case "string":
control = new BaseControlText(property.Name);
case ControlType.ControlString:
control = new BaseControlString(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MaxLength);
break;
case "int32":
control = new BaseControlInt(property.Name);
case ControlType.ControlText:
control = new BaseControlText(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MaxLength, attribute.Height);
break;
case ControlType.ControlInt:
control = new BaseControlInt(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinValue, attribute.MaxValue);
break;
case ControlType.ControlDecimal:
control = new BaseControlDecimal(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinValue,
attribute.MaxValue, attribute.DecimalPlaces);
break;
case ControlType.ControlBool:
control = new BaseControlBool(property.Name, attribute.MustHaveValue, attribute.ReadOnly);
break;
case ControlType.ControlDateTime:
control = new BaseControlDateTime(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinDate,
attribute.MaxDate, attribute.CustomDateFormat);
break;
case ControlType.ControlImage:
control = new BaseControlImage(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.Width, attribute.Height);
break;
case ControlType.ControlEnum:
control = new BaseControlEnum(property.Name, attribute.MustHaveValue, attribute.ReadOnly, property.PropertyType);
break;
case ControlType.ControlGuid:
if (attribute.ControlTypeObject.IsNotEmpty())
{
control = new BaseControlGuid(property.Name, attribute.MustHaveValue, attribute.ReadOnly,
DependencyManager.Instance.Resolve(Type.GetType(attribute.ControlTypeObject)) as AbstractControlViewEntityList);
}
break;
}
if (control == null)
{
continue;
}
if (Element != null)
{
control.SetValueToControl(property.GetValue(Element));
}
var widthTitle = control.SetTitle(attribute.DisplayName);
if (widthTitle > titleWidth)
@ -96,19 +122,17 @@ namespace DesktopTools.Controls
}
control.OnValueChangeEvent += ValueChange;
SetValues += control.SetValue;
DropValues += control.DropValue;
CheckValues += control.CheckValue;
SetTitleWidth += control.SetTitleWidth;
GetValues += control.FillPropertyToObject;
GetValues += control.GetValue;
control.Location = new System.Drawing.Point(positionX, positionY);
control.Width = Width - positionX * 2;
control.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left;
positionY += control.Height + interval;
control.SetReadOnly(attribute.ReadOnly);
control.SetMustCheckValue(attribute.MustHaveValue);
panelContainer.Controls.Add(control);
}
}
@ -141,6 +165,7 @@ namespace DesktopTools.Controls
throw new Exception($"Ошибка при сохранении: {_businessLogic.Errors.LastOrDefault().Message}");
}
_haveChages = false;
MessageBox.Show("Сохранение прошло успешно", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
}

View File

@ -11,6 +11,6 @@ namespace DesktopTools.Models
public string Title { get; set; }
public BaseControlViewEntityList Control { get; set; }
public AbstractControlViewEntityList Control { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using System;
using ModuleTools.Enums;
using System;
namespace ModuleTools.Attributes
{
@ -14,6 +15,11 @@ namespace ModuleTools.Attributes
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// Через какой тип контрола отображать свойство
/// </summary>
public ControlType ControlType { get; set; }
/// <summary>
/// Поле должно быть обязательно заполнено
/// </summary>
@ -27,31 +33,80 @@ namespace ModuleTools.Attributes
/// <summary>
/// Ширина
/// </summary>
public int? Width { get; set; }
public int? Width { get; set; } = null;
/// <summary>
/// Высота
/// </summary>
public int? Height { get; set; }
public int? Height { get; set; } = null;
/// <summary>
/// Максимальное длина строки
/// </summary>
public int? MaxLength { get; set; } = null;
/// <summary>
/// Минимальное значение для числового параметра
/// </summary>
public decimal? MinValue { get; set; } = null;
/// <summary>
/// Максимальное значение для числового параметра
/// </summary>
public decimal? MaxValue { get; set; } = null;
/// <summary>
/// Количество знаков после запятой
/// </summary>
public int? DecimalPlaces { get; set; } = null;
/// <summary>
/// Минимальное значение для даты
/// </summary>
public DateTime? MinDate { get; set; } = null;
/// <summary>
/// Максимальное значение для даты
/// </summary>
public DateTime? MaxDate { get; set; } = null;
/// <summary>
/// Пользовательский формат отображения даты
/// </summary>
public string CustomDateFormat { get; set; } = null;
/// <summary>
/// Имя контрола (включая namespace) для вызова формы выбора элемента-объекта другого класса
/// </summary>
public string ControlTypeObject { get; set; } = string.Empty;
/// <summary>
/// Имя свйоства, где лежит текстовое значение для ссылочного типа (опсанного через Id на другую сущность)
/// </summary>
public string PropertyNameForTitle { get; set; }
/// <summary>
/// Конструктор
/// </summary>
/// <param name="displayName">Название на форме</param>
public ViewModelOnElementPropertyAttribute(string displayName)
/// <param name="controlType">Через какой тип контрола отображать свойство</param>
public ViewModelOnElementPropertyAttribute(string displayName, ControlType controlType)
{
DisplayName = displayName;
ControlType = controlType;
}
/// <summary>
/// Конструктор
/// </summary>
/// <param name="displayName">Название на форме</param>
/// <param name="controlType">Через какой тип контрола отображать свойство</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
public ViewModelOnElementPropertyAttribute(string displayName, int width, int height)
public ViewModelOnElementPropertyAttribute(string displayName, ControlType controlType, int width, int height)
{
DisplayName = displayName;
ControlType = controlType;
Width = width;
Height = height;
}

View File

@ -58,5 +58,12 @@ namespace ModuleTools.BusinessLogics
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T Resolve<T>() => _dependencyManager.Resolve<T>();
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public object Resolve(Type t) => _dependencyManager.Resolve(t);
}
}

View File

@ -1,4 +1,5 @@
using ModuleTools.Interfaces;
using System;
using Unity;
using Unity.Lifetime;
@ -18,5 +19,7 @@ namespace ModuleTools.BusinessLogics
public void RegisterType<T>() => _unityContainer.RegisterType<T>(new HierarchicalLifetimeManager());
public T Resolve<T>() => _unityContainer.Resolve<T>();
public object Resolve(Type t) => _unityContainer.Resolve(t);
}
}

View File

@ -0,0 +1,53 @@
namespace ModuleTools.Enums
{
/// <summary>
/// Тип контрола, через который следует отображать свойство с ViewModel
/// </summary>
public enum ControlType
{
/// <summary>
/// Простое однострочное текстовое поле
/// </summary>
ControlString = 0,
/// <summary>
/// Текстовое поле в несколько строк
/// </summary>
ControlText = 1,
/// <summary>
/// Поле для целочисленного значения
/// </summary>
ControlInt = 2,
/// <summary>
/// Поле для вещественного значения
/// </summary>
ControlDecimal = 3,
/// <summary>
/// Поле для bool-значения
/// </summary>
ControlBool = 4,
/// <summary>
/// Поле для даты
/// </summary>
ControlDateTime = 5,
/// <summary>
/// Поле для изображения
/// </summary>
ControlImage = 6,
/// <summary>
/// Поле для пеерчисления
/// </summary>
ControlEnum = 7,
/// <summary>
/// Поле для идентифкатора на другую сущность
/// </summary>
ControlGuid = 8
}
}

View File

@ -1,4 +1,6 @@
namespace ModuleTools.Interfaces
using System;
namespace ModuleTools.Interfaces
{
/// <summary>
/// Интерфейс установки зависмости между элементами
@ -25,5 +27,12 @@
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T Resolve<T>();
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
object Resolve(Type t);
}
}

View File

@ -9,15 +9,15 @@ namespace DepartmentPortalDesctop
{
public partial class FormMain : Form
{
private readonly Dictionary<Guid, BaseControlViewEntityList> _baseControls;
private readonly Dictionary<Guid, AbstractControlViewEntityList> _baseControls;
private readonly Dictionary<Guid, BaseControlViewEntityList> _controls;
private readonly Dictionary<Guid, AbstractControlViewEntityList> _controls;
public FormMain()
{
InitializeComponent();
_baseControls = new Dictionary<Guid, BaseControlViewEntityList>();
_controls = new Dictionary<Guid, BaseControlViewEntityList>();
_baseControls = new Dictionary<Guid, AbstractControlViewEntityList>();
_controls = new Dictionary<Guid, AbstractControlViewEntityList>();
var extensions = DesktopLoader.GetWindowDesktopExtensions();
foreach (var extens in extensions)
@ -28,7 +28,7 @@ namespace DepartmentPortalDesctop
var menu = new ToolStripMenuItem { Text = list[0].Title };
for (int i = 0; i < list.Count; i++)
{
if (list[i].Control is BaseControlViewEntityList control)
if (list[i].Control is AbstractControlViewEntityList control)
{
if (_baseControls.ContainsKey(list[i].Id))
{

View File

@ -22,17 +22,9 @@ namespace SecurityBusinessLogic.BindingModels
public string Login { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("Password")]
public string Password { get; set; }
[MapConfiguration("StudentId")]
public Guid? StudentId { get; set; }
[MapConfiguration("LecturerId")]
public Guid? LecturerId { get; set; }
[MapConfiguration("EmployeeId")]
public Guid? EmployeeId { get; set; }
[MapConfiguration("Avatar")]
public byte[] Avatar { get; set; }

View File

@ -12,4 +12,8 @@
<ProjectReference Include="..\..\Common\ModuleTools\ModuleTools.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -16,6 +16,7 @@ namespace SecurityBusinessLogic.ViewModels
public class AccessViewModel : ElementViewModel
{
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ControlTypeObject = "SecurityWindowsDesktop.Controls.RolesControl, SecurityWindowsDesktop")]
public Guid RoleId { get; set; }
[ViewModelOnListProperty("Роль", 100)]
@ -23,12 +24,14 @@ namespace SecurityBusinessLogic.ViewModels
public string RoleName { get; set; }
[MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)]
public AccessOperation AccessOperation { get; set; }
[ViewModelOnListProperty("Операция")]
public string AccessOperationTitle => AccessOperation.ToString("G");
[MapConfiguration("AccessType", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)]
public AccessType AccessType { get; set; }
[ViewModelOnListProperty("Тип", 150)]

View File

@ -1,4 +1,5 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
namespace SecurityBusinessLogic.ViewModels
@ -14,17 +15,17 @@ namespace SecurityBusinessLogic.ViewModels
public class EnviromentSettingViewModel : ElementViewModel
{
[ViewModelOnListProperty("Ключ")]
[ViewModelOnElementProperty("Ключ", MustHaveValue = true, ReadOnly = true)]
[ViewModelOnElementProperty("Ключ", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)]
[MapConfiguration("Key", AllowCopyWithoutRigth = false)]
public string Key { get; set; }
[ViewModelOnListProperty("Значение")]
[ViewModelOnElementProperty("Значение", MustHaveValue = true)]
[ViewModelOnElementProperty("Значение", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Value", AllowCopyWithoutRigth = false)]
public string Value { get; set; }
[ViewModelOnListProperty("Описание")]
[ViewModelOnElementProperty("Описание")]
[ViewModelOnElementProperty("Описание", ControlType.ControlText, 0, 200)]
[MapConfiguration("Description", AllowCopyWithoutRigth = false)]
public string Description { get; set; }

View File

@ -1,4 +1,5 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
namespace SecurityBusinessLogic.ViewModels
@ -14,12 +15,12 @@ namespace SecurityBusinessLogic.ViewModels
public class RoleViewModel : ElementViewModel
{
[ViewModelOnListProperty("Название роли")]
[ViewModelOnElementProperty("Название роли")]
[ViewModelOnElementProperty("Название роли", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("RoleName")]
public string RoleName { get; set; }
[ViewModelOnListProperty("Приоритет", 100)]
[ViewModelOnElementProperty("Приоритет")]
[ViewModelOnElementProperty("Приоритет", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("RolePriority")]
public int RolePriority { get; set; }

View File

@ -1,4 +1,5 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
@ -15,23 +16,15 @@ namespace SecurityBusinessLogic.ViewModels
public class UserViewModel : ElementViewModel
{
[ViewModelOnListProperty("Пользователь")]
[ViewModelOnElementProperty("Логин")]
[ViewModelOnElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("UserName")]
public string Login { get; set; }
[MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
public string Password { get; set; }
[MapConfiguration("StudentId")]
public Guid? StudentId { get; set; }
[MapConfiguration("LecturerId")]
public Guid? LecturerId { get; set; }
[MapConfiguration("EmployeeId")]
public Guid? EmployeeId { get; set; }
[MapConfiguration("Avatar")]
[ViewModelOnElementProperty("Фото", ControlType.ControlImage, 200, 200)]
public byte[] Avatar { get; set; }
[ViewModelOnListProperty("Посл. визит", 100)]
@ -39,18 +32,21 @@ namespace SecurityBusinessLogic.ViewModels
public DateTime? DateLastVisit { get; set; }
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
public bool IsBanned { get; set; }
[ViewModelOnListProperty("Блокир.", 80)]
public string Banned => IsBanned ? "Да" : "Нет";
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
public DateTime? DateBanned { get; set; }
[ViewModelOnListProperty("Дата Б.", 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
[ViewModelOnElementProperty("Попытки входа", ControlType.ControlInt , ReadOnly = true)]
public int CountAttempt { get; set; }
public override string ToString() => Login;

View File

@ -132,6 +132,11 @@ namespace SecurityImplementation.SecurityDatabaseImplementation
{
return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete);
}
if(entity.IsBanned && !model.IsBanned)
{
model.DateBanned = null;
model.CountAttempt = 0;
}
entity = Mapper.MapToClass(model, entity, true);
context.SaveChanges();

View File

@ -11,7 +11,7 @@ using System.Linq;
namespace SecurityWindowsDesktop.Controls
{
public partial class AccessesControl : GenericControlEntityList<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel, AccessBusinessLogic>
public partial class AccessesControl : AbstractGenericControlEntityList<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel, AccessBusinessLogic>
{
private readonly RoleBusinessLogic _roleBusinessLogic;
@ -25,7 +25,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Доступы;
}
public override BaseControlViewEntityList Clone() => new AccessesControl() { ControlId = Guid.NewGuid() };
public override AbstractControlViewEntityList Clone() => new AccessesControl() { ControlId = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new()
{
@ -33,10 +33,20 @@ namespace SecurityWindowsDesktop.Controls
PageNamesForPagination = _roleBusinessLogic.GetList(new RoleGetBindingModel())?.List?.Select(x => x.RoleName)?.ToList()
};
protected override AccessListViewModel GetData()
{
throw new NotImplementedException();
}
protected override AccessListViewModel GetDataWithPageName(string key)
{
var list = _businessLogic.GetList(new AccessGetBindingModel { RoleName = key });
return list;
}
protected override AccessListViewModel GetDataWithPageNumber(int page, int count)
{
throw new NotImplementedException();
}
}
}

View File

@ -9,7 +9,7 @@ using System;
namespace SecurityWindowsDesktop.Controls
{
public partial class EnviromentSettingControl : GenericControlEntityList<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSettingListViewModel, EnviromentSettingViewModel, EnviromentSettingBusinessLogic>
public partial class EnviromentSettingControl : AbstractGenericControlEntityList<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSettingListViewModel, EnviromentSettingViewModel, EnviromentSettingBusinessLogic>
{
public EnviromentSettingControl()
{
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.НастройкиСреды;
}
public override BaseControlViewEntityList Clone() => new EnviromentSettingControl() { ControlId = Guid.NewGuid() };
public override AbstractControlViewEntityList Clone() => new EnviromentSettingControl() { ControlId = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new()
{
@ -32,5 +32,15 @@ namespace SecurityWindowsDesktop.Controls
var list = _businessLogic.GetList(new EnviromentSettingGetBindingModel());
return list;
}
protected override EnviromentSettingListViewModel GetDataWithPageName(string key)
{
throw new NotImplementedException();
}
protected override EnviromentSettingListViewModel GetDataWithPageNumber(int page, int count)
{
throw new NotImplementedException();
}
}
}

View File

@ -9,7 +9,7 @@ using System;
namespace SecurityWindowsDesktop.Controls
{
public partial class RolesControl : GenericControlEntityList<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel, RoleBusinessLogic>
public partial class RolesControl : AbstractGenericControlEntityList<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel, RoleBusinessLogic>
{
public RolesControl() : base()
{
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Роли;
}
public override BaseControlViewEntityList Clone() => new RolesControl() { ControlId = Guid.NewGuid() };
public override AbstractControlViewEntityList Clone() => new RolesControl() { ControlId = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new()
{
@ -32,5 +32,15 @@ namespace SecurityWindowsDesktop.Controls
var list = _businessLogic.GetList(new RoleGetBindingModel());
return list;
}
protected override RoleListViewModel GetDataWithPageName(string key)
{
throw new NotImplementedException();
}
protected override RoleListViewModel GetDataWithPageNumber(int page, int count)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,6 +1,5 @@
using DesktopTools.Controls;
using DesktopTools.Models;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
@ -9,7 +8,7 @@ using System;
namespace SecurityWindowsDesktop.Controls
{
public partial class UsersControl : GenericControlEntityList<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel, UserBusinessLogic>
public partial class UsersControl : AbstractGenericControlEntityList<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel, UserBusinessLogic>
{
public UsersControl() : base()
{
@ -20,7 +19,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Пользователи;
}
public override BaseControlViewEntityList Clone() => new UsersControl() { ControlId = Guid.NewGuid() };
public override AbstractControlViewEntityList Clone() => new UsersControl() { ControlId = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new()
{
@ -28,6 +27,16 @@ namespace SecurityWindowsDesktop.Controls
CountElementsOnPage = 40
};
protected override UserListViewModel GetData()
{
throw new NotImplementedException();
}
protected override UserListViewModel GetDataWithPageName(string key)
{
throw new NotImplementedException();
}
protected override UserListViewModel GetDataWithPageNumber(int page, int count)
{
var list = _businessLogic.GetList(new UserGetBindingModel

View File

@ -31,7 +31,7 @@ namespace SecurityWindowsDesktop
{
new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" }
};
List<BaseControlViewEntityList> _controls = new()
List<AbstractControlViewEntityList> _controls = new()
{
new UsersControl(),
new RolesControl(),
@ -53,6 +53,10 @@ namespace SecurityWindowsDesktop
});
}
}
DependencyManager.Instance.RegisterType<UsersControl>();
DependencyManager.Instance.RegisterType<RolesControl>();
DependencyManager.Instance.RegisterType<AccessesControl>();
DependencyManager.Instance.RegisterType<EnviromentSettingControl>();
return list;
}