using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace DPumpHydr.WinFrmUI.WenSkin.Controls
|
{
|
public class WenDialogLableTextBox : WenLableTextBox
|
{
|
public WenDialogLableTextBox()
|
{
|
Image = Properties.Resources.选择;
|
|
this.ButtonClick += WenChoiceLableTextBox_ButtonClick;
|
}
|
|
private void WenChoiceLableTextBox_ButtonClick(object sender, WenLableTextBoxButtonEventArgs e)
|
{
|
e.ShowTextBox = false;
|
|
if (Dialog == DialogStyle.File)
|
{
|
OpenFileDialog ofd = new OpenFileDialog();
|
ofd.Filter = this.Filter;
|
var dia = ofd.ShowDialog();
|
if(dia != DialogResult.OK)
|
{
|
return;
|
}
|
this.Text = ofd.FileName;
|
}
|
else
|
{
|
FolderBrowserDialog fol = new FolderBrowserDialog();
|
var dia = fol.ShowDialog();
|
if(dia != DialogResult.OK)
|
{
|
return;
|
}
|
this.Text = fol.SelectedPath;
|
}
|
|
}
|
|
#region 公有属性
|
[Category("Wen"), Description("选择类型"), DefaultValue(false)]
|
public DialogStyle Dialog { get; set; } = DialogStyle.File;
|
|
|
[Category("Wen"), Description("选择类型"), DefaultValue(false)]
|
public string Filter { get; set; } = "所有文件(*.*)|*.*";
|
#endregion
|
|
|
public enum DialogStyle
|
{
|
Folder,
|
File
|
}
|
}
|
}
|