public void RefreshForm() { if (Form == null) { Form = new ColorEditorForm(); } }
// ------------------------------------------------------------------ /// <summary> /// Edits the specified object's value using the editor style indicated /// by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> /// method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> /// that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> /// that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns> /// The new value of the object. If the value of the object has not /// changed, this should return the same object it was passed. /// </returns> public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value ) { Color color; if ( value == null ) { color = Color.Empty; }else { color = (Color)value; } using ( var form = new ColorEditorForm() ) { form.SelectedColor = color; if ( form.ShowDialog() == DialogResult.OK ) { value = form.SelectedColor; } } return value; }
// ------------------------------------------------------------------ /// <summary> /// Edits the specified object's value using the editor style indicated /// by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> /// method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> /// that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> /// that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns> /// The new value of the object. If the value of the object has not /// changed, this should return the same object it was passed. /// </returns> public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { Color color; if (value == null) { color = Color.Empty; } else { color = (Color)value; } using (var form = new ColorEditorForm()) { form.SelectedColor = color; if (form.ShowDialog() == DialogResult.OK) { value = form.SelectedColor; } } return(value); }
public MainForm() { InitializeComponent(); #if DEBUG ColorEditorForm.Test(); #endif }
private void launchColorEditorButton_Click(object sender, EventArgs e) { using (var form = new ColorEditorForm()) { // Must set the extender _first_, since it helps in lookup // of the selected color. form.ExternalColorEditorInformationProvider = new ExternalTestProvider(); form.SelectedColor = colorPanel.BackColor; if (form.ShowDialog(this) == DialogResult.OK) { colorPanel.BackColor = form.SelectedColor; } } }