aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI/Controls/WindowCommands.xaml.cs
blob: e285cced1266756e993249abfd5f1e5b4af85f76 (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
using System.Windows;
using System.Windows.Controls;

namespace MediaBrowser.UI.Controls
{
    /// <summary>
    /// Interaction logic for WindowCommands.xaml
    /// </summary>
    public partial class WindowCommands : UserControl
    {
        /// <summary>
        /// Gets the parent window.
        /// </summary>
        /// <value>The parent window.</value>
        public Window ParentWindow
        {
            get { return TreeHelper.TryFindParent<Window>(this); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="WindowCommands" /> class.
        /// </summary>
        public WindowCommands()
        {
            InitializeComponent();
            Loaded += WindowCommandsLoaded;
        }

        /// <summary>
        /// Windows the commands loaded.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void WindowCommandsLoaded(object sender, RoutedEventArgs e)
        {
            CloseApplicationButton.Click += CloseApplicationButtonClick;
            MinimizeApplicationButton.Click += MinimizeApplicationButtonClick;
            MaximizeApplicationButton.Click += MaximizeApplicationButtonClick;
            UndoMaximizeApplicationButton.Click += UndoMaximizeApplicationButtonClick;
        }

        /// <summary>
        /// Undoes the maximize application button click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void UndoMaximizeApplicationButtonClick(object sender, RoutedEventArgs e)
        {
            ParentWindow.WindowState = WindowState.Normal;
        }

        /// <summary>
        /// Maximizes the application button click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void MaximizeApplicationButtonClick(object sender, RoutedEventArgs e)
        {
            ParentWindow.WindowState = WindowState.Maximized;
        }

        /// <summary>
        /// Minimizes the application button click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void MinimizeApplicationButtonClick(object sender, RoutedEventArgs e)
        {
            ParentWindow.WindowState = WindowState.Minimized;
        }

        /// <summary>
        /// Closes the application button click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        void CloseApplicationButtonClick(object sender, RoutedEventArgs e)
        {
            App.Instance.Shutdown();
        }
    }
}