bookmark-manager-r4/RyzStudio/Windows/ThemedForms/TextBox/TFolderTextBox.cs

47 lines
1.3 KiB
C#
Raw Normal View History

using System.IO;
2021-09-07 11:32:24 +00:00
using System.Windows.Forms;
using UIResources = BookmarkManager.UIResource;
namespace RyzStudio.Windows.ThemedForms
{
public class TFolderTextBox : TButtonTextBox
{
public TFolderTextBox() : base()
{
this.NormalImage = UIResources.folder;
this.HighlightImage = UIResources.folder2;
this.Text = string.Empty;
}
public FolderBrowserDialog FolderDialog { get; set; } = null;
protected override void imageBox1_MouseClick(object sender, MouseEventArgs e)
2021-09-07 11:32:24 +00:00
{
if (e.Button != MouseButtons.Left)
{
return;
}
2021-09-07 11:32:24 +00:00
if (this.FolderDialog == null)
{
this.FolderDialog = new FolderBrowserDialog();
this.FolderDialog.Description = "Choose a directory";
}
if (!string.IsNullOrWhiteSpace(this.Text))
{
if (Directory.Exists(this.Text))
{
this.FolderDialog.SelectedPath = this.Text;
}
}
if (this.FolderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.Text = this.FolderDialog.SelectedPath;
}
}
}
}