Ejemplo n.º 1
0
        public static bool PickColorDialogue(out Color c, Color inital)
        {
            using (ColorPickerForm cpf = new ColorPickerForm(inital))
            {
                cpf.ShowDialog();

                if (cpf.DialogResult == DialogResult.Cancel)
                {
                    c = inital;
                    return(false);
                }

                c = cpf.GetCurrentColor();
                return(true);
            }
        }
Ejemplo n.º 2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value.GetType() != typeof(Color))
            {
                return(value);
            }

            IWindowsFormsEditorService svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (svc != null)
            {
                Color color = (Color)value;

                using (ColorPickerForm form = new ColorPickerForm(color))
                {
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        return(form.GetCurrentColor().ARGB.ToColor());
                    }
                }
            }

            return(value);
        }