コード例 #1
0
 private OverwriteDialogResult BeforeCopy(IVirtualItem source, IVirtualItem dest, out string newName)
 {
     newName = string.Empty;
     OverwriteDialogResult overwrite = OverwriteDialogResult.Overwrite;
     if (this.OnBeforeCopyItem != null)
     {
         BeforeCopyItemEventArgs e = new BeforeCopyItemEventArgs(source, dest);
         this.OnBeforeCopyItem(this, e);
         newName = e.NewName;
         overwrite = e.OverwriteResult;
     }
     return overwrite;
 }
コード例 #2
0
        private void BeforeCopyStreamsPrompt(object sender, BeforeCopyItemEventArgs e)
        {
            this.ChangeProgressState(ProgressState.Pause);
            this.ShowCopyItem();
            MessageDialogResult[] buttons = new MessageDialogResult[] { MessageDialogResult.Yes, MessageDialogResult.YesToAll, MessageDialogResult.No, MessageDialogResult.Cancel };
            bool checkBoxChecked = false;
            switch (MessageDialog.Show(this, string.Format(Resources.sWarningCopyAlternateDataStreams, e.Source.FullName), Resources.sCaptionErrorCopingFile, Resources.sDoNotAskAgain, ref checkBoxChecked, buttons, MessageBoxIcon.Exclamation))
            {
                case MessageDialogResult.Yes:
                    if (checkBoxChecked)
                    {
                        this.DefaultCopyStreamsAction = MessageDialogResult.Yes;
                    }
                    break;

                case MessageDialogResult.No:
                    e.OverwriteResult = OverwriteDialogResult.Skip;
                    if ((Control.ModifierKeys == Keys.Shift) || checkBoxChecked)
                    {
                        this.DefaultCopyStreamsAction = MessageDialogResult.No;
                    }
                    break;

                case MessageDialogResult.YesToAll:
                    this.DefaultCopyStreamsAction = MessageDialogResult.Yes;
                    break;

                default:
                    e.OverwriteResult = OverwriteDialogResult.Abort;
                    break;
            }
            if (checkBoxChecked)
            {
                ConfirmationSettings.Default.CopyAlternateDataStreams = false;
            }
            this.ChangeProgressState(ProgressState.Normal);
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
 private void BeforeCopyOverwritePrompt(object sender, BeforeCopyItemEventArgs e)
 {
     this.ChangeProgressState(ProgressState.Pause);
     this.ShowCopyItem();
     if (this.OverwriteDialog == null)
     {
         this.OverwriteDialog = new OverwritePromtDialog();
     }
     this.OverwriteDialog.Execute(this, e.Source, e.Dest);
     IOverwriteRule overwriteRule = this.OverwriteDialog.OverwriteRule;
     if (overwriteRule != null)
     {
         if (this.DefaultOverwriteRules == null)
         {
             this.DefaultOverwriteRules = new List<IOverwriteRule>();
         }
         this.DefaultOverwriteRules.Add(overwriteRule);
     }
     e.OverwriteResult = this.OverwriteDialog.OverwriteResult;
     e.NewName = this.OverwriteDialog.NewName;
     if (e.OverwriteResult != OverwriteDialogResult.Abort)
     {
         this.ChangeProgressState(ProgressState.Normal);
     }
 }