Ejemplo n.º 1
0
        StackLayout GetStepEntries(string labelText, string bindingPropRight, int n)
        {
            Label headLabel = new Label()
            {
                Text = labelText,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize = 18,
                Margin   = new Thickness(0, 0, 0, 10)
            };

            RoundedBorderedEntry right = n == 1 ?  GetEntry("Total de pares") : n == 2 ? GetEntry("Tempo de reação") : GetEntryText("Usuario");

            right.SetBinding(RoundedEntry.TextProperty, new Binding(bindingPropRight));

            StackLayout stack = new StackLayout()
            {
                Children =
                {
                    headLabel,
                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    = { right }
                    }
                },
                Margin = 10
            };

            stack.BindingContext = ViewModel;

            return(stack);
        }
Ejemplo n.º 2
0
        private void ConfigureScreen()
        {
            NavBar = BaseContentPage.Instance.ConfigureNavBar("Carro personalizado".ToUpper(), true, true);
            NavBar.BackButton.GestureRecognizers.Clear();
            NavBar.BackButton.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    BaseContentPage.Instance.PopModal();
                })
            });

            RoundedBorderedEntry car = GetEntryText("Marca");

            car.SetBinding(RoundedEntry.TextProperty, new Binding($"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.Name)}"));

            RoundedBorderedEntry style = GetEntryText("Modelo");

            style.SetBinding(RoundedEntry.TextProperty, new Binding($"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.Style)}"));

            RoundedBorderedEntry parkingSpace = GetEntry("Tamanho minimo de vaga (CM)");

            parkingSpace.SetBinding(RoundedEntry.TextProperty, new Binding($"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.ParkingSpace)}", converter: Converter));

            RoundedBorderedEntry wheelRadiusInt = GetEntry("Raio da roda Interno");

            wheelRadiusInt.SetBinding(RoundedEntry.TextProperty, new Binding($"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.WheelRadiusInternal)}"));

            RoundedBorderedEntry wheelRadiusExt = GetEntryText("Raio da roda Externo");

            wheelRadiusExt.SetBinding(RoundedEntry.TextProperty, new Binding($"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.WheelRadiusExternal)}"));



            Label passosDaBaliza = new Label()
            {
                FontSize = 16, Text = "Passos da baliza (em CM, sempre positivo)"
            };

            StackLayout first = GetStepEntries("Primeiro passo - Centralizado/Frente",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FirstLeft)}",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FirstRight)}");
            StackLayout second = GetStepEntries("Segundo passo - Esquerda/Trás",
                                                $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.SecondLeft)}",
                                                $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.SecondRight)}");
            StackLayout third = GetStepEntries("Terceiro passo - Centralizado/Trás",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.ThirdLeft)}",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.ThirdRight)}");
            StackLayout fourth = GetStepEntries("Quarto passo - Esquerda/Frente",
                                                $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FourthLeft)}",
                                                $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FourthRight)}");
            StackLayout fifth = GetStepEntries("Quinto passo - Direita/Frente",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FifthLeft)}",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.FifthRight)}");
            StackLayout sixth = GetStepEntries("Sexto passo - Esquerda/Frente",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.SixthLeft)}",
                                               $"{nameof(ViewModel.Car)}.{nameof(ViewModel.Car.SixthRight)}");

            var button = new Button()
            {
                Text            = "Concluido",
                BackgroundColor = ColorPalette.LightBlue,
                TextColor       = Color.White,
                BorderRadius    = 18,
                Margin          = 10,
                HeightRequest   = 55,
                FontSize        = 17,
                Command         = ViewModel.Continue,
            };

            Content = new StackLayout()
            {
                Children =
                {
                    NavBar,
                    car,
                    style,
                    parkingSpace,
                    wheelRadiusExt,
                    wheelRadiusInt,
                    first,
                    second,
                    third,
                    fourth,
                    fifth,
                    sixth,
                    button
                }
            };
        }
Ejemplo n.º 3
0
        StackLayout GetStepEntries(string labelText, string bindingPropLeft, string bindingPropRight)
        {
            Label headLabel = new Label()
            {
                Text = labelText,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize = 18,
                Margin   = new Thickness(0, 0, 0, 10)
            };

            RoundedBorderedEntry left  = GetEntry("Esquerda");
            RoundedBorderedEntry right = GetEntry("Direita");

            left.SetBinding(RoundedEntry.TextProperty, new Binding(bindingPropLeft));
            right.SetBinding(RoundedEntry.TextProperty, new Binding(bindingPropRight));

            StackLayout stack = new StackLayout()
            {
                Children =
                {
                    headLabel,
                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    = { left, right }
                    }
                },
                Margin = 10
            };

            /*
             * if (App.IsAndroidSDKBelowMarshmallow)
             * {
             *
             *  var propLeft = bindingPropLeft.Split('.')[1];
             *  var propRight = bindingPropRight.Split('.')[1];
             *
             *  ViewModel.PropertyChanged += (sender, args) =>
             *  {
             *      if (args.PropertyName == propLeft)
             *          left.Text = ViewModel.GetType().GetProperty(propLeft).GetValue(ViewModel).ToString();
             *      else if (args.PropertyName == propRight)
             *          right.Text = ViewModel.GetType().GetProperty(propLeft).GetValue(ViewModel).ToString();
             *  };
             *
             *  left.TextChanged += (sender, args) =>
             *  {
             *      double value = 0;
             *      double.TryParse(left.Text, out value);
             *      var viewmodelType = typeof(NewCarViewModel);
             *      var prop = viewmodelType.GetProperty(propLeft);
             *      prop.SetValue(ViewModel, value);
             *  };
             *
             *  right.TextChanged += (sender, args) =>
             *  {
             *      double value = 0;
             *      double.TryParse(right.Text, out value);
             *      var viewmodelType = typeof(NewCarViewModel);
             *      var prop = viewmodelType.GetProperty(propRight);
             *      prop.SetValue(ViewModel, value);
             *      //ViewModel.GetType().GetProperty(propRight).SetValue(ViewModel, value);
             *  };
             *
             * }
             */
            stack.BindingContext = ViewModel;

            return(stack);
        }