MainWindow.xaml.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. namespace GDNXFD.Alert.Config.Views
  2. {
  3. using GDNXFD.Alert.Config.ViewModel;
  4. using System;
  5. using System.ComponentModel;
  6. using System.Windows;
  7. using System.Windows.Input;
  8. using GDNXFD.Alert.Config.Services.Navigation;
  9. using Data;
  10. /// <summary>
  11. /// Interaction logic for MainWindow.xaml
  12. /// </summary>
  13. public partial class MainWindow : Window
  14. {
  15. private bool isReady = false;
  16. private INavigationService navSvc;
  17. /// <summary>
  18. /// main Window constructor
  19. /// </summary>
  20. public MainWindow()
  21. {
  22. var vm = ViewModelLocator.Instance.Main;// (MainViewModel)this.DataContext;
  23. this.DataContext = vm;
  24. InitializeComponent();
  25. vm.InitializeData();
  26. navSvc = ViewModelLocator.Instance.NavService;
  27. isReady = true;
  28. }
  29. private void Window_Closing(object sender, CancelEventArgs e)
  30. {
  31. //if (!String.IsNullOrWhiteSpace(SecurityService.AccessToken))
  32. //{
  33. // e.Cancel = true;
  34. // var task = SecurityService.Logout();
  35. //}
  36. }
  37. private void MainWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  38. {
  39. if (e.ClickCount == 2)
  40. {
  41. if (this.WindowState == System.Windows.WindowState.Maximized)
  42. this.WindowState = System.Windows.WindowState.Normal;
  43. else
  44. this.WindowState = System.Windows.WindowState.Maximized;
  45. }
  46. this.DragMove();
  47. }
  48. private void MinimizeButton(object sender, RoutedEventArgs e)
  49. {
  50. this.WindowState = WindowState.Minimized;
  51. }
  52. private void MaximizeButton(object sender, RoutedEventArgs e)
  53. {
  54. if (WindowState == WindowState.Normal)
  55. {
  56. this.WindowState = System.Windows.WindowState.Maximized;
  57. }
  58. else
  59. {
  60. this.WindowState = System.Windows.WindowState.Normal;
  61. }
  62. }
  63. private void CloseButton(object sender, RoutedEventArgs e)
  64. {
  65. this.Close();
  66. }
  67. private void rbtnCustom_Checked(object sender, RoutedEventArgs e)
  68. {
  69. if (isReady == false)
  70. return;
  71. navSvc.NavigateToRuleList();
  72. }
  73. private void rbtnDI_Checked(object sender, RoutedEventArgs e)
  74. {
  75. navSvc.NavigateToDIList();
  76. }
  77. }
  78. }