DisplayPreferences.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using MediaBrowser.Model.Drawing;
  2. using ProtoBuf;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace MediaBrowser.Model.Entities
  6. {
  7. /// <summary>
  8. /// Defines the display preferences for any item that supports them (usually Folders)
  9. /// </summary>
  10. [ProtoContract]
  11. public class DisplayPreferences
  12. {
  13. /// <summary>
  14. /// The image scale
  15. /// </summary>
  16. private const double ImageScale = .9;
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="DisplayPreferences" /> class.
  19. /// </summary>
  20. public DisplayPreferences()
  21. {
  22. ViewType = ViewTypes.Poster;
  23. PrimaryImageType = ImageType.Primary;
  24. RememberIndexing = false;
  25. PrimaryImageHeight = 250;
  26. PrimaryImageWidth = 250;
  27. CustomPrefs = new Dictionary<string, string>();
  28. }
  29. /// <summary>
  30. /// Gets or sets the user id.
  31. /// </summary>
  32. /// <value>The user id.</value>
  33. [ProtoMember(1)]
  34. public Guid UserId { get; set; }
  35. /// <summary>
  36. /// Gets or sets the type of the view.
  37. /// </summary>
  38. /// <value>The type of the view.</value>
  39. [ProtoMember(2)]
  40. public ViewTypes ViewType { get; set; }
  41. /// <summary>
  42. /// Gets or sets the type of the primary image.
  43. /// </summary>
  44. /// <value>The type of the primary image.</value>
  45. [ProtoMember(3)]
  46. public ImageType PrimaryImageType { get; set; }
  47. /// <summary>
  48. /// Gets or sets the sort by.
  49. /// </summary>
  50. /// <value>The sort by.</value>
  51. [ProtoMember(4)]
  52. public string SortBy { get; set; }
  53. /// <summary>
  54. /// Gets or sets the index by.
  55. /// </summary>
  56. /// <value>The index by.</value>
  57. [ProtoMember(5)]
  58. public string IndexBy { get; set; }
  59. /// <summary>
  60. /// Gets or sets a value indicating whether [remember indexing].
  61. /// </summary>
  62. /// <value><c>true</c> if [remember indexing]; otherwise, <c>false</c>.</value>
  63. [ProtoMember(6)]
  64. public bool RememberIndexing { get; set; }
  65. /// <summary>
  66. /// Gets or sets the height of the primary image.
  67. /// </summary>
  68. /// <value>The height of the primary image.</value>
  69. [ProtoMember(7)]
  70. public int PrimaryImageHeight { get; set; }
  71. /// <summary>
  72. /// Gets or sets the width of the primary image.
  73. /// </summary>
  74. /// <value>The width of the primary image.</value>
  75. [ProtoMember(8)]
  76. public int PrimaryImageWidth { get; set; }
  77. /// <summary>
  78. /// Gets or sets the custom prefs.
  79. /// </summary>
  80. /// <value>The custom prefs.</value>
  81. [ProtoMember(9)]
  82. public Dictionary<string, string> CustomPrefs { get; set; }
  83. /// <summary>
  84. /// Gets or sets the scroll direction.
  85. /// </summary>
  86. /// <value>The scroll direction.</value>
  87. [ProtoMember(10)]
  88. public ScrollDirection ScrollDirection { get; set; }
  89. /// <summary>
  90. /// Gets or sets a value indicating whether [remember sorting].
  91. /// </summary>
  92. /// <value><c>true</c> if [remember sorting]; otherwise, <c>false</c>.</value>
  93. [ProtoMember(11)]
  94. public bool RememberSorting { get; set; }
  95. /// <summary>
  96. /// Gets or sets the sort order.
  97. /// </summary>
  98. /// <value>The sort order.</value>
  99. [ProtoMember(12)]
  100. public SortOrder SortOrder { get; set; }
  101. /// <summary>
  102. /// Increases the size of the image.
  103. /// </summary>
  104. public void IncreaseImageSize()
  105. {
  106. var newWidth = PrimaryImageWidth / ImageScale;
  107. var size = DrawingUtils.Resize(PrimaryImageWidth, PrimaryImageHeight, newWidth);
  108. PrimaryImageWidth = Convert.ToInt32(size.Width);
  109. PrimaryImageHeight = Convert.ToInt32(size.Height);
  110. }
  111. /// <summary>
  112. /// Decreases the size of the image.
  113. /// </summary>
  114. public void DecreaseImageSize()
  115. {
  116. var size = DrawingUtils.Scale(PrimaryImageWidth, PrimaryImageHeight, ImageScale);
  117. PrimaryImageWidth = Convert.ToInt32(size.Width);
  118. PrimaryImageHeight = Convert.ToInt32(size.Height);
  119. }
  120. }
  121. /// <summary>
  122. /// Enum ViewTypes
  123. /// </summary>
  124. public enum ViewTypes
  125. {
  126. /// <summary>
  127. /// The poster
  128. /// </summary>
  129. Poster,
  130. /// <summary>
  131. /// The cover flow
  132. /// </summary>
  133. CoverFlow,
  134. /// <summary>
  135. /// The thumb strip
  136. /// </summary>
  137. ThumbStrip,
  138. /// <summary>
  139. /// The list
  140. /// </summary>
  141. List
  142. }
  143. /// <summary>
  144. /// Enum ScrollDirection
  145. /// </summary>
  146. public enum ScrollDirection
  147. {
  148. /// <summary>
  149. /// The horizontal
  150. /// </summary>
  151. Horizontal,
  152. /// <summary>
  153. /// The vertical
  154. /// </summary>
  155. Vertical
  156. }
  157. /// <summary>
  158. /// Enum SortOrder
  159. /// </summary>
  160. public enum SortOrder
  161. {
  162. /// <summary>
  163. /// The ascending
  164. /// </summary>
  165. Ascending,
  166. /// <summary>
  167. /// The descending
  168. /// </summary>
  169. Descending
  170. }
  171. }