Beispiel #1
0
        public static string GetRecognizeLanguage()
        {
            string languagert = "English";

            if (LocalSettingHelper.IsExistsLocalSettingKey(LocalSettingHelper.RecogLanguageKey))
            {
                // Ngôn ngữ được sử dụng để phân tích hình ảnh
                var ocrlanguage = (OcrLanguage)LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey);

                if (ocrlanguage == OcrLanguage.English)
                {
                    return("English");
                }
                // Lấy ra các key của các countries ví dụ es, jp
                var keycode = Util.AvailableCountries.Where(country => country.Value == ocrlanguage).Select(c => c.Key).First();

                var temp = Util.CountryLanguagePair.Where(country => country.Value == keycode);

                if (temp.Any())
                {
                    var list = temp.Select(lang => lang.Key);
                    foreach (var item in list)
                    {
                        if (Util.SupportedLanguages.Values.Contains(item))
                        {
                            languagert = Util.SupportedLanguages.Where(lang => lang.Value == item).Select(l => l.Key).First();
                            break;
                        }
                    }
                }
            }
            return(languagert);
        }
Beispiel #2
0
        public static async Task <string> GetLocalityLanguage()
        {
            string langreturn = String.Empty;

            if (LocalSettingHelper.IsExistsLocalSettingKey(LocalSettingHelper.LanguageTranslateTo) == false)
            {
                bool isAllowGPS = false;

                isAllowGPS = Convert.ToBoolean(LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.AllowGPSKey));
                if (isAllowGPS == true)
                {
                    Point coordinates = await Util.GetGeo2Coordinates();

                    string local = await Util.GetLocalCountryCode(coordinates);

                    langreturn = getLanguageFromCountryCode(local);
                }
                else
                {
                    langreturn = "English";
                }
            }
            else
            {
                langreturn = Convert.ToString(LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.LanguageTranslateTo));
            }
            return(langreturn);
        }
Beispiel #3
0
        public ImageRecognizeViewModel()
        {
            OcrLanguage language = (OcrLanguage)Enum.Parse(
                typeof(OcrLanguage),
                (LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey)).ToString());

            _ocrEngine  = new OcrEngine(language);
            _imageModel = new ImageModel();
        }
        public ImageRecognizePage()
        {
            Current = this;

            this.InitializeComponent();
            this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;
            // gán static resouce bên xaml để xài
            _imageViewModel = Resources["imageDataContext"] as ImageRecognizeViewModel;

            listpickerflyout.ItemsSource = Util.AvailableCountries.Values;

            _imageViewModel.Language = (OcrLanguage)Enum.Parse(
                typeof(OcrLanguage),
                LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey).ToString());

            HardwareButtons.BackPressed += hardwareButtons_BackPressed;
        }
Beispiel #5
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            listpickerflyout1.ItemsSource = Util.AvailableCountries.Values;
            OcrLanguage language = (OcrLanguage)Enum.Parse(
                typeof(OcrLanguage),
                LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey).ToString());

            langRecog.Content = Util.AvailableCountries.Where(country => country.Value == language).First().Key;

            listpickerflyout2.ItemsSource = Util.SupportedLanguages.Keys;
            string lang = LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.LanguageTranslateTo).ToString();

            langtoTranslate.Content = Util.SupportedLanguages[lang];


            geoLocalSwitchToggle.IsOn = Convert.ToBoolean(
                LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.AllowGPSKey)
                );

            SdCardSwitchToggle.IsOn = Convert.ToBoolean(
                LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.SaveOnSdCard)
                );
        }