using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;

namespace Telerik.QuickStart.WinControls
{
    public class CarouselItemCursorBehavior : PropertyChangeBehavior
    {
        private RadCarouselElement carousel;

        public CarouselItemCursorBehavior(RadCarouselElement carousel)
            : base(RadItem.IsMouseOverProperty)
        {
            this.carousel = carousel;
        }

        public override void OnPropertyChange(RadElement element, RadPropertyChangedEventArgs e)
        {
            if (element.ElementTree == null)
            {
                return;
            }

            if ((bool)e.NewValue)
            {
                if (this.carousel.SelectedIndex >= 0 && this.carousel.SelectedIndex < this.carousel.Items.Count)
                {
                    if (this.carousel.Items[this.carousel.SelectedIndex] == element)
                    {
                        element.ElementTree.Control.Cursor = Cursors.Hand;
                    }
                }
            }
            else
            {
                element.ElementTree.Control.Cursor = Cursors.Default;
            }
        }
    }
}
