From 908c920d26f3928e102f2f71446f7446c34ef8e2 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sat, 3 Apr 2021 11:38:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=BD=D0=B5=20null?= =?UTF-8?q?=20=D0=B2=20=D0=B0=D1=82=D1=80=D0=B8=D0=B1=D1=83=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseControls/BaseControlDateTime.cs | 10 +++--- .../BaseControls/BaseControlDecimal.cs | 14 ++++----- .../BaseControls/BaseControlImage.cs | 10 +++--- .../BaseControls/BaseControlInt.cs | 10 +++--- .../BaseControls/BaseControlString.cs | 6 ++-- .../BaseControls/BaseControlText.cs | 12 +++---- ...iewModelControlElementPropertyAttribute.cs | 31 +++++-------------- .../ViewModels/EnviromentSettingViewModels.cs | 2 +- .../ViewModels/UserViewModels.cs | 2 +- 9 files changed, 41 insertions(+), 56 deletions(-) diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs index 243fff0..7c22b9f 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs @@ -19,7 +19,7 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _baseControl = this; @@ -35,13 +35,13 @@ namespace DesktopTools.BaseControls } 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()) { diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs index 02f9fc7..103e96b 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs @@ -18,7 +18,7 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _baseControl = this; @@ -34,17 +34,17 @@ namespace DesktopTools.BaseControls } 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); } diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs index 86403c4..461fedd 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs @@ -19,18 +19,18 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _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) => diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs index 398daf0..4bc53c3 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs @@ -17,7 +17,7 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _baseControl = this; @@ -33,13 +33,13 @@ namespace DesktopTools.BaseControls } 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); } diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs index 8854e62..8ba18e6 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs @@ -17,14 +17,14 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _baseControl = this; - if (maxLength.HasValue) + if (maxLength != 0) { - textBox.MaxLength = maxLength.Value; + textBox.MaxLength = maxLength; } textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; panelControl.Controls.Add(textBox); diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs index 1f90d71..d84cb0b 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs @@ -18,19 +18,19 @@ namespace DesktopTools.BaseControls /// /// /// - 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(); _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; - Height = height.Value; + textBox.Height = height; + Height = height; } textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; panelControl.Controls.Add(textBox); diff --git a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlElementPropertyAttribute.cs b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlElementPropertyAttribute.cs index cd6bc18..c2562a9 100644 --- a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlElementPropertyAttribute.cs +++ b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlElementPropertyAttribute.cs @@ -33,42 +33,42 @@ namespace ModuleTools.Attributes /// /// Ширина /// - public int? Width { get; set; } = null; + public int Width { get; set; } = 0; /// /// Высота /// - public int? Height { get; set; } = null; + public int Height { get; set; } = 0; /// /// Максимальное длина строки /// - public int? MaxLength { get; set; } = null; + public int MaxLength { get; set; } = 0; /// /// Минимальное значение для числового параметра /// - public decimal? MinValue { get; set; } = null; + public decimal MinValue { get; set; } = 0; /// /// Максимальное значение для числового параметра /// - public decimal? MaxValue { get; set; } = null; + public decimal MaxValue { get; set; } = 0; /// /// Количество знаков после запятой /// - public int? DecimalPlaces { get; set; } = null; + public int DecimalPlaces { get; set; } = 0; /// /// Минимальное значение для даты /// - public DateTime? MinDate { get; set; } = null; + public DateTime MinDate { get; set; } = DateTime.MinValue; /// /// Максимальное значение для даты /// - public DateTime? MaxDate { get; set; } = null; + public DateTime MaxDate { get; set; } = DateTime.MinValue; /// /// Пользовательский формат отображения даты @@ -90,20 +90,5 @@ namespace ModuleTools.Attributes DisplayName = displayName; ControlType = controlType; } - - /// - /// Конструктор - /// - /// Название на форме - /// Через какой тип контрола отображать свойство - /// Ширина - /// Высота - public ViewModelControlElementPropertyAttribute(string displayName, ControlType controlType, int width, int height) - { - DisplayName = displayName; - ControlType = controlType; - Width = width; - Height = height; - } } } \ No newline at end of file diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs index 19adcce..7c3267d 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs @@ -26,7 +26,7 @@ namespace SecurityBusinessLogic.ViewModels public string Value { get; set; } [ViewModelControlListProperty("Описание")] - [ViewModelControlElementProperty("Описание", ControlType.ControlText, 0, 200)] + [ViewModelControlElementProperty("Описание", ControlType.ControlText, Height = 200)] [MapConfiguration("Description", AllowCopyWithoutRigth = false)] public string Description { get; set; } diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs index 8503f6b..ff359d3 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs @@ -27,7 +27,7 @@ namespace SecurityBusinessLogic.ViewModels public string Password { get; set; } [MapConfiguration("Avatar")] - [ViewModelControlElementProperty("Фото", ControlType.ControlImage, 200, 200)] + [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)] public byte[] Avatar { get; set; } [ViewModelControlListProperty("Посл. визит", 100)]