Exemple #1
0
        public DistTravelledViewModel(WalkEntries walkEntry)
        {
            this.Hours     = 0;
            this.Minutes   = 0;
            this.Seconds   = 0;
            this.Travelled = 100;

            WalkEntry = walkEntry;
        }
        void ExecuteSaveCommand()
        {
            var newWalkItem = new WalkEntries
            {
                Title      = this.Title,
                Notes      = this.Notes,
                Latitude   = this.Latitude,
                Longitude  = this.Longitude,
                Kilometers = this.Kilometers,
                Difficulty = this.Difficulty,
                Distance   = this.Distance,
                ImageUrl   = this.ImageUrl
            };

            // Here, we will save the details entered in a later chapter.
        }
Exemple #3
0
        async Task ExecuteSaveCommand()
        {
            var newWalkItem = new WalkEntries
            {
                Title      = this.Title,
                Notes      = this.Notes,
                Latitude   = this.Latitude,
                Longitude  = this.Longitude,
                Kilometers = this.Kilometers,
                Difficulty = this.Difficulty,
                Distance   = this.Distance,
                ImageUrl   = this.ImageUrl
            };

            //tu będzie kod zapisujący dane
            await NavService.PreviousPage();
        }
        async Task ExecuteSaveCommand()
        {
            var newWalkItem = new WalkEntries
            {
                Title      = this.Title,
                Notes      = this.Notes,
                Latitude   = this.Latitude,
                Longitude  = this.Longitude,
                Kilometers = this.Kilometers,
                Difficulty = this.Difficulty,
                Distance   = this.Distance,
                ImageUrl   = this.ImageUrl
            };

            // Upon exiting our New Walk Entry Page, we need to
            // stop checking for location updates
            myLocation = null;

            // Here, we will save the details entered in a later chapter.
            await NavService.PreviousPage();
        }
Exemple #5
0
        public WalkTrailPage(WalkEntries walkItem)
        {
            Title = "Szlak";
            var beginTrailWalk = new Button
            {
                BackgroundColor = Color.FromHex("#008080"),
                TextColor       = Color.White,
                Text            = "Rozpocznij ten szlak"
            };

            // definicja procedury obsługi zdarzeń
            beginTrailWalk.Clicked += (sender, e) =>
            {
                if (walkItem == null)
                {
                    return;
                }
                Navigation.PushAsync(new DistanceTravelledPage(walkItem));
                Navigation.RemovePage(this);
                walkItem = null;
            };
            var walkTrailImage = new Image()
            {
                Aspect = Aspect.AspectFill,
                Source = walkItem.ImageUrl
            };
            var trailNameLabel = new Label()
            {
                FontSize       = 28,
                FontAttributes = FontAttributes.Bold,
                TextColor      = Color.Black,
                Text           = walkItem.Title
            };
            var trailKilometersLabel = new Label()
            {
                FontAttributes = FontAttributes.Bold,
                FontSize       = 12,
                TextColor      = Color.Black,
                Text           = $"Długość: { walkItem.Kilometers } km"
            };
            var trailDifficultyLabel = new Label()
            {
                FontAttributes = FontAttributes.Bold,
                FontSize       = 12,
                TextColor      = Color.Black,
                Text           = $"Poziom trudności: { walkItem.Difficulty } "
            };
            var trailFullDescription = new Label()
            {
                FontSize          = 11,
                TextColor         = Color.Black,
                Text              = $"{ walkItem.Notes }",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            this.Content = new ScrollView
            {
                Padding = 10,
                Content = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children          =
                    {
                        walkTrailImage,
                        trailNameLabel,
                        trailKilometersLabel,
                        trailDifficultyLabel,
                        trailFullDescription,
                        beginTrailWalk
                    }
                }
            };
        }
Exemple #6
0
        public WalkTrailPage(WalkEntries walkItem)
        {
            Title = "Walks Trail";

            // Declare and intialize our Model Binding Context
            BindingContext = new WalksTrailViewModel(walkItem);

            var beginTrailWalk = new Button
            {
                BackgroundColor = Color.FromHex("#008080"),
                TextColor       = Color.White,
                Text            = "Begin this Trail"
            };

            // Set up event handler
            beginTrailWalk.Clicked += (sender, e) =>
            {
                if (walkItem == null)
                {
                    return;
                }
                Navigation.PushAsync(new DistanceTravelledPage(walkItem));
                Navigation.RemovePage(this);
                walkItem = null;
            };

            var walkTrailImage = new Image()
            {
                Aspect = Aspect.AspectFill,
            };

            walkTrailImage.SetBinding(Image.SourceProperty, "WalkEntry.ImageUrl");

            var trailNameLabel = new Label()
            {
                FontSize       = 28,
                FontAttributes = FontAttributes.Bold,
                TextColor      = Color.Black,
            };

            trailNameLabel.SetBinding(Label.TextProperty, "WalkEntry.Title");

            var trailKilometersLabel = new Label()
            {
                FontSize       = 12,
                FontAttributes = FontAttributes.Bold,
                TextColor      = Color.Black,
            };

            trailKilometersLabel.SetBinding(Label.TextProperty, "WalkEntry.Kilometers", stringFormat: "Length: {0} km");

            var trailDifficultyLabel = new Label()
            {
                FontSize       = 12,
                FontAttributes = FontAttributes.Bold,
                TextColor      = Color.Black,
            };

            trailDifficultyLabel.SetBinding(Label.TextProperty, "WalkEntry.Difficulty", stringFormat: "Difficulty: {0}");

            var trailFullDescription = new Label()
            {
                FontSize          = 11,
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            trailFullDescription.SetBinding(Label.TextProperty, "WalkEntry.Notes");

            this.Content = new ScrollView
            {
                Padding = 10,
                Content = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children          =
                    {
                        walkTrailImage,
                        trailNameLabel,
                        trailKilometersLabel,
                        trailDifficultyLabel,
                        trailFullDescription,
                        beginTrailWalk
                    }
                }
            };
        }
        public DistanceTravelledPage(WalkEntries walkItem)
        {
            Title = "Przebyty dystans";

            //deklaracja i inicjalizacja kontekstu wiązania modelu
            BindingContext = new DistTravelledViewModel(walkItem);

            //tworzenie obiektu mapy

            var trailMap = new Map();

            //wbicie szpilki w mapę dla wybranego szlaku
            trailMap.Pins.Add(new Pin
            {
                Type     = PinType.Place,
                Label    = _viewModel.WalkEntry.Title,
                Position = new Position(_viewModel.WalkEntry.Latitude, _viewModel.WalkEntry.Longitude),
            });
            //Wyśrodkowanie mapy na początku szlaku / szpilce
            trailMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(_viewModel.WalkEntry.Latitude, _viewModel.WalkEntry.Longitude), Distance.FromKilometers(1.0)));

            var trailNameLabel = new Label()
            {
                FontSize                = 18,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            trailNameLabel.SetBinding(Label.TextProperty, "WalkEntry.Title");

            var TrailDistanceTravelledLabel = new Label()
            {
                FontSize                = 20,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            TrailDistanceTravelledLabel.SetBinding(Label.TextProperty, "Travelled", stringFormat: "Przebyty dystans: {0} km");

            var totalTimeTakenLabel = new Label()
            {
                FontSize                = 20,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            totalTimeTakenLabel.SetBinding(Label.TextProperty, "TimeTaken", stringFormat: "Czas: {0}");

            //przycisk
            var walksHomeButton = new Button()
            {
                BackgroundColor = Color.FromHex("#008080"),
                TextColor       = Color.White,
                Text            = "zakończ ten szlak"
            };

            //procedura obsługi kliknięcia w przycisk wróć do domowej
            walksHomeButton.Clicked += (sender, e) =>
            {
                if (walkItem == null)
                {
                    return;
                }
                Navigation.PopToRootAsync(true);
                walkItem = null;
            };

            //kontrolka do przewijania
            this.Content = new ScrollView
            {
                Padding = 10,
                Content = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children          =
                    {
                        trailMap,
                        trailNameLabel,
                        TrailDistanceTravelledLabel,
                        totalTimeTakenLabel,
                        walksHomeButton
                    }
                }
            };
        }
 public WalksTrailViewModel(WalkEntries walkEntry)
 {
     WalkEntry = walkEntry;
 }
        public DistanceTravelledPage(WalkEntries walkItem)
        {
            Title = "Distance Travelled";

            // Declare and initialise our Model Binding Context
            BindingContext = new DistTravelledViewModel(walkItem);

            // Instantiate our map object
            var trailMap = new Map();

            // Place a pin on the map for the chosen walk type
            trailMap.Pins.Add(new Pin
            {
                Type     = PinType.Place,
                Label    = _viewModel.WalkEntry.Title,
                Position = new Position(_viewModel.WalkEntry.Latitude, _viewModel.WalkEntry.Longitude)
            });

            // Center the map around the list of walks entry's location
            trailMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(_viewModel.WalkEntry.Latitude, _viewModel.WalkEntry.Longitude), Distance.FromKilometers(1.0)));

            var trailNameLabel = new Label()
            {
                FontSize                = 18,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            trailNameLabel.SetBinding(Label.TextProperty, "WalkEntry.Title");

            var trailDistanceTravelledLabel = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            trailDistanceTravelledLabel.SetBinding(Label.TextProperty, "Travelled", stringFormat: "Distance Travelled: {0} km");

            var totalTimeTakenLabel = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center
            };

            totalTimeTakenLabel.SetBinding(Label.TextProperty, "TimeTaken", stringFormat: "Time Taken: {0}");

            var walksHomeButton = new Button
            {
                BackgroundColor = Color.FromHex("#008080"),
                TextColor       = Color.White,
                Text            = "End this Trail"
            };

            // Set up our event handler
            walksHomeButton.Clicked += (sender, e) =>
            {
                if (walkItem == null)
                {
                    return;
                }
                Navigation.PopToRootAsync(true);
                walkItem = null;
            };

            this.Content = new ScrollView
            {
                Padding = 10,
                Content = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children          =
                    {
                        trailMap,
                        trailNameLabel,
                        trailDistanceTravelledLabel,
                        totalTimeTakenLabel,
                        walksHomeButton
                    }
                }
            };
        }
        public DistanceTravelledPage(WalkEntries walkItem)
        {
            Title = "Przebyty dystans";
            // utworzenie egzemplarza obiektu mapy
            var trailMap = new Map();

            // wbicie szpilki w mapę dla wybranego szlaku
            trailMap.Pins.Add(new Pin
            {
                Type     = PinType.Place,
                Label    = walkItem.Title,
                Position = new Position(walkItem.Latitude, walkItem.Longitude)
            });
            // wyśrodkowanie mapy na początku szlaku
            trailMap.MoveToRegion(MapSpan.FromCenterAndRadius(new
                                                              Position(walkItem.Latitude, walkItem.Longitude),
                                                              Distance.FromKilometers(1.0)));
            var trailNameLabel = new Label()
            {
                FontSize       = 18,
                FontAttributes = FontAttributes.Bold,
                TextColor      = Color.Black,
                Text           = walkItem.Title
            };
            var trailDistanceTravelledLabel = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                Text                    = "Przebyty dystans:",
                HorizontalTextAlignment = TextAlignment.Center
            };
            var totalDistanceTaken = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                Text                    = $"{ walkItem.Distance } km",
                HorizontalTextAlignment = TextAlignment.Center
            };
            var totalTimeTakenLabel = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                Text                    = "Czas:",
                HorizontalTextAlignment = TextAlignment.Center
            };
            var totalTimeTaken = new Label()
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 20,
                TextColor               = Color.Black,
                Text                    = "0 h 0 m 0 s",
                HorizontalTextAlignment = TextAlignment.Center
            };
            var walksHomeButton = new Button
            {
                BackgroundColor = Color.FromHex("#008080"),
                TextColor       = Color.White,
                Text            = "Zakończ ten szlak"
            };

            // definicja procedury obsługi zdarzeń
            walksHomeButton.Clicked += (sender, e) =>
            {
                if (walkItem == null)
                {
                    return;
                }
                Navigation.PopToRootAsync(true);
                walkItem = null;
            };
            this.Content = new ScrollView
            {
                Padding = 10,
                Content = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children          =
                    {
                        trailMap,
                        trailNameLabel,
                        trailDistanceTravelledLabel,
                        totalDistanceTaken,
                        totalTimeTakenLabel,
                        totalTimeTaken,
                        walksHomeButton
                    }
                }
            };
        }