262 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			262 lines
		
	
	
		
			5.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Windows.Forms;
 | 
						|
using DevComponents.DotNetBar.Charts.Style;
 | 
						|
 | 
						|
namespace DevComponents.DotNetBar.Charts
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// ChartAxisLable
 | 
						|
    /// </summary>
 | 
						|
    public class ChartAxisLable : ChartVisualElement
 | 
						|
    {
 | 
						|
        #region Private variables
 | 
						|
 | 
						|
        private States _States;
 | 
						|
 | 
						|
        private string _Text;
 | 
						|
        private int _FixedHeight;
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Public properties
 | 
						|
 | 
						|
        #region FixedHeight
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the fixed Text height of the label (0 to auto-size)
 | 
						|
        /// </summary>
 | 
						|
        [DefaultValue(0), Category("Layout")]
 | 
						|
        [Description("Indicates the fixed Text height of the label (0 to auto-size)")]
 | 
						|
        public int FixedHeight
 | 
						|
        {
 | 
						|
            get { return (_FixedHeight); }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (value != _FixedHeight)
 | 
						|
                {
 | 
						|
                    _FixedHeight = value;
 | 
						|
 | 
						|
                    OnPropertyChangedEx("FixedHeight", VisualChangeType.Layout);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Text
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the label Text.
 | 
						|
        /// </summary>
 | 
						|
        [DefaultValue(null), Category("Appearance")]
 | 
						|
        [Description("Indicates the label Text.")]
 | 
						|
        public string Text
 | 
						|
        {
 | 
						|
            get { return (_Text); }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                _Text = value;
 | 
						|
 | 
						|
                OnPropertyChangedEx("Text", VisualChangeType.Layout);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region MeasureOverride
 | 
						|
 | 
						|
        protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
 | 
						|
        {
 | 
						|
            throw new NotImplementedException();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region ArrangeOverride
 | 
						|
 | 
						|
        protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
 | 
						|
        {
 | 
						|
            throw new NotImplementedException();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region RenderOverride
 | 
						|
 | 
						|
        protected override void RenderOverride(ChartRenderInfo renderInfo)
 | 
						|
        {
 | 
						|
            throw new NotImplementedException();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Mouse handling
 | 
						|
 | 
						|
        #region OnMouseEnter
 | 
						|
 | 
						|
        protected override bool OnMouseEnter(EventArgs e)
 | 
						|
        {
 | 
						|
            return (true);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region OnMouseLeave
 | 
						|
 | 
						|
        protected override bool OnMouseLeave(EventArgs e)
 | 
						|
        {
 | 
						|
            return (true);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region OnMouseMove
 | 
						|
 | 
						|
        protected override bool OnMouseMove(MouseEventArgs e)
 | 
						|
        {
 | 
						|
            ChartCursor = Cursors.Default;
 | 
						|
 | 
						|
            return (false);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region OnMouseDown
 | 
						|
 | 
						|
        protected override bool OnMouseDown(MouseEventArgs e)
 | 
						|
        {
 | 
						|
            return (false);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region OnMouseUp
 | 
						|
 | 
						|
        protected override bool OnMouseUp(MouseEventArgs e)
 | 
						|
        {
 | 
						|
            base.OnMouseUp(e);
 | 
						|
 | 
						|
            return (true);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Copy/CopyTo
 | 
						|
 | 
						|
        public override ChartVisualElement Copy()
 | 
						|
        {
 | 
						|
            ChartAxisLable copy = new ChartAxisLable();
 | 
						|
 | 
						|
            CopyTo(copy);
 | 
						|
 | 
						|
            return (copy);
 | 
						|
        }
 | 
						|
 | 
						|
        public override void CopyTo(ChartVisualElement copy)
 | 
						|
        {
 | 
						|
            ChartAxisLable c = copy as ChartAxisLable;
 | 
						|
 | 
						|
            if (c != null)
 | 
						|
            {
 | 
						|
                base.CopyTo(c);
 | 
						|
 | 
						|
                c.FixedHeight = FixedHeight;
 | 
						|
                c.Text = Text;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region GetSerialData
 | 
						|
 | 
						|
        internal override SerialElementCollection GetSerialData(string serialName)
 | 
						|
        {
 | 
						|
            SerialElementCollection sec = new SerialElementCollection();
 | 
						|
 | 
						|
            if (serialName != null)
 | 
						|
            {
 | 
						|
                if (serialName.Equals("") == true)
 | 
						|
                    serialName = "BaseChart";
 | 
						|
 | 
						|
                sec.AddStartElement(serialName);
 | 
						|
            }
 | 
						|
 | 
						|
            sec.AddValue("FixedHeight", FixedHeight, 0);
 | 
						|
            sec.AddValue("Text", Text, null);
 | 
						|
 | 
						|
            sec.AddElement(base.GetSerialData(null));
 | 
						|
 | 
						|
            if (serialName != null)
 | 
						|
                sec.AddEndElement(serialName);
 | 
						|
 | 
						|
            return (sec);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region PutSerialData
 | 
						|
 | 
						|
        #region ProcessValue
 | 
						|
 | 
						|
        internal override void ProcessValue(SerialElement se)
 | 
						|
        {
 | 
						|
            switch (se.Name)
 | 
						|
            {
 | 
						|
                case "FixedHeight":
 | 
						|
                    FixedHeight = int.Parse(se.StringValue);
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "Text":
 | 
						|
                    Text = se.StringValue;
 | 
						|
                    break;
 | 
						|
 | 
						|
                default:
 | 
						|
                    base.ProcessValue(se);
 | 
						|
                    break;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region States
 | 
						|
 | 
						|
        [Flags]
 | 
						|
        private enum States : uint
 | 
						|
        {
 | 
						|
            EnableTextMarkup = (1U << 0),
 | 
						|
        }
 | 
						|
 | 
						|
        #region TestState
 | 
						|
 | 
						|
        private bool TestState(States state)
 | 
						|
        {
 | 
						|
            return ((_States & state) == state);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region SetState
 | 
						|
 | 
						|
        private void SetState(States state, bool value)
 | 
						|
        {
 | 
						|
            if (value == true)
 | 
						|
                _States |= state;
 | 
						|
            else
 | 
						|
                _States &= ~state;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |