using System;

namespace Icarus.Input.ButtonEvents {

    /// <summary>
	/// Stores event information for when a button is pressed on a device.
	/// </summary>
	public class ButtonPressEvent {

        #region Instance Variables
		/// <summary>
		/// Name of the button or key that was pressed.
		/// </summary>
        private string buttonName = string.Empty;
        /// <summary>
        /// Initial button state for when a button or key has been pressed.
        /// </summary>
        private bool buttonPressed = false;
        /// <summary>
        /// Button state for when a button has been depressed and held down.
        /// </summary>
        private bool buttonDown = false;
        /// <summary>
        /// Final button state for when a button has been released.
        /// </summary>
        private bool buttonReleased = false;
        #endregion

        #region Accessors and Modifiers
        /// <summary>
        /// The name of the button or key that was pressed.
        /// </summary>
        public string Name {
            get { return buttonName; }
            set { buttonName = value; }
        }

        /// <summary>
        /// Whether or not the button or key was just pressed.
        /// </summary>
        public bool Pressed {
            get { return buttonPressed; }
            set { buttonPressed = value; }
        }

        /// <summary>
        /// Whether or not the button or key is being held down.
        /// </summary>
        public bool Down {
            get { return buttonDown; }
            set { buttonDown = value; }
        }

        /// <summary>
        /// Whether or not the button or key was just released.
        /// </summary>
        public bool Released {
            get { return buttonReleased; }
            set { buttonReleased = value; }
        }
        #endregion

        #region General Use
        /// <summary>
        /// Overridden string representation of this object.
        /// </summary>
        /// <returns>String representation of this object.</returns>
        public override string ToString() {
            string state = string.Empty;
            
            if (buttonPressed) {
                state = "Pressed";
            } else if (buttonDown) {
                state = "Down";
            } else if (buttonReleased) {
                state = "Released";
            }

            return buttonName + " " + state;
        }
        #endregion

	}
}
