95 lines
2.5 KiB
C#
95 lines
2.5 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using DevComponents.DotNetBar.Charts;
|
|
|
|
namespace DevComponents.Charts.Design
|
|
{
|
|
public class ChartAxesCollectionEditor : BaseCollectionEditor
|
|
{
|
|
#region Private variables
|
|
|
|
private ChartXy _ChartXy;
|
|
private Type _CollectionType;
|
|
|
|
#endregion
|
|
|
|
public ChartAxesCollectionEditor(Type type)
|
|
: base(type)
|
|
{
|
|
_CollectionType = type;
|
|
}
|
|
|
|
#region EditValue
|
|
|
|
public override object EditValue(
|
|
ITypeDescriptorContext context, IServiceProvider provider, object value)
|
|
{
|
|
_ChartXy = context.Instance as ChartXy;
|
|
|
|
return (base.EditValue(context, provider, value));
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CreateInstance
|
|
|
|
protected override object CreateInstance(Type itemType)
|
|
{
|
|
ChartAxis axis = (ChartAxis)base.CreateInstance(itemType);
|
|
|
|
axis.Name = (_CollectionType == typeof(ChartAxesXCollection))
|
|
? _ChartXy.AncillaryAxesX.GetUniqueName() : _ChartXy.AncillaryAxesY.GetUniqueName();
|
|
|
|
return (axis);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyButton_Click
|
|
|
|
protected override void CopyButton_Click(object sender, EventArgs e)
|
|
{
|
|
ChartAxis item = ChartItem as ChartAxis;
|
|
|
|
if (item != null)
|
|
{
|
|
if (AddButton != null)
|
|
{
|
|
AddButton.PerformClick();
|
|
|
|
if (_CollectionType == typeof(ChartAxesXCollection))
|
|
{
|
|
ChartAxesXCollection cac = _ChartXy.AncillaryAxesX;
|
|
ChartAxis clone = cac[cac.Count - 1];
|
|
|
|
string name = clone.Name;
|
|
item.CopyTo(clone);
|
|
clone.Name = name;
|
|
}
|
|
else
|
|
{
|
|
ChartAxesYCollection cac = _ChartXy.AncillaryAxesY;
|
|
ChartAxis clone = cac[cac.Count - 1];
|
|
|
|
item.CopyTo(clone);
|
|
|
|
clone.Name = cac.GetUniqueName();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CreateCollectionItemType
|
|
|
|
protected override Type CreateCollectionItemType()
|
|
{
|
|
return (_CollectionType == typeof(ChartAxesXCollection)
|
|
? typeof(ChartAxisX) : typeof(ChartAxisY));
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|