/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</para> /// </summary> /// <param name="context"><para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para></param> /// <param name="provider"><para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para></param> /// <param name="value"><para>The object to edit. This should be a <see cref="Password"/> object.</para></param> /// <returns><para>The new value of the <see cref="Password"/> object.</para></returns> /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/> 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)); using (PasswordEditorUI dialog = new PasswordEditorUI()) { if (DialogResult.OK == service.ShowDialog(dialog)) { return new Password(dialog.Password); } else { return value; } } } } return value; }
/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</para> /// </summary> /// <param name="context"><para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para></param> /// <param name="provider"><para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para></param> /// <param name="value"><para>The object to edit. This should be a <see cref="Password"/> object.</para></param> /// <returns><para>The new value of the <see cref="Password"/> object.</para></returns> /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/> 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)); using (PasswordEditorUI dialog = new PasswordEditorUI()) { if (DialogResult.OK == service.ShowDialog(dialog)) { return(new Password(dialog.Password)); } else { return(value); } } } } return(value); }