ForestWindow.xaml.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Firewatch_2._0
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для ForestWindow.xaml
  18. /// </summary>
  19. public partial class ForestWindow : Window
  20. {
  21. public ForestWindow()
  22. {
  23. InitializeComponent();
  24. DataContext = new Forest();
  25. }
  26. public ForestWindow(Forest forest)
  27. {
  28. InitializeComponent();
  29. DataContext = forest;
  30. }
  31. private void Forest_OK(object sender, RoutedEventArgs e)
  32. {
  33. if (DataContext is Forest forest && forest.Forest_ID== 0)
  34. {
  35. Helper.context.Forests.Add(forest);
  36. }
  37. Helper.context.SaveChanges();
  38. Close();
  39. }
  40. private void Forest_Close(object sender, RoutedEventArgs e)
  41. {
  42. Close();
  43. }
  44. }
  45. }