using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

namespace Assets.Scripts.UI.Control
{
    public class PFUIDropdown : PFUIComponentBase
    {
        private int mSelectedIndex = -1;

        private object mSelectedValue;

        public int SelectedIndex
        {
            get
            {
                return this.mSelectedIndex;
            }
        }

        public int Value
        {
            get
            {
                return this.GetComponent<Dropdown>().value;
            }
            set
            {
                this.GetComponent<Dropdown>().value = value;
            }
        }

        void Awake()
        {
            //this.mSelectedIndex =             
            //UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Select, new UnityEngine.Events.UnityAction<BaseEventData>(OnSelect));
            //UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(OnDeselect));
        }

        public void OnSelect(BaseEventData eventData)
        {
            var image = this.transform.GetComponent<Image>();
            var png = Resources.Load<Sprite>("Images/input-bg2");
            image.sprite = png;
        }
        public void OnDeselect(BaseEventData eventData)
        {
            var image = this.transform.GetComponent<Image>();
            var png1 = Resources.Load<Sprite>("Images/input-bg1");
            image.sprite = png1;
        }


        public void AddOptions(List<Dropdown.OptionData> options)
        {
            this.GetComponent<Dropdown>().AddOptions(options);
            
        }
    }
}
