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; }
/// 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; }
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); } }
/// <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; }
/// <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; }
/// <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; }
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; }
/// <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; }
/// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param> public ExploreParentEventArgs(ExplorerModes mode) : base(mode) { }
/// <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; }
/// <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; }
/// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param> public CreateFileEventArgs(ExplorerModes mode) : base(mode) { }
/// <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; }
/// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param> public GetFilesEventArgs(ExplorerModes mode) : base(mode) { }
/// <param name="mode">See <see cref="Mode"/></param> protected ExplorerEventArgs(ExplorerModes mode) { Mode = mode; }
/// <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; }
/// <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; }
/// <param name="mode">See <see cref="ExplorerEventArgs.Mode"/></param> public ExploreRootEventArgs(ExplorerModes mode) : base(mode) { }
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); }
/// <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; }
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; } }
/// <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) { }
/// 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); }
/// <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; }