public WalksPageViewModel() { Title = "New Walk"; Difficulty = "Easy"; Distance = 1.0; var margs = new WalkEntry() { Title = "10 Mile Brook Trail, Margaret River", Notes = "The 10 Mile Brook Trail in Rotary Park near Old Kate, a preserved steam engine at the northern edge of Margaret River.", Latitude = -33.9727604, Longitude = 115.0861599, Kilometers = 7.5, Distance = 0, Difficulty = "Medium", ImageUrl = "http://trailswa.com.au/media/cache/media/images/trails/_mid/FullSizeRender1_600_480_c1.jpg" }; var giants = new WalkEntry() { Title = "Acient Empire Walk, Valley of the Giant", Notes = "The Ancient Empire is a 450m waslk trail that takes you around and through some of the giant tingle trees including the most popullat of the gnarled veterans, known as Grandma Tingle.", Latitude = -34.9749188, Longitude = 117.3560796, Kilometers = 450, Distance = 0, Difficulty = "Hard", ImageUrl = "http://trailswa.com.au/media/cache/media/images/trails/_mid/Ancient_Empire_534_480_c1.jpg" }; WalkEntries = new ObservableCollection <WalkEntry> { margs, giants }; }
public DistTravelledViewModel(WalkEntry walkEntry) { this.Hours = 0; this.Minutes = 0; this.Seconds = 0; this.Travelled = 100; WalkEntry = walkEntry; }
void ExecuteSaveCommand() { var newWalkItem = new WalkEntry { 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. }
//WalkEntry walkItem; public WalkTrailPage(WalkEntry walkItem) { //this.walkItem = walkItem; InitializeComponent(); var beginTrailWalk = new Button { BackgroundColor = Color.FromHex("#008080"), TextColor = Color.White, Text = "Begin this Trail" }; // Set up our 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, 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 = $"Length: { walkItem.Kilometers } km" }; var trailDifficultyLabel = new Label() { FontAttributes = FontAttributes.Bold, FontSize = 12, TextColor = Color.Black, Text = $"Difficulty: { 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 } } }; }
public WalksTrailViewModel(WalkEntry walkEntry) { WalkEntry = walkEntry; }
public WalksPage() { InitializeComponent(); //ToolbarItem newWalkItem = new ToolbarItem() //{ // Text = "Add Walk" //}; //newWalkItem.Clicked += NewWalkItem_Clicked; //ToolbarItems.Add(newWalkItem); var margs = new WalkEntry() { Title = "10 Mile Brook Trail, Margaret River", Notes = "The 10 Mile Brook Trail in Rotary Park near Old Kate, a preserved steam engine at the northern edge of Margaret River.", Latitude = -33.9727604, Longitude = 115.0861599, Kilometers = 7.5, Distance = 0, Difficulty = "Medium", ImageUrl = "http://trailswa.com.au/media/cache/media/images/trails/_mid/FullSizeRender1_600_480_c1.jpg" }; var giants = new WalkEntry() { Title = "Acient Empire Walk, Valley of the Giant", Notes = "The Ancient Empire is a 450m waslk trail that takes you around and through some of the giant tingle trees including the most popullat of the gnarled veterans, known as Grandma Tingle.", Latitude = -34.9749188, Longitude = 117.3560796, Kilometers = 450, Distance = 0, Difficulty = "Hard", ImageUrl = "http://trailswa.com.au/media/cache/media/images/trails/_mid/Ancient_Empire_534_480_c1.jpg" }; var itemTemplate = new DataTemplate(typeof(ImageCell)); itemTemplate.SetBinding(TextCell.TextProperty, "Title"); itemTemplate.SetBinding(TextCell.DetailProperty, "Notes"); itemTemplate.SetBinding(ImageCell.ImageSourceProperty, "ImageUrl"); WalkEntries = new List <WalkEntry> { margs, giants }; var walksList = new ListView { HasUnevenRows = true, ItemTemplate = itemTemplate, ItemsSource = WalkEntries, SeparatorColor = Color.FromHex("#ddd") }; // Set up our event handler walksList.ItemTapped += (object sender, ItemTappedEventArgs e) => { var item = (WalkEntry)e.Item; if (item == null) { return; } Navigation.PushAsync(new WalkTrailPage(item)); item = null; }; Content = walksList; }
public DistanceTravelledPage(WalkEntry walkItem) { InitializeComponent(); this.walkItem = walkItem; // Instantiate our map object var trailMap = new Map(); // Place a pin on the map for the chosen walk type var mapPosition = new Position(walkItem.Latitude, walkItem.Longitude); trailMap.Pins.Add(new Pin { Type = PinType.Place, Label = walkItem.Title, Position = mapPosition }); // Center the map around the list of walks entry's location trailMap.MoveToRegion(MapSpan.FromCenterAndRadius(mapPosition, 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 = "Distance Travelled", 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 = "Time Taken:", HorizontalTextAlignment = TextAlignment.Center }; var totalTimeTaken = new Label() { FontAttributes = FontAttributes.Bold, FontSize = 20, TextColor = Color.Black, Text = "0h 0m 0s", HorizontalTextAlignment = TextAlignment.Center }; 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, totalDistanceTaken, totalTimeTakenLabel, totalTimeTaken, walksHomeButton } } }; }