ProfilePage.xaml.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.Navigation;
  14. using System.Windows.Shapes;
  15. namespace MyTests.Pages
  16. {
  17. public partial class ProfilePage : Page
  18. {
  19. public ProfilePage()
  20. {
  21. InitializeComponent();
  22. TestsLoading();
  23. //EmailBox.Content = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.Email).FirstOrDefault();
  24. //PhoneNumBox.Content = "+7(" + phone.Substring(0, 3) + ")" + phone.Substring(3, 3) + "-" + phone.Substring(6, 2) + "-" + phone.Substring(8, 2);
  25. }
  26. private void EditImageButton_Click(object sender, RoutedEventArgs e)
  27. {
  28. //OpenFileDialog ofd = new OpenFileDialog();
  29. //ofd.DefaultExt = ".png";
  30. //ofd.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg";
  31. //Nullable<bool> result = ofd.ShowDialog();
  32. //if (result == true)
  33. //{
  34. // string filename = ofd.FileName;
  35. // ProfileImg.Source = new BitmapImage(new Uri(filename));
  36. // Dispatcher dispatcher = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).FirstOrDefault();
  37. // dispatcher.ProfileImgSource = filename;
  38. // cnt.db.SaveChanges();
  39. //}
  40. }
  41. private void TestsLoading()
  42. {
  43. foreach (Tests test in cnt.db.Tests.Where(item => item.IdUser == Session.UserId).ToList())
  44. {
  45. try
  46. {
  47. BitmapImage img = test.Image == null ?
  48. new BitmapImage(new Uri("../Resources/StandartProfile.png", UriKind.RelativeOrAbsolute)) :
  49. ImagesManip.NewImage(cnt.db.Users.Where(item => item.IdUser == Session.UserId).FirstOrDefault());
  50. AddTest(test.Name, img, cnt.db.Questions.Where(item => item.IdTest == test.IdTest).Count());
  51. }
  52. catch (Exception ex)
  53. {
  54. new ErrorWindow(ex.ToString()).ShowDialog();
  55. }
  56. }
  57. }
  58. private void AddTest(string name, BitmapImage image, int questCount)
  59. {
  60. //MessageBox.Show($"{name}, quests:, {questCount}");
  61. }
  62. private void SaveButton(object sender, RoutedEventArgs e)
  63. {
  64. }
  65. private void BackButton(object sender, RoutedEventArgs e)
  66. {
  67. }
  68. }
  69. class Test
  70. {
  71. public string Name { get; set; }
  72. public Image Image { get; set; }
  73. public int QuestionsCount { get; set; }
  74. }
  75. }