private Grid AddRacer(RacerOption type, int left) { TextBlock textblock = new TextBlock() { Text = "\U0001F3CE", IsColorFontEnabled = true, FontFamily = new FontFamily("Segoe UI Emoji") }; Viewbox viewbox = new Viewbox() { Child = textblock }; Grid grid = new Grid() { Tag = new Racer() { Option = type } }; grid.Tapped += Racer_Tapped; grid.Children.Add(viewbox); Canvas.SetLeft(grid, left); return(grid); }
private void Racer_Tapped(object sender, RoutedEventArgs e) { if (_state == RacerState.Select) { Grid grid = (Grid)sender; Racer racer = (Racer)grid.Tag; _selected = racer.Option; _state = RacerState.Ready; ShowMessage(); } }
private void Add(ref Grid grid, RacerOption type, int row) { Canvas canvas = new Canvas() { Width = width, Margin = new Thickness(0, 0, 0, 30) }; Grid racer = AddRacer(type, width); _items.Add(racer); canvas.Children.Add(racer); canvas.SetValue(Grid.RowProperty, row); grid.Children.Add(canvas); }
private async void Storyboard_Completed(object sender, object e) { if (_state == RacerState.Started) { Storyboard storyboard = (Storyboard)sender; TimeSpan duration = storyboard.GetCurrentTime(); Racer racer = (Racer)_items.FirstOrDefault(w => ((Racer)w.Tag).Time == duration).Tag; _count++; if (_count == 1) { _winner = racer.Option; string name = Enum.GetName(typeof(RacerOption), _winner); await ShowDialogAsync($"{name} completed Race in {duration.ToString()}"); } if (_count == total) { _state = RacerState.Finished; ShowMessage(); } _finished = true; } }