public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); } if (service != null) { // This is the code you want to run when the [...] is clicked and after it has been verified. // Get our currently selected color. XnaColor color = (XnaColor)value; // Create a new instance of the ColorDialog. ColorDialog selectionControl = new ColorDialog(); // Set the selected color in the dialog. selectionControl.Color = Color.FromArgb(color.GetARGB()); // Show the dialog. selectionControl.ShowDialog(); // Return the newly selected color. value = new XnaColor(selectionControl.Color.ToArgb()); } return(value); }
// This is used, for example, by the PropertyGrid to convert MyColor to a string. public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) { if ((destType == typeof(string)) && (value is XnaColor)) { XnaColor color = (XnaColor)value; return(color.ToString()); } return(base.ConvertTo(context, culture, value, destType)); }