ソースを参照

Added image viewer

jancoow 10 年 前
コミット
3d79dc7359

+ 7 - 0
Breda-Tour/Breda-Tour.csproj

@@ -146,6 +146,9 @@
     <Compile Include="MainPage.xaml.cs">
       <DependentUpon>MainPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="MapScreen\ImageViewPage.xaml.cs">
+      <DependentUpon>ImageViewPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="MapScreen\MapPage.xaml.cs">
       <DependentUpon>MapPage.xaml</DependentUpon>
     </Compile>
@@ -202,6 +205,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="MapScreen\ImageViewPage.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="MapScreen\MapPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 27 - 0
Breda-Tour/MapScreen/ImageViewPage.xaml

@@ -0,0 +1,27 @@
+<Page
+    x:Class="Breda_Tour.MapScreen.ImageViewPage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:local="using:Breda_Tour.MapScreen"
+    xmlns:c="using:Breda_Tour.CustomControls"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:Maps ="using:Windows.UI.Xaml.Controls.Maps"
+    xmlns:customControls="using:Breda_Tour.CustomControls"
+    mc:Ignorable="d"
+    x:Name="ImageViewer" 
+    >
+
+    <Grid>
+        <ScrollViewer ZoomMode="Enabled"  
+              MinZoomFactor="1" 
+              MaxZoomFactor="4"
+              HorizontalScrollBarVisibility="Hidden"
+              VerticalScrollBarVisibility="Hidden"
+              >
+            <Image Name="Image"  
+            MaxWidth="{Binding DataContext.PageWidth, ElementName=ImageViewer}"
+            MaxHeight="{Binding DataContext.PageHeight, ElementName=ImageViewer}"/>
+        </ScrollViewer>
+    </Grid>
+</Page>

+ 49 - 0
Breda-Tour/MapScreen/ImageViewPage.xaml.cs

@@ -0,0 +1,49 @@
+// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
+
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Core;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using Breda_Tour.Data;
+
+namespace Breda_Tour.MapScreen
+{
+    /// <summary>
+    /// An empty page that can be used on its own or navigated to within a Frame.
+    /// </summary>
+    public sealed partial class ImageViewPage : Page
+    {
+        Waypoint previouswaypoint;
+        public ImageViewPage()
+        {
+            this.InitializeComponent();
+        }
+
+        protected override void OnNavigatedTo(NavigationEventArgs e)
+        {
+            Tuple<ImageSource, Waypoint> parameters = (Tuple<ImageSource, Waypoint>)e.Parameter;
+            this.Image.Source = parameters.Item1;
+            previouswaypoint = parameters.Item2;
+            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
+            SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested;
+        }
+
+        private void MainPage_BackRequested(object sender, BackRequestedEventArgs e)
+        {
+            e.Handled = true;
+            SystemNavigationManager.GetForCurrentView().BackRequested -= MainPage_BackRequested;
+            MainPage.RootFrame.Navigate(typeof (WpDetailPage), previouswaypoint);
+        }
+    }
+}

+ 2 - 2
Breda-Tour/MapScreen/WpDetailPage.xaml

@@ -30,11 +30,11 @@
             <ListView.ItemTemplate >
                 <DataTemplate x:DataType="data:Picture">
                      <ListViewItem Padding="0">
-                        <Canvas Height="140"  Width="140" HorizontalAlignment="Center" VerticalAlignment="Center">
+                        <Canvas Height="170"  Width="170" HorizontalAlignment="Center" VerticalAlignment="Center">
                             <Canvas.Background>
                                 <ImageBrush />
                             </Canvas.Background>
-                            <Image Source="{x:Bind Source}"  Width="140" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                            <Image Tapped="Image_PointerPressed" Source="{x:Bind Source}"  Width="170" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                         </Canvas>
                     </ListViewItem>
                 </DataTemplate>

+ 11 - 0
Breda-Tour/MapScreen/WpDetailPage.xaml.cs

@@ -46,6 +46,17 @@ namespace Breda_Tour.MapScreen
             SystemNavigationManager.GetForCurrentView().BackRequested -= MainPage_BackRequested;
             MainPage.RootFrame.Navigate(typeof (MapPage));
         }
+
+        private void Image_PointerPressed(object sender, TappedRoutedEventArgs e)
+        {
+            Image i = (Image)sender;
+            MainPage.RootFrame.Navigate(typeof(ImageViewPage), new Tuple<ImageSource, Waypoint>(i.Source, wp));
+        }
+
+        private void Image_Tapped(object sender, TappedRoutedEventArgs e)
+        {
+
+        }
     }
 }