aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/MainPage.xaml.cs
blob: ffe269f77069203b7f77d5246e19ac343af74e93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using MediaBrowser.Model.Entities;
using System.Windows;

namespace MediaBrowser.Plugins.DefaultTheme.DisplayPreferences
{
    /// <summary>
    /// Interaction logic for MainPage.xaml
    /// </summary>
    public partial class MainPage : BaseDisplayPreferencesPage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage" /> class.
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            btnScroll.Click += btnScroll_Click;
            btnIncrease.Click += btnIncrease_Click;
            btnDecrease.Click += btnDecrease_Click;
            ViewMenuButton.Click += ViewMenuButton_Click;
            SortMenuButton.Click += SortMenuButton_Click;
            IndexMenuButton.Click += IndexMenuButton_Click;
        }

        /// <summary>
        /// Handles the Click event of the IndexMenuButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void IndexMenuButton_Click(object sender, RoutedEventArgs e)
        {
            DisplayPreferencesWindow.NavigateToIndexMenu();
        }

        /// <summary>
        /// Handles the Click event of the SortMenuButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void SortMenuButton_Click(object sender, RoutedEventArgs e)
        {
            DisplayPreferencesWindow.NavigateToSortMenu();
        }

        /// <summary>
        /// Called when [loaded].
        /// </summary>
        protected override void OnLoaded()
        {
            base.OnLoaded();

            UpdateFields();
        }

        /// <summary>
        /// Handles the Click event of the ViewMenuButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void ViewMenuButton_Click(object sender, RoutedEventArgs e)
        {
            DisplayPreferencesWindow.NavigateToViewMenu();
        }

        /// <summary>
        /// Handles the Click event of the btnDecrease control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void btnDecrease_Click(object sender, RoutedEventArgs e)
        {
            MainPage.DisplayPreferences.DecreaseImageSize();
            MainPage.NotifyDisplayPreferencesChanged();
        }

        /// <summary>
        /// Handles the Click event of the btnIncrease control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void btnIncrease_Click(object sender, RoutedEventArgs e)
        {
            MainPage.DisplayPreferences.IncreaseImageSize();
            MainPage.NotifyDisplayPreferencesChanged();
        }

        /// <summary>
        /// Handles the Click event of the btnScroll control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void btnScroll_Click(object sender, RoutedEventArgs e)
        {
            MainPage.DisplayPreferences.ScrollDirection = MainPage.DisplayPreferences.ScrollDirection == ScrollDirection.Horizontal
                                                     ? ScrollDirection.Vertical
                                                     : ScrollDirection.Horizontal;

            MainPage.NotifyDisplayPreferencesChanged();
           
            UpdateFields();
        }

        /// <summary>
        /// Updates the fields.
        /// </summary>
        private void UpdateFields()
        {
            var displayPreferences = MainPage.DisplayPreferences;

            btnScroll.Visibility = displayPreferences.ViewType == ViewTypes.Poster
                                       ? Visibility.Visible
                                       : Visibility.Collapsed;

            txtScrollDirection.Text = displayPreferences.ScrollDirection == ScrollDirection.Horizontal ? "Scroll: Horizontal" : "Scroll: Vertical";
        }
    }
}