Procházet zdrojové kódy

Make FileDialog strings more customizeable and public

tznind před 1 rokem
rodič
revize
a3f58d3c29

+ 13 - 8
Terminal.Gui/FileServices/FileDialogStyle.cs

@@ -80,12 +80,12 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Gets or sets the text displayed in the 'Search' text box when user has not supplied any input yet.
 		/// </summary>
-		public string SearchCaption { get; internal set; } = Strings.fdSearchCaption;
+		public string SearchCaption { get; set; } = Strings.fdSearchCaption;
 
 		/// <summary>
 		/// Gets or sets the text displayed in the 'Path' text box when user has not supplied any input yet.
 		/// </summary>
-		public string PathCaption { get; internal set; } = Strings.fdPathCaption;
+		public string PathCaption { get; set; } = Strings.fdPathCaption;
 
 		/// <summary>
 		/// Gets or sets the text on the 'Ok' button.  Typically you may want to change this to
@@ -93,40 +93,45 @@ namespace Terminal.Gui {
 		/// </summary>
 		public string OkButtonText { get; set; } = "Ok";
 
+		/// <summary>
+		/// Gets or sets the text on the 'Cancel' button.
+		/// </summary>
+		public string CancelButtonText { get; set; } = "Cancel";
+
 		/// <summary>
 		/// Gets or sets error message when user attempts to select a file type that is not one of <see cref="FileDialog.AllowedTypes"/>
 		/// </summary>
-		public string WrongFileTypeFeedback { get; internal set; } = Strings.fdWrongFileTypeFeedback;
+		public string WrongFileTypeFeedback { get; set; } = Strings.fdWrongFileTypeFeedback;
 
 		/// <summary>
 		/// Gets or sets error message when user selects a directory that does not exist and
 		/// <see cref="OpenMode"/> is <see cref="OpenMode.Directory"/> and <see cref="FileDialog.MustExist"/> is <see langword="true"/>.
 		/// </summary>
-		public string DirectoryMustExistFeedback { get; internal set; } = Strings.fdDirectoryMustExistFeedback;
+		public string DirectoryMustExistFeedback { get; set; } = Strings.fdDirectoryMustExistFeedback;
 
 		/// <summary>
 		/// Gets or sets error message when user <see cref="OpenMode"/> is <see cref="OpenMode.Directory"/>
 		/// and user enters the name of an existing file (File system cannot have a folder with the same name as a file).
 		/// </summary>
-		public string FileAlreadyExistsFeedback { get; internal set; } = Strings.fdFileAlreadyExistsFeedback;
+		public string FileAlreadyExistsFeedback { get; set; } = Strings.fdFileAlreadyExistsFeedback;
 
 		/// <summary>
 		/// Gets or sets error message when user selects a file that does not exist and
 		/// <see cref="OpenMode"/> is <see cref="OpenMode.File"/> and <see cref="FileDialog.MustExist"/> is <see langword="true"/>.
 		/// </summary>
-		public string FileMustExistFeedback { get; internal set; } = Strings.fdFileMustExistFeedback;
+		public string FileMustExistFeedback { get; set; } = Strings.fdFileMustExistFeedback;
 
 		/// <summary>
 		/// Gets or sets error message when user <see cref="OpenMode"/> is <see cref="OpenMode.File"/>
 		/// and user enters the name of an existing directory (File system cannot have a folder with the same name as a file).
 		/// </summary>
-		public string DirectoryAlreadyExistsFeedback { get; internal set; } = Strings.fdDirectoryAlreadyExistsFeedback;
+		public string DirectoryAlreadyExistsFeedback { get; set; } = Strings.fdDirectoryAlreadyExistsFeedback;
 
 		/// <summary>
 		/// Gets or sets error message when user selects a file/dir that does not exist and
 		/// <see cref="OpenMode"/> is <see cref="OpenMode.Mixed"/> and <see cref="FileDialog.MustExist"/> is <see langword="true"/>.
 		/// </summary>
-		public string FileOrDirectoryMustExistFeedback { get; internal set; } = Strings.fdFileOrDirectoryMustExistFeedback;
+		public string FileOrDirectoryMustExistFeedback { get; set; } = Strings.fdFileOrDirectoryMustExistFeedback;
 
 		/// <summary>
 		/// Gets the style settings for the table of files (in currently selected directory).

+ 4 - 1
Terminal.Gui/Views/FileDialog.cs

@@ -188,7 +188,6 @@ namespace Terminal.Gui {
 
 			this.tbPath = new TextField {
 				Width = Dim.Fill (0),
-				Caption = Style.PathCaption,
 				CaptionColor = Color.Black
 			};
 			this.tbPath.KeyPress += (s, k) => {
@@ -644,11 +643,15 @@ namespace Terminal.Gui {
 
 			// May have been updated after instance was constructed
 			this.btnOk.Text = Style.OkButtonText;
+			this.btnCancel.Text = Style.CancelButtonText;
 			this.btnUp.Text = this.GetUpButtonText ();
 			this.btnBack.Text = this.GetBackButtonText ();
 			this.btnForward.Text = this.GetForwardButtonText ();
 			this.btnToggleSplitterCollapse.Text = this.GetToggleSplitterText (false);
 
+			tbPath.Caption = Style.PathCaption;
+			tbFind.Caption = Style.SearchCaption;
+
 			tbPath.Autocomplete.ColorScheme.Normal = Attribute.Make (Color.Black, tbPath.ColorScheme.Normal.Background);
 
 			_treeRoots = Style.TreeRootGetter ();