using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.UI;
using Debug = UnityEngine.Debug;

public class UI_TestPanel : BasePanel
{
    //public Button testBtn1;
    //public Button testBtn2;
    //public Button testBtn3;
    public Image imageTest;
    public Text textTest;
    public int testInt;
    public string testString;
    public Color testColor = new Color();

    protected override void Awake()
    {
        base.Awake();
        //testBtn1 = GetControl<Button>("testBtn1");
        //testBtn2 = GetControl<Button>("testBtn2");
        //testBtn3 = GetControl<Button>("testBtn3");
        imageTest = GetControl<Image>("imagePPT");
        textTest = GetControl<Text>("textTest");
        Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.TestEvent1, UI_TestPanelTestFunc1);
    }

    private void UI_TestPanelTestFunc1()
    {
        testInt++;
        Debug.Log("UI_TestPanel=TestFunc1ÊÕµ½ÐÅÏ¢==" + testInt);
    }

    public void OnInit()
    {
        Debug.Log("ÎÒ±»³õʼ»¯ÁËOnInit");
    }

    public override void ShowMe()
    {
        base.ShowMe();
        Debug.Log("ÎÒÏÔʾ³öÀ´ÎÒÒª¸Éʲô£¬±ÈÈçÎÒҪ֪ͨ±ðÈ˸ÉɶÂð");
    }

    public override void HideMe()
    {
        base.HideMe();
        Debug.Log("ÎҹرÕÁË£¬¹Ø±ÕÎÒҪʲô");
    }

    protected override void OnClick(string btnPath)
    {
        base.OnClick(btnPath);
        switch (btnPath)
        {
            case "testBtn1":
                Debug.Log(1);
                textTest.text = (testInt++).ToString();
                break;
            case "testBtn2":
                Debug.Log(2);
                testColor = new Color(Random.Range(1, 255f) / 255f, Random.Range(1, 255f) / 255f, Random.Range(1, 255f) / 255f, 1f);
                imageTest.color = testColor;
                break;
            case "testBtn3":
                Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.TestEvent1);
                Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.TestEvent2, testInt);
                textTest.text = "testBtn3333";
                testString = $"<color={testColor}>{textTest.text + testInt}</color>";
                Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.TestEvent3, testString);
                break;
        }
    }
}