using Misc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FLY.Thick.Base.UI;
namespace FLY.Thick.Base.UI.CustomSection
{
///
/// UcSectionLanguage.xaml 的交互逻辑
///
public partial class UcSectionLanguage : UserControl
{
UcSectionLanguageVm viewModel;
public UcSectionLanguage()
{
InitializeComponent();
}
[Unity.InjectionMethod]
public void Init(ParamDictionary paramDictionary)
{
viewModel = new UcSectionLanguageVm();
viewModel.Init(paramDictionary);
this.DataContext = viewModel;
}
}
public class UcSectionLanguageVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
///
/// 是英语
///
public bool IsEn { get; set; }
ParamDictionary paramDictionary;
public UcSectionLanguageVm()
{
}
public void Init(ParamDictionary paramDictionary)
{
this.paramDictionary = paramDictionary;
string language = paramDictionary.GetValue(ParamDistItemKeys.Language, "zh-CN");
if (language == "en-US")
{
IsEn = true;
}
else
{
IsEn = false;
}
this.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "IsEn")
{
if (IsEn)
{
this.paramDictionary.SetValue(ParamDistItemKeys.Language, "en-US");
}
else
{
this.paramDictionary.SetValue(ParamDistItemKeys.Language, "zh-CN");
}
}
};
}
}
}