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/TOpenFileTextBox.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2020-05-12 23:37:01 +00:00
using System;
using System.IO;
using System.Windows.Forms;
2020-10-21 01:17:24 +00:00
using Resources = AppLauncher.Properties.Resources16;
2020-05-12 23:37:01 +00:00
namespace RyzStudio.Windows.ThemedForms
{
public class TOpenFileTextBox : TButtonTextBox
{
public TOpenFileTextBox() : base()
{
2020-10-21 01:17:24 +00:00
this.NormalImage = Resources.file;
this.HighlightImage = Resources.file2;
2020-05-12 23:37:01 +00:00
this.Text = string.Empty;
}
public OpenFileDialog FileDialog { get; set; } = null;
protected override void imageBox1_Click(object sender, EventArgs e)
{
if (this.FileDialog == null)
{
this.FileDialog = new OpenFileDialog();
this.FileDialog.Title = "Choose a file";
this.FileDialog.Filter = "All files|*";
}
if (!string.IsNullOrWhiteSpace(this.Text))
{
if (File.Exists(this.Text))
{
this.FileDialog.InitialDirectory = Path.GetDirectoryName(this.Text);
}
}
if (this.FileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.Text = this.FileDialog.FileName;
}
}
}
}