MainWindow.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using PDF_Office.ViewModels;
  2. using Prism.Regions;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. using Prism.Events;
  18. using PDF_Office.EventAggregators;
  19. using PDF_Office.CustomControl;
  20. using Prism.Ioc;
  21. namespace PDF_Office.Views
  22. {
  23. /// <summary>
  24. /// MainWindow.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class MainWindow : Window
  27. {
  28. public IEventAggregator aggregator;
  29. public IRegionManager region;
  30. public MainWindow()
  31. {
  32. InitializeComponent();
  33. }
  34. /// <summary>
  35. /// 此类因为Dragablz控件的原因需要特殊处理
  36. /// </summary>
  37. /// <param name="eventAggregator"></param>
  38. public MainWindow(IEventAggregator eventAggregator, IContainerProvider container) :this()
  39. {
  40. aggregator = eventAggregator;
  41. eventAggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Opened });
  42. }
  43. private void BtnMiniSize_Click(object sender, RoutedEventArgs e)
  44. {
  45. System.Windows.SystemCommands.MinimizeWindow(this);
  46. }
  47. private void BtnClose_Click(object sender, RoutedEventArgs e)
  48. {
  49. System.Windows.SystemCommands.CloseWindow(this);
  50. }
  51. private void BtnReStore_Click(object sender, RoutedEventArgs e)
  52. {
  53. if (this.WindowState == WindowState.Maximized)
  54. System.Windows.SystemCommands.RestoreWindow(this);
  55. else
  56. System.Windows.SystemCommands.MaximizeWindow(this);
  57. }
  58. private void Window_Activated(object sender, EventArgs e)
  59. {
  60. App.Current.MainWindow = this;
  61. aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Activated });
  62. }
  63. private void Window_Closed(object sender, EventArgs e)
  64. {
  65. aggregator?.GetEvent<DragablzWindowEvent>().Publish(new DragablzWindowEventArgs() { TabControl = TabablzControl, Type = DragablzWindowEventType.Closed });
  66. }
  67. }
  68. }