diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs
index 893982e6..9283b491 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs
@@ -18,7 +18,8 @@ namespace CampusAppWP8.Pages.Events
using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
-
+ using Windows.Phone.Speech.Synthesis;
+
///
/// EventPage, where every event fees has his own PivotItem.
///
@@ -39,6 +40,12 @@ namespace CampusAppWP8.Pages.Events
///
private bool isNewInstance = false;
+ /// The speech synthesizer object.
+ private SpeechSynthesizer synth = null;
+
+ /// The is in speech.
+ private volatile bool isInSpeech = false;
+
///
/// Initializes a new instance of the class.
///
@@ -52,7 +59,16 @@ namespace CampusAppWP8.Pages.Events
linkBtn.Click += new EventHandler(this.EventLink_Click);
ApplicationBar.Buttons.Add(linkBtn);
+ ApplicationBarIconButton ttsBtn = new ApplicationBarIconButton();
+ ttsBtn.IconUri = new Uri(Icons.TextToSpeech, UriKind.Relative);
+ ttsBtn.Text = AppResources.TextToSpeech_Btn;
+ ttsBtn.Click += new EventHandler(this.EventTextToSpeech_Click);
+ ApplicationBar.Buttons.Add(ttsBtn);
+
this.isNewInstance = true;
+
+ this.synth = new SpeechSynthesizer();
+ this.isInSpeech = false;
}
///
@@ -134,6 +150,11 @@ namespace CampusAppWP8.Pages.Events
{
App.SaveToIsolatedStorage(Constants.IsolatedStorage_EventRSSModel, EventIndexPage.GetEventFeed().GetModel());
}
+
+ if (this.synth != null)
+ {
+ this.synth.CancelAll();
+ }
}
///
@@ -151,7 +172,7 @@ namespace CampusAppWP8.Pages.Events
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventWebBrowser", Visibility.Collapsed, this.lastSelectedIndex);
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", Visibility.Visible, this.lastSelectedIndex);
}
-
+
this.lastSelectedIndex = selIndex;
}
@@ -175,5 +196,31 @@ namespace CampusAppWP8.Pages.Events
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", Visibility.Visible, this.EventPivot.SelectedIndex);
}
}
+
+ /// Event handler. Called by EventTextToSpeech for click events.
+ /// parent pivot object.
+ /// Event information.
+ private async void EventTextToSpeech_Click(object sender, EventArgs e)
+ {
+ if (this.synth != null && this.isInSpeech == false)
+ {
+ string ssmlPrompt = "";
+ ssmlPrompt += EventIndexPage.GetEventFeed().GetModel().Channel[0].Item[this.EventPivot.SelectedIndex].Text;
+ ssmlPrompt += "";
+
+ this.isInSpeech = true;
+
+ try
+ {
+ await this.synth.SpeakSsmlAsync(ssmlPrompt);
+ }
+ catch (Exception)
+ {
+ }
+
+ this.isInSpeech = false;
+ }
+ }
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs
index 3c26f7cb..3565b225 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs
@@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages.News
using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
+ using Windows.Phone.Speech.Synthesis;
///
/// EventPage, where every news fees has his own PivotItem.
@@ -39,6 +40,12 @@ namespace CampusAppWP8.Pages.News
///
private bool isNewInstance = false;
+ /// The speech synthesizer object.
+ private SpeechSynthesizer synth = null;
+
+ /// The is in speech.
+ private volatile bool isInSpeech = false;
+
///
/// Initializes a new instance of the class.
///
@@ -52,7 +59,16 @@ namespace CampusAppWP8.Pages.News
linkBtn.Click += new EventHandler(this.NewsLink_Click);
ApplicationBar.Buttons.Add(linkBtn);
+ ApplicationBarIconButton ttsBtn = new ApplicationBarIconButton();
+ ttsBtn.IconUri = new Uri(Icons.TextToSpeech, UriKind.Relative);
+ ttsBtn.Text = AppResources.TextToSpeech_Btn;
+ ttsBtn.Click += new EventHandler(this.NewsTextToSpeech_Click);
+ ApplicationBar.Buttons.Add(ttsBtn);
+
this.isNewInstance = true;
+
+ this.synth = new SpeechSynthesizer();
+ this.isInSpeech = false;
}
///
@@ -127,6 +143,11 @@ namespace CampusAppWP8.Pages.News
{
App.SaveToIsolatedStorage(Constants.IsolatedStorage_NewsRSSModel, NewsIndexPage.GetNewsFeed().GetModel());
}
+
+ if (this.synth != null)
+ {
+ this.synth.CancelAll();
+ }
}
///
@@ -168,5 +189,31 @@ namespace CampusAppWP8.Pages.News
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsTextGrid", Visibility.Visible, this.NewsPivot.SelectedIndex);
}
}
+
+ /// Event handler. Called by EventTextToSpeech for click events.
+ /// parent pivot object.
+ /// Event information.
+ private async void NewsTextToSpeech_Click(object sender, EventArgs e)
+ {
+ if (this.synth != null && this.isInSpeech == false)
+ {
+ string ssmlPrompt = "";
+ ssmlPrompt += NewsIndexPage.GetNewsFeed().GetModel().Channel[0].Item[this.NewsPivot.SelectedIndex].Text;
+ ssmlPrompt += "";
+
+ this.isInSpeech = true;
+
+ try
+ {
+ await this.synth.SpeakSsmlAsync(ssmlPrompt);
+ }
+ catch (Exception)
+ {
+ }
+
+ this.isInSpeech = false;
+ }
+ }
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml
index 94181ca5..4d8b94b2 100644
--- a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml
+++ b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml
@@ -15,6 +15,7 @@
+
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
index 23bebb98..7b79160f 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs
@@ -852,6 +852,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die vorlesen ähnelt.
+ ///
+ public static string TextToSpeech_Btn {
+ get {
+ return ResourceManager.GetString("TextToSpeech_Btn", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Freitag ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
index a0baa5ea..db84d97c 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx
@@ -413,4 +413,7 @@
... suche
+
+ vorlesen
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs
index 8d43489b..7d6a9c8a 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs
@@ -275,6 +275,17 @@ namespace CampusAppWP8.Resources
}
}
+ ///
+ /// Gets the uri string of the TextToSpeech icon.
+ ///
+ public static string TextToSpeech
+ {
+ get
+ {
+ return Themerize("info_159.png");
+ }
+ }
+
///
/// Gets the uri string of the Update icon.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx
index 5f901171..f981d217 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx
@@ -186,6 +186,9 @@
student_council_159.png
+
+ info_159.png
+
update_159.png