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; } }