78 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Drawing;
 | 
						|
using System.Drawing.Design;
 | 
						|
using System.Windows.Forms.Design;
 | 
						|
using DevComponents.DotNetBar.Charts;
 | 
						|
 | 
						|
namespace DevComponents.Charts.Design
 | 
						|
{
 | 
						|
    public class PivotPointEditor : UITypeEditor
 | 
						|
    {
 | 
						|
        #region GetEditStyle
 | 
						|
 | 
						|
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
 | 
						|
        {
 | 
						|
            return (UITypeEditorEditStyle.DropDown);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region GetPaintValueSupported
 | 
						|
 | 
						|
        public override bool GetPaintValueSupported(ITypeDescriptorContext context)
 | 
						|
        {
 | 
						|
            return (false);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region EditValue
 | 
						|
 | 
						|
        public override object EditValue(
 | 
						|
            ITypeDescriptorContext context, IServiceProvider provider, object value)
 | 
						|
        {
 | 
						|
            if (provider != null)
 | 
						|
            {
 | 
						|
                IWindowsFormsEditorService editorService =
 | 
						|
                    provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
 | 
						|
 | 
						|
                if (editorService != null)
 | 
						|
                {
 | 
						|
                    PieChart pieChart = context.Instance as PieChart;
 | 
						|
 | 
						|
                    if (pieChart != null)
 | 
						|
                    {
 | 
						|
                        double scale = pieChart.OuterRadius;
 | 
						|
 | 
						|
                        if (scale >= 1)
 | 
						|
                        {
 | 
						|
                            int n = Math.Min(pieChart.ContentBounds.Width, pieChart.ContentBounds.Height);
 | 
						|
                            scale = (n > 0) ? pieChart.ActualOuterRadius / n : 0;
 | 
						|
                        }
 | 
						|
 | 
						|
                        scale /= 2;
 | 
						|
 | 
						|
                        PivotPointDropDown pv = new PivotPointDropDown((PointF) value,
 | 
						|
                            scale, pieChart.SubSliceVisualLayout.StartAngle,
 | 
						|
                            pieChart.SubSliceVisualLayout.SweepAngle, editorService, context);
 | 
						|
 | 
						|
                        pv.EscapePressed = false;
 | 
						|
 | 
						|
                        editorService.DropDownControl(pv);
 | 
						|
 | 
						|
                        if (pv.EscapePressed == true)
 | 
						|
                            context.PropertyDescriptor.SetValue(context.Instance, value);
 | 
						|
                        else
 | 
						|
                            return (pv.PivotPoint);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
            return (base.EditValue(context, provider, value));
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |