diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
index ddc82665..6733b1b8 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
@@ -32,7 +32,8 @@ namespace CampusAppWP8.Pages.Campusmap
public CampusMapPage()
{
this.InitializeComponent();
- this.map = new CBMainMapModel();
+
+
this.MapCanvas.DataContext = this.map;
}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml
index cac77add..f4a6505a 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml
@@ -24,10 +24,19 @@
-
+ ed
+
+
+
+
+
+
+
+
+
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs
index be6879c1..463f2f11 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Dev/NFC.xaml.cs
@@ -1,90 +1,127 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using Windows.Networking.Proximity;
-using System.Runtime.InteropServices.WindowsRuntime;
-using CampusAppWP8.Utility.NDEF;
-using Windows.Storage.Streams;
-using CampusAppWP8.Model.GeoDb;
-
+//-----------------------------------------------------------------------
+//
+// Company copyright tag.
+//
+// stubbfel
+// 08.08.2013
+//----------------------------------------------------------------------
namespace CampusAppWP8.Pages.Dev
{
+ using System;
+ using System.Collections.Generic;
+ using System.Runtime.InteropServices.WindowsRuntime;
+ using System.Windows;
+ using System.Windows.Navigation;
+ using CampusAppWP8.Model.Campusmap;
+ using CampusAppWP8.Model.GeoDb;
+ using CampusAppWP8.Utility.NDEF;
+ using Microsoft.Phone.Controls;
+ using Windows.Networking.Proximity;
+
+ /// Nfc page.
+ /// Stubbfel, 22.08.2013.
public partial class NFC : PhoneApplicationPage
{
-
+ /// The device.
private readonly ProximityDevice device = ProximityDevice.GetDefault();
- private long lastMsgId;
+
+ /// Zero-based index of the act ndef.
+ private int actNDEFIndex;
+
+ /// List of ndefs.
+ private List ndefList;
+
+ /// Initializes a new instance of the NFC class.
+ /// Stubbfel, 22.08.2013.
public NFC()
{
- InitializeComponent();
+ this.InitializeComponent();
+ this.ndefList = new List();
+ MapModel map = new CBMainMapModel();
+ foreach (PlaceModel place in map.Spatial.Places)
+ {
+ this.ndefList.Add(new NDEFMessage(place.ToNfcString(), NDEFMessage.TYPEVAL.TEXT));
+ }
+
+ this.actNDEFIndex = 0;
}
- ///
- /// Override the OnNavigatedTo method
- ///
- /// Arguments of navigation
+ /// Override the OnNavigatedTo method.
+ /// Stubbfel, 22.08.2013.
+ /// Arguments of navigation.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
-
- if (this.device != null)
- {
- MessageBox.Show("NFC present");
- }
- else
- {
- MessageBox.Show("Your phone has no NFC or NFC is disabled");
- }
- this.lastMsgId = this.device.SubscribeForMessage("WriteableTag", WriteableTagDetected);
+ this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
}
- protected override void OnNavigatedFrom(NavigationEventArgs e)
+ /// Handler, called when the publish.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// Identifier for the message.
+ private void PublishHandler(ProximityDevice sender, long messageId)
{
- base.OnNavigatedTo(e);
-
- this.device.StopSubscribingForMessage(this.lastMsgId);
+ this.device.StopPublishingMessage(messageId);
+ this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show("Writed:" + this.actNDEFIndex)));
}
-
- private void WriteableTagDetected(ProximityDevice sender, ProximityMessage message)
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- MessageBox.Show("message");
- });
-
- this.device.StopSubscribingForMessage(message.SubscriptionId);
-
- NDEFMessage ndef = new NDEFMessage((new PlaceModel() { PlaceId = "1"}).ToNfcString(), NDEFMessage.TYPEVAL.TEXT);
- byte[] ndefB = ndef.ToByteArray();
- IBuffer buffer = ndefB.AsBuffer();
- device.PublishBinaryMessage("NDEF:WriteTag", ndef.ToByteArray().AsBuffer(), publishHandler);
- }
-
- private void publishHandler(ProximityDevice sender, long messageId)
- {
- device.StopPublishingMessage(messageId);
-
- device.SubscribeForMessage("NDEF", NDEFHandler);
- }
-
-
+ /// Handler, called when the ndef.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// The message.
private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
{
-
- var NDefMessage = message.Data;
- byte[] testa = NDefMessage.ToArray();
+ this.device.StopSubscribingForMessage(message.SubscriptionId);
+ var ndefMessage = message.Data;
+ byte[] testa = ndefMessage.ToArray();
NDEFMessage ndef = new NDEFMessage(testa);
- Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
+ this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
+ }
+ /// Event handler. Called by Read for click events.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// Routed event information.
+ private void Read_Click(object sender, RoutedEventArgs e)
+ {
+ this.device.SubscribeForMessage("NDEF", this.NDEFHandler);
+ }
+
+ /// Event handler. Called by Next for click events.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// Routed event information.
+ private void Next_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.actNDEFIndex < this.ndefList.Count - 1)
+ {
+ this.actNDEFIndex++;
+ this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
+ }
+ }
+
+ /// Event handler. Called by Prev for click events.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// Routed event information.
+ private void Prev_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.actNDEFIndex > 0)
+ {
+ this.actNDEFIndex--;
+ this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
+ }
+ }
+
+ /// Event handler. Called by Write for click events.
+ /// Stubbfel, 22.08.2013.
+ /// The sender.
+ /// Routed event information.
+ private void Write_Click(object sender, RoutedEventArgs e)
+ {
+ this.device.PublishBinaryMessage("NDEF:WriteTag", this.ndefList[this.actNDEFIndex].ToByteArray().AsBuffer(), this.PublishHandler);
}
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
index 0ab67a9c..3f855f1b 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
@@ -279,19 +279,5 @@ namespace CampusAppWP8.Utility
}
}
}
-
- /// Writes a nfc tag.
- /// Stubbfel, 21.08.2013.
- /// The tag content.
- /// The action.
- public static void WriteNfcTag(string tagContent)
- {
- NDEFMessage ndef = new NDEFMessage(tagContent, NDEFMessage.TYPEVAL.TEXT);
- ProximityDevice device = ProximityDevice.GetDefault();
- if (device != null)
- {
- device.PublishBinaryMessage("NDEF:WriteTag", ndef.ToByteArray().AsBuffer());
- }
- }
}
}
\ No newline at end of file