Esempio n. 1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (_editorService == null)
            {
                return(base.EditValue(context, provider, value));
            }

            if (value != null && !(value is Color?))
            {
                return(base.EditValue(context, provider, value));
            }

            Color?       c     = (Color?)value;
            C1SolidBrush brush = new C1SolidBrush(c.HasValue ? c.Value : Color.Empty);

            var editor = new BackgroundEditorControl(_editorService);

            editor.Init(brush, false, true, NullValueAlias);
            _editorService.DropDownControl(editor);
            brush = editor.Background as C1SolidBrush;
            if (brush == null || brush.Color.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(brush.Color);
            }
        }
Esempio n. 2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (_editorService == null)
            {
                return(base.EditValue(context, provider, value));
            }

            var background = value as C1Brush;

            background = background ?? new C1SolidBrush();

            var editor = new BackgroundEditorControl(_editorService);

            editor.Init(background, true, false, null);
            _editorService.DropDownControl(editor);
            return(editor.Background);
        }