Exemple #1
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            System.Configuration.Color c = (System.Configuration.Color)e.Value;
            using (SolidBrush brush = new SolidBrush(System.Drawing.Color.FromArgb(c.R, c.G, c.B)))
            {
                e.Graphics.FillRectangle(brush, e.Bounds);
            }

            e.Graphics.DrawRectangle(Pens.Black, e.Bounds);
        }
Exemple #2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value.GetType() != typeof(System.Configuration.Color))
            {
                return(value);
            }

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

            if (svc != null)
            {
                System.Configuration.Color c = (System.Configuration.Color)value;
                var editor = new System.Drawing.Design.ColorEditor();
                System.Drawing.Color edited = (System.Drawing.Color)editor.EditValue(context, provider, System.Drawing.Color.FromArgb(c.R, c.G, c.B));

                c.R = edited.R;
                c.G = edited.G;
                c.B = edited.B;

                return(c);
            }

            return(value);
        }