3faab33a65784e4cc16bfafec5be256b17dc10ef
[clanbomber-xamarin-client.git] / src / full_system / ConnectionTest / ConnectionTest / ConnectionTest / PostGamePage.cs
1 ´╗┐using System;
2
3 using Xamarin.Forms;
4 using static Bomberman.TcpJsonConnection;
5
6
7 namespace Bomberman
8 {
9     public class PostGamePage : ContentPage
10     {
11         private Label labelTime;
12
13         public PostGamePage(ServerPackage pkg)
14         {
15             Label labelTitle = new Label
16             {
17                 Text = "Results:",
18                 FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
19                 VerticalOptions = LayoutOptions.CenterAndExpand,
20                 HorizontalOptions = LayoutOptions.CenterAndExpand
21             };
22
23             labelTime = new Label
24             {
25                 Text = "Time until restart: " + pkg.Timeout.ToString("0.00"),
26                 FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
27                 VerticalOptions = LayoutOptions.CenterAndExpand,
28                 HorizontalOptions = LayoutOptions.CenterAndExpand
29             };
30
31             Grid outGrid = new Grid();
32             ScrollView scrollView = new ScrollView();
33             Grid innerGrid = new Grid();
34
35             outGrid.ColumnDefinitions = new ColumnDefinitionCollection()
36             {
37                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
38                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
39                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
40             };
41             outGrid.Children.Add(new Label() { Text = "Position" }, 0, 0);
42             outGrid.Children.Add(new Label() { Text = "ID" }, 1, 0);
43             outGrid.Children.Add(new Label() { Text = "Color" }, 2, 0);
44
45
46             innerGrid.ColumnDefinitions = new ColumnDefinitionCollection()
47             {
48                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
49                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
50                 new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
51             };
52
53             innerGrid.RowDefinitions = new RowDefinitionCollection();
54
55             String[] playerColorText = new String[4];
56             playerColorText[0] = "Yellow";
57             playerColorText[1] = "Red";
58             playerColorText[2] = "Purple";
59             playerColorText[3] = "Green";
60
61             Color[] PlayerColor = new Color[4];
62             PlayerColor[0] = Color.Yellow;
63             PlayerColor[1] = Color.Red;
64             PlayerColor[2] = Color.Purple;
65             PlayerColor[3] = Color.Green;
66
67             for (int i = 0; i < pkg.Players.Count; i++)
68             {
69                 innerGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
70                 innerGrid.Children.Add(new Label() { Text = "" + (i + 1) }, 0, i);
71                 innerGrid.Children.Add(new Label() { Text = "" + pkg.Players[i].Id }, 1, i);
72                 innerGrid.Children.Add(new Label() { Text = playerColorText[i % 4], TextColor = PlayerColor[i % 4] }, 2, i);
73
74             }
75
76             scrollView.Content = innerGrid;
77
78             Content = new StackLayout
79             {
80                 Children =
81                 {
82                     labelTitle,
83                     outGrid,
84                     scrollView,
85                     labelTime
86
87                 }
88             };
89         }
90         public void UpdateTime(ServerPackage pkg)
91         {
92             labelTime.Text = "Time until restart: " + pkg.Timeout.ToString("0.00");
93         }
94     }
95 }
96