Code cleanup
This commit is contained in:
@@ -12,9 +12,6 @@ using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace NavCityBreda
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace NavCityBreda.Helpers.Converter
|
||||
{
|
||||
Model.Landmark.LandmarkStatus st = (Model.Landmark.LandmarkStatus)value;
|
||||
|
||||
switch(st)
|
||||
switch (st)
|
||||
{
|
||||
default:
|
||||
case Model.Landmark.LandmarkStatus.NOTVISITED:
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace NavCityBreda.Helpers
|
||||
|
||||
JToken[] waypoints = o["waypoints"].ToArray();
|
||||
int count = 0;
|
||||
foreach(JToken t in waypoints)
|
||||
foreach (JToken t in waypoints)
|
||||
{
|
||||
if(!ValidateWaypointObject(t, out error))
|
||||
throw new FileLoadException("Invalid Waypoint (#" + (count+1) + ") information in " + datafile + ", " + error);
|
||||
if (!ValidateWaypointObject(t, out error))
|
||||
throw new FileLoadException("Invalid Waypoint (#" + (count + 1) + ") information in " + datafile + ", " + error);
|
||||
|
||||
Waypoint w;
|
||||
|
||||
@@ -41,18 +41,18 @@ namespace NavCityBreda.Helpers
|
||||
{
|
||||
List<Image> images = new List<Image>();
|
||||
|
||||
if(! t["image"].NullOrEmpty())
|
||||
if (!t["image"].NullOrEmpty())
|
||||
{
|
||||
JToken img = t["image"];
|
||||
|
||||
if (img.Type == JTokenType.String)
|
||||
{
|
||||
if(ImageExists(foldername, (string)img))
|
||||
if (ImageExists(foldername, (string)img))
|
||||
images.Add(new Image(ImagePath(foldername, (string)img)));
|
||||
}
|
||||
else if(img.Type == JTokenType.Array)
|
||||
else if (img.Type == JTokenType.Array)
|
||||
{
|
||||
foreach(string s in img.ToArray())
|
||||
foreach (string s in img.ToArray())
|
||||
{
|
||||
if (ImageExists(foldername, s))
|
||||
images.Add(new Image(ImagePath(foldername, s)));
|
||||
@@ -143,7 +143,7 @@ namespace NavCityBreda.Helpers
|
||||
error = "Longitude missing";
|
||||
}
|
||||
|
||||
if( valid && (bool)o["landmark"])
|
||||
if (valid && (bool)o["landmark"])
|
||||
{
|
||||
if (o["description"].NullOrEmpty())
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace NavCityBreda.Helpers
|
||||
public delegate void OnLanguageUpdateHandler(EventArgs e);
|
||||
public static event OnLanguageUpdateHandler OnLanguageUpdate;
|
||||
|
||||
public static bool Tracking {
|
||||
public static bool Tracking
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)LOCAL_SETTINGS.Values["tracking"];
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace NavCityBreda.Helpers
|
||||
|
||||
public static ResourceLoader Loader
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
return new Windows.ApplicationModel.Resources.ResourceLoader();
|
||||
}
|
||||
}
|
||||
@@ -171,7 +172,7 @@ namespace NavCityBreda.Helpers
|
||||
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Yes")) { Id = 0 });
|
||||
dlg.Commands.Add(new UICommand(Util.Loader.GetString("No")) { Id = 1 });
|
||||
}
|
||||
else if(type == DialogType.OKCANCEL)
|
||||
else if (type == DialogType.OKCANCEL)
|
||||
{
|
||||
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Ok")) { Id = 0 });
|
||||
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Cancel")) { Id = 1 });
|
||||
|
||||
@@ -7,13 +7,8 @@ using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class InitPage : Page
|
||||
{
|
||||
internal Rect splashImageRect; // Rect to store splash screen image coordinates.
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
<Viewbox RelativePanel.RightOf="NavButton" RelativePanel.AlignBottomWith="NavButton" StretchDirection="DownOnly" Stretch="UniformToFill" Margin="10,0,10,0">
|
||||
<TextBlock FontSize="28" Name="PageTitle" Text="{Binding Map}" />
|
||||
</Viewbox>
|
||||
|
||||
</RelativePanel>
|
||||
|
||||
<!-- http://stackoverflow.com/questions/32108362/uwp-swipe-to-open-splitview-pane-->
|
||||
@@ -126,6 +125,7 @@
|
||||
</StackPanel>
|
||||
</RelativePanel>
|
||||
</SplitView.Pane>
|
||||
|
||||
<SplitView.Content>
|
||||
<Grid>
|
||||
<Frame Name="Frame"/>
|
||||
|
||||
@@ -10,13 +10,8 @@ using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace NavCityBreda
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
double bptime;
|
||||
@@ -48,7 +43,7 @@ namespace NavCityBreda
|
||||
lastbptime = bptime;
|
||||
bptime = Util.Now;
|
||||
|
||||
if(bptime - lastbptime > 2000)
|
||||
if (bptime - lastbptime > 2000)
|
||||
{
|
||||
ShowHideBackMessage();
|
||||
e.Handled = true;
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace NavCityBreda.Model
|
||||
switch (accessStatus)
|
||||
{
|
||||
case GeolocationAccessStatus.Allowed:
|
||||
geo = new Geolocator {
|
||||
geo = new Geolocator
|
||||
{
|
||||
DesiredAccuracy = PositionAccuracy.High,
|
||||
MovementThreshold = 3
|
||||
//ReportInterval = 1500
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace NavCityBreda.Model
|
||||
public MapIcon Icon { get; set; }
|
||||
|
||||
|
||||
public Landmark(Geopoint p, string name, int num, string desc, List<Image> images) : base (p, name, num)
|
||||
public Landmark(Geopoint p, string name, int num, string desc, List<Image> images) : base(p, name, num)
|
||||
{
|
||||
Create(name, desc, num, images);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace NavCityBreda.Model
|
||||
{
|
||||
Icon.Title = Name;
|
||||
|
||||
switch(_status)
|
||||
switch (_status)
|
||||
{
|
||||
default:
|
||||
case LandmarkStatus.NOTVISITED:
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace NavCityBreda.Model
|
||||
public GeoboundingBox Bounds { get { return _route.BoundingBox; } }
|
||||
|
||||
private string _namekey;
|
||||
public string Name { get { return Util.Loader.GetString( _namekey ); } }
|
||||
public string Name { get { return Util.Loader.GetString(_namekey); } }
|
||||
|
||||
private string _desckey;
|
||||
public string Description { get { return Util.Loader.GetString( _desckey ); } }
|
||||
public string Description { get { return Util.Loader.GetString(_desckey); } }
|
||||
|
||||
private string _landdesckey;
|
||||
public string LandmarksDescription { get { return Util.Loader.GetString( _landdesckey ); } }
|
||||
public string LandmarksDescription { get { return Util.Loader.GetString(_landdesckey); } }
|
||||
|
||||
private string foldername { get; set; }
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace NavCityBreda.Model
|
||||
|
||||
public async Task<String> Reset()
|
||||
{
|
||||
foreach(Landmark l in Landmarks)
|
||||
foreach (Landmark l in Landmarks)
|
||||
{
|
||||
l.Status = Landmark.LandmarkStatus.NOTVISITED;
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(2));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using NavCityBreda.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -20,10 +19,10 @@ namespace NavCityBreda.Model
|
||||
public delegate void OnLandmarkVisitedHandler(object sender, LandmarkVisitedEventArgs e);
|
||||
public event OnLandmarkVisitedHandler OnLandmarkVisited;
|
||||
|
||||
public delegate void OnLandmarkChangedHandler (object sender, LandmarkChangedEventArgs e);
|
||||
public delegate void OnLandmarkChangedHandler(object sender, LandmarkChangedEventArgs e);
|
||||
public event OnLandmarkChangedHandler OnLandmarkChanged;
|
||||
|
||||
public delegate void OnManeuverChangedHandler (object sender, ManeuverChangedEventArgs e);
|
||||
public delegate void OnManeuverChangedHandler(object sender, ManeuverChangedEventArgs e);
|
||||
public event OnManeuverChangedHandler OnManeuverChanged;
|
||||
|
||||
|
||||
@@ -73,7 +72,7 @@ namespace NavCityBreda.Model
|
||||
|
||||
private void Geo_OnPositionUpdate(object sender, PositionUpdatedEventArgs e)
|
||||
{
|
||||
if(Status == RouteStatus.STARTED)
|
||||
if (Status == RouteStatus.STARTED)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
@@ -98,11 +97,11 @@ namespace NavCityBreda.Model
|
||||
}
|
||||
}
|
||||
|
||||
if(found)
|
||||
if (found)
|
||||
{
|
||||
if(_currentmaneuvercount >= _currentmaneuvers.Count)
|
||||
if (_currentmaneuvercount >= _currentmaneuvers.Count)
|
||||
{
|
||||
if(_currentroutelegcount+1 < _currentroutelegs.Count)
|
||||
if (_currentroutelegcount + 1 < _currentroutelegs.Count)
|
||||
{
|
||||
_currentroutelegcount++;
|
||||
_currentmaneuvercount = 0;
|
||||
@@ -152,7 +151,7 @@ namespace NavCityBreda.Model
|
||||
UpdateRoute();
|
||||
}
|
||||
|
||||
else if(state == GeofenceState.Exited)
|
||||
else if (state == GeofenceState.Exited)
|
||||
{
|
||||
LandmarkVisited(i, LandmarkVisitedEventArgs.VisitedStatus.EXITED);
|
||||
}
|
||||
@@ -165,7 +164,7 @@ namespace NavCityBreda.Model
|
||||
|
||||
_routes.Clear();
|
||||
|
||||
foreach(string folder in routefolders)
|
||||
foreach (string folder in routefolders)
|
||||
{
|
||||
string foldername = Path.GetFileName(folder);
|
||||
if (foldername != "img")
|
||||
@@ -265,7 +264,7 @@ namespace NavCityBreda.Model
|
||||
{
|
||||
List<Landmark> l = new List<Landmark>();
|
||||
|
||||
foreach(Route r in _routes)
|
||||
foreach (Route r in _routes)
|
||||
{
|
||||
l.AddRange(r.Landmarks);
|
||||
}
|
||||
@@ -285,7 +284,7 @@ namespace NavCityBreda.Model
|
||||
|
||||
public async Task<String> Reset()
|
||||
{
|
||||
foreach(Route r in _routes)
|
||||
foreach (Route r in _routes)
|
||||
{
|
||||
await r.Reset();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace NavCityBreda.Model
|
||||
public Geopoint Position { get; protected set; }
|
||||
|
||||
protected string _namekey;
|
||||
public string Name { get { return Util.Loader.GetString( _namekey ); } }
|
||||
public string Name { get { return Util.Loader.GetString(_namekey); } }
|
||||
|
||||
public int Order { get; protected set; }
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace NavCityBreda.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(landmark.Status)
|
||||
switch (landmark.Status)
|
||||
{
|
||||
default:
|
||||
case Landmark.LandmarkStatus.NOTVISITED:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using NavCityBreda.Helpers;
|
||||
using NavCityBreda.Helpers.Comparer;
|
||||
using NavCityBreda.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NavCityBreda.ViewModels
|
||||
@@ -97,7 +96,7 @@ namespace NavCityBreda.ViewModels
|
||||
{
|
||||
IComparer<Landmark> comparer;
|
||||
|
||||
switch(s)
|
||||
switch (s)
|
||||
{
|
||||
default:
|
||||
case Sort.ALPHA:
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace NavCityBreda.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(App.Geo.Status)
|
||||
switch (App.Geo.Status)
|
||||
{
|
||||
case PositionStatus.Disabled:
|
||||
return Util.Loader.GetString("Disabled");
|
||||
@@ -129,7 +129,7 @@ namespace NavCityBreda.ViewModels
|
||||
get
|
||||
{
|
||||
if (App.Geo.Connected == true && App.Geo.Position != null)
|
||||
switch(App.Geo.Position.Coordinate.PositionSource)
|
||||
switch (App.Geo.Position.Coordinate.PositionSource)
|
||||
{
|
||||
case PositionSource.Cellular:
|
||||
return Util.Loader.GetString("Cellular");
|
||||
|
||||
@@ -5,11 +5,6 @@ namespace NavCityBreda.ViewModels
|
||||
{
|
||||
public class MapVM : TemplateVM
|
||||
{
|
||||
//In een route de MapLegs gaan bijhouden. Dan de eerste als current instellen.
|
||||
//Dan kan je daarvan de informatie laten zien. Ook een event toevoegen als je dan aan het einde bent, dat weet je door lon-lon > 0.? te doen elke positie update.
|
||||
//Allemaal in RouteManager afhandelen
|
||||
//Nog een manier vinden om van een route afwijken op te vangen en dan opnieuw de route te berekenen.
|
||||
|
||||
public MapVM() : base(Util.Loader.GetString("Map"))
|
||||
{
|
||||
App.RouteManager.OnManeuverChanged += RouteManager_OnManeuverChanged;
|
||||
@@ -24,14 +19,16 @@ namespace NavCityBreda.ViewModels
|
||||
|
||||
private void RouteManager_OnStatusUpdate(object sender, Model.RouteStatusChangedEventArgs e)
|
||||
{
|
||||
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
|
||||
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
NotifyPropertyChanged(nameof(Instructions));
|
||||
});
|
||||
}
|
||||
|
||||
private void RouteManager_OnManeuverChanged(object sender, Model.ManeuverChangedEventArgs e)
|
||||
{
|
||||
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
|
||||
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
NotifyPropertyChanged(nameof(Landmark));
|
||||
NotifyPropertyChanged(nameof(Maneuver));
|
||||
});
|
||||
@@ -82,7 +79,7 @@ namespace NavCityBreda.ViewModels
|
||||
|
||||
public void UpdateMap()
|
||||
{
|
||||
if(App.MainPage != null)
|
||||
if (App.MainPage != null)
|
||||
App.MainPage.Title = Util.Loader.GetString("Map");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace NavCityBreda.ViewModels
|
||||
dispatcher = App.Dispatcher;
|
||||
Settings.OnLanguageUpdate += Settings_OnLanguageUpdate;
|
||||
|
||||
if(App.MainPage != null)
|
||||
if (App.MainPage != null)
|
||||
App.MainPage.Title = title;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using NavCityBreda.ViewModels;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class HelpView : Page
|
||||
{
|
||||
HelpVM helpvm;
|
||||
|
||||
@@ -3,13 +3,8 @@ using NavCityBreda.ViewModels;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class LandmarkDetailView : Page
|
||||
{
|
||||
LandmarkDetailVM landmarkvm;
|
||||
|
||||
@@ -17,13 +17,8 @@ using System.Threading.Tasks;
|
||||
using Windows.Devices.Geolocation.Geofencing;
|
||||
using Windows.UI.Core;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MapView : Page
|
||||
{
|
||||
MapIcon CurrentPosition;
|
||||
@@ -274,7 +269,7 @@ namespace NavCityBreda.Views
|
||||
{
|
||||
mapvm.Tracking = tracking;
|
||||
|
||||
if(tracking)
|
||||
if (tracking)
|
||||
{
|
||||
DisableControls(true);
|
||||
|
||||
|
||||
@@ -9,13 +9,8 @@ using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Maps;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class RouteDetailView : Page
|
||||
{
|
||||
private Route route;
|
||||
@@ -41,12 +36,13 @@ namespace NavCityBreda.Views
|
||||
{
|
||||
routedetailvm.UpdateRoute();
|
||||
LandmarkList.SelectedIndex = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
route = r;
|
||||
routedetailvm = new RouteDetailVM(route);
|
||||
this.DataContext = routedetailvm;
|
||||
}
|
||||
|
||||
DrawRoute();
|
||||
}
|
||||
@@ -57,7 +53,7 @@ namespace NavCityBreda.Views
|
||||
|
||||
Zoom();
|
||||
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(10));
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(25));
|
||||
|
||||
MapPolyline m = Util.GetRouteLine(route.RouteObject, Color.FromArgb(255, 100, 100, 255), 25, 6);
|
||||
Map.MapElements.Add(m);
|
||||
|
||||
@@ -2,13 +2,8 @@
|
||||
using NavCityBreda.ViewModels;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class RouteView : Page
|
||||
{
|
||||
RouteVM routevm;
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
using NavCityBreda.Helpers;
|
||||
using NavCityBreda.ViewModels;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace NavCityBreda.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsView : Page
|
||||
{
|
||||
SettingsVM settingsvm;
|
||||
@@ -23,7 +16,6 @@ namespace NavCityBreda.Views
|
||||
this.InitializeComponent();
|
||||
settingsvm = new SettingsVM();
|
||||
this.DataContext = settingsvm;
|
||||
//throw new NotImplementedException("Tracking + tilemaps");
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
@@ -51,13 +43,13 @@ namespace NavCityBreda.Views
|
||||
|
||||
private void Language_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
switch(Language.SelectedIndex)
|
||||
switch (Language.SelectedIndex)
|
||||
{
|
||||
default:
|
||||
Language.SelectedIndex = 0;
|
||||
break;
|
||||
case 0:
|
||||
if(Settings.CurrentLanguage != "en")
|
||||
if (Settings.CurrentLanguage != "en")
|
||||
Settings.ChangeLanguage("en");
|
||||
break;
|
||||
case 1:
|
||||
@@ -79,7 +71,7 @@ namespace NavCityBreda.Views
|
||||
{
|
||||
bool confirm = await Util.ShowConfirmDialog(Util.Loader.GetString("Reset"), Util.Loader.GetString("ResetConfirmation"), Util.DialogType.YESNO);
|
||||
|
||||
if(confirm)
|
||||
if (confirm)
|
||||
{
|
||||
ResetProgress.IsActive = true;
|
||||
App.RouteManager.StopRoute();
|
||||
|
||||
Reference in New Issue
Block a user