public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null)) { ISite site = null; if (context.Instance is IComponent) { site = ((IComponent)context.Instance).Site; } else if (context.Instance is object[]) { object[] instance = (object[])context.Instance; if (instance[0] is IComponent) { site = ((IComponent)instance[0]).Site; } } RegexEditorDialog dialog = new RegexEditorDialog(site) { RegularExpression = value.ToString() }; if (dialog.ShowDialog() == DialogResult.OK) { value = dialog.RegularExpression; } } return(value); }
/// <include file='doc\RegexTypeEditor.uex' path='docs/doc[@for="RegexTypeEditor.EditValue"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { // Get the site // REVIEW amoore: there must be a better way to do this. ISite site = null; if (context.Instance is IComponent) { site = ((IComponent)context.Instance).Site; } else if (context.Instance is object[]) { object [] components = (object [])context.Instance; if (components[0] is IComponent) { site = ((IComponent)components[0]).Site; } } RegexEditorDialog editorDialog = new RegexEditorDialog(site); editorDialog.RegularExpression = value.ToString(); if (editorDialog.ShowDialog() == DialogResult.OK) { value = editorDialog.RegularExpression; } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null)) { ISite site = null; if (context.Instance is IComponent) { site = ((IComponent) context.Instance).Site; } else if (context.Instance is object[]) { object[] instance = (object[]) context.Instance; if (instance[0] is IComponent) { site = ((IComponent) instance[0]).Site; } } RegexEditorDialog dialog = new RegexEditorDialog(site) { RegularExpression = value.ToString() }; if (dialog.ShowDialog() == DialogResult.OK) { value = dialog.RegularExpression; } } return value; }