HandsOff/TeamCreatorPage.xaml.cs
/// <summary>
/// Creates GUI elements to display players of team, with attributes fields.
/// </summary>
Creates GUI elements to display players of team, with attributes fields.
Creates GUI elements to display players of team with attributes fields .
public async void CreateTeamCreatorUI()
        {
            int x = 0;
            Grid grid = TeamGrid;
            for (int i = 1; i < 12; i++)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    StackPanel stackPanel = new StackPanel
                    {
                        Name = "stackpanel" + i
                    };
                    TextBlock playerLabel = new TextBlock
                    {
                        HorizontalAlignment = HorizontalAlignment.Center,
                        FontSize = 18,
                        Foreground = new SolidColorBrush(Colors.White)
                    };
                    if (i == 1)
                    {
                        playerLabel.Text = "GK";
                    }
                    if (i == 2)
                    {
                        playerLabel.Text = "LB";
                    }
                    if (i == 3 || i == 4)
                    {
                        playerLabel.Text = "CB";
                    }
                    if (i == 5)
                    {
                        playerLabel.Text = "RB";
                    }
                    if (i >= 6 && i <= 9)
                    {
                        playerLabel.Text = "CM";
                    }
                    if (i == 10 || i == 11)
                    {
                        playerLabel.Text = "ST";
                    }
                    TextBlock speedLabel = new TextBlock
                    {
                        Text = "Speed",
                        HorizontalAlignment = HorizontalAlignment.Center,
                        FontSize = 14,
                        Foreground = new SolidColorBrush(Colors.White),
                        Margin = new Thickness(15, 5, 0, 0)
                    };
                    TextBlock attackLabel = new TextBlock
                    {
                        Text = "Attack",
                        HorizontalAlignment = HorizontalAlignment.Center,
                        FontSize = 14,
                        Foreground = new SolidColorBrush(Colors.White),
                        Margin = new Thickness(15, 2, 0, 0)
                    };
                    TextBlock defenceLabel = new TextBlock
                    {
                        Text = "Defence",
                        HorizontalAlignment = HorizontalAlignment.Center,
                        FontSize = 14,
                        Foreground = new SolidColorBrush(Colors.White),
                        Margin = new Thickness(15, 2, 0, 0)
                    };
                    TextBox speedTextBox = new TextBox
                    {
                        Text = "55",
                        Background = new SolidColorBrush(Colors.Wheat),
                        Foreground = new SolidColorBrush(Colors.Black),
                        FontSize = 12,
                        Height = 35,
                        Width = 50
                    };
                    TextBox attackTextBox = new TextBox
                    {
                        Text = "55",
                        Background = new SolidColorBrush(Colors.Wheat),
                        Foreground = new SolidColorBrush(Colors.Black),
                        FontSize = 12,
                        Height = 35,
                        Width = 50
                    };
                    TextBox defenceTextBox = new TextBox
                    {
                        Text = "55",
                        Background = new SolidColorBrush(Colors.Wheat),
                        Foreground = new SolidColorBrush(Colors.Black),
                        FontSize = 12,
                        Height = 35,
                        Width = 50
                    };
                    grid.Children.Add(stackPanel);
                    stackPanel.Children.Add(playerLabel);
                    stackPanel.Children.Add(speedLabel);
                    stackPanel.Children.Add(speedTextBox);
                    stackPanel.Children.Add(attackLabel);
                    stackPanel.Children.Add(attackTextBox);
                    stackPanel.Children.Add(defenceLabel);
                    stackPanel.Children.Add(defenceTextBox);
                    if (i <= 1)
                    {
                        Grid.SetColumn(stackPanel, x + 2);
                        Grid.SetColumnSpan(stackPanel, 2);
                        Grid.SetRow(stackPanel, 3);
                        x++;
                        if (x == 1)
                        {
                            x = 0;
                        }
                    }
                    else if (i > 1 && i <= 5)
                    {
                        Grid.SetColumn(stackPanel, x + 1);
                        Grid.SetRow(stackPanel, 2);
                        x++;
                        if (x == 4)
                        {
                            x = 0;
                        }
                    }
                    else if (i > 5 && i <= 9)
                    {
                        Grid.SetColumn(stackPanel, x + 1);
                        Grid.SetRow(stackPanel, 1);
                        x++;
                        if (x == 4)
                        {
                            x = 0;
                        }
                    }
                    else if (i > 9)
                    {
                        Grid.SetColumn(stackPanel, x + 2);
                        Grid.SetRow(stackPanel, 0);
                        x++;
                        if (x == 2)
                        {
                            x = 0;
                        }
                    }
                });
            }
        }
public async void CreateTeamCreatorUI ( ) { int x = 0 ; Grid grid = TeamGrid ; for ( int i = 1 ; i < 12 ; i ++ ) { await Dispatcher . RunAsync ( CoreDispatcherPriority . Normal , ( ) => { StackPanel stackPanel = new StackPanel { Name = " " + i } ; TextBlock playerLabel = new TextBlock { HorizontalAlignment = HorizontalAlignment . Center , FontSize = 18 , Foreground = new SolidColorBrush ( Colors . White ) } ; if ( i == 1 ) { playerLabel . Text = " " ; } if ( i == 2 ) { playerLabel . Text = " " ; } if ( i == 3 || i == 4 ) { playerLabel . Text = " " ; } if ( i == 5 ) { playerLabel . Text = " " ; } if ( i >= 6 && i <= 9 ) { playerLabel . Text = " " ; } if ( i == 10 || i == 11 ) { playerLabel . Text = " " ; } TextBlock speedLabel = new TextBlock { Text = " " , HorizontalAlignment = HorizontalAlignment . Center , FontSize = 14 , Foreground = new SolidColorBrush ( Colors . White ) , Margin = new Thickness ( 15 , 5 , 0 , 0 ) } ; TextBlock attackLabel = new TextBlock { Text = " " , HorizontalAlignment = HorizontalAlignment . Center , FontSize = 14 , Foreground = new SolidColorBrush ( Colors . White ) , Margin = new Thickness ( 15 , 2 , 0 , 0 ) } ; TextBlock defenceLabel = new TextBlock { Text = " " , HorizontalAlignment = HorizontalAlignment . Center , FontSize = 14 , Foreground = new SolidColorBrush ( Colors . White ) , Margin = new Thickness ( 15 , 2 , 0 , 0 ) } ; TextBox speedTextBox = new TextBox { Text = " " , Background = new SolidColorBrush ( Colors . Wheat ) , Foreground = new SolidColorBrush ( Colors . Black ) , FontSize = 12 , Height = 35 , Width = 50 } ; TextBox attackTextBox = new TextBox { Text = " " , Background = new SolidColorBrush ( Colors . Wheat ) , Foreground = new SolidColorBrush ( Colors . Black ) , FontSize = 12 , Height = 35 , Width = 50 } ; TextBox defenceTextBox = new TextBox { Text = " " , Background = new SolidColorBrush ( Colors . Wheat ) , Foreground = new SolidColorBrush ( Colors . Black ) , FontSize = 12 , Height = 35 , Width = 50 } ; grid . Children . Add ( stackPanel ) ; stackPanel . Children . Add ( playerLabel ) ; stackPanel . Children . Add ( speedLabel ) ; stackPanel . Children . Add ( speedTextBox ) ; stackPanel . Children . Add ( attackLabel ) ; stackPanel . Children . Add ( attackTextBox ) ; stackPanel . Children . Add ( defenceLabel ) ; stackPanel . Children . Add ( defenceTextBox ) ; if ( i <= 1 ) { Grid . SetColumn ( stackPanel , x + 2 ) ; Grid . SetColumnSpan ( stackPanel , 2 ) ; Grid . SetRow ( stackPanel , 3 ) ; x ++ ; if ( x == 1 ) { x = 0 ; } } else if ( i > 1 && i <= 5 ) { Grid . SetColumn ( stackPanel , x + 1 ) ; Grid . SetRow ( stackPanel , 2 ) ; x ++ ; if ( x == 4 ) { x = 0 ; } } else if ( i > 5 && i <= 9 ) { Grid . SetColumn ( stackPanel , x + 1 ) ; Grid . SetRow ( stackPanel , 1 ) ; x ++ ; if ( x == 4 ) { x = 0 ; } } else if ( i > 9 ) { Grid . SetColumn ( stackPanel , x + 2 ) ; Grid . SetRow ( stackPanel , 0 ) ; x ++ ; if ( x == 2 ) { x = 0 ; } } } ) ; } }
Creates GUI elements to display players of team, with attributes fields.
Creates GUI elements to display players of team with attributes fields .
// Positions the players in the correct grid row.