ソースを参照

Added landmark detailview on click (only 1 works for now)

Jeroen 10 年 前
コミット
e65f9497a0

BIN
Breda-Tour/Assets/1.jpg


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

@@ -106,6 +106,7 @@
       <DependentUpon>DefaultTopBar.xaml</DependentUpon>
     </Compile>
     <Compile Include="Data_\Gps.cs" />
+    <Compile Include="Data_\Image.cs" />
     <Compile Include="Data_\Route.cs" />
     <Compile Include="Data_\RouteDatabase.cs" />
     <Compile Include="Data_\WayPoint.cs" />
@@ -119,6 +120,9 @@
     <Compile Include="MapScreen\MapPage.xaml.cs">
       <DependentUpon>MapPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="MapScreen\WpDetailPage.xaml.cs">
+      <DependentUpon>WpDetailPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RouteSelectScreen\RouteSelectPage.xaml.cs">
       <DependentUpon>RouteSelectPage.xaml</DependentUpon>
@@ -137,6 +141,7 @@
     <None Include="Breda-Tour_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="Assets\1.jpg" />
     <Content Include="Assets\Ags_Logo.png" />
     <Content Include="Assets\Marker.png" />
     <Content Include="Properties\Default.rd.xml" />
@@ -173,6 +178,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="MapScreen\WpDetailPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="RouteSelectScreen\RouteSelectPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 1 - 1
Breda-Tour/Data_/Gps.cs

@@ -42,7 +42,7 @@ namespace Breda_Tour.Data_
             switch (accessStatus)
             {
                 case GeolocationAccessStatus.Allowed:
-                    Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = 1, MovementThreshold = 2 };
+                    geolocator = new Geolocator { DesiredAccuracyInMeters = 1, MovementThreshold = 2 };
                     // Subscribe events
                     geolocator.StatusChanged += OnStatusChanged;
                     geolocator.PositionChanged += OnPositionChanged;

+ 24 - 0
Breda-Tour/Data_/Image.cs

@@ -0,0 +1,24 @@
+using Windows.UI.ViewManagement;
+
+namespace Breda_Tour.Data_
+{
+    public class Image
+    {
+        private string _source;
+
+        public string Source
+        {
+            get { return _source; }
+        }
+
+        public double Width
+        {
+            get { return ApplicationView.GetForCurrentView().VisibleBounds.Width; }
+        }
+
+        public Image(string source)
+        {
+            _source = source;
+        }
+    }
+}

+ 5 - 5
Breda-Tour/Data_/Route.cs

@@ -37,11 +37,11 @@ namespace Breda_Tour.Data_
 
         public void CreateTestWaypoints()
         {
-            _wayPoints.Add(new WayPoint(51.530805, 4.498676, "Test1", 1));
-            _wayPoints.Add(new WayPoint(51.533461, 4.492711, "Test2", 2));
-            _wayPoints.Add(new WayPoint(51.536998, 4.477862, "Test3", 3));
-            _wayPoints.Add(new WayPoint(51.531285, 4.475394, "Test4", 4));
-            _wayPoints.Add(new WayPoint(51.531566, 4.466747, "Test5", 5));
+            _wayPoints.Add(new WayPoint(51.530805, 4.498676, "Test1", 1, new Image("ms-appx:///Assets/1.jpg")) {description = "4. Als u de brug overgaat, ziet u aan uw linkerhand het Nassau-Baroniemonument. Bij de ingang van het stadspark, het Valkenberg, staat een monument dat u iets vertelt over de wordings- geschiedenis van de stad Breda, maar vooral over de Heren van de stad uit het Huis van Nassau en de 500-jarige band tussen Breda en het Huis van Nassau. Op 3 juli 1905 werd het Nassau-Baronie- monument, zoals het officieel heet, met  veel feestelijk vertoon door Koningin Wilhelmina onthuld. Het beeld herinnert aan het feit, dat in 1404 Graaf Engelbert, de eerste Bredase Nassau en zijn gemalin, Johanna van Polanen, werden ingehuldigd als Heer en Vrouwe van Breda. De ontwerper is de welbekende dr. P.J.H. Cuypers, die o.m. het Rijksmuseum en het Centraal Station in Amsterdam ontwierp. Op dit monument zijn niet alleen de wapenschilden van twintig gemeenten in en rond de Baronie aangebracht maar ook de Leeuw van Nassau die boven alles uittorent met koningskroon, zwaard en wapenschild. In de drie reliëfs is de 'blijde incomste' van Graaf Engelbert en zijn gemalin afgebeeld. De poortersbieden de sleutel van de stad aan."});
+            _wayPoints.Add(new WayPoint(51.533461, 4.492711, "Test2", 2, null));
+            _wayPoints.Add(new WayPoint(51.536998, 4.477862, "Test3", 3, null));
+            _wayPoints.Add(new WayPoint(51.531285, 4.475394, "Test4", 4, null));
+            _wayPoints.Add(new WayPoint(51.531566, 4.466747, "Test5", 5, null));
         }
     }
 }

+ 11 - 2
Breda-Tour/Data_/WayPoint.cs

@@ -1,4 +1,5 @@
 using Windows.Devices.Geolocation;
+using Windows.UI.Xaml.Controls;
 
 namespace Breda_Tour.Data_
 {
@@ -13,19 +14,27 @@ namespace Breda_Tour.Data_
         private string title;
         public string description { get; set; }
         public int number;
+        private Image image;
 
-        public WayPoint(Geopoint position, string title, int number)
+        public Image Image
+        {
+            get { return image; }
+        }
+
+        public WayPoint(Geopoint position, string title, int number, Image image)
         {
             this._position = position;
             this.title = title;
             this.number = number;
+            this.image = image;
         }
 
-        public WayPoint(double latitude, double longitude, string title, int number)
+        public WayPoint(double latitude, double longitude, string title, int number, Image image)
         {
             _position = new Geopoint(new BasicGeoposition() { Altitude = 0, Latitude = latitude, Longitude = longitude });
             this.title = title;
             this.number = number;
+            this.image = image;
         }
 
     }

+ 1 - 0
Breda-Tour/MainPage.xaml.cs

@@ -13,6 +13,7 @@ using Windows.UI.Xaml.Data;
 using Windows.UI.Xaml.Input;
 using Windows.UI.Xaml.Media;
 using Windows.UI.Xaml.Navigation;
+using Breda_Tour.MapScreen;
 using Breda_Tour.RouteSelectScreen;
 
 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

+ 1 - 3
Breda-Tour/MapScreen/MapPage.xaml

@@ -20,9 +20,7 @@
         <c:DefaultTopBar Header="Kaart" Grid.Row="0"/>
         <c:DefaultPivotControl x:Name="DefaultPivot" Grid.Row="1"/>
 
-        <Maps:MapControl
-       x:Name="Map"
-        Grid.Row="3"
+        <Maps:MapControl x:Name="Map" Grid.Row="2" MapElementClick="Map_OnMapElementClick"        
        ZoomInteractionMode="GestureAndControl"
        TiltInteractionMode="GestureAndControl"
        RotateInteractionMode="GestureAndControl"

+ 23 - 2
Breda-Tour/MapScreen/MapPage.xaml.cs

@@ -21,7 +21,9 @@ using Windows.UI.Core;
 using Windows.UI.Xaml.Automation;
 using Windows.UI.Xaml.Controls.Maps;
 using Windows.UI.Xaml.Shapes;
+using Breda_Tour.CustomControls;
 using Breda_Tour.Data_;
+using System.Diagnostics;
 
 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
 
@@ -47,13 +49,17 @@ namespace Breda_Tour.MapScreen
             route = new Route("TestRoute","Test Description");
             route.CreateTestWaypoints();
             this.InitializeComponent();
+            DefaultPivot.SetCheckedButton(DefaultPivotControl.Tab.Map);
+            Debug.Write("New Map generated");
         }
 
         protected override void OnNavigatedTo(NavigationEventArgs e)
         {
-            
+           SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
         }
 
+
+
         public async void ShowLocaton(Geopoint point)
         {
             this.point = point;
@@ -97,10 +103,25 @@ namespace Breda_Tour.MapScreen
             {
                 foreach (var waypoint in route.WayPoints)
                 {
-                    MapIcon wp = new MapIcon() {Location = waypoint.Position};
+                    MapIcon wp = new MapIcon() {Location = waypoint.Position, Title = waypoint.number.ToString()};
                     Map.MapElements.Add(wp);
                 }
             });
         }
+
+        private void Map_OnMapElementClick(MapControl sender, MapElementClickEventArgs args)
+        {
+            MapIcon Icon = args.MapElements.FirstOrDefault(x => x is MapIcon) as MapIcon;
+            foreach (var waypoint in route.WayPoints)
+            {
+                if (Icon.Title != "")
+                {
+                    if (waypoint.number == int.Parse(Icon.Title))
+                    {
+                        MainPage.RootFrame.Navigate(typeof(WpDetailPage), waypoint);
+                    }
+                }
+            }
+        }
     }
 }

+ 32 - 0
Breda-Tour/MapScreen/WpDetailPage.xaml

@@ -0,0 +1,32 @@
+<Page
+    x:Class="Breda_Tour.MapScreen.WpDetailPage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:local="using:Breda_Tour.MapScreen"
+    xmlns:c ="using:Breda_Tour.CustomControls"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    mc:Ignorable="d">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+
+        <c:DefaultTopBar x:Name="NameBar" Grid.Row="0" Header="Bezienswaardigheid"/>
+        <RelativePanel x:Name="ImagePanel" Grid.Row="1">
+            <Image Source="{x:Bind wp.Image.Source}" Height="{x:Bind wp.Image.Width}" Width="{x:Bind wp.Image.Width}" Stretch="UniformToFill" />
+        </RelativePanel>
+        <RelativePanel Grid.Row="2">
+            <TextBlock Text="Beschrijving" FontSize="20" Margin="15,15,0,15" />
+        </RelativePanel>
+        <RelativePanel Grid.Row="3">
+           <ScrollViewer Margin="15,0,0,0" VerticalScrollBarVisibility="Auto" >
+                <TextBlock HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" TextWrapping="Wrap" Text="{x:Bind wp.description }"/>
+           </ScrollViewer>
+        </RelativePanel>
+    </Grid>
+</Page>

+ 51 - 0
Breda-Tour/MapScreen/WpDetailPage.xaml.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+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;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using Breda_Tour.Data_;
+
+// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace Breda_Tour.MapScreen
+{
+    /// <summary>
+    /// An empty page that can be used on its own or navigated to within a Frame.
+    /// </summary>
+    public sealed partial class WpDetailPage : Page
+    {
+        private WayPoint wp;
+
+        public WpDetailPage()
+        {
+            this.InitializeComponent();
+        }
+
+        protected override void OnNavigatedTo(NavigationEventArgs e)
+        {
+            wp = e.Parameter as WayPoint;
+            this.DataContext = wp;
+
+            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
+            SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested;
+        }
+
+        private void MainPage_BackRequested(object sender, BackRequestedEventArgs e)
+        {
+            e.Handled = true;
+            SystemNavigationManager.GetForCurrentView().BackRequested -= MainPage_BackRequested;
+            MainPage.RootFrame.Navigate(typeof (MapPage));
+        }
+    }
+}
+