private void btn_Start_Learning_Click(object sender, RoutedEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                Helper.ClearToast();

                Vocabulary _item = DataAccess.GetVocabularyById(App.WordId);
                if (_item.Id == 0)
                {
                    App.WordId = DataAccess.GetFirstWordId();
                    _item      = DataAccess.GetVocabularyById(App.WordId);
                }
                App.WordId++;
                VocabularyToast.loadByVocabulary(_item);

                //while (true)
                //{

                //    await Task.Delay(1000);
                //}
            });
        }
Example #2
0
        private void processCustomAction(string main_action, QueryString args)
        {
            try
            {
                switch (main_action)
                {
                case "reload":
                    WordId = int.Parse(args["WordId"]);
                    var _item = DataAccess.GetVocabularyById(WordId);
                    VocabularyToast.loadByVocabulary(_item);
                    _item = null;
                    break;

                case "play":
                    WordId = int.Parse(args["WordId"]);
                    int playId = int.Parse(args["PlayId"]);
                    if (WordId > 0)
                    {
                        string _mp3Url;
                        if (VocabularyToast.reloadLastToast())
                        {
                            _mp3Url = args["PlayUrl"];
                        }
                        else
                        {
                            _item = DataAccess.GetVocabularyById(WordId);
                            VocabularyToast.loadByVocabulary(_item);
                            if (playId == 2)
                            {
                                _mp3Url = _item.PlayURL2;
                            }
                            else
                            {
                                _mp3Url = _item.PlayURL;
                            }
                        }

                        if (!String.IsNullOrEmpty(_mp3Url))
                        {
                            if (mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                            {
                                listPlayMp3.Enqueue(_mp3Url);
                            }
                            else
                            {
                                checkMediaPlayer();
                                Mp3.play(_mp3Url);
                            }
                        }
                    }
                    break;

                case "next":
                    WordId = int.Parse(args["WordId"]);
                    if (WordId > 0)
                    {
                        WordId++;
                    }
                    else
                    {
                        WordId = DataAccess.GetFirstWordId();
                    }
                    var _item2 = DataAccess.GetVocabularyById(WordId);
                    VocabularyToast.loadByVocabulary(_item2);
                    _item2 = null;
                    break;

                case "view":
                    string SearchUrl = args["url"];
                    // The URI to launch
                    var uriBing = new Uri(SearchUrl);
                    // Launch the URI
                    var success = Windows.System.Launcher.LaunchUriAsync(uriBing);
                    break;
                }
            } catch (Exception ex)
            {
                Helper.ShowToast("Action Background Error: " + ex.Message);
            }
        }