Пример #1
0
 public override void ExportFiles(ExportFilesEventArgs args)
 {
     foreach (var file in args.Files)
     {
         ExportFileEntry(file, Path.Combine(args.DirectoryName, file.Name));
     }
 }
Пример #2
0
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="args">.</param>
 public sealed override void ExportFiles(ExportFilesEventArgs args)
 {
     if (AsExportFiles == null)
     {
         DoExportFiles(args);
     }
     else
     {
         A.InvokeScriptReturnAsIs(AsExportFiles, this, args);
     }
 }
Пример #3
0
        public override void ExportFiles(ExportFilesEventArgs args)
        {
            FarPodOperationService s = get(args);

            if (!Far.Net.Panel2.RealNames && !s.IsInternalOperation())
            {
                args.Result = JobResult.Ignore;
                return;
            }

            OperationResult or = s.CopyOrMoveContentFromSelf(args.Files, args.DirectoryName, args.Move);

            args.Result = processResult(or, args.Mode.HasFlag(ExplorerModes.Silent), args.FilesToStay);
        }
Пример #4
0
        /// <inheritdoc/>
        public override void ExportFiles(ExportFilesEventArgs args)
        {
            if (args == null) return;

            var dicTypeId = GroupFiles(args.Files, ExplorerFunctions.ExportFiles);

            foreach (var xTypeId in dicTypeId)
            {
                Log.Source.TraceInformation("ExportFiles TypeId='{0}'", xTypeId.Key);
                object codata = null;
                foreach (var kv in xTypeId.Value)
                {
                    // explorer and its files
                    var explorer = kv.Key;
                    var xfiles = kv.Value;
                    var filesToExport = new List<FarFile>(xfiles.Count);
                    foreach (var file in xfiles)
                        filesToExport.Add(file.File);

                    // export, mind co-data
                    Log.Source.TraceInformation("ExportFiles Count='{0}' Location='{1}' DirectoryName='{2}'", filesToExport.Count, explorer.Location, args.DirectoryName);
                    var argsExport = new ExportFilesEventArgs(ExplorerModes.None, filesToExport, args.Move, args.DirectoryName);
                    argsExport.Data = codata;
                    explorer.ExportFiles(argsExport);
                    codata = argsExport.Data;

                    // info
                    bool isIncomplete = argsExport.Result == JobResult.Incomplete;
                    bool isAllToStay = isIncomplete && argsExport.FilesToStay.Count == 0;
                    if (isIncomplete)
                        args.Result = JobResult.Incomplete;

                    // Copy: do not update the source, files are the same
                    if (!args.Move)
                    {
                        // keep it as it is
                        if (isAllToStay)
                        {
                            foreach (var file in xfiles)
                                args.FilesToStay.Add(file);
                            continue;
                        }

                        // recover
                        if (isIncomplete)
                            foreach(var file in SuperFile.SuperFilesOfExplorerFiles(xfiles, argsExport.FilesToStay, explorer.FileComparer))
                                args.FilesToStay.Add(file);

                        continue;
                    }

                    // Move: no need to delete or all to stay or cannot delete
                    if (!argsExport.ToDeleteFiles || isAllToStay || !explorer.CanDeleteFiles)
                    {
                        // recover selection
                        if (isIncomplete)
                        {
                            var filesToStay = isAllToStay ? argsExport.Files : argsExport.FilesToStay;
                            foreach(var file in SuperFile.SuperFilesOfExplorerFiles(xfiles, filesToStay, explorer.FileComparer))
                                args.FilesToStay.Add(file);
                        }

                        continue;
                    }

                    // Move: delete is requested, delete the source files

                    // exclude this files to stay from to be deleted
                    if (isIncomplete)
                    {
                        foreach (SuperFile xfile in SuperFile.SuperFilesOfExplorerFiles(xfiles, argsExport.FilesToStay, explorer.FileComparer))
                        {
                            xfiles.Remove(xfile);
                            args.FilesToStay.Add(xfile);
                        }
                    }

                    // call delete on remaining files
                    object codata2 = null;
                    var result = DeleteFilesOfExplorer(explorer, xfiles, args.FilesToStay, ExplorerModes.Silent, false, ref codata2);
                    if (result == JobResult.Incomplete)
                        args.Result = JobResult.Incomplete;
                }
            }
        }
Пример #5
0
        public override void UIExportFiles(ExportFilesEventArgs args)
        {
            if (!ensurePathExist())
            {
                return;
            }

            base.UIExportFiles(args);
        }
Пример #6
0
        /// <inheritdoc/>
        public override void ExportFiles(ExportFilesEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            var dicTypeId = GroupFiles(args.Files, ExplorerFunctions.ExportFiles);

            foreach (var xTypeId in dicTypeId)
            {
                Log.Source.TraceInformation("ExportFiles TypeId='{0}'", xTypeId.Key);
                object codata = null;
                foreach (var kv in xTypeId.Value)
                {
                    // explorer and its files
                    var explorer      = kv.Key;
                    var xfiles        = kv.Value;
                    var filesToExport = new List <FarFile>(xfiles.Count);
                    foreach (var file in xfiles)
                    {
                        filesToExport.Add(file.File);
                    }

                    // export, mind co-data
                    Log.Source.TraceInformation("ExportFiles Count='{0}' Location='{1}' DirectoryName='{2}'", filesToExport.Count, explorer.Location, args.DirectoryName);
                    var argsExport = new ExportFilesEventArgs(ExplorerModes.None, filesToExport, args.Move, args.DirectoryName)
                    {
                        Data = codata
                    };
                    explorer.ExportFiles(argsExport);
                    codata = argsExport.Data;

                    // info
                    bool isIncomplete = argsExport.Result == JobResult.Incomplete;
                    bool isAllToStay  = isIncomplete && argsExport.FilesToStay.Count == 0;
                    if (isIncomplete)
                    {
                        args.Result = JobResult.Incomplete;
                    }

                    // Copy: do not update the source, files are the same
                    if (!args.Move)
                    {
                        // keep it as it is
                        if (isAllToStay)
                        {
                            foreach (var file in xfiles)
                            {
                                args.FilesToStay.Add(file);
                            }
                            continue;
                        }

                        // recover
                        if (isIncomplete)
                        {
                            foreach (var file in SuperFile.SuperFilesOfExplorerFiles(xfiles, argsExport.FilesToStay, explorer.FileComparer))
                            {
                                args.FilesToStay.Add(file);
                            }
                        }

                        continue;
                    }

                    // Move: no need to delete or all to stay or cannot delete
                    if (!argsExport.ToDeleteFiles || isAllToStay || !explorer.CanDeleteFiles)
                    {
                        // recover selection
                        if (isIncomplete)
                        {
                            var filesToStay = isAllToStay ? argsExport.Files : argsExport.FilesToStay;
                            foreach (var file in SuperFile.SuperFilesOfExplorerFiles(xfiles, filesToStay, explorer.FileComparer))
                            {
                                args.FilesToStay.Add(file);
                            }
                        }

                        continue;
                    }

                    // Move: delete is requested, delete the source files

                    // exclude this files to stay from to be deleted
                    if (isIncomplete)
                    {
                        foreach (SuperFile xfile in SuperFile.SuperFilesOfExplorerFiles(xfiles, argsExport.FilesToStay, explorer.FileComparer))
                        {
                            xfiles.Remove(xfile);
                            args.FilesToStay.Add(xfile);
                        }
                    }

                    // call delete on remaining files
                    object codata2 = null;
                    var    result  = DeleteFilesOfExplorer(explorer, xfiles, args.FilesToStay, ExplorerModes.Silent, false, ref codata2);
                    if (result == JobResult.Incomplete)
                    {
                        args.Result = JobResult.Incomplete;
                    }
                }
            }
        }
Пример #7
0
 /// <summary>
 /// <see cref="Explorer.ExportFiles"/> worker.
 /// </summary>
 /// <param name="args">.</param>
 public virtual void DoExportFiles(ExportFilesEventArgs args)
 {
     base.ExportFiles(args);
 }
Пример #8
0
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="args">.</param>
 public override sealed void ExportFiles(ExportFilesEventArgs args)
 {
     if (AsExportFiles == null)
         DoExportFiles(args);
     else
         A.InvokeScriptReturnAsIs(AsExportFiles, this, args);
 }
Пример #9
0
 /// <summary>
 /// <see cref="Explorer.ExportFiles"/> worker.
 /// </summary>
 /// <param name="args">.</param>
 public virtual void DoExportFiles(ExportFilesEventArgs args)
 {
     base.ExportFiles(args);
 }
Пример #10
0
 /// <summary>
 /// Exports files to a native destination.
 /// </summary>
 /// <param name="args">.</param>
 /// <remarks>
 /// This method gives some more control than default export performed with <see cref="GetContent"/>.
 /// </remarks>
 public virtual void ExportFiles(ExportFilesEventArgs args)
 {
     if (args != null) args.Result = JobResult.Ignore;
 }
Пример #11
0
        /// <summary>
        /// Copy/move action.
        /// </summary>
        /// <param name="move">Tells to move files.</param>
        /// <remarks>
        /// The source and target panel are module panels.
        /// The target panel explorer accepts the selected files.
        /// </remarks>
        public virtual void UICopyMove(bool move)
        {
            // target
            var that = TargetPanel;

            // commit
            if (that == null)
            {
                // can?
                if (!Explorer.CanExportFiles)
                    return;

                // target?
                var native = Far.Api.Panel2;
                if (native.IsPlugin || native.Kind != PanelKind.File)
                    return;

                // args
                var argsExport = new ExportFilesEventArgs(ExplorerModes.None, SelectedFiles, move, native.CurrentDirectory);
                if (argsExport.Files.Count == 0)
                    return;

                // call
                UIExportFiles(argsExport);
                if (argsExport.Result == JobResult.Ignore)
                    return;

                // show
                native.Update(true);
                native.Redraw();

                // complete
                UICopyMoveComplete(argsExport);
                return;
            }

            // can?
            if (!that.Explorer.CanAcceptFiles)
                return;

            // args
            var argsAccept = new AcceptFilesEventArgs(ExplorerModes.None, this.SelectedFiles, move, this.Explorer);
            if (argsAccept.Files.Count == 0)
                return;

            // call
            that.UIAcceptFiles(argsAccept);
            if (argsAccept.Result == JobResult.Ignore)
                return;

            // the target may have new files, update, keep selection
            that.Post(argsAccept);
            that.Update(true);
            that.Redraw();

            // complete
            UICopyMoveComplete(argsAccept);
        }
Пример #12
0
        /// <summary>
        /// Calls <see cref="FarNet.Explorer.ExportFiles"/> and <see cref="OnThisFileChanged"/>.
        /// </summary>
        /// <param name="args">.</param>
        public virtual void UIExportFiles(ExportFilesEventArgs args)
        {
            if (args == null) return;

            Explorer.ExportFiles(args);

            if (args.Result != JobResult.Ignore && args.Move)
                OnThisFileChanged(args);
        }