Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        private void RemoveDeleteListItem(object arg)
        {
            // Last chance to avoid deleting a file from MyDeltaFiles - remove it from the list.
            if (arg != null && (int)arg > -1)
            {
                FileDescriptorModel fdv = (FileDescriptorModel)MyDeltaFilesView.CurrentItem;
                if (fdv != null)
                {
                    // Remove only from Delta list, leave the rest of collections/lists alone...
                    MyDeltaFiles.Remove(fdv);
                    MyDeltaFilesView.MoveCurrentTo(null);

                    OnPropertyRaised("MyDeltaFilesNo");
                    OnPropertyRaised("MyRejectionRatio");
                }
            }
        }
Ejemplo n.º 3
0
        private void ProgressReportedEventHandler(object sender, DeletionProgressReportModel e)
        {
            MyDeletedFilesNo   = e.DeletedFilesNo;
            MyDeletionProgress = e.DeletionProgress;
            OnPropertyRaised("MyDeletionProgress");

            if (e.CurrentFd != null)
            {
                // Do this only when deletion is a single-threaded sequential operation (non-parallel)
                if (MyDeltaFiles.Contains(e.CurrentFd))
                {
                    MyDeltaFiles.Remove(e.CurrentFd);
                    MyDeltaFilesView.Refresh();

                    QualifiedRawNo--;

                    OnPropertyRaised("MyDeltaFilesNo");
                    OnPropertyRaised("MyRejectionRatio");
                }
            }
        }