コード例 #1
0
        public FarPodOperationService(FarPodExplorerBase fs, ExplorerModes om)
        {
            // OPM_FIND or OPM_EDIT or OPM_VIEW or OPM_QUICKVIEW - get one file for view
            // OPM_SILENT with no message

            _fs = fs;
            _operationModes = om;
        }
コード例 #2
0
ファイル: Panel.UI.cs プロジェクト: pezipink/FarNet
        ///
        public static GetContentEventArgs WorksExportExplorerFile(Explorer explorer, Panel panel, ExplorerModes mode, FarFile file, string fileName)
        {
            if (explorer == null) throw new ArgumentNullException("explorer");
            if (panel == null) throw new ArgumentNullException("panel");

            if (!explorer.CanGetContent)
                return null;

            // export file
            Log.Source.TraceInformation("ExportFile");
            var args = new GetContentEventArgs(mode, file, fileName);
            panel.UIGetContent(args);
            if (args.Result != JobResult.Done)
                return null;

            // no text or an actual file exists?
            if (args.UseText == null || !string.IsNullOrEmpty(args.UseFileName))
                return args;

            // export text
            string text = args.UseText as string;
            if (text == null)
            {
                IEnumerable collection = args.UseText as IEnumerable;
                if (collection == null)
                {
                    text = args.UseText.ToString();
                }
                else
                {
                    // write collection
                    using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.Unicode))
                        foreach (var it in collection)
                            writer.WriteLine(it);
                    return args;
                }
            }

            // write text
            File.WriteAllText(fileName, text, Encoding.Unicode);
            args.CodePage = 1200;
            return args;
        }
コード例 #3
0
 internal static Explorer ExploreSuperDirectory(Explorer explorer, ExplorerModes mode, FarFile file)
 {
     try
     {
         if (explorer.CanExploreLocation)
         {
             return(explorer.ExploreLocation(new ExploreLocationEventArgs(mode, file.Name)));
         }
         else
         {
             return(explorer.ExploreDirectory(new ExploreDirectoryEventArgs(mode, file)));
         }
     }
     catch (Exception ex)
     {
         FarNet.Log.TraceException(ex);
         return(null);
     }
 }
コード例 #4
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="files">See <see cref="ExplorerFilesEventArgs.Files"/></param>
 /// <param name="force">See <see cref="Force"/></param>
 public DeleteFilesEventArgs(ExplorerModes mode, IList <FarFile> files, bool force) : base(mode, files)
 {
     Force = force;
 }
コード例 #5
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="files">See <see cref="Files"/></param>
 protected ExplorerFilesEventArgs(ExplorerModes mode, IList <FarFile> files) : base(mode)
 {
     Files = files;
 }
コード例 #6
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="file">See <see cref="ExplorerFileEventArgs.File"/></param>
 /// <param name="text">See <see cref="Text"/></param>
 public SetTextEventArgs(ExplorerModes mode, FarFile file, string text) : base(mode, file)
 {
     Text = text;
 }
コード例 #7
0
ファイル: SuperExplorer.cs プロジェクト: pezipink/FarNet
        JobResult DeleteFilesOfExplorer(Explorer explorer, List<SuperFile> xfilesToDelete, IList<FarFile> xfilesToStay, ExplorerModes mode, bool force, ref object codata)
        {
            // explorer files
            var efilesToDelete = new List<FarFile>(xfilesToDelete.Count);
            foreach (var file in xfilesToDelete)
                efilesToDelete.Add(file.File);

            // delete, mind co-data
            Log.Source.TraceInformation("DeleteFiles Count='{0}' Location='{1}'", efilesToDelete.Count, explorer.Location);
            var argsDelete = new DeleteFilesEventArgs(mode, efilesToDelete, force);
            argsDelete.Data = codata;
            explorer.DeleteFiles(argsDelete);
            codata = argsDelete.Data;

            // result: break to delete
            switch (argsDelete.Result)
            {
                default:
                    return JobResult.Ignore;

                case JobResult.Done:
                    break;

                case JobResult.Incomplete:

                    // recover that files to stay
                    if (argsDelete.FilesToStay.Count == 0)
                    {
                        var filesAfterDelete = explorer.GetFiles(new GetFilesEventArgs(ExplorerModes.Silent));
                        var hashAfterDelete = Works.Kit.HashFiles(filesAfterDelete, explorer.FileComparer);
                        foreach (var file in efilesToDelete)
                            if (hashAfterDelete.ContainsKey(file))
                                argsDelete.FilesToStay.Add(file);
                    }

                    // convert that files to this files to stay
                    foreach (SuperFile xfile in SuperFile.SuperFilesOfExplorerFiles(xfilesToDelete, argsDelete.FilesToStay, explorer.FileComparer))
                    {
                        xfilesToDelete.Remove(xfile);
                        xfilesToStay.Add(xfile);
                    }

                    break;
            }

            // remove remaining super files
            foreach (var file in xfilesToDelete)
                _Cache.Remove(file);

            return argsDelete.Result;
        }
コード例 #8
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="files">See <see cref="ExplorerFilesEventArgs.Files"/></param>
 /// <param name="move">See <see cref="CopyFilesEventArgs.Move"/></param>
 /// <param name="directoryName">See <see cref="DirectoryName"/></param>
 public ExportFilesEventArgs(ExplorerModes mode, IList <FarFile> files, bool move, string directoryName)
     : base(mode, files, move)
 {
     DirectoryName = directoryName;
 }
コード例 #9
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 public ExploreParentEventArgs(ExplorerModes mode) : base(mode)
 {
 }
コード例 #10
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="location">See <see cref="Location"/></param>
 public ExploreLocationEventArgs(ExplorerModes mode, string location) : base(mode)
 {
     Location = location;
 }
コード例 #11
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="file">See <see cref="File"/></param>
 public ExploreDirectoryEventArgs(ExplorerModes mode, FarFile file) : base(mode)
 {
     File = file;
 }
コード例 #12
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 public CreateFileEventArgs(ExplorerModes mode) : base(mode)
 {
 }
コード例 #13
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="offset">See <see cref="Offset"/></param>
 /// <param name="limit">See <see cref="Limit"/></param>
 /// <param name="newFiles">See <see cref="NewFiles"/></param>
 public GetFilesEventArgs(ExplorerModes mode, int offset, int limit, bool newFiles) : base(mode)
 {
     Limit    = limit;
     Offset   = offset;
     NewFiles = newFiles;
 }
コード例 #14
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 public GetFilesEventArgs(ExplorerModes mode) : base(mode)
 {
 }
コード例 #15
0
 /// <param name="mode">See <see cref="Mode"/></param>
 protected ExplorerEventArgs(ExplorerModes mode)
 {
     Mode = mode;
 }
コード例 #16
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="files">See <see cref="ExplorerFilesEventArgs.Files"/></param>
 /// <param name="move">See <see cref="Move"/></param>
 protected CopyFilesEventArgs(ExplorerModes mode, IList <FarFile> files, bool move)
     : base(mode, files)
 {
     Move = move;
 }
コード例 #17
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="files">See <see cref="ExplorerFilesEventArgs.Files"/></param>
 /// <param name="move">See <see cref="CopyFilesEventArgs.Move"/></param>
 /// <param name="explorer">See <see cref="Explorer"/></param>
 public AcceptFilesEventArgs(ExplorerModes mode, IList <FarFile> files, bool move, Explorer explorer)
     : base(mode, files, move)
 {
     Explorer = explorer;
 }
コード例 #18
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 public ExploreRootEventArgs(ExplorerModes mode) : base(mode)
 {
 }
コード例 #19
0
        JobResult DeleteFilesOfExplorer(Explorer explorer, List <SuperFile> xfilesToDelete, IList <FarFile> xfilesToStay, ExplorerModes mode, bool force, ref object codata)
        {
            // explorer files
            var efilesToDelete = new List <FarFile>(xfilesToDelete.Count);

            foreach (var file in xfilesToDelete)
            {
                efilesToDelete.Add(file.File);
            }

            // delete, mind co-data
            Log.Source.TraceInformation("DeleteFiles Count='{0}' Location='{1}'", efilesToDelete.Count, explorer.Location);
            var argsDelete = new DeleteFilesEventArgs(mode, efilesToDelete, force)
            {
                Data = codata
            };

            explorer.DeleteFiles(argsDelete);
            codata = argsDelete.Data;

            // result: break to delete
            switch (argsDelete.Result)
            {
            default:
                return(JobResult.Ignore);

            case JobResult.Done:
                break;

            case JobResult.Incomplete:

                // recover that files to stay
                if (argsDelete.FilesToStay.Count == 0)
                {
                    var filesAfterDelete = explorer.GetFiles(new GetFilesEventArgs(ExplorerModes.Silent));
                    var hashAfterDelete  = Works.Kit.HashFiles(filesAfterDelete, explorer.FileComparer);
                    foreach (var file in efilesToDelete)
                    {
                        if (hashAfterDelete.ContainsKey(file))
                        {
                            argsDelete.FilesToStay.Add(file);
                        }
                    }
                }

                // convert that files to this files to stay
                foreach (SuperFile xfile in SuperFile.SuperFilesOfExplorerFiles(xfilesToDelete, argsDelete.FilesToStay, explorer.FileComparer))
                {
                    xfilesToDelete.Remove(xfile);
                    xfilesToStay.Add(xfile);
                }

                break;
            }

            // remove remaining super files
            foreach (var file in xfilesToDelete)
            {
                _Cache.Remove(file);
            }

            return(argsDelete.Result);
        }
コード例 #20
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="file">See <see cref="File"/></param>
 protected ExplorerFileEventArgs(ExplorerModes mode, FarFile file) : base(mode)
 {
     File = file;
 }
コード例 #21
0
ファイル: SuperExplorer.cs プロジェクト: pezipink/FarNet
 internal static Explorer ExploreSuperDirectory(Explorer explorer, ExplorerModes mode, FarFile file)
 {
     try
     {
         if (explorer.CanExploreLocation)
             return explorer.ExploreLocation(new ExploreLocationEventArgs(mode, file.Name));
         else
             return explorer.ExploreDirectory(new ExploreDirectoryEventArgs(mode, file));
     }
     catch (Exception ex)
     {
         FarNet.Log.TraceException(ex);
         return null;
     }
 }
コード例 #22
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="file">See <see cref="ExplorerFileEventArgs.File"/></param>
 public RenameFileEventArgs(ExplorerModes mode, FarFile file) : base(mode, file)
 {
 }
コード例 #23
0
        ///
        public static GetContentEventArgs WorksExportExplorerFile(Explorer explorer, Panel panel, ExplorerModes mode, FarFile file, string fileName)
        {
            if (explorer == null)
            {
                throw new ArgumentNullException("explorer");
            }
            if (panel == null)
            {
                throw new ArgumentNullException("panel");
            }

            if (!explorer.CanGetContent)
            {
                return(null);
            }

            // export file
            Log.Source.TraceInformation("ExportFile");
            var args = new GetContentEventArgs(mode, file, fileName);

            panel.UIGetContent(args);
            if (args.Result != JobResult.Done)
            {
                return(null);
            }

            // no text or an actual file exists?
            if (args.UseText == null || !string.IsNullOrEmpty(args.UseFileName))
            {
                return(args);
            }

            // export text
            string text = args.UseText as string;

            if (text == null)
            {
                IEnumerable collection = args.UseText as IEnumerable;
                if (collection == null)
                {
                    text = args.UseText.ToString();
                }
                else
                {
                    // write collection
                    using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.Unicode))
                        foreach (var it in collection)
                        {
                            writer.WriteLine(it);
                        }
                    return(args);
                }
            }

            // write text
            File.WriteAllText(fileName, text, Encoding.Unicode);
            args.CodePage = 1200;
            return(args);
        }
コード例 #24
0
 /// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param>
 /// <param name="file">See <see cref="ExplorerFileEventArgs.File"/></param>
 /// <param name="fileName">See <see cref="FileName"/></param>
 public SetFileEventArgs(ExplorerModes mode, FarFile file, string fileName) : base(mode, file)
 {
     FileName = fileName;
 }