DisplayPreferences.cs 4.6 KB

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