Added back x 2, added reset button

This commit is contained in:
2015-12-24 16:34:21 +01:00
parent 855448a00c
commit a169613b81
16 changed files with 172 additions and 20 deletions
+24
View File
@@ -270,4 +270,28 @@
<data name="HelpItem3Text" xml:space="preserve">
<value>You can find GPS Information at the bottom of the menu. It exists out of three parts. The first is the status of the GPS connection, for examle "disabled" or "ready". Secondly is the way in which the GPS is connecte, Cellular is the least accurate, Satellite the most. The third part is the accuracy in meters.</value>
</data>
<data name="Application" xml:space="preserve">
<value>Application</value>
</data>
<data name="Reset" xml:space="preserve">
<value>Reset</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="No" xml:space="preserve">
<value>No</value>
</data>
<data name="Ok" xml:space="preserve">
<value>Ok</value>
</data>
<data name="ResetConfirmation" xml:space="preserve">
<value>Are you sure you want to reset the application?</value>
</data>
<data name="Yes" xml:space="preserve">
<value>Yes</value>
</data>
<data name="BackTwiceText" xml:space="preserve">
<value>Press back again to exit</value>
</data>
</root>
+24
View File
@@ -270,4 +270,28 @@
<data name="HelpItem3Text" xml:space="preserve">
<value>U kunt de GPS informatie onder in het menu vinden. Het bestaat uit drie onderdelen. Het eerste is de status van de GPS verbinding, zoals "uitgeschakeld" of "klaar". Ten tweede staat er de manier waarop de GPS verbonden is, GSM is het minst nauwkeurig, Satelliet het meest. Ten derde staat er de accuratie in meters.</value>
</data>
<data name="Application" xml:space="preserve">
<value>Applicatie</value>
</data>
<data name="Reset" xml:space="preserve">
<value>Reset</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Annuleer</value>
</data>
<data name="No" xml:space="preserve">
<value>Nee</value>
</data>
<data name="Ok" xml:space="preserve">
<value>Ok</value>
</data>
<data name="ResetConfirmation" xml:space="preserve">
<value>Weet u zeker dat u de applicatie wilt resetten?</value>
</data>
<data name="Yes" xml:space="preserve">
<value>Ja</value>
</data>
<data name="BackTwiceText" xml:space="preserve">
<value>Druk nogmaals op vorige om te sluiten</value>
</data>
</root>
+4
View File
@@ -131,6 +131,10 @@
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
</StackPanel>
<StackPanel Name="BackMessage" Background="LightGray" Opacity="0.5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="0,0,0,40" Visibility="Collapsed" Height="Auto">
<TextBlock Text="{Binding BackText}" Margin="5" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Grid>
</SplitView.Content>
</SplitView>
+26 -1
View File
@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
@@ -27,24 +28,48 @@ namespace NavCityBreda
/// </summary>
public sealed partial class MainPage : Page
{
double bptime;
double lastbptime;
public MainPage()
{
this.InitializeComponent();
Frame.Navigated += Frame_Navigated;
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
bptime = Util.Now;
this.DataContext = new MainPageVM();
Frame.Navigate(typeof(MapView));
}
private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
if (e.Handled) return;
if (Frame.CanGoBack)
{
e.Handled = true;
Frame.GoBack();
return;
}
lastbptime = bptime;
bptime = Util.Now;
if(bptime - lastbptime > 2000)
{
ShowHideBackMessage();
e.Handled = true;
}
}
public async Task<String> ShowHideBackMessage()
{
BackMessage.Visibility = Visibility.Visible;
await Task.Delay(TimeSpan.FromSeconds(2));
BackMessage.Visibility = Visibility.Collapsed;
return "success";
}
public void Navigate(Type type)
+7 -2
View File
@@ -80,9 +80,14 @@ namespace NavCityBreda.Model
return "success";
}
public void Reset()
public async Task<String> Reset()
{
Landmarks.ForEach(l => l.Visited = false);
foreach(Landmark l in Landmarks)
{
l.Visited = false;
await Task.Delay(TimeSpan.FromMilliseconds(2));
}
return "success";
}
}
}
+9 -1
View File
@@ -207,7 +207,6 @@ namespace NavCityBreda.Model
{
if (Status == RouteStatus.STARTED)
{
_currentroute.Reset();
_currentroute = null;
_currentlandmark = null;
_routetolandmark = null;
@@ -219,6 +218,15 @@ namespace NavCityBreda.Model
}
}
public async Task<String> Reset()
{
foreach(Route r in _routes)
{
await r.Reset();
}
return "success";
}
// =============
// Handle Events
// =============
+4 -4
View File
@@ -171,7 +171,7 @@
<Compile Include="Model\Waypoint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\HelpVM.cs" />
<Compile Include="ViewModels\LandmarkVM.cs" />
<Compile Include="ViewModels\LandmarkDetailVM.cs" />
<Compile Include="ViewModels\MapVM.cs" />
<Compile Include="ViewModels\MainPageVM.cs" />
<Compile Include="ViewModels\RouteDetailVM.cs" />
@@ -193,8 +193,8 @@
<Compile Include="Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LandmarkView.xaml.cs">
<DependentUpon>LandmarkView.xaml</DependentUpon>
<Compile Include="Views\LandmarkDetailView.xaml.cs">
<DependentUpon>LandmarkDetailView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
@@ -278,7 +278,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LandmarkView.xaml">
<Page Include="Views\LandmarkDetailView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -12,13 +12,13 @@ using Windows.UI.Xaml;
namespace NavCityBreda.ViewModels
{
public class LandmarkVM : TemplateVM
public class LandmarkDetailVM : TemplateVM
{
Landmark landmark;
string address;
public LandmarkVM(Landmark l) : base(l.Name)
public LandmarkDetailVM(Landmark l) : base(l.Name)
{
this.landmark = l;
+9
View File
@@ -28,6 +28,15 @@ namespace NavCityBreda.ViewModels
NotifyPropertyChanged(nameof(Source));
NotifyPropertyChanged(nameof(Accuracy));
NotifyPropertyChanged(nameof(GPSInfo));
NotifyPropertyChanged(nameof(BackText));
}
public string BackText
{
get
{
return Util.Loader.GetString("BackTwiceText");
}
}
+18
View File
@@ -20,6 +20,8 @@ namespace NavCityBreda.ViewModels
protected override void UpdatePropertiesToNewLanguage()
{
NotifyPropertyChanged(nameof(Language));
NotifyPropertyChanged(nameof(Reset));
NotifyPropertyChanged(nameof(ResetHeader));
App.MainPage.Title = Util.Loader.GetString("Settings");
}
@@ -30,5 +32,21 @@ namespace NavCityBreda.ViewModels
return Util.Loader.GetString("Language");
}
}
public string ResetHeader
{
get
{
return Util.Loader.GetString("Reset");
}
}
public string Reset
{
get
{
return Util.Loader.GetString("Reset") + " " + Util.Loader.GetString("Application");
}
}
}
}
@@ -1,5 +1,5 @@
<Page
x:Class="NavCityBreda.Views.LandmarkView"
x:Class="NavCityBreda.Views.LandmarkDetailView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:NavCityBreda.Views"
@@ -25,11 +25,11 @@ 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 LandmarkView : Page
public sealed partial class LandmarkDetailView : Page
{
LandmarkVM landmarkvm;
LandmarkDetailVM landmarkvm;
public LandmarkView()
public LandmarkDetailView()
{
this.InitializeComponent();
}
@@ -37,7 +37,7 @@ namespace NavCityBreda.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Landmark landmark = e.Parameter as Landmark;
landmarkvm = new LandmarkVM(landmark);
landmarkvm = new LandmarkDetailVM(landmark);
this.DataContext = landmarkvm;
}
}
+3 -3
View File
@@ -92,7 +92,7 @@ namespace NavCityBreda.Views
Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
{
if (e.Status == LandmarkVisitedEventArgs.VisitedStatus.ENTERED)
App.MainPage.Navigate(typeof(LandmarkView), e.Landmark);
App.MainPage.Navigate(typeof(LandmarkDetailView), e.Landmark);
});
}
@@ -260,12 +260,12 @@ namespace NavCityBreda.Views
Landmark l = w as Landmark;
App.MainPage.Navigate(typeof(LandmarkView), l);
App.MainPage.Navigate(typeof(LandmarkDetailView), l);
}
private void LandmarkName_Tapped(object sender, TappedRoutedEventArgs e)
{
App.MainPage.Navigate(typeof(LandmarkView), App.RouteManager.CurrentLandmark);
App.MainPage.Navigate(typeof(LandmarkDetailView), App.RouteManager.CurrentLandmark);
}
private void RecalculateRoute_Click(object sender, RoutedEventArgs e)
+1 -1
View File
@@ -91,7 +91,7 @@ namespace NavCityBreda.Views
private void LandmarkList_ItemClick(object sender, ItemClickEventArgs e)
{
MainPage mp = App.MainPage;
mp.Navigate(typeof(LandmarkView), e.ClickedItem as Landmark);
mp.Navigate(typeof(LandmarkDetailView), e.ClickedItem as Landmark);
}
private void StartRouteButton_Click(object sender, RoutedEventArgs e)
+14 -1
View File
@@ -10,7 +10,7 @@
<ScrollViewer>
<StackPanel HorizontalAlignment="Stretch">
<StackPanel Margin="10">
<TextBlock FontSize="20" Text="{Binding Language}" Margin="0,0,0,10"/>
<TextBlock Text="{Binding Language}" Style="{StaticResource Header}"/>
<ComboBox Name="Language" SelectionChanged="Language_SelectionChanged" HorizontalAlignment="Stretch">
<ComboBoxItem>English</ComboBoxItem>
<ComboBoxItem>Nederlands</ComboBoxItem>
@@ -18,6 +18,19 @@
<!-- <ComboBoxItem>日本語</ComboBoxItem> -->
</ComboBox>
</StackPanel>
<StackPanel Margin="10">
<TextBlock Text="{Binding ResetHeader}" Style="{StaticResource Header}"/>
<StackPanel Orientation="Horizontal">
<Button Name="ResetButton" Click="ResetButton_Click">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE895;" Margin="0,0,10,0" />
<TextBlock Text="{Binding Reset}" />
</StackPanel>
</Button>
<ProgressRing Name="ResetProgress" IsActive="False" Margin="15,0,0,0"/>
</StackPanel>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Page>
+22
View File
@@ -8,6 +8,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
@@ -83,5 +84,26 @@ namespace NavCityBreda.Views
break;
}
}
private async void ResetButton_Click(object sender, RoutedEventArgs e)
{
MessageDialog dlg = new MessageDialog(Util.Loader.GetString("ResetConfirmation"), Util.Loader.GetString("Reset"));
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Yes")) { Id = 1 } );
dlg.Commands.Add(new UICommand(Util.Loader.GetString("No")) { Id = 0 });
dlg.DefaultCommandIndex = 0;
dlg.CancelCommandIndex = 1;
var result = await dlg.ShowAsync();
if((int)result.Id == 1)
{
ResetProgress.IsActive = true;
App.RouteManager.StopRoute();
Language.SelectedIndex = 0;
await App.RouteManager.Reset();
ResetProgress.IsActive = false;
}
}
}
}