| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="DisplayColumnOptionViewModel.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using MyNet.Observable; |
| | | 9 | | |
| | | 10 | | namespace MyNet.UI.ViewModels.Display.Options; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Represents one configurable column option for list display mode. |
| | | 14 | | /// </summary> |
| | | 15 | | public sealed class DisplayColumnOptionViewModel : ObservableObject |
| | | 16 | | { |
| | | 17 | | private readonly bool _defaultIsVisible; |
| | | 18 | | private readonly string _defaultWidth; |
| | | 19 | | private readonly int _defaultOrder; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Initializes a new instance of the <see cref="DisplayColumnOptionViewModel"/> class. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="identifier">The unique column identifier.</param> |
| | | 25 | | /// <param name="canBeHidden">Whether the column can be hidden.</param> |
| | | 26 | | /// <param name="isVisible">Whether the column is initially visible.</param> |
| | | 27 | | /// <param name="width">The column width string.</param> |
| | | 28 | | /// <param name="order">The initial display order.</param> |
| | 6 | 29 | | public DisplayColumnOptionViewModel( |
| | 6 | 30 | | string identifier, |
| | 6 | 31 | | bool canBeHidden = true, |
| | 6 | 32 | | bool isVisible = true, |
| | 6 | 33 | | string width = "*", |
| | 6 | 34 | | int order = 0) |
| | | 35 | | { |
| | 6 | 36 | | ArgumentException.ThrowIfNullOrWhiteSpace(identifier); |
| | | 37 | | |
| | | 38 | | Identifier = identifier; |
| | 6 | 39 | | CanBeHidden = canBeHidden; |
| | 6 | 40 | | IsVisible = isVisible; |
| | 6 | 41 | | Width = width; |
| | 6 | 42 | | Order = order; |
| | | 43 | | |
| | 6 | 44 | | _defaultIsVisible = isVisible; |
| | 6 | 45 | | _defaultWidth = width; |
| | 6 | 46 | | _defaultOrder = order; |
| | 6 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets the unique column identifier. |
| | | 51 | | /// </summary> |
| | | 52 | | public string Identifier { get; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets or sets a value indicating whether the column can be hidden. |
| | | 56 | | /// </summary> |
| | 6 | 57 | | public bool CanBeHidden { get; set => SetProperty(ref field, value); } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Gets or sets a value indicating whether the column is visible. |
| | | 61 | | /// </summary> |
| | 12 | 62 | | public bool IsVisible { get; set => SetProperty(ref field, value); } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// Gets or sets the column width. |
| | | 66 | | /// </summary> |
| | 6 | 67 | | public string Width { get; set => SetProperty(ref field, value); } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets or sets the column display order. |
| | | 71 | | /// </summary> |
| | 6 | 72 | | public int Order { get; set => SetProperty(ref field, value); } |
| | | 73 | | |
| | | 74 | | /// <summary> |
| | | 75 | | /// Resets this column option to its default values. |
| | | 76 | | /// </summary> |
| | | 77 | | public void Reset() |
| | | 78 | | { |
| | 0 | 79 | | IsVisible = _defaultIsVisible; |
| | 0 | 80 | | Width = _defaultWidth; |
| | 0 | 81 | | Order = _defaultOrder; |
| | 0 | 82 | | } |
| | | 83 | | } |
| | | 84 | | |