FileDialogRootTreeNode.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.IO.Abstractions;
  4. namespace Terminal.Gui {
  5. /// <summary>
  6. /// Delegate for providing an implementation that returns all <see cref="FileDialogRootTreeNode"/>
  7. /// that should be shown in a <see cref="FileDialog"/> (in the collapse-able tree area of the dialog).
  8. /// </summary>
  9. /// <returns></returns>
  10. public delegate IEnumerable<FileDialogRootTreeNode> FileDialogTreeRootGetter ();
  11. /// <summary>
  12. /// Describes a top level directory that should be offered to the user in the
  13. /// tree view section of a <see cref="FileDialog"/>. For example "Desktop",
  14. /// "Downloads", "Documents" etc.
  15. /// </summary>
  16. public class FileDialogRootTreeNode {
  17. /// <summary>
  18. /// Creates a new instance of the <see cref="FileDialogRootTreeNode"/> class
  19. /// </summary>
  20. /// <param name="displayName"></param>
  21. /// <param name="path"></param>
  22. public FileDialogRootTreeNode (string displayName, IDirectoryInfo path)
  23. {
  24. this.DisplayName = displayName;
  25. this.Path = path;
  26. }
  27. /// <summary>
  28. /// Gets the text that should be displayed in the tree for this item.
  29. /// </summary>
  30. public string DisplayName { get; }
  31. /// <summary>
  32. /// Gets the path that should be shown/explored when selecting this node
  33. /// of the tree.
  34. /// </summary>
  35. public IDirectoryInfo Path { get; }
  36. /// <summary>
  37. /// Returns a string representation of this instance (<see cref="DisplayName"/>).
  38. /// </summary>
  39. /// <returns></returns>
  40. public override string ToString ()
  41. {
  42. return this.DisplayName;
  43. }
  44. }
  45. }