using System;
using System.Text;
using System.ComponentModel;
namespace DevComponents.DotNetBar
{
    /// 
    /// Represents the typed command link for ColorPickerDropDown type.
    /// 
    public class CommandLinkColorPickerDropDown : CommandLink
    {
        #region Events
        /// 
        /// Occurs when color is choosen from drop-down color picker or from Custom Colors dialog box. Selected color can be accessed through SelectedColor property.
        /// 
        [Description("Occurs when color is choosen from drop-down color picker or from Custom Colors dialog box.")]
        public event EventHandler SelectedColorChanged;
        #endregion
        /// 
        /// Gets reference to the ColorPickerDropDown this CommandLink is linked to. Note that this is the first ColorPickerDropDown object found by DotNetBarManager.
        /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
        /// 
        [Browsable(false)]
        public ColorPickerDropDown Item
        {
            get
            {
                return this.GetItem(typeof(ColorPickerDropDown)) as ColorPickerDropDown;
            }
        }
        protected override void ConnectManager()
        {
            base.ConnectManager();
            if(this.Manager!=null)
                this.Manager.ColorPickerSelectedColorChanged += new EventHandler(ManagerColorPickerSelectedColorChanged);
        }
        private void ManagerColorPickerSelectedColorChanged(object sender, EventArgs e)
        {
            if (SelectedColorChanged != null)
                SelectedColorChanged(sender, e);
        }
        protected override void DisconnectManager()
        {
            base.DisconnectManager();
            if(this.Manager!=null)
                this.Manager.ColorPickerSelectedColorChanged -= new EventHandler(ManagerColorPickerSelectedColorChanged);
        }
    }
}