public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IntPtr focus = UnsafeNativeMethods.GetFocus(); try { ICom2PropertyPageDisplayService service = (ICom2PropertyPageDisplayService)provider.GetService(typeof(ICom2PropertyPageDisplayService)); if (service == null) { service = this; } object instance = context.Instance; if (!instance.GetType().IsArray) { instance = this.propDesc.TargetObject; if (instance is ICustomTypeDescriptor) { instance = ((ICustomTypeDescriptor)instance).GetPropertyOwner(this.propDesc); } } service.ShowPropertyPage(this.propDesc.Name, instance, this.propDesc.DISPID, this.guid, focus); } catch (Exception exception) { if (provider != null) { IUIService service2 = (IUIService)provider.GetService(typeof(IUIService)); if (service2 != null) { service2.ShowError(exception, System.Windows.Forms.SR.GetString("ErrorTypeConverterFailed")); } } } return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IntPtr hWndParent = User32.GetFocus(); // Windows.GetForegroundWindow try { ICom2PropertyPageDisplayService propPageSvc = (ICom2PropertyPageDisplayService)provider.GetService(typeof(ICom2PropertyPageDisplayService)); if (propPageSvc is null) { propPageSvc = this; } object instance = context.Instance; if (!instance.GetType().IsArray) { instance = propDesc.TargetObject; if (instance is ICustomTypeDescriptor) { instance = ((ICustomTypeDescriptor)instance).GetPropertyOwner(propDesc); } } propPageSvc.ShowPropertyPage(propDesc.Name, instance, (int)propDesc.DISPID, guid, hWndParent); } catch (Exception ex1) { if (provider is not null) { IUIService uiSvc = (IUIService)provider.GetService(typeof(IUIService)); if (uiSvc is not null) { uiSvc.ShowError(ex1, SR.ErrorTypeConverterFailed); } } } return(value); }