You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/UCDraw/SigmaDrawerStyle/PropertyEditorGriddingSourc...

39 lines
1.1 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GeoSigma.SigmaDrawerStyle
{
/// <summary>
/// 数据来源选择框
/// </summary>
public class PropertyEditorGriddingSource : UITypeEditor
{
private OpenFileDialog fileDialog = new OpenFileDialog();
/// <inheritdoc/>
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}
/// <inheritdoc/>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
fileDialog.FileName = value?.ToString();
fileDialog.Filter = "Point File|*.xyz|Text File|*.txt|All Files|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
return fileDialog.FileName;
}
return base.EditValue(context, provider, value);
}
}
}