/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Debug.Assert(provider != null, "No service provider; we cannot edit the value"); if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); Debug.Assert(edSvc != null, "No editor service; we cannot edit the value"); if (edSvc != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); TemplateEditorUI dialog = new TemplateEditorUI(); string originalText = (string)value; dialog.UserText = originalText; DialogResult dialogResult = service.ShowDialog(dialog); if (dialogResult == DialogResult.Cancel) { return originalText; } return dialog.UserText; } } return value; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Debug.Assert(provider != null, "No service provider; we cannot edit the value"); if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); Debug.Assert(edSvc != null, "No editor service; we cannot edit the value"); if (edSvc != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); TemplateEditorUI dialog = new TemplateEditorUI(); string originalText = ((Template)value).Text; dialog.UserText = originalText; DialogResult dialogResult = service.ShowDialog(dialog); if (dialogResult == DialogResult.Cancel) { return(new Template(originalText)); } return(new Template(dialog.UserText)); } } return(value); }