DisplayPreferences.cs 5.0 KB

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