116 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.ComponentModel.Design;
 | 
						|
using System.ComponentModel.Design.Serialization;
 | 
						|
using System.Globalization;
 | 
						|
using System.Reflection;
 | 
						|
using DevComponents.DotNetBar.Charts;
 | 
						|
 | 
						|
namespace DevComponents.Charts.Design
 | 
						|
{
 | 
						|
    public class AxisStripeCollectionEditor : BaseCollectionEditor
 | 
						|
    {
 | 
						|
        #region Private variables
 | 
						|
 | 
						|
        private ChartAxis _ChartAxis;
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        public AxisStripeCollectionEditor(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(AxisStripe))
 | 
						|
            {
 | 
						|
                AxisStripe stripe = (AxisStripe)base.CreateInstance(itemType);
 | 
						|
 | 
						|
                stripe.Name = _ChartAxis.AxisStripes.GetUniqueName();
 | 
						|
 | 
						|
                stripe.MinValue = _ChartAxis.ActualMinValue;
 | 
						|
                stripe.MaxValue = _ChartAxis.ActualMaxValue;
 | 
						|
 | 
						|
                return (stripe);
 | 
						|
            }
 | 
						|
 | 
						|
            return (base.CreateInstance(itemType));
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CopyButton_Click
 | 
						|
 | 
						|
        protected override void CopyButton_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            AxisStripe item = ChartItem as AxisStripe;
 | 
						|
 | 
						|
            if (item != null)
 | 
						|
            {
 | 
						|
                if (AddButton != null)
 | 
						|
                {
 | 
						|
                    ChartControlDesigner ccd = GetDesigner(_ChartAxis.ChartControl);
 | 
						|
 | 
						|
                    ccd.InCopyItem = true;
 | 
						|
 | 
						|
                    try
 | 
						|
                    {
 | 
						|
                        AddButton.PerformClick();
 | 
						|
 | 
						|
                        AxisStripeCollection asc = _ChartAxis.AxisStripes;
 | 
						|
                        AxisStripe clone = asc[asc.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(AxisStripe);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |