| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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.Design;
- using System.Windows.Forms;
- using XmlToTreeView;
- public class NodeTypeEditor: UITypeEditor
- {
- public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
- {
- return UITypeEditorEditStyle.Modal;
- }
- public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
- {
- if (provider != null)
- {
- // 获取对话框服务
- IWindowsFormsEditorService editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
- if (editorService != null)
- {
- // 创建自定义选择窗口
- NodeSelectionDialog dialog = new NodeSelectionDialog();
- // 设置初始值
- dialog.SelectedValue = (Node)value;
- // 显示模态对话框
- if (editorService.ShowDialog(dialog) == DialogResult.OK)
- {
- // 返回用户选择的值
- return dialog.SelectedValue;
- }
- }
- }
- return value;
- }
- }
|