private void CreateTimer() { if (_timer != null) { return; } _timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 1, 0) }; //1s _timer.Tick += (o, s) => { EnglishGameHelper.SpeakNumberBetween((int)(TimingProgress.Maximum - ProgressBarValue)); if (TimingProgress.Maximum > ProgressBarValue) { ProgressBarValue++; } else { _timer.IsEnabled = false; //Play sound //new SoundPlayer(Constant.FileAudioName).Play(); new SoundPlayer(Properties.Resources.beep).Play(); } }; }
private void ShowClick(object sender, RoutedEventArgs e) { ShowTitleVisibility = Visibility.Visible; _storyboard.Stop(); MovingImage.SetValue(Canvas.LeftProperty, (ActualWidth - MovingImage.ActualWidth) / 2); EnglishGameHelper.SpeakText(SelectedGameItem.Title); }
private void LoadData() { _gameItems = EnglishGameHelper.RandomOrder( FileManagement.GetListGameData().Where(x => x.GameName == Constant.GameConstant.Charades).ToList()); if (_gameItems != null && _gameItems.Count > 0) { SelectedGameItem = _gameItems[0]; _currentIndex = 0; } }
private void CreateSelectTopicButtons() { IEnumerable <GameItem> talkInMinuteItems = EnglishGameHelper.RandomOrder( FileManagement.GetListGameData().Where(x => x.GameName == Constant.GameConstant.TalkInMinute).ToList()); int index = 1; foreach (GameItem talkInMinuteItem in talkInMinuteItems) { var viewbox = new Viewbox { Child = new TextBlock { Text = index.ToString(CultureInfo.InvariantCulture) } }; var button = new Button { Content = viewbox, Tag = talkInMinuteItem, Width = 100, Height = 100, Margin = new Thickness(0, 0, 10, 10) }; button.Click += (s, e) => { var b = s as Button; if (b != null) { SelectTopicVisibility = Visibility.Collapsed; SelectedGameItem = (GameItem)b.Tag; b.Visibility = Visibility.Collapsed; EnglishGameHelper.SpeakText(SelectedGameItem.Title); _timer.IsEnabled = true; } }; LayoutRoot.Children.Add(button); index++; } }
private void CreateSelectTopicButtons(IEnumerable <string> topics) { foreach (string topic in topics) { var viewbox = new Viewbox { Child = new TextBlock { Text = topic } }; var button = new Button { Content = viewbox, Tag = topic, Width = 500, Height = 90, Margin = new Thickness(0, 0, 10, 10) }; button.Click += (s, e) => { var b = s as Button; if (b != null) { PictureDashHomeVisibility = Visibility.Collapsed; _gameItems = EnglishGameHelper.RandomOrder( FileManagement.GetListGameData().Where( x => x.GameName == Constant.GameConstant.PictureDash && x.Topic == b.Tag.ToString()).ToList()); SelectedGameItem = _gameItems[0]; _currentIndex = 0; _storyboard.Begin(); } }; LayoutRoot.Children.Add(button); } }