WindowCommands.xaml.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. namespace MediaBrowser.UI.Controls
  4. {
  5. /// <summary>
  6. /// Interaction logic for WindowCommands.xaml
  7. /// </summary>
  8. public partial class WindowCommands : UserControl
  9. {
  10. /// <summary>
  11. /// Gets the parent window.
  12. /// </summary>
  13. /// <value>The parent window.</value>
  14. public Window ParentWindow
  15. {
  16. get { return TreeHelper.TryFindParent<Window>(this); }
  17. }
  18. /// <summary>
  19. /// Initializes a new instance of the <see cref="WindowCommands" /> class.
  20. /// </summary>
  21. public WindowCommands()
  22. {
  23. InitializeComponent();
  24. Loaded += WindowCommandsLoaded;
  25. }
  26. /// <summary>
  27. /// Windows the commands loaded.
  28. /// </summary>
  29. /// <param name="sender">The sender.</param>
  30. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  31. void WindowCommandsLoaded(object sender, RoutedEventArgs e)
  32. {
  33. CloseApplicationButton.Click += CloseApplicationButtonClick;
  34. MinimizeApplicationButton.Click += MinimizeApplicationButtonClick;
  35. MaximizeApplicationButton.Click += MaximizeApplicationButtonClick;
  36. UndoMaximizeApplicationButton.Click += UndoMaximizeApplicationButtonClick;
  37. }
  38. /// <summary>
  39. /// Undoes the maximize application button click.
  40. /// </summary>
  41. /// <param name="sender">The sender.</param>
  42. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  43. void UndoMaximizeApplicationButtonClick(object sender, RoutedEventArgs e)
  44. {
  45. ParentWindow.WindowState = WindowState.Normal;
  46. }
  47. /// <summary>
  48. /// Maximizes the application button click.
  49. /// </summary>
  50. /// <param name="sender">The sender.</param>
  51. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  52. void MaximizeApplicationButtonClick(object sender, RoutedEventArgs e)
  53. {
  54. ParentWindow.WindowState = WindowState.Maximized;
  55. }
  56. /// <summary>
  57. /// Minimizes the application button click.
  58. /// </summary>
  59. /// <param name="sender">The sender.</param>
  60. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  61. void MinimizeApplicationButtonClick(object sender, RoutedEventArgs e)
  62. {
  63. ParentWindow.WindowState = WindowState.Minimized;
  64. }
  65. /// <summary>
  66. /// Closes the application button click.
  67. /// </summary>
  68. /// <param name="sender">The sender.</param>
  69. /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
  70. void CloseApplicationButtonClick(object sender, RoutedEventArgs e)
  71. {
  72. App.Instance.Shutdown();
  73. }
  74. }
  75. }