Menu.xaml.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace kursach.Windows
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для Menu.xaml
  18. /// </summary>
  19. public partial class Menu : Window
  20. {
  21. public static int UserId = 0;
  22. public Menu()
  23. {
  24. InitializeComponent();
  25. }
  26. private void Back(object sender, RoutedEventArgs e)
  27. {
  28. //вернуться назад
  29. this.Close();
  30. }
  31. private void Auth(object sender, RoutedEventArgs e)
  32. {
  33. if(Menu.UserId != 0)
  34. {
  35. MessageBox.Show("Вы уже вошли, переходим в профиль...");
  36. Windows.Account acc = new Windows.Account(UserId);
  37. acc.Show();
  38. foreach(var wnd in Application.Current.Windows)
  39. {
  40. if (wnd is MainWindow)
  41. {
  42. MainWindow boofWnd = (MainWindow)wnd;
  43. boofWnd.Close();
  44. }
  45. }
  46. Close();
  47. }
  48. else
  49. {
  50. //перейти к авторизации
  51. Windows.Auth auth = new Windows.Auth();
  52. auth.Show();
  53. foreach (var wnd in Application.Current.Windows)
  54. {
  55. if (wnd is MainWindow)
  56. {
  57. MainWindow boofWnd = (MainWindow)wnd;
  58. boofWnd.Close();
  59. }
  60. }
  61. Close();
  62. }
  63. }
  64. private void Search(object sender, RoutedEventArgs e)
  65. {
  66. //перейти к поиску
  67. Windows.Search search = new Windows.Search();
  68. search.Show();
  69. foreach (var wnd in Application.Current.Windows)
  70. {
  71. if (wnd is MainWindow)
  72. {
  73. MainWindow boofWnd = (MainWindow)wnd;
  74. boofWnd.Close();
  75. }
  76. }
  77. Close();
  78. }
  79. }
  80. }