From d8dd66a987af0800ff47948d1fe672a3eb57197d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Sat, 22 Apr 2023 16:53:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D1=82=D0=BE=20=D1=82=D0=BE=20=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=80=D0=B0=D1=81=D1=87=D0=B8=D1=82=D0=B0=D0=BB?= =?UTF-8?q?=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F,=20=D0=BF=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/ColumnAttribute.cs | 31 +++++++++++++++++++ .../Attributes/GridViewAutoSize.cs | 27 ++++++++++++++++ .../ViewModels/ClientViewModel.cs | 10 +++--- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/ColumnAttribute.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/GridViewAutoSize.cs diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/ColumnAttribute.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..78270bb --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class ColumnAttribute : Attribute + { + public string Title { get; private set; } + + public bool Visible { get; private set; } + + public int Width { get; private set; } + + public GridViewAutoSize GridViewAutoSize { get; private set; } + + public bool IsUseAutoSize { get; private set; } + + public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false) + { + Title = title; + Visible = visible; + Width = width; + GridViewAutoSize = gridViewAutoSize; + IsUseAutoSize = isUseAutoSize; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/GridViewAutoSize.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..eeec891 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + + None = 1, + + ColumnHeader = 2, + + AllCellsExceptHeader = 4, + + AllCells = 6, + + DisplayedCellsExceptHeader = 8, + + DisplayedCells = 10, + + Fill = 16 + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ClientViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ClientViewModel.cs index 85d2654..2ebc238 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ClientViewModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ClientViewModel.cs @@ -1,4 +1,5 @@ -using PrecastConcretePlantDataModels.Models; +using PrecastConcretePlantContracts.Attributes; +using PrecastConcretePlantDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,12 +11,13 @@ namespace PrecastConcretePlantContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column("Логин (эл. почта)", width: 150)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 150)] public string Password { get; set; } = string.Empty; } }