public Results(Wizard sb)
        {
            InitializeComponent();

            _fixTask = new Task(FixProblems);

            ScanBase = sb;

            // Update last scan stats
            var elapsedTime = DateTime.Now.Subtract(Wizard.ScanStartTime).Ticks;

            ResetInfo();

            ListViewFiles.AutoResizeColumns();
        }
Exemplo n.º 2
0
        private void PopulateListView()
        {
            DirectoryInfo di;

            try
            {
                di = new DirectoryInfo(Settings.Default.OptionsBackupDir);

                // If directory doesnt exist -> create it
                if (!di.Exists)
                {
                    di.Create();
                }

                // If list is already populated -> clear it
                if (RestoreFiles.Count > 0)
                {
                    RestoreFiles.Clear();
                }
            }
            catch (Exception ex)
            {
                string message =
                    $"Unable to get files from backup directory.\nThe following error occurred: {ex.Message}";
                MessageBox.Show(Application.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK,
                                MessageBoxImage.Error);

                return;
            }

            foreach (
                var fi in
                di.GetFiles().Where(fi => string.Compare(fi.Extension, ".bakx", StringComparison.Ordinal) == 0))
            {
                // Deserialize to creation date
                using (var backupReg = new BackupRegistry(fi.FullName))
                {
                    if (!backupReg.Open(true))
                    {
                        continue;
                    }

                    string error;
                    if (!backupReg.Deserialize(out error))
                    {
                        continue;
                    }

                    _restoreFiles.Add(new RestoreFile(fi, backupReg.Created));
                }
            }

            // Refresh listview
            ListViewFiles.Items.Refresh();

            // Auto resize columns
            if (ListViewFiles.Items.Count > 0)
            {
                ListViewFiles.AutoResizeColumns();
            }
        }