поля не null в атрибуте

This commit is contained in:
kotcheshir73 2021-04-03 11:38:27 +04:00
parent 0012615e11
commit 908c920d26
9 changed files with 41 additions and 56 deletions

View File

@ -19,7 +19,7 @@ namespace DesktopTools.BaseControls
/// <param name="minDate"></param> /// <param name="minDate"></param>
/// <param name="maxDate"></param> /// <param name="maxDate"></param>
/// <param name="customDateFormat"></param> /// <param name="customDateFormat"></param>
public BaseControlDateTime(string propertyName, bool mustFilling, bool readOnly, DateTime? minDate, DateTime? maxDate, string customDateFormat) : base(propertyName, mustFilling, readOnly) public BaseControlDateTime(string propertyName, bool mustFilling, bool readOnly, DateTime minDate, DateTime maxDate, string customDateFormat) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
@ -35,13 +35,13 @@ namespace DesktopTools.BaseControls
} }
dateTimePicker.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; dateTimePicker.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
if (minDate.HasValue) if (minDate > DateTime.MinValue)
{ {
dateTimePicker.MinDate = minDate.Value; dateTimePicker.MinDate = minDate;
} }
if (maxDate.HasValue) if (maxDate > DateTime.MinValue)
{ {
dateTimePicker.MaxDate = maxDate.Value; dateTimePicker.MaxDate = maxDate;
} }
if(customDateFormat.IsNotEmpty()) if(customDateFormat.IsNotEmpty())
{ {

View File

@ -18,7 +18,7 @@ namespace DesktopTools.BaseControls
/// <param name="minValue"></param> /// <param name="minValue"></param>
/// <param name="maxValue"></param> /// <param name="maxValue"></param>
/// <param name="decimalPlaces"></param> /// <param name="decimalPlaces"></param>
public BaseControlDecimal(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue, int? decimalPlaces) : base(propertyName, mustFilling, readOnly) public BaseControlDecimal(string propertyName, bool mustFilling, bool readOnly, decimal minValue, decimal maxValue, int decimalPlaces) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
@ -34,17 +34,17 @@ namespace DesktopTools.BaseControls
} }
numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
if (minValue.HasValue) if (minValue != 0)
{ {
numericUpDown.Minimum = minValue.Value; numericUpDown.Minimum = minValue;
} }
if (maxValue.HasValue) if (maxValue != 0)
{ {
numericUpDown.Maximum = maxValue.Value; numericUpDown.Maximum = maxValue;
} }
if (decimalPlaces.HasValue) if (decimalPlaces != 0)
{ {
numericUpDown.DecimalPlaces = decimalPlaces.Value; numericUpDown.DecimalPlaces = decimalPlaces;
} }
panelControl.Controls.Add(numericUpDown); panelControl.Controls.Add(numericUpDown);
} }

View File

@ -19,18 +19,18 @@ namespace DesktopTools.BaseControls
/// <param name="readOnly"></param> /// <param name="readOnly"></param>
/// <param name="width"></param> /// <param name="width"></param>
/// <param name="height"></param> /// <param name="height"></param>
public BaseControlImage(string propertyName, bool mustFilling, bool readOnly, int? width, int? height) : base(propertyName, mustFilling, readOnly) public BaseControlImage(string propertyName, bool mustFilling, bool readOnly, int width, int height) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
if (width.HasValue) if (width != 0)
{ {
Width = width.Value; Width = width;
} }
if (height.HasValue) if (height != 0)
{ {
Height = height.Value; Height = height;
} }
buttonLoad.Click += (object sender, EventArgs e) => buttonLoad.Click += (object sender, EventArgs e) =>

View File

@ -17,7 +17,7 @@ namespace DesktopTools.BaseControls
/// <param name="readOnly"></param> /// <param name="readOnly"></param>
/// <param name="minValue"></param> /// <param name="minValue"></param>
/// <param name="maxValue"></param> /// <param name="maxValue"></param>
public BaseControlInt(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue) : base(propertyName, mustFilling, readOnly) public BaseControlInt(string propertyName, bool mustFilling, bool readOnly, decimal minValue, decimal maxValue) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
@ -33,13 +33,13 @@ namespace DesktopTools.BaseControls
} }
numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
if (minValue.HasValue) if (minValue != 0)
{ {
numericUpDown.Minimum = minValue.Value; numericUpDown.Minimum = minValue;
} }
if (maxValue.HasValue) if (maxValue != 0)
{ {
numericUpDown.Maximum = maxValue.Value; numericUpDown.Maximum = maxValue;
} }
panelControl.Controls.Add(numericUpDown); panelControl.Controls.Add(numericUpDown);
} }

View File

@ -17,14 +17,14 @@ namespace DesktopTools.BaseControls
/// <param name="mustFilling"></param> /// <param name="mustFilling"></param>
/// <param name="readOnly"></param> /// <param name="readOnly"></param>
/// <param name="maxLength"></param> /// <param name="maxLength"></param>
public BaseControlString(string propertyName, bool mustFilling, bool readOnly, int? maxLength) : base(propertyName, mustFilling, readOnly) public BaseControlString(string propertyName, bool mustFilling, bool readOnly, int maxLength) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
if (maxLength.HasValue) if (maxLength != 0)
{ {
textBox.MaxLength = maxLength.Value; textBox.MaxLength = maxLength;
} }
textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(textBox); panelControl.Controls.Add(textBox);

View File

@ -18,19 +18,19 @@ namespace DesktopTools.BaseControls
/// <param name="readOnly"></param> /// <param name="readOnly"></param>
/// <param name="maxLength"></param> /// <param name="maxLength"></param>
/// <param name="height"></param> /// <param name="height"></param>
public BaseControlText(string propertyName, bool mustFilling, bool readOnly, int? maxLength, int? height) : base(propertyName, mustFilling, readOnly) public BaseControlText(string propertyName, bool mustFilling, bool readOnly, int maxLength, int height) : base(propertyName, mustFilling, readOnly)
{ {
InitializeComponent(); InitializeComponent();
_baseControl = this; _baseControl = this;
if (maxLength.HasValue) if (maxLength != 0)
{ {
textBox.MaxLength = maxLength.Value; textBox.MaxLength = maxLength;
} }
if (height.HasValue) if (height != 0)
{ {
textBox.Height = height.Value; textBox.Height = height;
Height = height.Value; Height = height;
} }
textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); };
panelControl.Controls.Add(textBox); panelControl.Controls.Add(textBox);

View File

@ -33,42 +33,42 @@ namespace ModuleTools.Attributes
/// <summary> /// <summary>
/// Ширина /// Ширина
/// </summary> /// </summary>
public int? Width { get; set; } = null; public int Width { get; set; } = 0;
/// <summary> /// <summary>
/// Высота /// Высота
/// </summary> /// </summary>
public int? Height { get; set; } = null; public int Height { get; set; } = 0;
/// <summary> /// <summary>
/// Максимальное длина строки /// Максимальное длина строки
/// </summary> /// </summary>
public int? MaxLength { get; set; } = null; public int MaxLength { get; set; } = 0;
/// <summary> /// <summary>
/// Минимальное значение для числового параметра /// Минимальное значение для числового параметра
/// </summary> /// </summary>
public decimal? MinValue { get; set; } = null; public decimal MinValue { get; set; } = 0;
/// <summary> /// <summary>
/// Максимальное значение для числового параметра /// Максимальное значение для числового параметра
/// </summary> /// </summary>
public decimal? MaxValue { get; set; } = null; public decimal MaxValue { get; set; } = 0;
/// <summary> /// <summary>
/// Количество знаков после запятой /// Количество знаков после запятой
/// </summary> /// </summary>
public int? DecimalPlaces { get; set; } = null; public int DecimalPlaces { get; set; } = 0;
/// <summary> /// <summary>
/// Минимальное значение для даты /// Минимальное значение для даты
/// </summary> /// </summary>
public DateTime? MinDate { get; set; } = null; public DateTime MinDate { get; set; } = DateTime.MinValue;
/// <summary> /// <summary>
/// Максимальное значение для даты /// Максимальное значение для даты
/// </summary> /// </summary>
public DateTime? MaxDate { get; set; } = null; public DateTime MaxDate { get; set; } = DateTime.MinValue;
/// <summary> /// <summary>
/// Пользовательский формат отображения даты /// Пользовательский формат отображения даты
@ -90,20 +90,5 @@ namespace ModuleTools.Attributes
DisplayName = displayName; DisplayName = displayName;
ControlType = controlType; ControlType = controlType;
} }
/// <summary>
/// Конструктор
/// </summary>
/// <param name="displayName">Название на форме</param>
/// <param name="controlType">Через какой тип контрола отображать свойство</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
public ViewModelControlElementPropertyAttribute(string displayName, ControlType controlType, int width, int height)
{
DisplayName = displayName;
ControlType = controlType;
Width = width;
Height = height;
}
} }
} }

View File

@ -26,7 +26,7 @@ namespace SecurityBusinessLogic.ViewModels
public string Value { get; set; } public string Value { get; set; }
[ViewModelControlListProperty("Описание")] [ViewModelControlListProperty("Описание")]
[ViewModelControlElementProperty("Описание", ControlType.ControlText, 0, 200)] [ViewModelControlElementProperty("Описание", ControlType.ControlText, Height = 200)]
[MapConfiguration("Description", AllowCopyWithoutRigth = false)] [MapConfiguration("Description", AllowCopyWithoutRigth = false)]
public string Description { get; set; } public string Description { get; set; }

View File

@ -27,7 +27,7 @@ namespace SecurityBusinessLogic.ViewModels
public string Password { get; set; } public string Password { get; set; }
[MapConfiguration("Avatar")] [MapConfiguration("Avatar")]
[ViewModelControlElementProperty("Фото", ControlType.ControlImage, 200, 200)] [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
public byte[] Avatar { get; set; } public byte[] Avatar { get; set; }
[ViewModelControlListProperty("Посл. визит", 100)] [ViewModelControlListProperty("Посл. визит", 100)]