示例#1
0
 private void lvPresets_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (isReady && lvPresets.SelectedItems.Count > 0)
     {
         ListViewItem lvi          = lvPresets.SelectedItems[0];
         GradientInfo gradientInfo = lvi.Tag as GradientInfo;
         if (gradientInfo != null)
         {
             Gradient = gradientInfo.Copy();
             UpdateGradientList(true);
             lvi.Selected = false;
         }
     }
 }
示例#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);
        }