Exemple #1
0
        // Displays the UI for value selection.
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // Return the value if the value is not of type Int32, Double and Single.
            if (value != null && value.GetType() != typeof(ColourValue))
            {
                return(value);
            }

            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            //IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            ColorDialog colorDialog = new ColorDialog();

            using (colorDialog)
                if (colorDialog.ShowDialog() == DialogResult.OK)
                {
                    ColourValue cv = new ColourValue();
                    cv.SetAsARGB((uint)colorDialog.Color.ToArgb());
                    return(cv);
                }

            return(value);
        }