コード例 #1
0
        private async void DeleteDeltaFiles(object arg)
        {
            _deletionBusy = true;

            Progress <DeletionProgressReportModel> progress = new Progress <DeletionProgressReportModel>();

            progress.ProgressChanged += ProgressReportedEventHandler;

            MyDeletedFilesNo   = 0;
            MyDeletionProgress = 0;
            string msg = "completed";

            _cts = new CancellationTokenSource();
            try
            {
                if (RSSettingsModel.Instance.DeletePromptSetting)
                {
                    await DeleteDeltaFilesAsync(progress, _cts.Token);
                }
                else
                {
                    await QuickDeleteDeltaFilesAsync(progress, _cts.Token);
                }
            }
            catch (OperationCanceledException)
            {
                msg = "cancelled";
            }
            _cts.Dispose();

            if (RSSettingsModel.Instance.DeletePromptSetting == false)
            {
                // We are using quick parallel delete method (which may have been cancelled) - remove actually deleted items 'manually', when the above loop finishes
                foreach (var fd in SessionDeletedFiles)
                {
                    MyDeltaFiles.Remove(fd);
                    QualifiedRawNo--;
                }
                MyDeltaFilesView.Refresh();

                SessionDeletedFiles.Clear();

                OnPropertyRaised("MyDeltaFilesNo");
                OnPropertyRaised("MyRejectionRatio");
            }
            // We have done what we could, now
            // Fire the FilesDeleted Event so that the Main Window can update its raw list view, and
            // if the confirmation option is set, inform the user about the outcome of deletion.
            FilesDeletedEvent();
            if (RSSettingsModel.Instance.DeletePromptSetting)
            {
                WWMessageBox.Show($"Deletion { msg }.\nDeleted { MyDeletedFilesNo } file(s).", "Information", CustomMessageBoxButton.OK, MessageBoxImage.Information);
            }

            _deletionBusy = false;
            return;
        }
コード例 #2
0
        private async Task DeleteDeltaFilesAsync(IProgress <DeletionProgressReportModel> progress, CancellationToken cancellationToken)
        {
            DeletionProgressReportModel progressReport = new DeletionProgressReportModel(MyDeltaFiles.Count);
            bool ContinueAsking = true;

            List <FileDescriptorModel> IterationListCopy = new List <FileDescriptorModel>();

            for (int i = MyDeltaFiles.Count - 1; i >= 0; i--)
            {
                var fd = MyDeltaFiles[i];
                if (ContinueAsking)
                {
                    // ask user to confirm deletion in modal message box, by checking the returned result (Cancel, Skip, Delete, Delete All)
                    MessageBoxResult result = WWMessageBox.ShowOKYesNoCancel($"Confirm deletion of the file:\n{ fd.FullName }", "User decision required", "Delete All", "Delete this one", "Skip", "Cancel", MessageBoxImage.Question);
                    switch (result)
                    {
                    case MessageBoxResult.OK:
                        ContinueAsking = false;
                        break;

                    case MessageBoxResult.Yes:
                        break;

                    case MessageBoxResult.No:
                        continue;

                    case MessageBoxResult.Cancel:
                        return;

                    default:
                        break;
                    }
                }

                await Task.Run(() => DeleteSingleDeltaFile(fd));

                progressReport.DeletedFilesNo++;
                progressReport.CurrentFd = fd;

                progress.Report(progressReport);
                cancellationToken.ThrowIfCancellationRequested();
            }

            return;
        }
コード例 #3
0
        private void GetFolderListing()
        {
            if (!Directory.Exists(FolderPath))
            {
                // Don't throw any exceptions, just inform the user and fallback to default folder, so he can change it later

                // This sometimes is called at startup, before MainWindow is created,
                // For this occasion, App.xaml.cs needs to modify ShutdownMode and MainWindow Application properties.

                WWMessageBox.Show($"GetFolderListing(): Folder does not exist:\n{ FolderPath }\nChanging to default...", "RAW Sync v. 3.0: Warning", CustomMessageBoxButton.OK, MessageBoxImage.Warning);
                FolderPath = _folder; // Fallback to default
            }

            string[] FileEntries = Directory.GetFiles(FolderPath);

            foreach (string s in FileEntries)
            {
                FileDescriptorModel fd = new FileDescriptorModel();
                fd.FilePath = s;
                FileList.Add(fd);
                fd.Id = FileList.Count;
            }
            return;
        }
コード例 #4
0
 private void ProgramHelp(object arg)
 {
     WWMessageBox.Show("Raw Sync 3.0:\n\nSafely delete rejected RAW files,\nbased on matching the list of Processed files.\n\n© 2020 by Wojtek Wasiukiewicz.", "Help", CustomMessageBoxButton.OK, MessageBoxImage.Information);
 }