MainPage.xaml.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using MediaBrowser.Model.Entities;
  2. using System.Windows;
  3. namespace MediaBrowser.Plugins.DefaultTheme.DisplayPreferences
  4. {
  5. /// <summary>
  6. /// Interaction logic for MainPage.xaml
  7. /// </summary>
  8. public partial class MainPage : BaseDisplayPreferencesPage
  9. {
  10. /// <summary>
  11. /// Initializes a new instance of the <see cref="MainPage" /> class.
  12. /// </summary>
  13. public MainPage()
  14. {
  15. InitializeComponent();
  16. btnScroll.Click += btnScroll_Click;
  17. btnIncrease.Click += btnIncrease_Click;
  18. btnDecrease.Click += btnDecrease_Click;
  19. ViewMenuButton.Click += ViewMenuButton_Click;
  20. SortMenuButton.Click += SortMenuButton_Click;
  21. IndexMenuButton.Click += IndexMenuButton_Click;
  22. }
  23. /// <summary>
  24. /// Handles the Click event of the IndexMenuButton control.
  25. /// </summary>
  26. /// <param name="sender">The source of the event.</param>
  27. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  28. void IndexMenuButton_Click(object sender, RoutedEventArgs e)
  29. {
  30. DisplayPreferencesWindow.NavigateToIndexMenu();
  31. }
  32. /// <summary>
  33. /// Handles the Click event of the SortMenuButton control.
  34. /// </summary>
  35. /// <param name="sender">The source of the event.</param>
  36. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  37. void SortMenuButton_Click(object sender, RoutedEventArgs e)
  38. {
  39. DisplayPreferencesWindow.NavigateToSortMenu();
  40. }
  41. /// <summary>
  42. /// Called when [loaded].
  43. /// </summary>
  44. protected override void OnLoaded()
  45. {
  46. base.OnLoaded();
  47. UpdateFields();
  48. }
  49. /// <summary>
  50. /// Handles the Click event of the ViewMenuButton control.
  51. /// </summary>
  52. /// <param name="sender">The source of the event.</param>
  53. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  54. void ViewMenuButton_Click(object sender, RoutedEventArgs e)
  55. {
  56. DisplayPreferencesWindow.NavigateToViewMenu();
  57. }
  58. /// <summary>
  59. /// Handles the Click event of the btnDecrease control.
  60. /// </summary>
  61. /// <param name="sender">The source of the event.</param>
  62. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  63. void btnDecrease_Click(object sender, RoutedEventArgs e)
  64. {
  65. MainPage.DisplayPreferences.DecreaseImageSize();
  66. MainPage.NotifyDisplayPreferencesChanged();
  67. }
  68. /// <summary>
  69. /// Handles the Click event of the btnIncrease control.
  70. /// </summary>
  71. /// <param name="sender">The source of the event.</param>
  72. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  73. void btnIncrease_Click(object sender, RoutedEventArgs e)
  74. {
  75. MainPage.DisplayPreferences.IncreaseImageSize();
  76. MainPage.NotifyDisplayPreferencesChanged();
  77. }
  78. /// <summary>
  79. /// Handles the Click event of the btnScroll control.
  80. /// </summary>
  81. /// <param name="sender">The source of the event.</param>
  82. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  83. void btnScroll_Click(object sender, RoutedEventArgs e)
  84. {
  85. MainPage.DisplayPreferences.ScrollDirection = MainPage.DisplayPreferences.ScrollDirection == ScrollDirection.Horizontal
  86. ? ScrollDirection.Vertical
  87. : ScrollDirection.Horizontal;
  88. MainPage.NotifyDisplayPreferencesChanged();
  89. UpdateFields();
  90. }
  91. /// <summary>
  92. /// Updates the fields.
  93. /// </summary>
  94. private void UpdateFields()
  95. {
  96. var displayPreferences = MainPage.DisplayPreferences;
  97. btnScroll.Visibility = displayPreferences.ViewType == ViewTypes.Poster
  98. ? Visibility.Visible
  99. : Visibility.Collapsed;
  100. txtScrollDirection.Text = displayPreferences.ScrollDirection == ScrollDirection.Horizontal ? "Scroll: Horizontal" : "Scroll: Vertical";
  101. }
  102. }
  103. }