diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml
index 2033c099..d9c8457e 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml
@@ -69,8 +69,12 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
index 2b0dc3e4..74fadd03 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
@@ -11,15 +11,19 @@ namespace CampusAppWP8.Pages.Campusmap
using System.Collections.Generic;
using System.Device.Location;
using System.Globalization;
+ using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Windows;
- using System.Windows.Navigation;
+ using System.Windows.Navigation;
using CampusAppWP8.Model.Campusmap;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
+ using CampusAppWP8.Utility.NDEF;
using Microsoft.Phone.Controls;
+ using Microsoft.Phone.Shell;
+ using Windows.Networking.Proximity;
/// Class for the campusMap page.
/// Stubbfel, 19.08.2013.
@@ -27,6 +31,9 @@ namespace CampusAppWP8.Pages.Campusmap
{
#region Member
+ /// The device.
+ private readonly ProximityDevice device = ProximityDevice.GetDefault();
+
/// Variable for the map model.
private MapModel map;
@@ -35,6 +42,11 @@ namespace CampusAppWP8.Pages.Campusmap
///
private List informationsNames;
+ ///
+ /// Flag which indicates if an qrCode scan is running
+ ///
+ private bool qrcodeScan = false;
+
#endregion
#region Constructor
@@ -47,6 +59,19 @@ namespace CampusAppWP8.Pages.Campusmap
this.map = new CBMainMapModel();
this.MapCanvas.DataContext = this.map;
this.map.ShowMapInfos += new CBMainMapModel.MapInfos(this.ShowMapInfo);
+
+ ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
+ ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
+
+ if (menuItem1 != null)
+ {
+ menuItem1.Text = AppResources.CampusMapApp_ScanQR;
+ }
+
+ if (menuItem2 != null)
+ {
+ menuItem2.Text = AppResources.CampusMapApp_ScanNfc;
+ }
}
#endregion
@@ -61,7 +86,12 @@ namespace CampusAppWP8.Pages.Campusmap
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
- if (this.map.Spatial != null && e.NavigationMode == NavigationMode.New)
+ if (this.map.Spatial == null)
+ {
+ return;
+ }
+
+ if (e.NavigationMode == NavigationMode.New)
{
MapCanvas.Children.Clear();
@@ -80,12 +110,63 @@ namespace CampusAppWP8.Pages.Campusmap
this.ShowCurrentPositionDispatcher(scroll);
}
+ else if (this.qrcodeScan && e.NavigationMode == NavigationMode.Back)
+ {
+ this.qrcodeScan = false;
+ string qrcodeResult = App.LoadFromIsolatedStorage(Constants.CampusMapApp_QRCodeSearchResultStorageKey);
+ App.SaveToIsolatedStorage(Constants.CampusMapApp_QRCodeSearchResultStorageKey, null);
+
+ string searchPid = Wp8StringManager.FilterPlaceIdinQRResultString(qrcodeResult);
+ if (searchPid != null)
+ {
+ this.AddPinsByPids(new List() { searchPid }, MapPinModel.PinType.SearchPlace);
+ }
+ }
}
#endregion
#region private
+ ///
+ /// Method adds pin to the map by given list of placeId
+ ///
+ /// list of placeId
+ /// type of pin
+ /// (optional) if its true, clear canvas before adding
+ private void AddPinsByPids(List pidList, MapPinModel.PinType pinType, bool clearCanvas = true)
+ {
+ // clear canvas
+ if (clearCanvas)
+ {
+ MapCanvas.Children.Clear();
+ }
+
+ // null and empty list assert
+ if (pidList == null || pidList.Count < 1)
+ {
+ return;
+ }
+
+ List placeList = new List();
+ PlaceModel tmpPlace;
+
+ foreach (string pid in pidList)
+ {
+ tmpPlace = this.map.Spatial.GetPlaceById(pid);
+ if (tmpPlace != null)
+ {
+ placeList.Add(tmpPlace);
+ }
+ }
+
+ // add pins to map
+ if (placeList.Count > 0)
+ {
+ this.AddPins(placeList, pinType);
+ }
+ }
+
/// Button click method.
/// Stubbfel, 19.08.2013.
/// caller object.
@@ -95,6 +176,83 @@ namespace CampusAppWP8.Pages.Campusmap
// this.AddPin(double.Parse(XPoint.Text), double.Parse(YPoint.Text));
}
+ ///
+ /// Method start a NFCScan
+ ///
+ /// sender of event
+ /// the event args
+ private void SearchPlaceByNFC_Click(object sender, EventArgs e)
+ {
+ MessageBoxes.ShowMainModelInfoMessageBox(AppResources.ScarNfc_Search);
+ this.ProgressBar.Visibility = Visibility.Visible;
+ this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler);
+ }
+
+ ///
+ /// Method start a QRCodeScan
+ ///
+ /// sender of event
+ /// the event args
+ private void SearchPlaceByQR_Click(object sender, EventArgs e)
+ {
+ this.qrcodeScan = true;
+ string urlString = Constants.PathQR_QRPage;
+ urlString += "?" + Constants.ParamQRResultKey + "=" + Constants.CampusMapApp_QRCodeSearchResultStorageKey;
+ Uri url = new Uri(urlString as string, UriKind.Relative);
+ this.NavigationService.Navigate(url);
+ }
+
+ ///
+ /// Method handle the result of a NFCScan
+ ///
+ /// the sender device
+ /// the message of the device
+ private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
+ {
+ // create ndefMessage
+ this.device.StopSubscribingForMessage(message.SubscriptionId);
+ var ndefMessage = message.Data;
+ byte[] data = ndefMessage.ToArray();
+ NDEFMessage ndef = new NDEFMessage(data);
+
+ // search for placeId
+ string nfcContent = ndef.GetContent();
+ string searchPid = Wp8StringManager.FilterPlaceIdinNFCResultString(nfcContent.Trim());
+ if (searchPid != null)
+ {
+ // add pins to map
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => this.AddPinsByPids(new List() { searchPid }, MapPinModel.PinType.SearchPlace)));
+ }
+ else
+ {
+ this.AddPinsByPids(new List() { searchPid }, MapPinModel.PinType.SearchPlace);
+ }
+ }
+ else
+ {
+ // Errorcase
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail)));
+ }
+ else
+ {
+ MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail);
+ }
+ }
+
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = Visibility.Collapsed));
+ }
+ else
+ {
+ this.ProgressBar.Visibility = Visibility.Collapsed;
+ }
+ }
+
/// Button click method.
/// Stubbfel, 19.08.2013.
/// caller object.
diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs
index ab6f784e..6ad59c34 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs
@@ -25,6 +25,7 @@ namespace CampusAppWP8.Pages.PlaceNews
using Windows.Networking.Proximity;
using CampusAppWP8.Utility.NDEF;
using System.Runtime.InteropServices.WindowsRuntime;
+ using Microsoft.Phone.Shell;
/// Place news.
/// Stubbfel, 09.09.2013.
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
index b4a616bb..f3c27a3a 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
@@ -141,6 +141,24 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Info via NFC ähnelt.
+ ///
+ public static string CampusMapApp_ScanNfc {
+ get {
+ return ResourceManager.GetString("CampusMapApp_ScanNfc", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Info via QR-Code ähnelt.
+ ///
+ public static string CampusMapApp_ScanQR {
+ get {
+ return ResourceManager.GetString("CampusMapApp_ScanQR", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Campusplan ähnelt.
///
@@ -807,6 +825,24 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Kein gültigen NFC-Tag gefunden ähnelt.
+ ///
+ public static string ScarNfc_Fail {
+ get {
+ return ResourceManager.GetString("ScarNfc_Fail", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Bitte halten Sie das Handy vor dem NFC-Tag ähnelt.
+ ///
+ public static string ScarNfc_Search {
+ get {
+ return ResourceManager.GetString("ScarNfc_Search", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Appeinstellungen ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
index 08e76485..8eea55e9 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
@@ -440,4 +440,16 @@
Auf Startseite
+
+ Info via NFC
+
+
+ Info via QR-Code
+
+
+ Kein gültigen NFC-Tag gefunden
+
+
+ Bitte halten Sie das Handy vor dem NFC-Tag
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
index 50e0e97e..06e95858 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
@@ -177,6 +177,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die CampusMapAppQRCodeSearchResultStorageKey ähnelt.
+ ///
+ public static string CampusMapApp_QRCodeSearchResultStorageKey {
+ get {
+ return ResourceManager.GetString("CampusMapApp_QRCodeSearchResultStorageKey", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die +49 ähnelt.
///
@@ -555,6 +564,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die NDEF ähnelt.
+ ///
+ public static string NCFMessageType_NDEF {
+ get {
+ return ResourceManager.GetString("NCFMessageType_NDEF", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
index 522f7cf8..97cd1179 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -519,4 +519,10 @@
/Pages/Dev/QRScanner.xaml
+
+ CampusMapAppQRCodeSearchResultStorageKey
+
+
+ NDEF
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Settings.StyleCop b/CampusAppWP8/CampusAppWP8/Settings.StyleCop
index a049e944..d16b0ee3 100644
--- a/CampusAppWP8/CampusAppWP8/Settings.StyleCop
+++ b/CampusAppWP8/CampusAppWP8/Settings.StyleCop
@@ -17,6 +17,7 @@
pis
prev
pss
+ qr
Senftenberg
sps
Stubbfel
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs
index a572c10f..264fc2fa 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs
+++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs
@@ -122,11 +122,11 @@ namespace CampusAppWPortalLib8.Utility
///
/// Method gets the placeId of the result string for an qrCode string
///
- /// input qrCode string
+ /// input qrCode string
/// the id if it was found it in the string otherwise null
- public static string FilterPlaceIdinQRResultString(string qrCodeResult)
+ public static string FilterPlaceIdinQRResultString(string qrcodeResult)
{
- string[] lines = qrCodeResult.Split('\n');
+ string[] lines = qrcodeResult.Split('\n');
string tmpLineTrim;
foreach (string line in lines)