Beispiel #1
0
 public RouteWrapper()
     : base()
 {
     _route = new Route.Route();
     base.ConfigureProxy(_route);
     Language = "pt-br";
 }
        /// <summary>
        ///     Checks if a route can be resumed
        /// </summary>
        /// <returns>Whether there is a saved route available to resume</returns>
        public static async Task <bool> CheckIfLastSavedRouteExists()
        {
            try
            {
                var lastSavedRouteFile =
                    await ApplicationData.Current.LocalFolder.GetFileAsync($"{LastSavedRouteFileName}.json");

                string json = await Windows.Storage.FileIO.ReadTextAsync(lastSavedRouteFile);

                Route.Route r = JsonConvert.DeserializeObject <Route.Route>(json,
                                                                            new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                });
                var interestPoints = r.RoutePoints.FindAll(point => point.GetType().Equals(typeof(Route.PointOfInterest)));
                if (interestPoints.TrueForAll(point => point.IsVisited))
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #3
0
        public async void TestMethod()
        {
            RetrievedRoute = await TestRoute(FullRouteIO.BlindWallsFileName);

            Debug.WriteLine("Retrieved BlindWallsRoute");
            RetrievedRoute = await TestRoute(FullRouteIO.HistoricalKilometerFileName);

            Debug.WriteLine("Retrieved HistoricalKilometerRoute");
        }
Beispiel #4
0
        /// <summary>
        ///     Saves a route with user progress to a file
        /// </summary>
        /// <param name="routeInProgress">The Route object to save to a file</param>
        public static async void SaveRouteProgressToFile(Route.Route routeInProgress)
        {
            var folder = ApplicationData.Current.LocalFolder;
            var json   = JsonConvert.SerializeObject(routeInProgress,
                                                     new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            });
            var file = await folder.CreateFileAsync($"{LastSavedRouteFileName}.json", CreationCollisionOption.ReplaceExisting);

            await Windows.Storage.FileIO.WriteTextAsync(file, json);
        }
Beispiel #5
0
        public async void TestMethod()
        {
            if (await RouteProgressIO.CheckIfLastSavedRouteExists())
            {
                RetrievedRoute1 = await RouteProgressIO.LoadLastSavedRouteFromFile();

                Debug.WriteLine($"RetrievedRoute1 loaded");
            }
            RouteProgressIO.SaveRouteProgressToFile(await FullRouteIO.LoadRouteAsync(FullRouteIO.BlindWallsFileName));
            if (await RouteProgressIO.CheckIfLastSavedRouteExists())
            {
                RetrievedRoute2 = await RouteProgressIO.LoadLastSavedRouteFromFile();

                Debug.WriteLine($"RetrievedRoute2 loaded");
            }
        }
 private IRouteMark<IRoadInformation> MakeRoute( params IRoadInformation[] roadInformation )
 {
     var route = new Route.Route<IRoadInfomration>();
     roadInformation.ForEach( route.Add );
     return route;
 }