using System;
using System.Text;
using System.ComponentModel;
namespace DevComponents.DotNetBar
{
    /// 
    /// Indicates spacing for an user interface element either padding or margins.
    /// 
    [ToolboxItem(false),TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
    public class Spacing
    {
        #region Events
        public event EventHandler SpacingChanged;
        #endregion
        #region Private Variables
        private int m_Left = 0;
        private int m_Right = 0;
        private int m_Top = 0;
        private int m_Bottom = 0;
        #endregion
        #region Internal Implementation
        /// 
        /// Gets or sets the amount of the space on the left side.
        /// 
        [Browsable(true), DefaultValue(0), Description("Indicates the amount of the space on the left side."), DevCoSerialize()]
        public int Left
        {
            get { return m_Left; }
            set
            {
                m_Left = value;
                OnSpacingChanged();
            }
        }
        /// 
        /// Gets or sets the amount of the space on the right side.
        /// 
        [Browsable(true), DefaultValue(0), Description("Indicates the amount of the space on the right side."), DevCoSerialize()]
        public int Right
        {
            get { return m_Right; }
            set
            {
                m_Right = value;
                OnSpacingChanged();
            }
        }
        /// 
        /// Gets or sets the amount of the space on the top.
        /// 
        [Browsable(true), DefaultValue(0), Description("Indicates the amount of the space on the top."), DevCoSerialize()]
        public int Top
        {
            get { return m_Top; }
            set
            {
                m_Top = value;
                OnSpacingChanged();
            }
        }
        /// 
        /// Gets or sets the amount of the space on the bottom.
        /// 
        [Browsable(true), DefaultValue(0), Description("Indicates the amount of the space on the bottom."), DevCoSerialize()]
        public int Bottom
        {
            get { return m_Bottom; }
            set
            {
                m_Bottom = value;
                OnSpacingChanged();
            }
        }
        private void OnSpacingChanged()
        {
            if (SpacingChanged != null)
                SpacingChanged(this, new EventArgs());
        }
        /// 
        /// Gets total horizontal spacing.
        /// 
        [Browsable(false)]
        public int Horizontal
        {
            get { return Left + Right; }
        }
        /// 
        /// Gets total vertical spacing.
        /// 
        [Browsable(false)]
        public int Vertical
        {
            get { return Top + Bottom; }
        }
        /// 
        /// Gets whether all memebers of class are set to 0.
        /// 
        [Browsable(false)]
        public bool IsEmpty
        {
            get { return (m_Left==0 && m_Right==0 && m_Top==0 && m_Bottom==0); }
        }
        #endregion
    }
}