112 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			112 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.ComponentModel.Design;
 | 
						|
using DevComponents.DotNetBar.Charts;
 | 
						|
 | 
						|
namespace DevComponents.Charts.Design
 | 
						|
{
 | 
						|
    public class AxisReferenceCollectionEditor : BaseCollectionEditor
 | 
						|
    {
 | 
						|
        #region Private variables
 | 
						|
 | 
						|
        private ChartAxis _ChartAxis;
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        public AxisReferenceCollectionEditor(Type type)
 | 
						|
            : base(type)
 | 
						|
        {
 | 
						|
        }
 | 
						|
 | 
						|
        #region EditValue
 | 
						|
 | 
						|
        public override object EditValue(
 | 
						|
            ITypeDescriptorContext context, IServiceProvider provider, object value)
 | 
						|
        {
 | 
						|
            _ChartAxis = context.Instance as ChartAxis;
 | 
						|
 | 
						|
            IComponentChangeService cs = BeforeEditValue(context);
 | 
						|
 | 
						|
            object retval = value;
 | 
						|
 | 
						|
            try
 | 
						|
            {
 | 
						|
                retval = base.EditValue(context, provider, value);
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                AfterEditValue(context, cs);
 | 
						|
            }
 | 
						|
 | 
						|
            return (retval);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CreateInstance
 | 
						|
 | 
						|
        protected override object CreateInstance(Type itemType)
 | 
						|
        {
 | 
						|
            if (itemType == typeof(ReferenceLine))
 | 
						|
            {
 | 
						|
                ReferenceLine line = (ReferenceLine)base.CreateInstance(itemType);
 | 
						|
 | 
						|
                line.Name = _ChartAxis.ReferenceLines.GetUniqueName();
 | 
						|
 | 
						|
                if (_ChartAxis != null)
 | 
						|
                    line.AxisValue = _ChartAxis.ActualMinValue;
 | 
						|
 | 
						|
                return (line);
 | 
						|
            }
 | 
						|
 | 
						|
            return (base.CreateInstance(itemType));
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CopyButton_Click
 | 
						|
 | 
						|
        protected override void CopyButton_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            ReferenceLine item = ChartItem as ReferenceLine;
 | 
						|
 | 
						|
            if (item != null)
 | 
						|
            {
 | 
						|
                if (AddButton != null)
 | 
						|
                {
 | 
						|
                    ChartControlDesigner ccd = GetDesigner(_ChartAxis.ChartControl);
 | 
						|
 | 
						|
                    ccd.InCopyItem = true;
 | 
						|
 | 
						|
                    try
 | 
						|
                    {
 | 
						|
                        AddButton.PerformClick();
 | 
						|
 | 
						|
                        ReferenceLineCollection rlc = _ChartAxis.ReferenceLines;
 | 
						|
                        ReferenceLine clone = rlc[rlc.Count - 1];
 | 
						|
 | 
						|
                        string name = clone.Name;
 | 
						|
                        item.CopyTo(clone);
 | 
						|
                        clone.Name = name;
 | 
						|
                    }
 | 
						|
                    finally
 | 
						|
                    {
 | 
						|
                        ccd.InCopyItem = false;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CreateCollectionItemType
 | 
						|
 | 
						|
        protected override Type CreateCollectionItemType()
 | 
						|
        {
 | 
						|
            return typeof(ReferenceLine);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |