public SwipeCommandPageCS()
        {
            var boxView = new BoxView {
                Color = Color.Teal, WidthRequest = 300, HeightRequest = 300, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand
            };
            var label = new Label();

            label.SetBinding(Label.TextProperty, "SwipeDirection");

            var leftSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Left, CommandParameter = "Left"
            };

            leftSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            var rightSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Right, CommandParameter = "Right"
            };

            rightSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            var upSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Up, CommandParameter = "Up"
            };

            upSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            var downSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Down, CommandParameter = "Down"
            };

            downSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            boxView.GestureRecognizers.Add(leftSwipeGesture);
            boxView.GestureRecognizers.Add(rightSwipeGesture);
            boxView.GestureRecognizers.Add(upSwipeGesture);
            boxView.GestureRecognizers.Add(downSwipeGesture);

            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Label {
                        Margin = new Thickness(0, 10), Text = "Swipe inside the box with a single finger."
                    },
                    boxView,
                    label
                }
            };
            BindingContext = new SwipeCommandPageViewModel();
        }
        public DetailsPage(DetailsPageViewModel viewModel)
        {
            BindingContext  = viewModel;
            BackgroundColor = Color.PowderBlue;

            var textLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            textLabel.SetBinding(Label.TextProperty, nameof(DetailsPageViewModel.NoteText));

            var backButton = new Button
            {
                Text            = "Go Back",
                VerticalOptions = LayoutOptions.Center,
                Margin          = new Thickness(20),
                BackgroundColor = Color.Red,
                TextColor       = Color.White,
                FontSize        = 20
            };

            backButton.SetBinding(Button.CommandProperty, nameof(DetailsPageViewModel.GoBackCommand));

            var downSwipeGestureRecognizer = new SwipeGestureRecognizer
            {
                Direction = SwipeDirection.Down
            };

            downSwipeGestureRecognizer.SetBinding(SwipeGestureRecognizer.CommandProperty, nameof(DetailsPageViewModel.GoBackCommand));

            var stackLayout = new StackLayout
            {
                Margin = new Thickness(20, 40)
            };

            stackLayout.Children.Add(textLabel);
            stackLayout.Children.Add(backButton);
            stackLayout.GestureRecognizers.Add(downSwipeGestureRecognizer);

            Content = stackLayout;
        }
Ejemplo n.º 3
0
        public SwipeCommandPageCS()
        {
            var boxView = new BoxView {
                HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand
            };
            var img = new Image();

            img.SetBinding(Image.SourceProperty, "Img");

            var leftSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Left, CommandParameter = "Left"
            };

            leftSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            var rightSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Right, CommandParameter = "Right"
            };

            rightSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "SwipeCommand");

            boxView.GestureRecognizers.Add(leftSwipeGesture);
            boxView.GestureRecognizers.Add(rightSwipeGesture);

            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Image {
                        Margin = new Thickness(0, 10), Source = "Chick1"
                    },
                    boxView,
                    img
                }
            };
            BindingContext = new SwipeCommandPageViewModel();
        }
Ejemplo n.º 4
0
        public WorkoutPage()
        {
            var    ID     = Guid.NewGuid().ToString();
            string family = "materialdesignicons-webfont.ttf#Material Design Icons";

            BindingContext = new WorkoutViewModel(ID);
            var toolbar = new ToolbarItem {
                Text = "Save Workout"
            };

            toolbar.SetBinding(ToolbarItem.CommandProperty, "SaveCommand");
            this.ToolbarItems.Add(toolbar);
            ProgressBar progressBar = new ProgressBar();

            progressBar.SetBinding(ProgressBar.ProgressProperty, "Progress");
            var label1 = new CustomLabel {
                FontSize = 36, VerticalOptions = LayoutOptions.EndAndExpand
            };

            label1.SetBinding(Label.TextProperty, "Titles[0].Text");
            var label2 = new CustomLabel {
                FontSize = 36
            };

            label2.SetBinding(Label.TextProperty, "Titles[1].Text");
            var grid = new Grid {
                VerticalOptions = LayoutOptions.StartAndExpand
            };

            for (int i = 0; i < 3; i++)
            {
                var label = new Label {
                    FontFamily = family, HorizontalOptions = LayoutOptions.End, FontSize = 40, VerticalOptions = LayoutOptions.Center
                };
                label.SetBinding(Label.TextProperty, "Picture[" + i.ToString() + "].Text");
                grid.Children.Add(label, i * 2, 0);
                label = new Label {
                    HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, FontSize = 30
                };
                label.SetBinding(Label.TextProperty, "Text[" + i.ToString() + "].Text");
                grid.Children.Add(label, i * 2 + 1, 0);
            }
            var label4 = new CustomLabel {
                FontSize = 20
            };

            label4.SetBinding(Label.TextProperty, "Titles[3].Text");
            var label5 = new CustomLabel {
                FontSize = 20
            };

            label5.SetBinding(Label.TextProperty, "Titles[4].Text");
            var timerLabel = new CustomLabel {
                FontSize = 50, TextColor = Color.Black, VerticalOptions = LayoutOptions.EndAndExpand
            };

            timerLabel.SetBinding(Label.TextProperty, "Time");
            // f40a or f40d
            Button buttonStart = new Button {
                Text = "\uf40a", FontFamily = family, FontSize = 50, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonStart.SetBinding(Button.CommandProperty, "StartTimerCommand");
            // f3e6 or f3e4
            Button buttonStop = new Button {
                Text = "\uf3e4", FontFamily = family, FontSize = 50, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonStop.SetBinding(Button.CommandProperty, "StopTimerCommand");
            // f667 or F99A
            Button buttonReset = new Button {
                Text = "\uf99a", FontFamily = family, FontSize = 50, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonReset.SetBinding(Button.CommandProperty, "ResetTimerCommand");


            var leftSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Left
            };

            leftSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "NextCommand");
            var rightSwipeGesture = new SwipeGestureRecognizer {
                Direction = SwipeDirection.Right
            };

            rightSwipeGesture.SetBinding(SwipeGestureRecognizer.CommandProperty, "LastCommand");

            Button buttonLast = new Button {
                Text = "Last", HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonLast.SetBinding(Button.CommandProperty, "LastCommand");
            Button buttonNext = new Button {
                Text = "Next", HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonNext.SetBinding(Button.CommandProperty, "NextCommand");

            Title = "Workout";
            var content = new StackLayout
            {
                Children =
                {
                    progressBar, label1,      label2,     grid, label4, label5,
                    timerLabel,  new StackLayout {
                        BackgroundColor = Color.DarkGray,Children = { timerLabel, new StackLayout {
                                                  Orientation = StackOrientation.Horizontal, Children = { buttonStart, buttonStop, buttonReset }
                                              } }
                    }
                    //,new StackLayout{Orientation=StackOrientation.Horizontal,Children={buttonLast,buttonNext} }
                }
            };

            content.GestureRecognizers.Add(leftSwipeGesture);
            content.GestureRecognizers.Add(rightSwipeGesture);
            Content = content;
            MessagingCenter.Subscribe <WorkoutViewModel>(this, ID, async(s) => {
                MessagingCenter.Send(this, "PopUpResult" + ID, await DisplayPromptAsync("Enter Value", "", maxLength: 3, keyboard: Keyboard.Numeric));
            });
        }
Ejemplo n.º 5
0
        public void InitializeUIElements()
        {
            CityName = new Entry
            {
                Placeholder = "Enter city",
                Margin      = new Thickness(10, 10),
            };
            CityName.SetBinding(Entry.TextProperty, nameof(WeatherDataViewModel.CityName));

            GetWeather = new Button
            {
                Text            = "Get Weather",
                BackgroundColor = Color.Green,
                Margin          = new Thickness(5, 10),
            };
            GetWeather.SetBinding(Button.CommandProperty, nameof(WeatherDataViewModel.GetWeatherCommand));

            Location = new Label
            {
                FontSize  = 16,
                TextColor = Color.Black
            };
            Location.SetBinding(
                Label.TextProperty,
                $"{nameof(WeatherData)}.{nameof(WeatherData.Title)}",
                stringFormat: "City: {0}"
                );

            Temperature = new Label
            {
                FontSize  = 16,
                TextColor = Color.Black
            };
            Temperature.SetBinding(
                Label.TextProperty,
                $"{nameof(WeatherData)}.{nameof(WeatherData.Main)}.{nameof(WeatherData.Main.Temperature)}",
                stringFormat: "Temperature: {0}° F"
                );

            WindSpeed = new Label
            {
                FontSize  = 16,
                TextColor = Color.Black
            };
            WindSpeed.SetBinding(
                Label.TextProperty,
                $"{nameof(WeatherData)}.{nameof(WeatherData.Wind)}.{nameof(WeatherData.Wind.Speed)}",
                stringFormat: "Wind Speed: {0} mph"
                );

            Humidity = new Label
            {
                FontSize  = 16,
                TextColor = Color.Black
            };
            Humidity.SetBinding(
                Label.TextProperty,
                $"{nameof(WeatherData)}.{nameof(WeatherData.Main)}.{nameof(WeatherData.Main.Humidity)}",
                stringFormat: "Humidity: {0}%"
                );

            Visibility = new Label
            {
                FontSize  = 16,
                TextColor = Color.Black
            };
            Visibility.SetBinding(
                Label.TextProperty,
                $"{nameof(WeatherData)}.{nameof(WeatherData.Visibility)}",
                stringFormat: "Visibility: {0}"
                );

            swipeDownGestureRecognizer = new SwipeGestureRecognizer
            {
                Direction = SwipeDirection.Down,
            };
            swipeDownGestureRecognizer.SetBinding(SwipeGestureRecognizer.CommandProperty, nameof(WeatherDataViewModel.GoBackCommand));
        }