| 123456789101112131415161718192021222324252627282930313233 |
- using GalaSoft.MvvmLight.Ioc;
- using MuchInfo.Chart.App.Services;
- using MuchInfo.Chart.Data.EnumTypes;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Data;
- namespace MuchInfo.Chart.App.Converters
- {
- [ValueConversion(typeof(KeyValuePair<ChartLanguageType, string>), typeof(ChartLanguageType))]
- public class LanguageConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- var dataService = SimpleIoc.Default.GetInstance<IDataService>();
- var list = dataService.GetLanguages();
- if (value == null)
- return list.FirstOrDefault();
- var type = (ChartLanguageType)value;
- IndexFormula.Finance.Win.SetLanguage.SetcurrentLanguage((ChartLanguageType)value);
- return list.FirstOrDefault(z => z.Key == type);
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- var keyPair = (KeyValuePair<ChartLanguageType, string>)value;
- return keyPair.Key;
- }
- }
- }
|