using MultiLayout.UiModule;
using Misc;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Unity;

namespace FLY.Thick.Base.UI.OnInit
{
    /// <summary>
    /// 虚拟键盘
    /// </summary>
    public class OnInitOSK : IOnInit
    {
        ParamDictionary paramDictionary;
        public OnInitOSK(ParamDictionary paramDictionary,int lv=1) 
        {
            this.paramDictionary = paramDictionary;
            Level = lv;
        }

        public int Level { get; }

        public void OnInit()
        {
            FLY.ControlLibrary.UI.OSK.KeyboardBehavior.Enable = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK, true);

            FLY.ControlLibrary.UI.OSK.KeyboardBehavior.EnableMouseDown = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK_mouse, false);

            paramDictionary.ValueChanged += ParamDictionary_ValueChanged;
        }

        private void ParamDictionary_ValueChanged(object sender, ParamDictionaryValueChangedEventArgs e)
        {
            if (e.Key == ParamDistItemKeys.HaveOSK)
            {
                FLY.ControlLibrary.UI.OSK.KeyboardBehavior.Enable = (bool)e.Value;
            }
            else if (e.Key == ParamDistItemKeys.HaveOSK_mouse)
            {
                FLY.ControlLibrary.UI.OSK.KeyboardBehavior.EnableMouseDown = (bool)e.Value;
            }
        }
    }
}