/// <summary> /// Delete item from the list. /// </summary> /// <param name="item"></param> /// <param name="e"></param> internal void DeleteItem(object item, EventArgs e) { try { var theitem = item as CopyItem; if (theitem != null) { CopyItems.Remove(theitem); } } catch (Exception ex) { ErrorMessage = ex.InnerException.ToString(); } }
/// <summary> /// Add an item from clipboard to the list. /// </summary> /// <param name="it"></param> private void AddToList(CopyItem it) { try { if (!it.IsCopyBaseItem()) { if (CopyItems == null) { CopyItems = new ObservableCollection <CopyItem>(); } CopyItems.Add(it); SelectedCopyItem = it; } } catch (Exception) { CopyItems = new ObservableCollection <CopyItem>(); CopyItems.Add(it); SelectedCopyItem = it; } finally { } }
/// <summary> /// Empty the item list. /// </summary> internal void ListClear() { CopyItems.Clear(); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; //Initial Progress Store this._progressStore = new ProgressStore(); //The procedures use Invoke, otherwise the application will crash in some conditions. //This can also be prevented by replace this two function calls to the _worker_ProgressChanged function this._uscProgress.SetProgressStates.SetControlesValue.InitialControles(); //Initial LogFile Writer this._logFile = new LogFile(this._projectManager.ActiveProject.Settings, this.Mode, this._progressStore, this.chkLogFileCreate.Checked) { LogFilePath = this._logFilePath }; this._logFile.WriteHead(this.txtHandleExistingFileText.Text); this._uscProgress.SetProgressStates.ClearExceptionlog(); try { // Count Data if (this.chkCountItemsAndBytes.Checked) { // Initial counter this._counter.Project = this._projectManager.ActiveProject; //Start count progress worker.ReportProgress((int)TaskStep.Count_Start, new ProgressState(this._progressStore, true)); switch (this._mode) { //Start Counting in backup mode case ControleMode.CreateBackup: this._counter.Backup(worker, e, this._progressStore); break; //Start Counting in restore mode case ControleMode.RestoreBackup: this._counter.Restore(worker, e, this._progressStore); break; default: throw new ArgumentException("uscTaskControle->worker_DoWork(Count)->Invalid value", nameof(this._mode)); } worker.ReportProgress((int)TaskStep.Count_Finish, new ProgressState(this._progressStore, true)); } //Copy Data if (this.chkCopyData.Checked) { // Initial copier this._copier = new CopyItems(this._mainForm) { Project = this._projectManager.ActiveProject }; //Start copy progress worker.ReportProgress((int)TaskStep.Copy_Start, new ProgressState(this._progressStore, true)); switch (this._mode) { //Start Counting in backup mode case ControleMode.CreateBackup: this._copier.Backup(worker, e, this._progressStore); break; //Start Counting in restore mode case ControleMode.RestoreBackup: switch ((DialogResult)this.Invoke((Func <DialogResult>)(() => MessageBox.Show(this._mainForm, Properties.Stringtable._0x002Fm, Properties.Stringtable._0x002Fc, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)))) { case DialogResult.Yes: this._copier.Restore(worker, e, this._progressStore); break; case DialogResult.No: case DialogResult.Cancel: if (worker.IsBusy) { worker.CancelAsync(); } break; default: break; } break; default: throw new ArgumentException("uscTaskControle->worker_DoWork(CopyData)->Invalid value", nameof(this._mode)); } if (!e.Cancel) { worker.ReportProgress((int)TaskStep.Copy_Finish, new ProgressState(true)); } } //Delete old Data at Backup Target if (this._mode == ControleMode.CreateBackup && this.chkRootDirectory.Checked && this.chkDeleteOld.Checked) { // Initial deleter this._deleter = new DeleteOldItems() { Project = this._projectManager.ActiveProject }; //Start delete old items worker.ReportProgress((int)TaskStep.DeleteOldItems_Start, new ProgressState(this._progressStore, true)); this._deleter.Backup(worker, e, this._progressStore); if (!e.Cancel) { worker.ReportProgress((int)TaskStep.DeleteOldItems_Finish, new ProgressState(true)); } } } catch (Exception ex) { this._progressStore.Exception = new TaskException { Description = "", Exception = ex, Level = TaskException.ExceptionLevel.Critical, Source = "", Target = "" }; worker.ReportProgress((int)TaskControle.TaskStep.Exception, new ProgressState(this._progressStore, true)); } }