using System.Windows; using System.Windows.Controls; namespace MediaBrowser.UI.Controls { /// /// Interaction logic for WindowCommands.xaml /// public partial class WindowCommands : UserControl { /// /// Gets the parent window. /// /// The parent window. public Window ParentWindow { get { return TreeHelper.TryFindParent(this); } } /// /// Initializes a new instance of the class. /// public WindowCommands() { InitializeComponent(); Loaded += WindowCommandsLoaded; } /// /// Windows the commands loaded. /// /// The sender. /// The instance containing the event data. void WindowCommandsLoaded(object sender, RoutedEventArgs e) { CloseApplicationButton.Click += CloseApplicationButtonClick; MinimizeApplicationButton.Click += MinimizeApplicationButtonClick; MaximizeApplicationButton.Click += MaximizeApplicationButtonClick; UndoMaximizeApplicationButton.Click += UndoMaximizeApplicationButtonClick; } /// /// Undoes the maximize application button click. /// /// The sender. /// The instance containing the event data. void UndoMaximizeApplicationButtonClick(object sender, RoutedEventArgs e) { ParentWindow.WindowState = WindowState.Normal; } /// /// Maximizes the application button click. /// /// The sender. /// The instance containing the event data. void MaximizeApplicationButtonClick(object sender, RoutedEventArgs e) { ParentWindow.WindowState = WindowState.Maximized; } /// /// Minimizes the application button click. /// /// The sender. /// The instance containing the event data. void MinimizeApplicationButtonClick(object sender, RoutedEventArgs e) { ParentWindow.WindowState = WindowState.Minimized; } /// /// Closes the application button click. /// /// The sender. /// The instance containing the event data. void CloseApplicationButtonClick(object sender, RoutedEventArgs e) { App.Instance.Shutdown(); } } }