Added route list and detail page

This commit is contained in:
2015-12-17 14:08:12 +01:00
parent c8a6d836d5
commit 4114562bc3
6 changed files with 83 additions and 6 deletions
+16
View File
@@ -13,10 +13,16 @@ namespace NavCityBreda.Model
private List<Route> _routes; private List<Route> _routes;
public List<Route> Routes { get { return _routes; } } public List<Route> Routes { get { return _routes; } }
private Route _currentroute;
public Route CurrentRoute { get { return _currentroute; } }
public RouteManager() public RouteManager()
{ {
_routes = new List<Route>(); _routes = new List<Route>();
LoadRoutes(); LoadRoutes();
if (_routes.Count > 0)
_currentroute = _routes.First();
} }
private void LoadRoutes() private void LoadRoutes()
@@ -30,5 +36,15 @@ namespace NavCityBreda.Model
_routes.Add(JSONParser.LoadRoute(file)); _routes.Add(JSONParser.LoadRoute(file));
} }
} }
public void SetCurrentRoute(int index)
{
_currentroute = _routes.ElementAt(index);
}
public void SetCurrentRoute(Route r)
{
_currentroute = r;
}
} }
} }
+24
View File
@@ -0,0 +1,24 @@
using NavCityBreda.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NavCityBreda.ViewModel
{
class RouteVM
{
private List<Route> _routes;
public RouteVM()
{
_routes = App.RouteManager.Routes;
}
public List<Route> GetRoutes()
{
return _routes;
}
}
}
+1 -1
View File
@@ -8,6 +8,6 @@
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<TextBlock Text="Route Detail"/> <TextBlock Text="{Binding Name}"/>
</Grid> </Grid>
</Page> </Page>
+10 -1
View File
@@ -1,4 +1,5 @@
using System; using NavCityBreda.Model;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -22,9 +23,17 @@ namespace NavCityBreda.Views
/// </summary> /// </summary>
public sealed partial class RouteDetailView : Page public sealed partial class RouteDetailView : Page
{ {
private Route route;
public RouteDetailView() public RouteDetailView()
{ {
this.InitializeComponent(); this.InitializeComponent();
} }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
route = e.Parameter as Route;
this.DataContext = route;
}
} }
} }
+15 -3
View File
@@ -7,7 +7,19 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <RelativePanel Grid.Row="2" Margin="0,10,0,0" Name="RouteListPanel">
<TextBlock Text="Route"/> <ListView x:Name="RouteList" ItemsSource="{Binding}" IsItemClickEnabled="True" ItemClick="RouteList_ItemClick" SelectionMode="Extended" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignTopWithPanel="True" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True">
</Grid> <ListView.ItemTemplate>
<DataTemplate x:Name="ListViewDataTemplate">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Width="140" Margin="10,0,0,0" >
<TextBlock Text="{Binding Name}" FontSize="24" />
<TextBlock Text="{Binding Landmarks}" FontSize="14" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RelativePanel>
</Page> </Page>
+17 -1
View File
@@ -1,4 +1,7 @@
using System; using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.ViewModel;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -22,9 +25,22 @@ namespace NavCityBreda.Views
/// </summary> /// </summary>
public sealed partial class RouteView : Page public sealed partial class RouteView : Page
{ {
private RouteVM _routemodel = new RouteVM();
public List<Route> RouteViewModel
{
get { return _routemodel.GetRoutes(); }
}
public RouteView() public RouteView()
{ {
this.InitializeComponent(); this.InitializeComponent();
this.DataContext = RouteViewModel;
}
private void RouteList_ItemClick(object sender, ItemClickEventArgs e)
{
MainPage mp = Util.MainPage;
mp.Navigate(typeof(RouteDetailView), e.ClickedItem as Route);
} }
} }
} }