Ejemplo n.º 1
0
        private void Import_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                CheckFileExists = true,
                DefaultExt      = ".xlsx",
                Multiselect     = true,
            };

            if ((dialog.ShowDialog() ?? false) && dialog.FileNames.Any())
            {
                MainViewModel.Instance.Models.SuccessfulImport = false;

                MainViewModel.Instance.Models.ImportText = "Import réussi :";

                ImportProgressBar.Visibility = Visibility.Visible;
                ImportProgressBar.Value      = 0;
                int fileCount = 0;
                foreach (string file in dialog.FileNames)
                {
                    ExportUtils.Import(file);
                    fileCount++;
                    Dispatcher.Invoke(_updateImport, System.Windows.Threading.DispatcherPriority.Background, fileCount * 1000 / dialog.FileNames.Length);
                    MainViewModel.Instance.Models.ImportText += $"\r\n{Path.GetFileNameWithoutExtension(file)}";
                }
                ImportProgressBar.Visibility = Visibility.Collapsed;

                MainViewModel.Instance.Models.SuccessfulImport = true;
            }
        }