add appointment to eventpage
This commit is contained in:
@@ -10,15 +10,19 @@ namespace CampusAppWP8.Pages.Events
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Windows.Phone.Speech.Synthesis;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility;
|
||||
using CampusAppWP8.Utility.ICSProperties;
|
||||
using CampusAppWP8.Utility.Lui.Page;
|
||||
using CampusAppWPortalLib8.Model.RSS;
|
||||
using Microsoft.Phone.Shell;
|
||||
using Windows.Phone.Speech.Synthesis;
|
||||
|
||||
/// <summary> EventPage, where every event feed has his own PivotItem. </summary>
|
||||
/// <remarks> Stubbfel, 22.10.2013. </remarks>
|
||||
@@ -39,6 +43,9 @@ namespace CampusAppWP8.Pages.Events
|
||||
/// <summary> The is in speech. </summary>
|
||||
private volatile bool isInSpeech = false;
|
||||
|
||||
/// <summary> The event model. </summary>
|
||||
private RSSModel eventModel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -57,10 +64,16 @@ namespace CampusAppWP8.Pages.Events
|
||||
|
||||
ApplicationBarIconButton ttsBtn = new ApplicationBarIconButton();
|
||||
ttsBtn.IconUri = new Uri(Icons.TextToSpeech, UriKind.Relative);
|
||||
ttsBtn.Text = AppResources.TextToSpeech_Btn;
|
||||
ttsBtn.Text = AppResources.Add;
|
||||
ttsBtn.Click += new EventHandler(this.EventTextToSpeech_Click);
|
||||
ApplicationBar.Buttons.Add(ttsBtn);
|
||||
|
||||
ApplicationBarIconButton addCalBtn = new ApplicationBarIconButton();
|
||||
addCalBtn.IconUri = new Uri(Icons.Calendar_Add, UriKind.Relative);
|
||||
addCalBtn.Text = AppResources.TextToSpeech_Btn;
|
||||
addCalBtn.Click += new EventHandler(this.AddCalender_Click);
|
||||
ApplicationBar.Buttons.Add(addCalBtn);
|
||||
|
||||
this.isNewInstance = true;
|
||||
|
||||
this.synth = new SpeechSynthesizer();
|
||||
@@ -229,6 +242,78 @@ namespace CampusAppWP8.Pages.Events
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by AddCalendar for click events. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="sender"> parent pivot object. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void AddCalender_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.eventModel = EventIndexPage.GetEventFeed().Model.Channel[0].Item[this.EventPivot.SelectedIndex];
|
||||
AppointmentModel appoinment = this.CreateAppointment(this.eventModel);
|
||||
string urlString = Constants.PathTimeTable_AppointmentEdit;
|
||||
|
||||
if (appoinment != null)
|
||||
{
|
||||
App.SaveToIsolatedStorage<string>(Constants.IsolatedStorage_EventAppointment, ICSManager.ExportToICS(appoinment.CalendarObj));
|
||||
urlString += "?" + Constants.ParamIsoKey + "=" + Constants.IsolatedStorage_EventAppointment;
|
||||
}
|
||||
|
||||
Uri url = new Uri(urlString as string, UriKind.Relative);
|
||||
NavigationService.Navigate(url);
|
||||
}
|
||||
|
||||
/// <summary> Creates an appointment. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="eventModel"> The event model. </param>
|
||||
/// <returns> The new appointment. </returns>
|
||||
private AppointmentModel CreateAppointment(RSSModel eventModel)
|
||||
{
|
||||
if (eventModel == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
CultureInfo german = Wp8StringManager.GermanCultur;
|
||||
AppointmentModel appoinment = new AppointmentModel();
|
||||
DateTime time = eventModel.DTTimestamp;
|
||||
DTStart start = new DTStart();
|
||||
start.Value = time;
|
||||
|
||||
string dateValue = eventModel.Title;
|
||||
|
||||
if (dateValue != null)
|
||||
{
|
||||
Summary summary = new Summary();
|
||||
summary.Value = dateValue;
|
||||
appoinment.SetValue(summary);
|
||||
}
|
||||
|
||||
// set cat
|
||||
Categories category = new Categories();
|
||||
category.AddCategory("Veranstaltung");
|
||||
appoinment.SetValue(category);
|
||||
|
||||
// set description
|
||||
dateValue = this.eventModel.Text;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Description desc = new Description();
|
||||
desc.Value = dateValue;
|
||||
appoinment.SetValue(desc);
|
||||
}
|
||||
|
||||
// set url
|
||||
dateValue = this.eventModel.Link;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Url url = new Url();
|
||||
url.Value = dateValue;
|
||||
appoinment.SetValue(url);
|
||||
}
|
||||
|
||||
return appoinment;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -100,8 +100,8 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
|
||||
if (appoinment != null)
|
||||
{
|
||||
App.SaveToIsolatedStorage<string>("LectureAppointment", ICSManager.ExportToICS(appoinment.CalendarObj));
|
||||
// urlString += "?" + this.QuerryStringName + "=" + this.QuerryStringValue;
|
||||
App.SaveToIsolatedStorage<string>(Constants.IsolatedStorage_LectureAppointment, ICSManager.ExportToICS(appoinment.CalendarObj));
|
||||
urlString += "?" + Constants.ParamIsoKey + "=" + Constants.IsolatedStorage_LectureAppointment;
|
||||
}
|
||||
|
||||
Uri url = new Uri(urlString as string, UriKind.Relative);
|
||||
|
||||
@@ -612,4 +612,10 @@
|
||||
<data name="ParamIsoKey" xml:space="preserve">
|
||||
<value>isolated</value>
|
||||
</data>
|
||||
<data name="IsolatedStorage_LectureAppointment" xml:space="preserve">
|
||||
<value>LectureAppointment</value>
|
||||
</data>
|
||||
<data name="IsolatedStorage_EventAppointment" xml:space="preserve">
|
||||
<value>EventAppointment</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -474,6 +474,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die EventAppointment ähnelt.
|
||||
/// </summary>
|
||||
public static string IsolatedStorage_EventAppointment {
|
||||
get {
|
||||
return ResourceManager.GetString("IsolatedStorage_EventAppointment", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_EventRSSModel ähnelt.
|
||||
/// </summary>
|
||||
@@ -483,6 +492,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die LectureAppointment ähnelt.
|
||||
/// </summary>
|
||||
public static string IsolatedStorage_LectureAppointment {
|
||||
get {
|
||||
return ResourceManager.GetString("IsolatedStorage_LectureAppointment", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die LectureModel ähnelt.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user