DisplayPreferences.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using MediaBrowser.Model.Drawing;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MediaBrowser.Model.Entities
  5. {
  6. /// <summary>
  7. /// Defines the display preferences for any item that supports them (usually Folders)
  8. /// </summary>
  9. public class DisplayPreferences
  10. {
  11. /// <summary>
  12. /// The image scale
  13. /// </summary>
  14. private const double ImageScale = .9;
  15. /// <summary>
  16. /// Initializes a new instance of the <see cref="DisplayPreferences" /> class.
  17. /// </summary>
  18. public DisplayPreferences()
  19. {
  20. RememberIndexing = false;
  21. PrimaryImageHeight = 250;
  22. PrimaryImageWidth = 250;
  23. CustomPrefs = new Dictionary<string, string>();
  24. }
  25. /// <summary>
  26. /// Gets or sets the user id.
  27. /// </summary>
  28. /// <value>The user id.</value>
  29. public Guid Id { get; set; }
  30. /// <summary>
  31. /// Gets or sets the type of the view.
  32. /// </summary>
  33. /// <value>The type of the view.</value>
  34. public string ViewType { get; set; }
  35. /// <summary>
  36. /// Gets or sets the sort by.
  37. /// </summary>
  38. /// <value>The sort by.</value>
  39. public string SortBy { get; set; }
  40. /// <summary>
  41. /// Gets or sets the index by.
  42. /// </summary>
  43. /// <value>The index by.</value>
  44. public string IndexBy { get; set; }
  45. /// <summary>
  46. /// Gets or sets a value indicating whether [remember indexing].
  47. /// </summary>
  48. /// <value><c>true</c> if [remember indexing]; otherwise, <c>false</c>.</value>
  49. public bool RememberIndexing { get; set; }
  50. /// <summary>
  51. /// Gets or sets the height of the primary image.
  52. /// </summary>
  53. /// <value>The height of the primary image.</value>
  54. public int PrimaryImageHeight { get; set; }
  55. /// <summary>
  56. /// Gets or sets the width of the primary image.
  57. /// </summary>
  58. /// <value>The width of the primary image.</value>
  59. public int PrimaryImageWidth { get; set; }
  60. /// <summary>
  61. /// Gets or sets the custom prefs.
  62. /// </summary>
  63. /// <value>The custom prefs.</value>
  64. public Dictionary<string, string> CustomPrefs { get; set; }
  65. /// <summary>
  66. /// Gets or sets the scroll direction.
  67. /// </summary>
  68. /// <value>The scroll direction.</value>
  69. public ScrollDirection ScrollDirection { get; set; }
  70. /// <summary>
  71. /// Gets or sets a value indicating whether [remember sorting].
  72. /// </summary>
  73. /// <value><c>true</c> if [remember sorting]; otherwise, <c>false</c>.</value>
  74. public bool RememberSorting { get; set; }
  75. /// <summary>
  76. /// Gets or sets the sort order.
  77. /// </summary>
  78. /// <value>The sort order.</value>
  79. public SortOrder SortOrder { get; set; }
  80. /// <summary>
  81. /// Increases the size of the image.
  82. /// </summary>
  83. public void IncreaseImageSize()
  84. {
  85. var newWidth = PrimaryImageWidth / ImageScale;
  86. var size = DrawingUtils.Resize(PrimaryImageWidth, PrimaryImageHeight, newWidth);
  87. PrimaryImageWidth = Convert.ToInt32(size.Width);
  88. PrimaryImageHeight = Convert.ToInt32(size.Height);
  89. }
  90. /// <summary>
  91. /// Decreases the size of the image.
  92. /// </summary>
  93. public void DecreaseImageSize()
  94. {
  95. var size = DrawingUtils.Scale(PrimaryImageWidth, PrimaryImageHeight, ImageScale);
  96. PrimaryImageWidth = Convert.ToInt32(size.Width);
  97. PrimaryImageHeight = Convert.ToInt32(size.Height);
  98. }
  99. }
  100. /// <summary>
  101. /// Enum ScrollDirection
  102. /// </summary>
  103. public enum ScrollDirection
  104. {
  105. /// <summary>
  106. /// The horizontal
  107. /// </summary>
  108. Horizontal,
  109. /// <summary>
  110. /// The vertical
  111. /// </summary>
  112. Vertical
  113. }
  114. /// <summary>
  115. /// Enum SortOrder
  116. /// </summary>
  117. public enum SortOrder
  118. {
  119. /// <summary>
  120. /// The ascending
  121. /// </summary>
  122. Ascending,
  123. /// <summary>
  124. /// The descending
  125. /// </summary>
  126. Descending
  127. }
  128. }