using Misc;
using System.ComponentModel;
using System.Windows.Controls;

namespace FLY.Thick.Base.UI.CustomSection
{
    /// <summary>
    /// UcSectionOsk.xaml 的交互逻辑
    /// </summary>
    public partial class UcSectionOsk : UserControl
    {
        UcSectionOskVm viewModel;

        public UcSectionOsk()
        {
            InitializeComponent();
        }
        [Unity.InjectionMethod]
        public void Init(ParamDictionary paramDictionary)
        {
            viewModel = new UcSectionOskVm();
            viewModel.Init(paramDictionary);
            this.DataContext = viewModel;
        }
    }
    public class UcSectionOskVm : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;


        /// <summary>
        /// 使用虚拟键盘
        /// </summary>
        public bool HaveOSK { get; set; }


        /// <summary>
        /// 虚拟键盘支持鼠标
        /// </summary>
        public bool HaveOSK_mouse { get; set; }


        ParamDictionary paramDictionary;
        public UcSectionOskVm()
        {

        }

        public void Init(ParamDictionary paramDictionary)
        {
            this.paramDictionary = paramDictionary;
            HaveOSK = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK, true);
            HaveOSK_mouse = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK_mouse, false);
            this.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == ParamDistItemKeys.HaveOSK)
                    this.paramDictionary.SetValue(ParamDistItemKeys.HaveOSK, HaveOSK);
                else if (e.PropertyName == ParamDistItemKeys.HaveOSK_mouse)
                    this.paramDictionary.SetValue(ParamDistItemKeys.HaveOSK_mouse, HaveOSK_mouse);
            };
        }

    }
}
