📄 expendinfotexteditor.cs
字号:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Yinde.Cnc.PageLister
{
/// <summary>
/// 提供可用于 ExpendInfoText 的设计值编辑器,用来表示和编辑所支持的数据类型的对象值。
/// </summary>
public class ExpendInfoTextEditor:UITypeEditor
{
/// <summary>
/// 为 UITypeEditors 提供接口,用于显示 Windows 窗体,或者在设计模式下在属性网格控件的下拉区域中显示控件。
/// </summary>
private IWindowsFormsEditorService edSvc = null;
/// <summary>
/// 重写 EditValue,获取由 EditValue 方法使用的编辑器样式
/// </summary>
/// <param name="context">可用于获取附加上下文信息的 ITypeDescriptorContext</param>
/// <param name="provider">IServiceProvider,此编辑器可用其来获取服务</param>
/// <param name="value">要编辑的对象</param>
/// <returns></returns>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if(context!=null && provider!=null)
{
edSvc=(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc!=null)
{
ExpendInfoTextEditorForm form=new ExpendInfoTextEditorForm();
form.Value=(string)value;
DialogResult result=edSvc.ShowDialog(form);
if(result==DialogResult.OK)
value=form.Value;
}
}
return base.EditValue (context, provider, value);
}
/// <summary>
/// 重写 GetEditStyle 使用 GetEditStyle 指示的编辑器样式编辑指定的对象值
/// </summary>
/// <param name="context">可用于获取附加上下文信息的 ITypeDescriptorContext</param>
/// <returns></returns>
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null)
{
return UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -