226 lines
4.7 KiB
C#
226 lines
4.7 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing.Design;
|
|
using System.Windows.Forms.Design;
|
|
|
|
namespace DevComponents.Charts.Design
|
|
{
|
|
public class RangeValueEditor : UITypeEditor
|
|
{
|
|
#region Private variables
|
|
|
|
private const double MinValue = 0;
|
|
private const double MaxValue = 1;
|
|
|
|
#endregion
|
|
|
|
#region Public properties
|
|
|
|
public virtual double Minimum
|
|
{
|
|
get { return (MinValue); }
|
|
}
|
|
|
|
public virtual double Maximum
|
|
{
|
|
get { return (MaxValue); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#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)
|
|
{
|
|
double dvalue = Convert.ToDouble(value);
|
|
|
|
RangeValueDropDown rv = new
|
|
RangeValueDropDown(dvalue, Minimum, Maximum, editorService, context);
|
|
|
|
rv.EscapePressed = false;
|
|
|
|
editorService.DropDownControl(rv);
|
|
|
|
if (rv.EscapePressed == true)
|
|
{
|
|
context.PropertyDescriptor.SetValue(context.Instance, value);
|
|
}
|
|
else
|
|
{
|
|
Type type = value.GetType();
|
|
|
|
value = Convert.ChangeType(rv.Value, type);
|
|
|
|
return (value);
|
|
}
|
|
}
|
|
}
|
|
|
|
return (base.EditValue(context, provider, value));
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#region AngleRangeValueEditor
|
|
|
|
public class AngleRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (360); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region AngleOffsetRangeValueEditor
|
|
|
|
public class AngleOffsetRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (360); }
|
|
}
|
|
|
|
public override double Minimum
|
|
{
|
|
get { return (-360); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region AngleMarginRangeValueEditor
|
|
|
|
public class AngleMarginRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (10); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MarginRangeValueEditor
|
|
|
|
public class MarginRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (50); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RadiusRangeValueEditor
|
|
|
|
public class RadiusRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (1); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WidthRangeValueEditor
|
|
|
|
public class WidthRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (.3); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OffsetRangeValueEditor
|
|
|
|
public class OffsetRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (.3); }
|
|
}
|
|
|
|
public override double Minimum
|
|
{
|
|
get { return (-.3); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OffsetRangeValueEditor
|
|
|
|
public class OffsetPosRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (.9); }
|
|
}
|
|
|
|
public override double Minimum
|
|
{
|
|
get { return (0); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WidthMaxRangeValueEditor
|
|
|
|
public class WidthMaxRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (1); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HalfRadiusRangeValueEditor
|
|
|
|
public class HalfRadiusRangeValueEditor : RangeValueEditor
|
|
{
|
|
public override double Maximum
|
|
{
|
|
get { return (.5); }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|