BaoKai_202508-Wms-Jingwang..../ShapeControl_CodeProject/FormLoadFileEditor.cs

90 lines
2.9 KiB
C#
Raw Permalink Normal View History

2025-08-24 09:35:55 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Drawing.Drawing2D;
using System.IO;
namespace ShapeControl
{
internal partial class FormLoadFileEditor : Form
{
public string filename = "";
public FormLoadFileEditor()
{
InitializeComponent();
}
private void FormLoadFileEditor_Load(object sender, EventArgs e)
{
this.Hide();
// openFileDialog1.InitialDirectory = Application.LocalUserAppDataPath;
openFileDialog1.Filter = "Shape Files|*.shp.jpg";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
filename = openFileDialog1.FileName;
}
this.Close();
}
}
public class FileLoadEditor : System.Drawing.Design.UITypeEditor
{
public FileLoadEditor()
{
}
// Indicates whether the UITypeEditor provides a form-based (modal) dialog,
// drop down dialog, or no UI outside of the properties window.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
// Displays the UI for value selection.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
//if( value.GetType() != typeof(Color))
// return value;
// Uses the IWindowsFormsEditorService to display a
// drop-down UI in the Properties window.
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
//ColorEditorControl editor = new ColorEditorControl((Color)value);
//edSvc.DropDownControl(editor);
//// Return the value in the appropraite data format.
//if (value.GetType() == typeof(Color))
// return editor.color;
FormLoadFileEditor lfeditor = new FormLoadFileEditor();
edSvc.ShowDialog(lfeditor);
//if (value.GetType() == typeof(Color))
// return sfeditor.color;
return lfeditor.filename;
}
return value;
}
}
}