mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
FileDialog2 improvements
- Expose table/tree style properties - Rename Monochrome to UseColors and default to false - IconGetter no longer forces space - On Windows in Scenario just use a backslash for folder icon (i.e. not unicode) -
This commit is contained in:
@@ -35,6 +35,16 @@ namespace Terminal.Gui {
|
|||||||
public string FileMustExistFeedback { get; internal set; } = Strings.fdFileMustExistFeedback;
|
public string FileMustExistFeedback { get; internal set; } = Strings.fdFileMustExistFeedback;
|
||||||
public string DirectoryAlreadyExistsFeedback { get; internal set; } = Strings.fdDirectoryAlreadyExistsFeedback;
|
public string DirectoryAlreadyExistsFeedback { get; internal set; } = Strings.fdDirectoryAlreadyExistsFeedback;
|
||||||
public string FileOrDirectoryMustExistFeedback { get; internal set; } = Strings.fdFileOrDirectoryMustExistFeedback;
|
public string FileOrDirectoryMustExistFeedback { get; internal set; } = Strings.fdFileOrDirectoryMustExistFeedback;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the style settings for the table of files (in currently selected directory).
|
||||||
|
/// </summary>
|
||||||
|
public TableView.TableStyle TableStyle { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the style settings for the collapse-able directory/places tree
|
||||||
|
/// </summary>
|
||||||
|
public TreeStyle TreeStyle { get; internal set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -199,6 +209,7 @@ namespace Terminal.Gui {
|
|||||||
FullRowSelect = true,
|
FullRowSelect = true,
|
||||||
};
|
};
|
||||||
this.tableView.AddKeyBinding (Key.Space, Command.ToggleChecked);
|
this.tableView.AddKeyBinding (Key.Space, Command.ToggleChecked);
|
||||||
|
Style.TableStyle = tableView.Style;
|
||||||
this.tableView.KeyPress += (k) => {
|
this.tableView.KeyPress += (k) => {
|
||||||
if (this.tableView.SelectedRow <= 0) {
|
if (this.tableView.SelectedRow <= 0) {
|
||||||
this.NavigateIf (k, Key.CursorUp, this.tbPath);
|
this.NavigateIf (k, Key.CursorUp, this.tbPath);
|
||||||
@@ -224,7 +235,7 @@ namespace Terminal.Gui {
|
|||||||
|
|
||||||
this.treeView.TreeBuilder = new FileDialogTreeBuilder ();
|
this.treeView.TreeBuilder = new FileDialogTreeBuilder ();
|
||||||
this.treeView.AspectGetter = (m) => m is DirectoryInfo d ? d.Name : m.ToString ();
|
this.treeView.AspectGetter = (m) => m is DirectoryInfo d ? d.Name : m.ToString ();
|
||||||
|
this.Style.TreeStyle = treeView.Style;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.treeView.AddObjects (
|
this.treeView.AddObjects (
|
||||||
@@ -512,9 +523,10 @@ namespace Terminal.Gui {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets a value indicating whether different colors
|
/// Gets or Sets a value indicating whether different colors
|
||||||
/// should be used for different file types/directories.
|
/// should be used for different file types/directories. Defaults
|
||||||
|
/// to false.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Monochrome { get; set; }
|
public bool UseColors { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets a collection of file types that the user can/must select. Only applies
|
/// Gets or Sets a collection of file types that the user can/must select. Only applies
|
||||||
@@ -940,7 +952,7 @@ namespace Terminal.Gui {
|
|||||||
var icon = stats.IsParent ? null : IconGetter?.Invoke (stats.FileSystemInfo);
|
var icon = stats.IsParent ? null : IconGetter?.Invoke (stats.FileSystemInfo);
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
return icon + " " + stats.Name;
|
return icon + stats.Name;
|
||||||
}
|
}
|
||||||
return stats.Name;
|
return stats.Name;
|
||||||
};
|
};
|
||||||
@@ -1155,7 +1167,7 @@ namespace Terminal.Gui {
|
|||||||
{
|
{
|
||||||
var stats = this.RowToStats (args.RowIndex);
|
var stats = this.RowToStats (args.RowIndex);
|
||||||
|
|
||||||
if (Monochrome) {
|
if (!UseColors) {
|
||||||
return ColorSchemeDefault;
|
return ColorSchemeDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using Terminal.Gui;
|
using Terminal.Gui;
|
||||||
using Terminal.Gui.Graphs;
|
using Terminal.Gui.Graphs;
|
||||||
using static Terminal.Gui.OpenDialog;
|
using static Terminal.Gui.OpenDialog;
|
||||||
@@ -12,7 +13,7 @@ namespace UICatalog.Scenarios {
|
|||||||
public class FileDialog2Examples : Scenario {
|
public class FileDialog2Examples : Scenario {
|
||||||
private CheckBox cbMustExist;
|
private CheckBox cbMustExist;
|
||||||
private CheckBox cbIcons;
|
private CheckBox cbIcons;
|
||||||
private CheckBox cbMonochrome;
|
private CheckBox cbUseColors;
|
||||||
private CheckBox cbCaseSensitive;
|
private CheckBox cbCaseSensitive;
|
||||||
private CheckBox cbAllowMultipleSelection;
|
private CheckBox cbAllowMultipleSelection;
|
||||||
|
|
||||||
@@ -32,8 +33,8 @@ namespace UICatalog.Scenarios {
|
|||||||
cbIcons = new CheckBox ("Icons") { Checked = true, Y = y++, X=x };
|
cbIcons = new CheckBox ("Icons") { Checked = true, Y = y++, X=x };
|
||||||
Win.Add (cbIcons);
|
Win.Add (cbIcons);
|
||||||
|
|
||||||
cbMonochrome = new CheckBox ("Monochrome") { Checked = false, Y = y++, X=x};
|
cbUseColors = new CheckBox ("Use Colors") { Checked = false, Y = y++, X=x};
|
||||||
Win.Add (cbMonochrome);
|
Win.Add (cbUseColors);
|
||||||
|
|
||||||
cbCaseSensitive = new CheckBox ("Case Sensitive Search") { Checked = false, Y = y++, X=x };
|
cbCaseSensitive = new CheckBox ("Case Sensitive Search") { Checked = false, Y = y++, X=x };
|
||||||
Win.Add (cbCaseSensitive);
|
Win.Add (cbCaseSensitive);
|
||||||
@@ -114,7 +115,7 @@ namespace UICatalog.Scenarios {
|
|||||||
fd.SearchMatcher = new CaseSensitiveSearchMatcher ();
|
fd.SearchMatcher = new CaseSensitiveSearchMatcher ();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd.Monochrome = cbMonochrome.Checked ?? false;
|
fd.UseColors = cbUseColors.Checked ?? false;
|
||||||
|
|
||||||
if (rgAllowedTypes.SelectedItem > 0) {
|
if (rgAllowedTypes.SelectedItem > 0) {
|
||||||
fd.AllowedTypes.Add (new FileDialog2.AllowedType ("Data File", ".csv", ".tsv"));
|
fd.AllowedTypes.Add (new FileDialog2.AllowedType ("Data File", ".csv", ".tsv"));
|
||||||
@@ -159,11 +160,17 @@ namespace UICatalog.Scenarios {
|
|||||||
|
|
||||||
private string GetIcon (FileSystemInfo arg)
|
private string GetIcon (FileSystemInfo arg)
|
||||||
{
|
{
|
||||||
if (arg is DirectoryInfo) {
|
// Typically most windows terminals will not have these unicode characters installed
|
||||||
return "\ua909";
|
// so for the demo lets not bother having any icons on windows
|
||||||
|
if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
|
||||||
|
return arg is DirectoryInfo ? "\\" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\u2630";
|
if (arg is DirectoryInfo) {
|
||||||
|
return "\ua909 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "\u2630 ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user