Example #1
0
 private void initSdCardValue()
 {
     if (LocalSettingHelper.IsExistsLocalSettingKey(LocalSettingHelper.SaveOnSdCard) == false)
     {
         LocalSettingHelper.SetLocalSettingKeyValue(LocalSettingHelper.SaveOnSdCard, true);
     }
 }
Example #2
0
        private void ListPickerFlyOutPicker(ListPickerFlyout sender, ItemsPickedEventArgs args)
        {
            var items = args.AddedItems;

            if (items.Any() == false)
            {
                return;
            }
            LocalSettingHelper.SetLocalSettingKeyValue(LocalSettingHelper.RecogLanguageKey, (int)items.First());
            //settingbtn.Content = items.First().ToString();
            _imageViewModel.Language = (OcrLanguage)Enum.Parse(
                typeof(OcrLanguage),
                items.First().ToString());
        }
Example #3
0
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;
            Current = this;

            // gán static resouce bên mainpage.xaml để xài
            _imageViewModel = Resources["imageDataContext"] as ImageRecognizeViewModel;
            //listpickerflyout.ItemsSource = Util.AvailableCountries.Values;
            //int language = Convert.ToInt32(LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey));
            //settingbtn.Content = Enum.Parse (typeof(OcrLanguage),LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey).ToString());
            _imageViewModel.Language = (OcrLanguage)Enum.Parse(
                typeof(OcrLanguage),
                LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.RecogLanguageKey).ToString());
        }
Example #4
0
        private async Task <bool> AskForUseGPS()
        {
            bool isAllowed = false;

            if (LocalSettingHelper.IsExistsLocalSettingKey(LocalSettingHelper.AllowGPSKey) == false)
            {
                // Nếu khôgn có key setting
                MessageDialog msgbox = new MessageDialog("Do you want to use GPS?");
                msgbox.Commands.Add(new UICommand("No")
                {
                    Id = 0
                });
                msgbox.Commands.Add(new UICommand("Yes")
                {
                    Id = 1
                });

                var result = await msgbox.ShowAsync() as UICommand;

                int id = Convert.ToInt32(result.Id);
                switch (id)
                {
                case 1:
                    isAllowed = true;
                    // localSettings.Values["AllowsGPS"] = true;
                    break;

                default:
                    isAllowed = false;
                    // localSettings.Values["AllowsGPS"] = false;
                    break;
                }
                //localSettings.Values["AllowsGPS"] = isAllowed;
                LocalSettingHelper.SetLocalSettingKeyValue(LocalSettingHelper.AllowGPSKey, isAllowed);
            }
            else
            {
                //isAllowed = Convert.ToBoolean(localSettings.Values["AllowsGPS"]);
                isAllowed = Convert.ToBoolean(LocalSettingHelper.GetLocalSettingValue(LocalSettingHelper.AllowGPSKey));
            }
            return(isAllowed);
        }
Example #5
0
        private async Task initRecognizeLanguage()
        {
            // Kiểm tra key có tồn tại hay không.
            // Nếu có => return khôgn làm gì
            // Nếu không => Hỏi có cho dùng GPS không
            // ____________ Nếu khôgn cho thì lưu key với value là english
            // ____________ Nếu cho thì gọi CharacterRecognizeModel.InitLanguage(); => lưu key

            if (LocalSettingHelper.IsExistsLocalSettingKey(LocalSettingHelper.RecogLanguageKey) == false)
            {
                bool isAllowGPS = await AskForUseGPS();

                OcrLanguage language = OcrLanguage.English;
                if (isAllowGPS == true)
                {
                    language = await CharacterRecognizeModel.InitLanguage();
                }
                else
                {
                    language = OcrLanguage.English;
                }
                LocalSettingHelper.SetLocalSettingKeyValue(LocalSettingHelper.RecogLanguageKey, (int)language);
            }
        }