コード例 #1
0
ファイル: GamePage.cs プロジェクト: rafelcnet/Xamarin
        public GamePage(int nivel, double width)
        {
            BindingContext  = new MemoramaViewModel();
            App.Width       = width;
            ViewModel.Nivel = nivel;
            ViewModel.ExecuteBarajaCartasCommand();
            Title           = ViewModel.CardCount.ToString() + " pares";
            BackgroundColor = Color.White;

            var refresh = new Button
            {
                Command         = ViewModel.BarajaCartasCommand,
                Text            = "Barajar de nuevo",
                TextColor       = Color.White,
                BorderColor     = Color.Green,
                BackgroundColor = Color.Green,
                WidthRequest    = 140,
                HeightRequest   = 60
            };

            StackLayout panel = new StackLayout
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Vertical,
                Spacing           = 6,
                Padding           = new Thickness(20, Device.OnPlatform(10, 20, 20), 20, Device.OnPlatform(10, 20, 20)),
            };

            panel.Children.Add(new Label
            {
                Text      = "juego de memoria",
                TextColor = Color.Gray,
                Font      = Font.SystemFontOfSize(Device.OnPlatform(30, 30, 50))
            });

            StackLayout stats = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                HeightRequest     = 40,
                Spacing           = 4
            };

            stats.Children.Add(new Label
            {
                Text      = "Movimientos:",
                TextColor = Color.Green,
            });

            Label movtos = new Label
            {
                WidthRequest = 30,
                Text         = "0",
                TextColor    = Color.Red
            };

            movtos.SetBinding(Label.TextProperty, new Binding("Tiradas", BindingMode.OneWay, new StringConverter()));
            stats.Children.Add(movtos);
            stats.Children.Add(new Label
            {
                Text      = "Pares:",
                TextColor = Color.Green,
            });

            Label pares = new Label
            {
                WidthRequest = 30,
                Text         = "0",
                TextColor    = Color.Red
            };

            pares.SetBinding <MemoramaViewModel>(Label.TextProperty, vm => vm.Pares, BindingMode.OneWay, new StringConverter());
            stats.Children.Add(pares);
            panel.Children.Add(stats);

            StackLayout status = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 4,
            };

            status.Children.Add(new Label
            {
                Text      = "Estado:",
                TextColor = Color.Green,
            });

            Label estado = new Label
            {
                WidthRequest = 340,
                Text         = "",
                TextColor    = Color.Red
            };

            estado.SetBinding(Label.TextProperty, "Status");
            status.Children.Add(estado);
            panel.Children.Add(status);

            if (ViewModel.Nivel == 0)
            {
                var cartas = new Grid6Cartas(ViewModel);
                panel.Children.Add(cartas);
            }
            else if (ViewModel.Nivel == 1)
            {
                var cartas = new Grid10Cartas(ViewModel);
                panel.Children.Add(cartas);
            }
            panel.Children.Add(refresh);

            var scrollview = new ScrollView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Orientation     = ScrollOrientation.Vertical,
                HeightRequest   = App.Height,
                Content         = panel
            };

            Content = scrollview;
        }
コード例 #2
0
ファイル: GamePage.cs プロジェクト: palaniakasapu/Xamarin
        public GamePage(int nivel, double width)
        {
            BindingContext = new MemoramaViewModel();
            App.Width = width;
            ViewModel.Nivel = nivel;
            ViewModel.ExecuteBarajaCartasCommand();
            Title = ViewModel.CardCount.ToString() + " pares";
            BackgroundColor = Color.White;

            var refresh = new Button
            {
                Command = ViewModel.BarajaCartasCommand,
                Text = "Barajar de nuevo",
                TextColor = Color.White,
                BorderColor = Color.Green,
                BackgroundColor = Color.Green,
                WidthRequest = 140,
                HeightRequest = 60
            };

            StackLayout panel = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation = StackOrientation.Vertical,
                Spacing = 6,
                Padding = new Thickness(20, Device.OnPlatform(10, 20, 20), 20, Device.OnPlatform(10, 20, 20)),
            };
            panel.Children.Add(new Label
            {
                Text = "juego de memoria",
                TextColor = Color.Gray,
                Font = Font.SystemFontOfSize(Device.OnPlatform(30, 30, 50))
            });

            StackLayout stats = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                HeightRequest = 40,
                Spacing = 4
            };
            stats.Children.Add(new Label
            {
                Text = "Movimientos:",
                TextColor = Color.Green,
            });

            Label movtos = new Label
            {
                WidthRequest = 30,
                Text = "0",
                TextColor = Color.Red
            };
            movtos.SetBinding(Label.TextProperty, new Binding("Tiradas", BindingMode.OneWay, new StringConverter()));
            stats.Children.Add(movtos);
            stats.Children.Add(new Label
            {
                Text = "Pares:",
                TextColor = Color.Green,
            });

            Label pares = new Label
            {
                WidthRequest = 30,
                Text = "0",
                TextColor = Color.Red
            };
            pares.SetBinding<MemoramaViewModel>(Label.TextProperty, vm => vm.Pares, BindingMode.OneWay, new StringConverter());
            stats.Children.Add(pares);
            panel.Children.Add(stats);

            StackLayout status = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing = 4,
            };
            status.Children.Add(new Label
            {
                Text = "Estado:",
                TextColor = Color.Green,
            });

            Label estado = new Label
            {
                WidthRequest = 340,
                Text = "",
                TextColor = Color.Red
            };
            estado.SetBinding(Label.TextProperty, "Status");
            status.Children.Add(estado);
            panel.Children.Add(status);

            if (ViewModel.Nivel == 0)
            {
                var cartas = new Grid6Cartas(ViewModel);
                panel.Children.Add(cartas);
            }
            else if (ViewModel.Nivel == 1)
            {
                var cartas = new Grid10Cartas(ViewModel);
                panel.Children.Add(cartas);
            }
            panel.Children.Add(refresh);

            var scrollview = new ScrollView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Orientation = ScrollOrientation.Vertical,
                HeightRequest = App.Height,
                Content = panel
            };

            Content = scrollview;
        }