示例#1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value.GetType() != typeof(GradientInfo))
            {
                return value;
            }

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

            if (svc != null)
            {
                GradientInfo gradient = (GradientInfo)value;

                using (GradientPickerForm form = new GradientPickerForm(gradient.Copy()))
                {
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        return form.Gradient;
                    }
                }
            }

            return value;
        }
示例#2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value.GetType() != typeof(GradientInfo))
            {
                return(value);
            }

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

            if (svc != null)
            {
                GradientInfo gradient = (GradientInfo)value;

                using (GradientPickerForm form = new GradientPickerForm(gradient.Copy()))
                {
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        return(form.Gradient);
                    }
                }
            }

            return(value);
        }