aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Entities/DisplayPreferences.cs
blob: 009df26788c7533f00ce334d9575fd7b1171da7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using MediaBrowser.Model.Drawing;
using System;
using System.Collections.Generic;

namespace MediaBrowser.Model.Entities
{
    /// <summary>
    /// Defines the display preferences for any item that supports them (usually Folders)
    /// </summary>
    public class DisplayPreferences
    {
        /// <summary>
        /// The image scale
        /// </summary>
        private const double ImageScale = .9;

        /// <summary>
        /// Initializes a new instance of the <see cref="DisplayPreferences" /> class.
        /// </summary>
        public DisplayPreferences()
        {
            RememberIndexing = false;
            PrimaryImageHeight = 250;
            PrimaryImageWidth = 250;
            CustomPrefs = new Dictionary<string, string>();
        }

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>The user id.</value>
        public Guid Id { get; set; }
        /// <summary>
        /// Gets or sets the type of the view.
        /// </summary>
        /// <value>The type of the view.</value>
        public string ViewType { get; set; }
        /// <summary>
        /// Gets or sets the sort by.
        /// </summary>
        /// <value>The sort by.</value>
        public string SortBy { get; set; }
        /// <summary>
        /// Gets or sets the index by.
        /// </summary>
        /// <value>The index by.</value>
        public string IndexBy { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [remember indexing].
        /// </summary>
        /// <value><c>true</c> if [remember indexing]; otherwise, <c>false</c>.</value>
        public bool RememberIndexing { get; set; }
        /// <summary>
        /// Gets or sets the height of the primary image.
        /// </summary>
        /// <value>The height of the primary image.</value>
        public int PrimaryImageHeight { get; set; }
        /// <summary>
        /// Gets or sets the width of the primary image.
        /// </summary>
        /// <value>The width of the primary image.</value>
        public int PrimaryImageWidth { get; set; }
        /// <summary>
        /// Gets or sets the custom prefs.
        /// </summary>
        /// <value>The custom prefs.</value>
        public Dictionary<string, string> CustomPrefs { get; set; }
        /// <summary>
        /// Gets or sets the scroll direction.
        /// </summary>
        /// <value>The scroll direction.</value>
        public ScrollDirection ScrollDirection { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [remember sorting].
        /// </summary>
        /// <value><c>true</c> if [remember sorting]; otherwise, <c>false</c>.</value>
        public bool RememberSorting { get; set; }
        /// <summary>
        /// Gets or sets the sort order.
        /// </summary>
        /// <value>The sort order.</value>
        public SortOrder SortOrder { get; set; }

        /// <summary>
        /// Increases the size of the image.
        /// </summary>
        public void IncreaseImageSize()
        {
            var newWidth = PrimaryImageWidth / ImageScale;

            var size = DrawingUtils.Resize(PrimaryImageWidth, PrimaryImageHeight, newWidth);

            PrimaryImageWidth = Convert.ToInt32(size.Width);
            PrimaryImageHeight = Convert.ToInt32(size.Height);
        }

        /// <summary>
        /// Decreases the size of the image.
        /// </summary>
        public void DecreaseImageSize()
        {
            var size = DrawingUtils.Scale(PrimaryImageWidth, PrimaryImageHeight, ImageScale);

            PrimaryImageWidth = Convert.ToInt32(size.Width);
            PrimaryImageHeight = Convert.ToInt32(size.Height);
        }
    }

    /// <summary>
    /// Enum ScrollDirection
    /// </summary>
    public enum ScrollDirection
    {
        /// <summary>
        /// The horizontal
        /// </summary>
        Horizontal,
        /// <summary>
        /// The vertical
        /// </summary>
        Vertical
    }

    /// <summary>
    /// Enum SortOrder
    /// </summary>
    public enum SortOrder
    {
        /// <summary>
        /// The ascending
        /// </summary>
        Ascending,
        /// <summary>
        /// The descending
        /// </summary>
        Descending
    }
}