Пример #1
0
        private CopyItemAction CopyItemError(IVirtualItem item, IVirtualItem source, IVirtualItem dest, AvailableItemActions available, Exception error)
        {
            ChangeItemAction none = ChangeItemAction.None;
            bool undoDest = true;
            if (this.OnCopyItemError != null)
            {
                CopyItemErrorEventArgs e = new CopyItemErrorEventArgs(item, source, dest, available, error);
                this.OnCopyItemError(this, e);
                none = e.Action;
                undoDest = e.UndoDest;
            }
            switch (none)
            {
                case ChangeItemAction.Retry:
                    return CopyItemAction.Next;

                case ChangeItemAction.Skip:
                    return (undoDest ? CopyItemAction.SkipUndoDest : CopyItemAction.Skip);

                case ChangeItemAction.Cancel:
                    base.CancelAsync();
                    return (undoDest ? CopyItemAction.SkipUndoDest : CopyItemAction.Skip);
            }
            throw error;
        }
Пример #2
0
 private ChangeItemAction ChangeItemError(IVirtualItem item, IVirtualItem source, IVirtualItem dest, AvailableItemActions available, Exception error)
 {
     ChangeItemAction none = ChangeItemAction.None;
     if (this.OnCopyItemError != null)
     {
         CopyItemErrorEventArgs e = new CopyItemErrorEventArgs(item, source, dest, available, error);
         this.OnCopyItemError(this, e);
         none = e.Action;
     }
     return none;
 }
 private void SyncronizedCopyItemError(object sender, CopyItemErrorEventArgs e)
 {
     MessageDialogResult[] buttonsRetryIgnoreSkipCancel;
     this.ChangeProgressState(ProgressState.Error);
     MessageDialogResult retry = MessageDialogResult.Retry;
     if (e.CanRetry && e.CanIgnore)
     {
         buttonsRetryIgnoreSkipCancel = MessageDialog.ButtonsRetryIgnoreSkipCancel;
     }
     else if (e.CanRetry)
     {
         buttonsRetryIgnoreSkipCancel = CustomWorkerDialog.ButtonsRetrySkipCancel;
     }
     else
     {
         buttonsRetryIgnoreSkipCancel = CustomWorkerDialog.ButtonsSkipCancel;
         retry = MessageDialogResult.Skip;
     }
     MessageDialogResult result = base.ProcessUnauthorizedAccessException(e);
     if (result == MessageDialogResult.None)
     {
         MessageBoxIcon exclamation;
         if (e.Error is WarningException)
         {
             exclamation = MessageBoxIcon.Exclamation;
         }
         else
         {
             exclamation = MessageBoxIcon.Hand;
         }
         if (e.CanUndoDestination)
         {
             result = MessageDialog.Show(this, e.Error.Message, Resources.sCaptionErrorCopingFile, Resources.sUndoDestFile, ref e.UndoDest, buttonsRetryIgnoreSkipCancel, exclamation, retry);
         }
         else
         {
             result = MessageDialog.Show(this, e.Error.Message, Resources.sCaptionErrorCopingFile, buttonsRetryIgnoreSkipCancel, exclamation, retry);
         }
     }
     if ((result == MessageDialogResult.SkipAll) || ((result == MessageDialogResult.Skip) && ((Control.ModifierKeys & Keys.Shift) > Keys.None)))
     {
         if (base.DefaultErrorAction == null)
         {
             base.DefaultErrorAction = new Dictionary<System.Type, ChangeItemAction>();
         }
         base.DefaultErrorAction.Add(e.Error.GetType(), ChangeItemAction.Skip);
         e.Action = ChangeItemAction.Skip;
     }
     else
     {
         e.FromMessageDialogResult(result);
     }
     if (e.Action != ChangeItemAction.Cancel)
     {
         this.ChangeProgressState(ProgressState.Normal);
     }
 }
        private void BeforeCopyItem(object sender, BeforeCopyItemEventArgs e)
        {
            TableLayoutPanel panel;
            bool flag = false;
            bool flag2 = false;
            IPersistVirtualItem dest = e.Dest as IPersistVirtualItem;
            bool flag3 = (dest != null) && dest.Exists;
            if (flag3)
            {
                OverwriteDialogResult defaultOverwriteResult = this.GetDefaultOverwriteResult(e.Source, e.Dest);
                if (defaultOverwriteResult != OverwriteDialogResult.None)
                {
                    e.OverwriteResult = defaultOverwriteResult;
                }
                else
                {
                    flag = true;
                }
            }
            IVirtualAlternateStreams source = e.Source as IVirtualAlternateStreams;
            IVirtualAlternateStreams streams2 = e.Dest as IVirtualAlternateStreams;
            bool flag4 = this.DefaultCopyStreamsAction != MessageDialogResult.Yes;
            if (!flag4)
            {
                goto Label_0159;
            }
        Label_008C:;
            try
            {
                flag4 = (((source != null) && source.IsSupported) && source.GetStreamNames().Any<string>(delegate (string x) {
                    return (x != ":Zone.Identifier:$DATA");
                })) && ((streams2 == null) || !streams2.IsSupported);
            }
            catch (UnauthorizedAccessException exception)
            {
                CopyItemErrorEventArgs args = new CopyItemErrorEventArgs(e.Source, e.Source, e.Dest, AvailableItemActions.CanElevate, exception);
                this.CopyItemError(sender, args);
                switch (args.Action)
                {
                    case ChangeItemAction.Retry:
                        goto Label_008C;

                    case ChangeItemAction.Skip:
                        e.OverwriteResult = OverwriteDialogResult.Skip;
                        break;

                    case ChangeItemAction.Cancel:
                        e.OverwriteResult = OverwriteDialogResult.Abort;
                        break;

                    default:
                        throw new InvalidEnumArgumentException();
                }
                flag4 = false;
                flag = false;
            }
        Label_0159:
            if (flag4)
            {
                switch (this.DefaultCopyStreamsAction)
                {
                    case MessageDialogResult.Yes:
                        goto Label_0190;

                    case MessageDialogResult.No:
                        e.OverwriteResult = OverwriteDialogResult.Skip;
                        flag = false;
                        goto Label_0190;
                }
                flag2 = true;
            }
        Label_0190:
            Monitor.Enter(panel = this.tblCopyDetails);
            try
            {
                if (((Nomad.Workers.CopyWorker) sender).CheckOption(CopyWorkerOptions.DeleteSource) && (e.Source is IChangeVirtualItem))
                {
                    if (!(!flag3 && ((IChangeVirtualItem) e.Source).CanMoveTo(e.Dest.Parent)))
                    {
                        this.FFileAction = Resources.sFileActionMove;
                    }
                    else
                    {
                        this.FFileAction = Resources.sFileActionRename;
                    }
                }
                else
                {
                    this.FFileAction = GetCopyAction(e.Source, e.Dest);
                }
                TextFormatFlags formatFlags = TextFormatFlags.PathEllipsis | TextFormatFlags.NoPrefix;
                this.FSourceFileName = StringHelper.CompactString(e.Source.FullName, this.lblFromName.Width, this.lblFromName.Font, formatFlags);
                this.FDestFileName = StringHelper.CompactString(e.Dest.FullName, this.lblToName.Width, this.lblToName.Font, formatFlags);
            }
            finally
            {
                Monitor.Exit(panel);
            }
            this.SkipFileCount = 0;
            this.SkipFileRequested = false;
            this.FFileProgress = 0;
            if (flag)
            {
                if (base.InvokeRequired)
                {
                    base.Invoke(new EventHandler<BeforeCopyItemEventArgs>(this.BeforeCopyOverwritePrompt), new object[] { sender, e });
                }
                else
                {
                    this.BeforeCopyOverwritePrompt(sender, e);
                }
            }
            if (flag2)
            {
                if (base.InvokeRequired)
                {
                    base.Invoke(new EventHandler<BeforeCopyItemEventArgs>(this.BeforeCopyStreamsPrompt), new object[] { sender, e });
                }
                else
                {
                    this.BeforeCopyStreamsPrompt(sender, e);
                }
            }
        }
 private void CopyItemError(object sender, CopyItemErrorEventArgs e)
 {
     ChangeItemAction action;
     if ((base.DefaultErrorAction != null) && base.DefaultErrorAction.TryGetValue(e.Error.GetType(), out action))
     {
         e.Action = action;
     }
     else if (base.TryAutoElevate(e))
     {
         e.Action = ChangeItemAction.Retry;
     }
     else
     {
         base.WorkerTrace.TraceException(TraceEventType.Error, e.Error);
         if (base.InvokeRequired)
         {
             base.Invoke(new EventHandler<CopyItemErrorEventArgs>(this.SyncronizedCopyItemError), new object[] { sender, e });
         }
         else
         {
             this.SyncronizedCopyItemError(sender, e);
         }
     }
 }