/// <inheritdoc/> public override void UIRedrawing(PanelEventArgs e) { base.UIRedrawing(e); string dir = string.Empty; var file = CurrentFile; if (file != null) { TreeFile node = (TreeFile)file; TreeFile parent = node.Parent; if (parent != null) { dir = parent.Path; } else { dir = node.Path; } } if (dir.Length > 0) { Title = "Tree: " + dir; } else { Title = "Tree"; dir = "*"; // to avoid empty (Far closes on dots or CtrlPgUp); STOP: see _130117_234326 } //! panel directory is not the same as the explorer location CurrentLocation = dir; }
/// <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); } }
internal override void UIAttributes() { FarFile file = CurrentFile; if (file == null) { return; } TreeFile node = (TreeFile)file; PSObject data = node.Data as PSObject; if (data == null) { return; } // validate provider ProviderInfo provider = (ProviderInfo)data.Properties["PSProvider"].Value; if (!My.ProviderInfoEx.HasProperty(provider)) { A.Message(Res.NotSupportedByProvider); return; } // show property panel (new PropertyExplorer(node.Path)).OpenPanelChild(this); }
static void Fill(TreeFile node) { // get Collection <PSObject> items = A.GetChildItems(node.Path); foreach (PSObject item in items) { if (!(bool)item.Properties["PSIsContainer"].Value) { continue; } TreeFile t = node.ChildFiles.Add(); // name t.Data = item; t.Name = (string)item.Properties["PSChildName"].Value; t.Fill = TheFill; // description PSPropertyInfo pi = item.Properties["FarDescription"]; if (pi != null && pi.Value != null) { t.Description = pi.Value.ToString(); } // attributes _090810_180151 if (item.BaseObject is FileSystemInfo fsi) { t.Attributes = fsi.Attributes & ~FileAttributes.Directory; } } }
/// <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); }
void AddFileFromTreeItem(TreeFile item, bool showHidden) { if (!showHidden && item.IsHidden) { return; } int level = item.Level; string nodePrefix = new string(' ', level * 2); if (item.IsNode) { if (item._State == 1) { nodePrefix += "- "; } else { nodePrefix += "+ "; } } else { nodePrefix += " "; } if (string.IsNullOrEmpty(item.Name)) //??? { item.Name = string.Empty; } item.Owner = nodePrefix + item.Name; _Files.Add(item); if (item._State == 1) { foreach (TreeFile ti in item.ChildFiles) { AddFileFromTreeItem(ti, showHidden); } } }
void Reset(string path) { // set location if (!string.IsNullOrEmpty(path) && path != ".") { A.Psf.Engine.SessionState.Path.SetLocation(path); } // get location PathInfoEx location = new PathInfoEx(A.Psf.Engine.SessionState.Path.CurrentLocation); if (!My.ProviderInfoEx.IsNavigation(location.Provider)) { throw new RuntimeException("Provider '" + location.Provider + "' does not support navigation."); } // get root item Collection <PSObject> items = A.Psf.Engine.SessionState.InvokeProvider.Item.Get(new string[] { "." }, true, true); //! trap Get-Item at Cert: if (items.Count == 0) { throw new RuntimeException(string.Format(null, "Provider '{0}' cannot get '{1}'.", location.Provider, location.Path)); } PSObject data = items[0]; // reset roots RootFiles.Clear(); var ti = new TreeFile { Name = location.Path, // special case name for the root Fill = TheFill, Data = data }; RootFiles.Add(ti); ti.Expand(); // panel info Location = ti.Path; }
/// <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/> 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)); }