12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using OUP.ForOUP;
- using OUP.Services;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace OUP
- {
- /// <summary>
- /// Логика взаимодействия для OUP.xaml
- /// </summary>
- public partial class OUP : Window
- {
- private readonly string PATH = $"{Environment.CurrentDirectory}\\todoDataList";
- private BindingList<Descriptions> _todoDataList;
- private FileService _fileService;
- public OUP()
- {
- InitializeComponent();
- }
-
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- _fileService = new FileService(PATH);
- try
- {
- _todoDataList = _fileService.LoadData();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- Close();
- }
-
- Supply.ItemsSource = _todoDataList;
- _todoDataList.ListChanged += _todoDataList_ListChanged;
- }
- private void _todoDataList_ListChanged(object sender, ListChangedEventArgs e)
- {
- if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged)
- {
- try
- {
- _fileService.SaveData(sender);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- Close();
- }
- }
- }
- }
- }
|