Pārlūkot izejas kodu

Completed Route preview pane
Added numbers in json @ titles

Jeroen 10 gadi atpakaļ
vecāks
revīzija
32e644d8c8

BIN
Breda-Tour/Assets/Map.png


+ 1 - 0
Breda-Tour/Breda-Tour.csproj

@@ -95,6 +95,7 @@
     </Content>
     <None Include="project.json" />
     <Content Include="Assets\Flag_Icon.png" />
+    <Content Include="Assets\Map.png" />
     <Content Include="Assets\Map_Icon.png" />
     <Content Include="Assets\UitklapIcon1.png" />
     <Content Include="Assets\UitklapIcon2.png" />

+ 1 - 0
Breda-Tour/Data/waypoint.cs

@@ -18,6 +18,7 @@ namespace Breda_Tour.Data
         public String Title { get; private set; }
         public String Description { get; private set; }
         public List<Picture> Pictures { get; private set; }
+        public bool FromPreview { get; set; } 
 
         public Waypoint(double Lat, double Long, String Title, String Description, List<string> pictures)
         {

+ 17 - 2
Breda-Tour/MapScreen/WpDetailPage.xaml.cs

@@ -15,6 +15,7 @@ using Windows.UI.Xaml.Input;
 using Windows.UI.Xaml.Media;
 using Windows.UI.Xaml.Navigation;
 using Breda_Tour.Data;
+using Breda_Tour.RouteSelectScreen;
 
 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
 
@@ -38,9 +39,23 @@ namespace Breda_Tour.MapScreen
         {
             wp = e.Parameter as Waypoint;
             this.DataContext = wp;
-
+            if (wp.FromPreview)
+            {
+                SystemNavigationManager.GetForCurrentView().BackRequested += RouteExample_BackRequested;
+            }
+            else
+            {
+                SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested;
+            }
             SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
-            SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested;
+            wp.FromPreview = false;
+        }
+
+        private void RouteExample_BackRequested(object sender, BackRequestedEventArgs e)
+        {
+            e.Handled = true;
+            SystemNavigationManager.GetForCurrentView().BackRequested -= RouteExample_BackRequested;
+            MainPage.RootFrame.Navigate(typeof(RouteExample));
         }
 
         private void MainPage_BackRequested(object sender, BackRequestedEventArgs e)

+ 30 - 14
Breda-Tour/RouteSelectScreen/RouteExample.xaml

@@ -9,27 +9,43 @@
     xmlns:data="using:Breda_Tour.Data"
     mc:Ignorable="d">
 
-    <Grid Background="White">
-        <c:DefaultTopBar Header="Routevoorbeeld" Margin="0,-300,0,300"/>
-        <TextBlock Text="Routeinformatie" FontSize="16" Margin="17,45,0,-23"/>
-        <TextBlock Text="Tijdsduur: " FontSize="16" Margin="17,80,0,-25"/>
-        <TextBlock Text="Loopafstand: " FontSize="16" Margin="17,95,0,-25"/>
-        <TextBlock Text="{x:Bind WaypointsText}" FontSize="16" Margin="17,110,0,-25"/>
-        <Button Visibility="Visible" Click="Button_Click" >
-            <TextBlock Text="Kappa Button"/>
-        </Button>
-            <ListView x:Name="Waypoints" ItemsSource="{x:Bind route.Waypoints}" Margin="0,328,0,0">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+
+        <c:DefaultTopBar Grid.Row="0" Header="Routevoorbeeld"/>
+
+        <StackPanel Grid.Row="1">
+            <StackPanel Orientation="Horizontal" Margin="10,10,0,0">
+                <TextBlock Text="Route informatie" FontSize="16"/>
+                <Button x:Name="StartButton" Visibility="Collapsed" Click="Button_Click" Margin="120,0,0,0" >
+                    <TextBlock Text="Start Route"/>
+                </Button>
+            </StackPanel>
+            <TextBlock x:Name="RouteBlok" FontSize="16" Margin="10,0,0,0"/>
+            <ProgressRing x:Name="ProgressRing" Height="40" Width="40" IsActive="True" HorizontalAlignment="Left" Margin="20,0,0,0" Foreground="Black"/>
+            <TextBlock x:Name="Loopblok" FontSize="16" Margin="10,0,0,0" />
+            <TextBlock x:Name="WaypointsBlok" FontSize="16" Margin="10,0,0,10"/>
+
+        </StackPanel>
+        <StackPanel Grid.Row="2">
+            <Image Source="ms-appx:///Assets/Map.png" Width="360"  />
+        </StackPanel>
+
+        <ListView Grid.Row="3" Margin="10,0,0,0" x:Name="Waypoints" ItemsSource="{x:Bind route.Waypoints}" IsItemClickEnabled="True" ItemClick="Waypoints_OnItemClick">
             <ListView.ItemContainerStyle>
                 <Style TargetType="ListViewItem">
                     <Setter Property="Padding" Value="0"/>
                     <Setter Property="Margin" Value="0"/>
                 </Style>
             </ListView.ItemContainerStyle>
-            <ListView.ItemTemplate>
+            <ListView.ItemTemplate >
                 <DataTemplate x:DataType="data:Waypoint">
-                    <StackPanel>
-                        <TextBlock Text="{Binding Title}" Margin="10,0,0,0"/>
-                    </StackPanel>
+                    <TextBlock Text="{x:Bind Title}" />
                 </DataTemplate>
             </ListView.ItemTemplate>
         </ListView>

+ 61 - 9
Breda-Tour/RouteSelectScreen/RouteExample.xaml.cs

@@ -5,10 +5,15 @@ using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Devices.Geolocation;
 using Windows.Foundation;
 using Windows.Foundation.Collections;
+using Windows.Services.Maps;
+using Windows.UI;
+using Windows.UI.Core;
 using Windows.UI.Xaml;
 using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Maps;
 using Windows.UI.Xaml.Controls.Primitives;
 using Windows.UI.Xaml.Data;
 using Windows.UI.Xaml.Input;
@@ -26,30 +31,77 @@ namespace Breda_Tour.RouteSelectScreen
     public sealed partial class RouteExample : Page
     {
         Route route;
-        public string WaypointsText { get; set; } 
+        public string WaypointsText { get; set; }
+        public string RouteTijdText { get; set; }
+        public string LoopafstandText { get; set; }
 
         public RouteExample()
         {
-            this.InitializeComponent();
+            InitializeComponent();
+            NavigationCacheMode = NavigationCacheMode.Enabled;
         }
 
         protected override void OnNavigatedTo(NavigationEventArgs e)
         {
-            route = e.Parameter as Route;
-            WaypointsText = "Aantal waypoints: " + 0;
-            if (route.Waypoints.Count != 0){
-                WaypointsText = "Aantal waypoints: " +route.Waypoints.Count;
+            if (route == null)
+            {
+                route = e.Parameter as Route;
+                ShowRouteInfo();
             }
+            //Setting the back button functionality
+            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
+            SystemNavigationManager.GetForCurrentView().BackRequested += BackRequested;
+            
+        }
+
+        private void BackRequested(object sender, BackRequestedEventArgs e)
+        {
+            e.Handled = true;
+            SystemNavigationManager.GetForCurrentView().BackRequested -= BackRequested;
+            MainPage.RootFrame.Navigate(typeof(RouteSelectPage));
         }
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
-            MainPage.RootFrame.Navigate(typeof(MapPage),route);
+            MainPage.RootFrame.Navigate(typeof(MapPage), route);
         }
 
-        private void ShowRouteInfo()
+        private async void ShowRouteInfo()
         {
-            
+            //Setting the x amount of waypoints text
+            WaypointsText = "Aantal waypoints: " + 0;
+            if (route.Waypoints.Count != 0)
+            {
+                WaypointsText = "Aantal waypoints: " + route.Waypoints.Count;
+            }
+            //Setting the Route distance and time text
+            List<Geopoint> geopoints = new List<Geopoint>();
+            foreach (Waypoint wayPoint in route.Waypoints)
+            {
+                geopoints.Add(wayPoint.Position);
+            }
+            MapRouteFinderResult finder = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(geopoints);
+            if (finder.Status == MapRouteFinderStatus.Success)
+            {
+                //route duration
+                int tijd = ((int)finder.Route.EstimatedDuration.TotalMinutes);
+                RouteTijdText = $"Tijdsduur: {tijd} min";
+                RouteBlok.Text = RouteTijdText;
+                //Route distance
+                LoopafstandText = $"Loopafstand: {(finder.Route.LengthInMeters/1000)} km";
+                Loopblok.Text = LoopafstandText;
+                //Waypoint text
+                WaypointsBlok.Text = WaypointsText;
+                ProgressRing.Visibility = Visibility.Collapsed;
+                StartButton.Visibility = Visibility.Visible;
+            }
+        }
+
+        private void Waypoints_OnItemClick(object sender, ItemClickEventArgs e)
+        {
+            Waypoint wp = e.ClickedItem as Waypoint;
+            wp.FromPreview = true;
+            MainPage.RootFrame.Navigate(typeof(WpDetailPage),wp);
         }
     }
 }

+ 6 - 0
Breda-Tour/RouteSelectScreen/RouteSelectPage.xaml.cs

@@ -6,6 +6,7 @@ using System.Linq;
 using System.Runtime.InteropServices.WindowsRuntime;
 using Windows.Foundation;
 using Windows.Foundation.Collections;
+using Windows.UI.Core;
 using Windows.UI.Xaml;
 using Windows.UI.Xaml.Controls;
 using Windows.UI.Xaml.Controls.Primitives;
@@ -32,6 +33,11 @@ namespace Breda_Tour.RouteSelectScreen
             DefaultPivot.SetCheckedButton(CustomControls.DefaultPivotControl.Tab.RouteSelected);
         }
 
+        protected override void OnNavigatedTo(NavigationEventArgs e)
+        {
+            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
+        }
+
         private void Routes_ItemClick(object sender, ItemClickEventArgs e)
         {
             Route route = e.ClickedItem as Route;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 16 - 16
Breda-Tour/Storage/routes/routes.json


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels