/// <summary> /// Opens the path on another panel for the FileSystem provider or an item panel as a child of this panel for other providers. /// </summary> /// <param name="file">The file to open.</param> public override void OpenFile(FarFile file) { // base if (UserWants != UserAction.Enter) { base.OpenFile(file); return; } // get data TreeFile node = (TreeFile)file; PSObject data = node.Data as PSObject; ProviderInfo provider = (ProviderInfo)data.Properties["PSProvider"].Value; // open at the passive panel if (provider.Name == "FileSystem") { Far.Api.Panel2.CurrentDirectory = node.Path; Far.Api.Panel2.Update(false); Far.Api.Panel2.Redraw(); } // open at the same panel as child else { ItemPanel panel = new ItemPanel(node.Path); panel.OpenChild(this); } }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="args">.</param> public sealed override IList <FarFile> GetFiles(GetFilesEventArgs args) { if (AsGetFiles == null) { return(DoGetFiles(args)); } // nothing, use the predefined file list var output = A.InvokeScript(AsGetFiles, this, args); if (output.Count == 0) { return(Cache); } // convert the output to files var result = new List <FarFile>(); foreach (var it in output) { FarFile file = (FarFile)LanguagePrimitives.ConvertTo(it, typeof(FarFile), null); if (file != null) { result.Add(file); } } return(result); }
internal static void CompleteFileData(FarFile file, SettingsPropertyValue value) { // defaults var prefix = value.UsingDefaultValue ? "- " : "+ "; file.Owner = prefix + file.Name; }
/// internal void UIOpenFileMembers() { FarFile file = CurrentFile; if (file != null) { //OpenFileMembers(file); } }
/// <summary> /// New super file with its explorer. /// </summary> /// <param name="explorer">The file's explorer.</param> /// <param name="file">The base file.</param> public SuperFile(Explorer explorer, FarFile file) : base(file) { if (explorer == null) { throw new ArgumentNullException("explorer"); } _Explorer = explorer; }
static PSObject ConvertFileToItem(FarFile file) { if (file == null || file.Data == null) { return(null); } return(PSObject.AsPSObject(file.Data)); }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="file">The file to edit.</param> public sealed override void UIEditFile(FarFile file) //_091202_073429 NB: Data can be wrapped by PSObject. { if (AsEditFile != null) { A.InvokeScriptReturnAsIs(AsEditFile, this, file); } else { DoEditFile(file); } }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="file">The file to view.</param> public sealed override void UIViewFile(FarFile file) //_091202_073429 { if (AsViewFile != null) { A.InvokeScriptReturnAsIs(AsViewFile, this, file); } else { DoViewFile(file); } }
/// <summary> /// Puts a value into the command line or opens a lookup panel or member panel. /// </summary> /// <param name="file">The file to process.</param> public override void OpenFile(FarFile file) { if (file == null) { throw new ArgumentNullException("file"); } PSPropertyInfo pi = file.Data as PSPropertyInfo; // e.g. visible mode: sender is MemberDefinition if (pi == null) { return; } // lookup opener? if (_LookupOpeners != null) { ScriptHandler <OpenFileEventArgs> handler; if (_LookupOpeners.TryGetValue(file.Name, out handler)) { handler.Invoke(this, new OpenFileEventArgs(file)); return; } } // case: can show value in the command line string s = Converter.InfoToLine(pi); if (s != null) { // set command line ILine cl = Far.Api.CommandLine; cl.Text = "=" + s; cl.SelectText(1, s.Length + 1); return; } // case: enumerable IEnumerable ie = Cast <IEnumerable> .From(pi.Value); if (ie != null) { ObjectPanel op = new ObjectPanel(); op.AddObjects(ie); op.OpenChild(this); return; } // open members OpenFileMembers(file); }
/// <summary> /// Creates a panel for provider items at the given location. /// </summary> /// <param name="path">Path to start at.</param> public ItemPanel(string path) : this(new ItemExplorer(new PathInfoEx(path))) { // current location, post the current name if (string.IsNullOrEmpty(path)) { FarFile file = Far.Api.Panel.CurrentFile; if (file != null) { PostName(file.Name); } } }
/// <summary> /// New folder tree at the given location path. /// </summary> /// <param name="path">The location path.</param> public FolderTree(string path) : this(new FolderExplorer(path)) { // post name if (string.IsNullOrEmpty(path) || path == ".") { FarFile currentFile = Far.Api.Panel.CurrentFile; if (currentFile != null) { PostName(currentFile.Name); } } }
internal override MemberPanel OpenFileMembers(FarFile file) { if (!(file.Data is PSPropertyInfo pi)) { return(null); } if (pi.Value == null) { return(null); } MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value)); r.OpenChild(this); return(r); }
/// <summary> /// Opens <see cref="MemberPanel"/> for a file. /// File <c>Data</c> must not be null. /// </summary> internal override MemberPanel OpenFileMembers(FarFile file) { // get data TreeFile t = (TreeFile)file; if (t.Data == null) { return(null); } //! use null as parent: this panel can be not open now MemberPanel r = new MemberPanel(new MemberExplorer(t.Data)); r.OpenChild(null); return(r); }
/// <summary> /// Puts a value into the command line or opens a lookup panel or member panel. /// </summary> /// <param name="file">The file to process.</param> public override void OpenFile(FarFile file) { if (file == null) throw new ArgumentNullException("file"); PSPropertyInfo pi = file.Data as PSPropertyInfo; // e.g. visible mode: sender is MemberDefinition if (pi == null) return; // lookup opener? if (_LookupOpeners != null) { ScriptHandler<OpenFileEventArgs> handler; if (_LookupOpeners.TryGetValue(file.Name, out handler)) { handler.Invoke(this, new OpenFileEventArgs(file)); return; } } // case: can show value in the command line string s = Converter.InfoToLine(pi); if (s != null) { // set command line ILine cl = Far.Api.CommandLine; cl.Text = "=" + s; cl.SelectText(1, s.Length + 1); return; } // case: enumerable IEnumerable ie = Cast<IEnumerable>.From(pi.Value); if (ie != null) { ObjectPanel op = new ObjectPanel(); op.AddObjects(ie); op.OpenChild(this); return; } // open members OpenFileMembers(file); }
private void ExportFileEntry(FarFile file, string Dir) { var filedata = file.Data ?? GetFileData(file); if (file.IsDirectory) { Directory.CreateDirectory(Dir); if (filedata is PakExplorer index) { index._files.ForEach(f => ExportFileEntry(f, Path.Combine(Dir, f.Name))); } } else if (file.Name.EndsWith(".bnk") && filedata is FPakEntry entry) { UE4.VorbisBank.BankFile bank = null; var data = InspectedFile.ReadEntry(entry); var bankinfo = _files.Where(f => f.Name == "SoundbanksInfo.xml").SingleOrDefault(); if (bankinfo != null) { var bankData = InspectedFile.ReadEntry(bankinfo.Data); var doc = new XmlDocument(); var xml = Encoding.UTF8.GetString(bankData); doc.LoadXml(xml); var info = new SoundBankInfo(doc); bank = new UE4.VorbisBank.BankFile(data, info); } else { bank = new UE4.VorbisBank.BankFile(data); } File.WriteAllBytes(Dir, data); var folder = Path.Combine(Path.GetDirectoryName(Dir), Path.GetFileNameWithoutExtension(Dir)); Directory.CreateDirectory(folder); bank.Files.ForEach(track => File.WriteAllBytes(Path.Combine(folder, track.Name), bank.ReadTrack(track))); } else { var data = InspectedFile.ReadEntry(filedata); if (data != null) { File.WriteAllBytes(Dir, data); } } }
/// <summary> /// Sets file name if any suitable exists. /// </summary> static void SetFileName(FarFile file) { // case: try to get display name PSObject data = PSObject.AsPSObject(file.Data); PSPropertyInfo pi = A.FindDisplayProperty(data); if (pi != null) { file.Name = pi.Value == null ? Res.NullText : pi.Value.ToString(); return; } // other: use ToString(), but skip too verbose PSCustomObject if (!(data.BaseObject is PSCustomObject)) { file.Name = data.ToString(); } }
/// 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 IList <FarFile> Explore(GetFilesEventArgs args) { if (args == null) { return(null); } var Files = Explorer.Cache; // refill if (NeedsNewFiles) { if (CanClose()) { if (Adapter != null) { Table.Clear(); } Fill(); } } // no job? if (!ToUpdateData && !NeedsNewFiles) { return(Files); } // refresh data for (int iFile = Files.Count; --iFile >= 0;) { FarFile f = Files[iFile]; DataRow Row = f.Data as DataRow; if (Row == null || Row.RowState == DataRowState.Deleted || Row.RowState == DataRowState.Detached) { Files.RemoveAt(iFile); continue; } } // prevent next job ToUpdateData = false; return(Files); }
internal override void UIAttributes() { if (Drive.Length > 0) { return; } // has property? if (!My.ProviderInfoEx.HasProperty(Explorer.Provider)) { A.Message(Res.NotSupportedByProvider); return; } // open property panel FarFile file = CurrentFile; (new PropertyExplorer(file == null ? Explorer.Location : My.PathEx.Combine(Explorer.Location, file.Name))).OpenPanelChild(this); }
/// <summary> /// Opens/closes the node. /// </summary> /// <param name="file">The node to open/close.</param> public override void OpenFile(FarFile file) { if (file == null) throw new ArgumentNullException("file"); TreeFile node = (TreeFile)file; if (node._State == 0) { if (!node.IsNode) return; node.FillNode(); node._State = 1; } else { node._State = -node._State; } UpdateRedraw(false); }
/// <inheritdoc/> protected override bool CanClose() { if (Child != null) { return(true); } FarFile f = CurrentFile; if (f == null) { _lastCurrentName = null; } else { _lastCurrentName = f.Name; } return(true); }
internal override MemberPanel OpenFileMembers(FarFile file) { PSObject o = PSObject.AsPSObject(file.Data); string memberType = o.Properties["MemberType"].Value.ToString(); if (!memberType.EndsWith("Property", StringComparison.Ordinal)) //?? { return(null); } string name = o.Properties[Word.Name].Value.ToString(); object instance = Target.Properties[name].Value; if (instance == null) { return(null); } MemberPanel r = new MemberPanel(new MemberExplorer(instance)); r.OpenChild(this); return(r); }
/// <summary> /// Calls base or assigns a value to the current property. /// </summary> void OnInvokingCommand(object sender, CommandLineEventArgs e) { // base string code = e.Command.TrimStart(); if (!code.StartsWith("=", StringComparison.Ordinal)) { return; } // we do e.Ignore = true; // skip empty FarFile f = CurrentFile; if (f == null) { return; } PSPropertyInfo pi = f.Data as PSPropertyInfo; if (pi == null) { return; } try { SetUserValue(pi, code.Substring(1)); UpdateRedraw(true); } catch (RuntimeException ex) { A.Message(ex.Message); } }
/// <summary> /// Opens/closes the node. /// </summary> /// <param name="file">The node to open/close.</param> public override void OpenFile(FarFile file) { if (file == null) { throw new ArgumentNullException("file"); } TreeFile node = (TreeFile)file; if (node._State == 0) { if (!node.IsNode) { return; } node.FillNode(); node._State = 1; } else { node._State = -node._State; } UpdateRedraw(false); }
internal override MemberPanel OpenFileMembers(FarFile file) { PSPropertyInfo pi = file.Data as PSPropertyInfo; if (pi == null) return null; if (pi.Value == null) return null; MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value)); r.OpenChild(this); return r; }
/// <summary> /// Opens the file member panel. /// </summary> /// <remarks> /// The base method propagates lookup openers. /// </remarks> internal virtual MemberPanel OpenFileMembers(FarFile file) { //??? _090610_071700, + $panel.SetOpen({ @ Test-Panel-Tree-.ps1 object target = file.Data == null ? file : file.Data; MemberPanel panel = new MemberPanel(new MemberExplorer(target)); panel._LookupOpeners = _LookupOpeners; var tablePanel = Far.Api.Panel as TablePanel; if (tablePanel != null) { if (!string.IsNullOrEmpty(tablePanel.ExcludeMemberPattern)) panel.Explorer.ExcludeMemberPattern = tablePanel.ExcludeMemberPattern; if (!string.IsNullOrEmpty(tablePanel.HideMemberPattern)) panel.Explorer.HideMemberPattern = tablePanel.HideMemberPattern; } //! use null as parent: this panel can be not open now panel.OpenChild(null); return panel; }
void OpenFileActor(FarFile file) { var memberPanel = OpenFileMembers(file); memberPanel.Explorer.CanDeleteFiles = false; }
static PSObject ConvertFileToItem(FarFile file) { if (file == null || file.Data == null) return null; return PSObject.AsPSObject(file.Data); }
/// <summary> /// Opens the file using <see cref="AsOpenFile"/> or the default method. /// </summary> /// <param name="file">The file to be opened.</param> public override sealed void UIOpenFile(FarFile file) { if (file == null) return; // lookup closer? if (UserWants == UserAction.Enter && Lookup != null) { Lookup.Invoke(this, new OpenFileEventArgs(file)); UIEscape(false); return; } // script if (AsOpenFile != null) { A.InvokeScriptReturnAsIs(AsOpenFile, this, new OpenFileEventArgs(file)); return; } // base if (Explorer.CanOpenFile) { base.UIOpenFile(file); return; } // PSF OpenFile(file); }
/// <summary> /// New super file with its explorer. /// </summary> /// <param name="explorer">The file's explorer.</param> /// <param name="file">The base file.</param> public SuperFile(Explorer explorer, FarFile file) : base(file) { if (explorer == null) throw new ArgumentNullException("explorer"); _Explorer = explorer; }
/// <summary> /// <see cref="UIEditFile"/> worker. /// </summary> /// <param name="file">The file to edit.</param> public void DoEditFile(FarFile file) { base.UIEditFile(file); }
/// <summary> /// Opens a member panel to edit the record. /// </summary> /// <param name="file">The file to open.</param> public override void OpenFile(FarFile file) { BuildUpdateCommand(); OpenFileActor(file); }
/// <summary> /// Opens the file in the editor. /// </summary> /// <param name="file">The file to edit.</param> /// <remarks> /// The default method calls <see cref="FarNet.Explorer.GetContent"/> to get a temporary file to edit /// and <see cref="FarNet.Explorer.SetFile"/> to save changes when the editor closes. /// The explorer should have at least export implemented. /// </remarks> public virtual void UIEditFile(FarFile file) { if (file == null) return; // target var temp = Far.Api.TempName(); // export var xExportArgs = WorksExportExplorerFile(Explorer, this, ExplorerModes.Edit, file, temp); if (xExportArgs == null) return; // case: actual file exists var asExportFileEventArgs = xExportArgs as GetContentEventArgs; if (asExportFileEventArgs != null && !string.IsNullOrEmpty(asExportFileEventArgs.UseFileName)) { var editorActual = Far.Api.CreateEditor(); editorActual.FileName = asExportFileEventArgs.UseFileName; editorActual.Title = file.Name; if (!asExportFileEventArgs.CanSet) editorActual.IsLocked = true; editorActual.Open(); return; } // rename if (!string.IsNullOrEmpty(xExportArgs.UseFileExtension)) { string temp2 = temp + xExportArgs.UseFileExtension; File.Move(temp, temp2); temp = temp2; } // editor var editorTemp = Far.Api.CreateEditor(); editorTemp.DeleteSource = DeleteSource.File; editorTemp.DisableHistory = true; editorTemp.FileName = temp; editorTemp.Title = file.Name; if (asExportFileEventArgs.CodePage != 0) editorTemp.CodePage = asExportFileEventArgs.CodePage; // future if (xExportArgs.CanSet) { if (Explorer.CanSetText) { editorTemp.Saving += delegate { var xImportTextArgs = new SetTextEventArgs(ExplorerModes.Edit, file, editorTemp.GetText()); Log.Source.TraceInformation("ImportText"); UISetText(xImportTextArgs); }; } else { editorTemp.Closed += delegate //???? to use Saved (Far 3), update docs. { if (editorTemp.TimeOfSave == DateTime.MinValue) return; var xImportFileArgs = new SetFileEventArgs(ExplorerModes.Edit, file, temp); Log.Source.TraceInformation("ImportFile"); UISetFile(xImportFileArgs); }; } } else { // to lock editorTemp.IsLocked = true; } // go editorTemp.Open(); }
/// <summary> /// Opens the file. /// </summary> /// <remarks> /// It is called for the current file when [Enter] is pressed. /// The base method just calls <see cref="FarNet.Explorer.OpenFile"/> if the explorer supports it. /// </remarks> /// <param name="file">The file to be opened.</param> public virtual void UIOpenFile(FarFile file) { if (file == null) return; if (!Explorer.CanOpenFile) return; var args = new OpenFileEventArgs(file); var explorer = UIOpenFile(args); if (explorer != null) explorer.OpenPanelChild(this); }
/// <summary> /// Opens the file in the viewer. /// </summary> /// <param name="file">The file to view.</param> /// <remarks> /// The default method calls <see cref="FarNet.Explorer.GetContent"/> to get a temporary file to view. /// The explorer should have it implemented. /// </remarks> public virtual void UIViewFile(FarFile file) { if (file == null) return; // target var temp = Far.Api.TempName(); // export var xExportArgs = WorksExportExplorerFile(Explorer, this, ExplorerModes.View, file, temp); if (xExportArgs == null) return; // case: actual file exists var asExportFileEventArgs = xExportArgs as GetContentEventArgs; if (asExportFileEventArgs != null && !string.IsNullOrEmpty(asExportFileEventArgs.UseFileName)) { var viewerActual = Far.Api.CreateViewer(); viewerActual.FileName = asExportFileEventArgs.UseFileName; viewerActual.Title = file.Name; viewerActual.Open(); return; } // viewer var viewerTemp = Far.Api.CreateViewer(); viewerTemp.DeleteSource = DeleteSource.File; viewerTemp.DisableHistory = true; viewerTemp.FileName = temp; viewerTemp.Title = file.Name; viewerTemp.Switching = Switching.Enabled; if (asExportFileEventArgs.CodePage != 0) viewerTemp.CodePage = asExportFileEventArgs.CodePage; // open viewerTemp.Open(); }
/// <summary> /// Opens <see cref="MemberPanel"/> for a file. /// File <c>Data</c> must not be null. /// </summary> internal override MemberPanel OpenFileMembers(FarFile file) { // get data TreeFile t = (TreeFile)file; if (t.Data == null) return null; //! use null as parent: this panel can be not open now MemberPanel r = new MemberPanel(new MemberExplorer(t.Data)); r.OpenChild(null); return r; }
public OperationResult DirectLocalCopyOrRename(FarFile currentFile, bool isMove) { // IsSilentOperation() || ??? OnDeviceOperation doc = null; Playlist pl = (Playlist)currentFile.Data; string name = pl.Name; PlaylistSortField sortField = pl.SortField; if (CommonDialog.ForGetPlayListParams(ref name, ref sortField, isMove) == 0) { doc = new DirectPlaylistOperation( _fs.CurrentDevice, pl, name, sortField, isMove); } return execOperation(doc, null).SetResult(name); }
/// <summary> /// <see cref="UIViewFile"/> worker. /// </summary> /// <param name="file">The file to view.</param> public void DoViewFile(FarFile file) { base.UIViewFile(file); }
//_091202_073429 /// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="file">The file to view.</param> public override sealed void UIViewFile(FarFile file) { if (AsViewFile != null) A.InvokeScriptReturnAsIs(AsViewFile, this, file); else DoViewFile(file); }
/// <summary> /// Posts the file to be found and set current on redrawing. /// </summary> /// <param name="file">The file to be found on redrawing.</param> /// <remarks> /// The posted file is ignored if <see cref="PostData"/> or <see cref="PostName"/> were called. /// The <see cref="FarNet.Explorer.FileComparer"/> is used in order to find the file. /// </remarks> public void PostFile(FarFile file) { _Panel.PostFile(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); } }
internal PanelMenuEventArgs(IMenu menu, FarFile currentFile, IList <FarFile> selectedList) { Menu = menu; CurrentFile = currentFile; SelectedList = selectedList; }
public override bool UIKeyPressed(KeyInfo key) { if (key == null) { throw new ArgumentNullException("key"); } UserWants = UserAction.None; try { switch (key.VirtualKeyCode) { case KeyCode.Enter: if (key.Is()) { FarFile file = CurrentFile; if (file == null) { break; } UserWants = UserAction.Enter; if (file.IsDirectory && !IgnoreDirectoryFlag) { break; } UIOpenFile(file); return(true); } if (key.IsShift()) { UIAttributes(); return(true); } break; case KeyCode.F1: if (key.Is()) { UIHelp(); return(true); } break; case KeyCode.F3: if (key.Is()) { if (CurrentFile == null) { UIViewAll(); return(true); } break; } if (key.IsShift()) { ShowMenu(); return(true); } break; case KeyCode.PageDown: if (key.IsCtrl()) { UIOpenFileMembers(); return(true); } break; case KeyCode.A: if (key.IsCtrl()) { UIAttributes(); return(true); } break; case KeyCode.G: if (key.IsCtrl()) { UIApply(); return(true); } break; case KeyCode.M: if (key.IsCtrlShift()) { UIMode(); return(true); } break; case KeyCode.S: //! Mantis#2635 Ignore if auto-completion menu is opened if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu) { SaveData(); return(true); } break; } // base return(base.UIKeyPressed(key)); } finally { UserWants = UserAction.None; } }
internal PanelMenuEventArgs(IMenu menu, FarFile currentFile, IList<FarFile> selectedList) { Menu = menu; CurrentFile = currentFile; SelectedList = selectedList; }
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; } }
/// <summary> /// Opens a file. /// </summary> /// <param name="file">The file to open.</param> /// <remarks> /// The base method calls Invoke-Item for <see cref="FileSystemInfo"/> files. /// </remarks> public virtual void OpenFile(FarFile file) { if (file == null) throw new ArgumentNullException("file"); if (file.Data == null) return; //! use try, e.g. Invoke-Item throws exception with any error action (PS bug?) try { // case: file system FileSystemInfo fi = Cast<FileSystemInfo>.From(file.Data); if (fi != null) { A.InvokeCode("Invoke-Item -LiteralPath $args[0] -ErrorAction Stop", fi.FullName); return; } } catch (RuntimeException ex) { A.Msg(ex); } }
public override bool UIKeyPressed(KeyInfo key) { if (key == null) { throw new ArgumentNullException("key"); } UserWants = UserAction.None; try { switch (key.VirtualKeyCode) { case KeyCode.Enter: if (key.Is()) { //Far.Api.ShowError("Not implemented", new NotImplementedException("Not implemented: "+ CurrentFile.Name)); FarFile file = CurrentFile; if (file == null) { break; } UserWants = UserAction.Enter; if (file.IsDirectory && !IgnoreDirectoryFlag) { break; } var cancellation = new CancellationTokenSource(); var _cancel = cancellation.Token; //var ptask = new ProgressTask("test", "test-title", _cancel); //var form = ptask.ShowDialog(); //Thread.Sleep(3000); //cancellation.Cancel(); //form.Complete(); UIOpenFile(file); return(true); } if (key.IsShift()) { UIAttributes(); return(true); } break; case KeyCode.F1: if (key.Is()) { UIHelp(); return(true); } break; case KeyCode.F3: if (key.Is()) { if (CurrentFile == null) { UIExploreLocation(null); //UIViewAll(); return(true); } /* * if (CurrentFile.IsDirectory) * { * Explorer.CanExploreLocation = true; * break; * } * * Explorer.CanExploreLocation = false; */ break; } if (key.IsShift()) { //ShowMenu(); return(true); } break; /* * case KeyCode.F5: * * if (key.Is()) * { * if (CurrentFile == null) * { * //UIViewAll(); * return true; * } * * Log.Source.TraceInformation("Tried to copy this file: {0}\\{1}", CurrentLocation, CurrentFile.Name); * * Log.Source.TraceInformation("Far.Api.Panel2.IsPlugin = {0}", Far.Api.Panel2.IsPlugin ? "true" : "false"); * Log.Source.TraceInformation("Far.Api.Panel2.CurrentFile = {0}", Far.Api.Panel2.CurrentFile); * Log.Source.TraceInformation("Far.Api.Panel2.CurrentDirectory = {0}", Far.Api.Panel2.CurrentDirectory); * * if (Far.Api.Panel2.IsPlugin) * { * // How to copy files to plugins?? * return true; * } * * if (Far.Api.Panel2.CurrentDirectory == null) * { * // how can it be? * return true; * } * * var item = ((CurrentFile.Data as Hashtable)["fsitem"] as FSItem); * var path = Path.Combine(Far.Api.Panel2.CurrentDirectory, item.Name); * * var form = new Tools.ProgressForm(); * form.Activity = "Downloading..."; * form.Title = "Amazon Cloud Drive - File Download Progress"; * form.CanCancel = true; * form.SetProgressValue(0, item.Length); * form.Canceled += (object sender, EventArgs e) => * { * form.Close(); * }; * * Task task = (Explorer as ACDExplorer).Client.DownloadFile(item, path, form); * var cs = new CancellationTokenSource(); * var token = cs.Token; * / * * token.Register(() => * { * form.Close(); * });* / * var _task = Task.Factory.StartNew(() => * { * form.Show(); * }, token); * task.Wait(); * * break; * } * * if (key.IsShift()) * { * //ShowMenu(); * return true; * } * * break; */ case KeyCode.PageDown: if (key.IsCtrl()) { UIOpenFileMembers(); return(true); } break; case KeyCode.A: if (key.IsCtrl()) { UIAttributes(); return(true); } break; case KeyCode.G: if (key.IsCtrl()) { UIApply(); return(true); } break; case KeyCode.M: if (key.IsCtrlShift()) { UIMode(); return(true); } break; case KeyCode.S: //! Mantis#2635 Ignore if auto-completion menu is opened if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu) { SaveData(); return(true); } break; case KeyCode.R: if (key.IsCtrl()) { CacheStorage.RemoveItems(Far.Api.Panel.CurrentDirectory); } break; } // base return(base.UIKeyPressed(key)); } finally { UserWants = UserAction.None; } }
/// <inheritdoc/> public override bool UIKeyPressed(KeyInfo key) { if (key == null) { throw new ArgumentNullException("key"); } switch (key.VirtualKeyCode) { case KeyCode.LeftArrow: { if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0) { break; } FarFile file = CurrentFile; if (file == null) { break; } TreeFile node = (TreeFile)file; if (node._State == 1) { // reset if (key.IsAlt()) { node.ChildFiles.Clear(); node._State = 0; UpdateRedraw(false); return(true); } // collapse OpenFile(file); } else if (node.Parent != null) { PostFile(node.Parent); Redraw(); } return(true); } case KeyCode.RightArrow: { if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0) { break; } FarFile file = CurrentFile; if (file == null) { break; } TreeFile node = (TreeFile)file; if (node != null && node._State != 1 && node.IsNode) { // reset if (key.IsAlt()) { node.ChildFiles.Clear(); node._State = 0; } // open OpenFile(file); } else { // go to next Redraw(CurrentIndex + 1, -1); } return(true); } } // base return(base.UIKeyPressed(key)); }
internal override MemberPanel OpenFileMembers(FarFile file) { PSObject o = PSObject.AsPSObject(file.Data); string memberType = o.Properties["MemberType"].Value.ToString(); if (!memberType.EndsWith("Property", StringComparison.Ordinal)) //?? return null; string name = o.Properties[Word.Name].Value.ToString(); object instance = Target.Properties[name].Value; if (instance == null) return null; MemberPanel r = new MemberPanel(new MemberExplorer(instance)); r.OpenChild(this); return r; }