소스 검색

added MultiLanguage compatibility to RouteSelect

Bart Reedijk 10 년 전
부모
커밋
603bbdf583

+ 5 - 1
Breda-Tour/Data/Route.cs

@@ -6,14 +6,18 @@ namespace Breda_Tour.Data
     public class Route
     {
         public String Title { get; private set; }
+
+        public String Language { get; private set; }
+
         private List<Waypoint> _waypoints;
         public List<Waypoint> Waypoints
         {
             get { return _waypoints; }
         }
 
-        public Route(String Title, List<Waypoint> Waypoints)
+        public Route(String Language, String Title, List<Waypoint> Waypoints)
         {
+            this.Language = Language;
             this.Title = Title;
             this._waypoints = Waypoints;
         }

+ 12 - 0
Breda-Tour/Data/RouteDatabase.cs

@@ -1,6 +1,7 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
@@ -29,5 +30,16 @@ namespace Breda_Tour.Data
                 Routes.Add(JsonConvert.DeserializeObject<Route>(route.ToString()));
             }
         }
+
+        public ObservableCollection<Route> GetCurrentRoutes()
+        {
+            ObservableCollection<Route> routes = new ObservableCollection<Route>();
+            foreach (var route in Routes)
+            {
+                if (route.Language == App.Language)
+                    routes.Add(route);
+            }
+            return routes;
+        }
     }
 }

+ 1 - 1
Breda-Tour/RouteSelectScreen/RouteSelectPage.xaml

@@ -24,7 +24,7 @@
                 <con:Converter x:Key="BoolToVis"/>
                 <con:BoolToString x:Key="BoolToString"/>
             </RelativePanel.Resources>
-            <ListView x:Name="Routes" ItemsSource="{x:Bind AllRoutes.Routes}" IsItemClickEnabled="True" ItemClick="Routes_ItemClick">
+            <ListView x:Name="Routes" ItemsSource="{x:Bind CurrentRoutes}" IsItemClickEnabled="True" ItemClick="Routes_ItemClick">
                 <ListView.ItemTemplate>
                     <DataTemplate x:DataType="data:Route">
                         <StackPanel>

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

@@ -1,6 +1,7 @@
 using Breda_Tour.Data;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.IO;
 using System.Linq;
 using System.Runtime.InteropServices.WindowsRuntime;
@@ -25,6 +26,7 @@ namespace Breda_Tour.RouteSelectScreen
     public sealed partial class RouteSelectPage : Page
     {
         RouteDatabase AllRoutes;
+        ObservableCollection<Route> CurrentRoutes;
 
         public RouteSelectPage()
         {
@@ -36,6 +38,7 @@ namespace Breda_Tour.RouteSelectScreen
         protected override void OnNavigatedTo(NavigationEventArgs e)
         {
             SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
+            CurrentRoutes = AllRoutes.GetCurrentRoutes();
         }
 
         private void Routes_ItemClick(object sender, ItemClickEventArgs e)

+ 1 - 1
Breda-Tour/project.lock.json

@@ -11523,7 +11523,7 @@
       ]
     },
     "Microsoft.ApplicationInsights.WindowsApps/1.0.0": {
-      "sha512": "NvBQnFeiFd0O1QdBz06UGApD7zn7ztVi7qO18IsM3EjiXRNgfrEBXB+azNm8XqLY8xGFAqh3HAuSd/wHZMe0XA==",
+      "sha512": "fNCAjIwvbTV+G0dT14bgM5tptsqeSaKQaCrlq7QknOq1Xdm8ZmgsDYddMgXkvykyKLjWyU6fKuOpj6fsQJy+wQ==",
       "type": "Package",
       "files": [
         "[Content_Types].xml",