Example #1
0
 private async void BtnReloadData_Click(object sender, RoutedEventArgs e)
 {
     btnReloadData.IsEnabled         = false;
     prgrsReloadData.IsIndeterminate = true;
     if (btnSourceFile.IsChecked == true)
     {
         string dataSourcePath = txtDataSource.Text;
         if (File.Exists(dataSourcePath) == false)
         {
             MessageBox.Show($"File {dataSourcePath} doesn't exist.", "Non-Exsiting file.", MessageBoxButton.OK, MessageBoxImage.Error);
             btnReloadData.IsEnabled         = true;
             prgrsReloadData.IsIndeterminate = false;
             return;
         }
         _classes.Clear();
         _classes = new List <UClass>(await UClass.FromFile(dataSourcePath));
     }
     else
     {
         _classes = new List <UClass>((await ProposedCoursesParser.GetClasses((USemester)cbxSemester.SelectedItem, udYear.Value)).OrderBy(c => c.Course.Id));
     }
     lstClasses.Dispatcher.Invoke(() =>
     {
         ReloadClassesModelsAndUpdateClassesList();
         btnReloadData.IsEnabled         = true;
         prgrsReloadData.IsIndeterminate = false;
         GC.Collect(3, GCCollectionMode.Forced, true, true);
     });
 }
        private async void BtnLoadSelection_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                Filter           = "JSON File (*.json)|*.json",
                AddExtension     = true,
                CheckFileExists  = false,
                DefaultExt       = ".json",
                Multiselect      = false,
                ValidateNames    = true,
                Title            = "Classes file",
                DereferenceLinks = true
            };

            if (ofd.ShowDialog() == false)
            {
                return;
            }
            UClass[] newSelection = await UClass.FromFile(ofd.FileName);

            ClearSelection();
            foreach (var selectedClass in newSelection)
            {
                _classesModels[selectedClass.Id].IsIncluded = true;
                AddMandatoryCourse(selectedClass.Course);
            }

            UpdateClassesListView();
        }