This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
linear-app-launcher/FizzyLauncher.UI/RyzStudio/Windows/ThemedForms/TFolderTextBox.cs
2020-10-21 01:54:00 +01:00

43 lines
1.2 KiB
C#

using System;
using System.IO;
using System.Windows.Forms;
using Resources = AppLauncher.Properties.Resources;
namespace RyzStudio.Windows.ThemedForms
{
public class TFolderTextBox : TButtonTextBox
{
public TFolderTextBox() : base()
{
this.NormalImage = Resources.folder16_a;
this.HighlightImage = Resources.folder16_b;
this.Text = string.Empty;
}
public FolderBrowserDialog FolderDialog { get; set; } = null;
protected override void imageBox1_Click(object sender, EventArgs e)
{
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;
}
}
}
}