WpDetailPage.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices.WindowsRuntime;
  6. using Windows.Foundation;
  7. using Windows.Foundation.Collections;
  8. using Windows.UI.Core;
  9. using Windows.UI.ViewManagement;
  10. using Windows.UI.Xaml;
  11. using Windows.UI.Xaml.Controls;
  12. using Windows.UI.Xaml.Controls.Primitives;
  13. using Windows.UI.Xaml.Data;
  14. using Windows.UI.Xaml.Input;
  15. using Windows.UI.Xaml.Media;
  16. using Windows.UI.Xaml.Navigation;
  17. using Breda_Tour.Data;
  18. using Breda_Tour.RouteSelectScreen;
  19. // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
  20. namespace Breda_Tour.MapScreen
  21. {
  22. /// <summary>
  23. /// An empty page that can be used on its own or navigated to within a Frame.
  24. /// </summary>
  25. public sealed partial class WpDetailPage : Page
  26. {
  27. private Waypoint wp;
  28. private Route route;
  29. public double Width { get; }
  30. public WpDetailPage()
  31. {
  32. this.InitializeComponent();
  33. Width = ApplicationView.GetForCurrentView().VisibleBounds.Width;
  34. }
  35. protected override void OnNavigatedTo(NavigationEventArgs e)
  36. {
  37. Tuple<Waypoint, Route> t = (Tuple < Waypoint, Route>) e.Parameter;
  38. wp = t.Item1;
  39. route = t.Item2;
  40. this.DataContext = wp;
  41. if (wp.FromPreview)
  42. {
  43. SystemNavigationManager.GetForCurrentView().BackRequested += RouteExample_BackRequested;
  44. }
  45. else
  46. {
  47. SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested;
  48. }
  49. SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
  50. wp.FromPreview = false;
  51. }
  52. private void RouteExample_BackRequested(object sender, BackRequestedEventArgs e)
  53. {
  54. e.Handled = true;
  55. SystemNavigationManager.GetForCurrentView().BackRequested -= RouteExample_BackRequested;
  56. MainPage.RootFrame.Navigate(typeof(RouteExample), route);
  57. }
  58. private void MainPage_BackRequested(object sender, BackRequestedEventArgs e)
  59. {
  60. e.Handled = true;
  61. SystemNavigationManager.GetForCurrentView().BackRequested -= MainPage_BackRequested;
  62. MainPage.RootFrame.Navigate(typeof(MapPage));
  63. }
  64. private void Image_PointerPressed(object sender, TappedRoutedEventArgs e)
  65. {
  66. Image i = (Image)sender;
  67. MainPage.RootFrame.Navigate(typeof(ImageViewPage), new Tuple<ImageSource, Waypoint>(i.Source, wp));
  68. }
  69. private void Image_Tapped(object sender, TappedRoutedEventArgs e)
  70. {
  71. }
  72. }
  73. }