|
@@ -84,6 +84,7 @@ namespace UICatalog.Scenarios {
|
|
Width = Dim.Percent (50),
|
|
Width = Dim.Percent (50),
|
|
Height = Dim.Fill (),
|
|
Height = Dim.Fill (),
|
|
};
|
|
};
|
|
|
|
+ treeViewFiles.DrawLine += TreeViewFiles_DrawLine;
|
|
|
|
|
|
_detailsFrame = new DetailsFrame (_iconProvider) {
|
|
_detailsFrame = new DetailsFrame (_iconProvider) {
|
|
X = Pos.Right (treeViewFiles),
|
|
X = Pos.Right (treeViewFiles),
|
|
@@ -106,7 +107,7 @@ namespace UICatalog.Scenarios {
|
|
SetupScrollBar ();
|
|
SetupScrollBar ();
|
|
|
|
|
|
treeViewFiles.SetFocus ();
|
|
treeViewFiles.SetFocus ();
|
|
-
|
|
|
|
|
|
+
|
|
UpdateIconCheckedness ();
|
|
UpdateIconCheckedness ();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,6 +141,23 @@ namespace UICatalog.Scenarios {
|
|
ShowPropertiesOf (e.NewValue);
|
|
ShowPropertiesOf (e.NewValue);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void TreeViewFiles_DrawLine (object sender, DrawTreeViewLineEventArgs<IFileSystemInfo> e)
|
|
|
|
+ {
|
|
|
|
+ // Render directory icons in yellow
|
|
|
|
+ if (e.Model is IDirectoryInfo d) {
|
|
|
|
+ if (_iconProvider.UseNerdIcons || _iconProvider.UseUnicodeCharacters) {
|
|
|
|
+ if (e.IndexOfModelText > 0 && e.IndexOfModelText < e.RuneCells.Count) {
|
|
|
|
+ var cell = e.RuneCells [e.IndexOfModelText];
|
|
|
|
+ cell.ColorScheme = new ColorScheme (
|
|
|
|
+ new Terminal.Gui.Attribute (
|
|
|
|
+ Color.BrightYellow,
|
|
|
|
+ cell.ColorScheme.Normal.Background)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void TreeViewFiles_KeyPress (object sender, KeyEventEventArgs obj)
|
|
private void TreeViewFiles_KeyPress (object sender, KeyEventEventArgs obj)
|
|
{
|
|
{
|
|
if (obj.KeyEvent.Key == (Key.R | Key.CtrlMask)) {
|
|
if (obj.KeyEvent.Key == (Key.R | Key.CtrlMask)) {
|
|
@@ -195,7 +213,7 @@ namespace UICatalog.Scenarios {
|
|
private IFileSystemInfo fileInfo;
|
|
private IFileSystemInfo fileInfo;
|
|
private FileSystemIconProvider _iconProvider;
|
|
private FileSystemIconProvider _iconProvider;
|
|
|
|
|
|
- public DetailsFrame (FileSystemIconProvider iconProvider)
|
|
|
|
|
|
+ public DetailsFrame (FileSystemIconProvider iconProvider)
|
|
{
|
|
{
|
|
Title = "Details";
|
|
Title = "Details";
|
|
Visible = true;
|
|
Visible = true;
|
|
@@ -209,7 +227,7 @@ namespace UICatalog.Scenarios {
|
|
System.Text.StringBuilder sb = null;
|
|
System.Text.StringBuilder sb = null;
|
|
|
|
|
|
if (fileInfo is IFileInfo f) {
|
|
if (fileInfo is IFileInfo f) {
|
|
- Title = $"{_iconProvider.GetIconWithOptionalSpace(f)}{f.Name}".Trim();
|
|
|
|
|
|
+ Title = $"{_iconProvider.GetIconWithOptionalSpace (f)}{f.Name}".Trim ();
|
|
sb = new System.Text.StringBuilder ();
|
|
sb = new System.Text.StringBuilder ();
|
|
sb.AppendLine ($"Path:\n {f.FullName}\n");
|
|
sb.AppendLine ($"Path:\n {f.FullName}\n");
|
|
sb.AppendLine ($"Size:\n {f.Length:N0} bytes\n");
|
|
sb.AppendLine ($"Size:\n {f.Length:N0} bytes\n");
|
|
@@ -218,7 +236,7 @@ namespace UICatalog.Scenarios {
|
|
}
|
|
}
|
|
|
|
|
|
if (fileInfo is IDirectoryInfo dir) {
|
|
if (fileInfo is IDirectoryInfo dir) {
|
|
- Title = $"{_iconProvider.GetIconWithOptionalSpace(dir)}{dir.Name}".Trim();
|
|
|
|
|
|
+ Title = $"{_iconProvider.GetIconWithOptionalSpace (dir)}{dir.Name}".Trim ();
|
|
sb = new System.Text.StringBuilder ();
|
|
sb = new System.Text.StringBuilder ();
|
|
sb.AppendLine ($"Path:\n {dir?.FullName}\n");
|
|
sb.AppendLine ($"Path:\n {dir?.FullName}\n");
|
|
sb.AppendLine ($"Modified:\n {dir.LastWriteTime}\n");
|
|
sb.AppendLine ($"Modified:\n {dir.LastWriteTime}\n");
|
|
@@ -241,7 +259,7 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
var scrollBar = new ScrollBarView (treeViewFiles, true);
|
|
var scrollBar = new ScrollBarView (treeViewFiles, true);
|
|
|
|
|
|
- scrollBar.ChangedPosition += (s,e) => {
|
|
|
|
|
|
+ scrollBar.ChangedPosition += (s, e) => {
|
|
treeViewFiles.ScrollOffsetVertical = scrollBar.Position;
|
|
treeViewFiles.ScrollOffsetVertical = scrollBar.Position;
|
|
if (treeViewFiles.ScrollOffsetVertical != scrollBar.Position) {
|
|
if (treeViewFiles.ScrollOffsetVertical != scrollBar.Position) {
|
|
scrollBar.Position = treeViewFiles.ScrollOffsetVertical;
|
|
scrollBar.Position = treeViewFiles.ScrollOffsetVertical;
|
|
@@ -249,7 +267,7 @@ namespace UICatalog.Scenarios {
|
|
treeViewFiles.SetNeedsDisplay ();
|
|
treeViewFiles.SetNeedsDisplay ();
|
|
};
|
|
};
|
|
|
|
|
|
- scrollBar.OtherScrollBarView.ChangedPosition += (s,e) => {
|
|
|
|
|
|
+ scrollBar.OtherScrollBarView.ChangedPosition += (s, e) => {
|
|
treeViewFiles.ScrollOffsetHorizontal = scrollBar.OtherScrollBarView.Position;
|
|
treeViewFiles.ScrollOffsetHorizontal = scrollBar.OtherScrollBarView.Position;
|
|
if (treeViewFiles.ScrollOffsetHorizontal != scrollBar.OtherScrollBarView.Position) {
|
|
if (treeViewFiles.ScrollOffsetHorizontal != scrollBar.OtherScrollBarView.Position) {
|
|
scrollBar.OtherScrollBarView.Position = treeViewFiles.ScrollOffsetHorizontal;
|
|
scrollBar.OtherScrollBarView.Position = treeViewFiles.ScrollOffsetHorizontal;
|
|
@@ -257,7 +275,7 @@ namespace UICatalog.Scenarios {
|
|
treeViewFiles.SetNeedsDisplay ();
|
|
treeViewFiles.SetNeedsDisplay ();
|
|
};
|
|
};
|
|
|
|
|
|
- treeViewFiles.DrawContent += (s,e) => {
|
|
|
|
|
|
+ treeViewFiles.DrawContent += (s, e) => {
|
|
scrollBar.Size = treeViewFiles.ContentHeight;
|
|
scrollBar.Size = treeViewFiles.ContentHeight;
|
|
scrollBar.Position = treeViewFiles.ScrollOffsetVertical;
|
|
scrollBar.Position = treeViewFiles.ScrollOffsetVertical;
|
|
scrollBar.OtherScrollBarView.Size = treeViewFiles.GetContentWidth (true);
|
|
scrollBar.OtherScrollBarView.Size = treeViewFiles.GetContentWidth (true);
|
|
@@ -269,20 +287,20 @@ namespace UICatalog.Scenarios {
|
|
private void SetupFileTree ()
|
|
private void SetupFileTree ()
|
|
{
|
|
{
|
|
// setup how to build tree
|
|
// setup how to build tree
|
|
- var fs = new FileSystem();
|
|
|
|
- var rootDirs = DriveInfo.GetDrives ().Select (d=>fs.DirectoryInfo.New(d.RootDirectory.FullName));
|
|
|
|
|
|
+ var fs = new FileSystem ();
|
|
|
|
+ var rootDirs = DriveInfo.GetDrives ().Select (d => fs.DirectoryInfo.New (d.RootDirectory.FullName));
|
|
treeViewFiles.TreeBuilder = new FileSystemTreeBuilder ();
|
|
treeViewFiles.TreeBuilder = new FileSystemTreeBuilder ();
|
|
treeViewFiles.AddObjects (rootDirs);
|
|
treeViewFiles.AddObjects (rootDirs);
|
|
|
|
|
|
// Determines how to represent objects as strings on the screen
|
|
// Determines how to represent objects as strings on the screen
|
|
treeViewFiles.AspectGetter = AspectGetter;
|
|
treeViewFiles.AspectGetter = AspectGetter;
|
|
-
|
|
|
|
|
|
+
|
|
_iconProvider.IsOpenGetter = treeViewFiles.IsExpanded;
|
|
_iconProvider.IsOpenGetter = treeViewFiles.IsExpanded;
|
|
}
|
|
}
|
|
|
|
|
|
private string AspectGetter (IFileSystemInfo f)
|
|
private string AspectGetter (IFileSystemInfo f)
|
|
{
|
|
{
|
|
- return (_iconProvider.GetIconWithOptionalSpace(f) + f.Name).Trim();
|
|
|
|
|
|
+ return (_iconProvider.GetIconWithOptionalSpace (f) + f.Name).Trim ();
|
|
}
|
|
}
|
|
|
|
|
|
private void ShowLines ()
|
|
private void ShowLines ()
|