Merge branch 'feature/#280' into develop
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
|
||||
|
||||
@@ -8,16 +8,31 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Pages.Lecture
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Model.Lecture;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
using CampusAppWP8.Resources;
|
||||
using Microsoft.Phone.Controls;
|
||||
using CampusAppWP8.Utility;
|
||||
using CampusAppWP8.Utility.ICSProperties;
|
||||
using CampusAppWPortalLib8.Model.Lecture;
|
||||
using Microsoft.Phone.Controls;
|
||||
|
||||
/// <summary> Class for the page which shows details of an activity. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <seealso cref="T:Microsoft.Phone.Controls.PhoneApplicationPage"/>
|
||||
public partial class ResultDetailPage : PhoneApplicationPage
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary> The activity. </summary>
|
||||
private LectureWp8Activity activity;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the <see cref="ResultDetailPage" /> class. </summary>
|
||||
@@ -54,25 +69,219 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// <summary> Method load a certain Activity from the model. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="activityId"> id of the activity. </param>
|
||||
private void LoadActivity(int activityId)
|
||||
private void LoadActivity(int activityId)
|
||||
{
|
||||
LectureWp8List list = App.LoadFromIsolatedStorage<LectureWp8List>(Constants.IsolatedStorage_LectureModel);
|
||||
if (list != null)
|
||||
{
|
||||
LectureWp8Activity activity = list.GetActivity(activityId);
|
||||
activity.CreateLectureString();
|
||||
activity.CreateCourseString();
|
||||
this.ContentPanel.DataContext = activity;
|
||||
this.activity = list.GetActivity(activityId);
|
||||
this.activity.CreateLectureString();
|
||||
this.activity.CreateCourseString();
|
||||
this.ContentPanel.DataContext = this.activity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by AddCalender for click events. </summary>
|
||||
/// <summary> Event handler. Called by AddCalendar for click events. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void AddCalender_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
FrameworkElement btn = sender as FrameworkElement;
|
||||
if (btn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string dateId = btn.Tag.ToString();
|
||||
LectureDate date = this.activity.GetDate(dateId);
|
||||
AppointmentModel appoinment = this.CreateAppointment(date);
|
||||
string urlString = Constants.PathTimeTable_AppointmentEdit;
|
||||
|
||||
if (appoinment != null)
|
||||
{
|
||||
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);
|
||||
NavigationService.Navigate(url);
|
||||
}
|
||||
|
||||
/// <summary> Creates an appointment. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="date"> The date. </param>
|
||||
/// <returns> The new appointment. </returns>
|
||||
private AppointmentModel CreateAppointment(LectureDate date)
|
||||
{
|
||||
if (date == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
CultureInfo german = Wp8StringManager.GermanCultur;
|
||||
AppointmentModel appoinment = new AppointmentModel();
|
||||
DTStart start;
|
||||
DateTime dtStart;
|
||||
TimeSpan fromTime;
|
||||
DTEnd end;
|
||||
DateTime dtEnd;
|
||||
TimeSpan toTime;
|
||||
TimeSpan duration = TimeSpan.FromTicks(0);
|
||||
RecurrenceRule rRule;
|
||||
|
||||
// set the room
|
||||
string dateValue = date.Room;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Location location = new Location();
|
||||
location.Value = dateValue;
|
||||
appoinment.SetValue(location);
|
||||
}
|
||||
|
||||
if (this.activity != null)
|
||||
{
|
||||
// set Tilte
|
||||
dateValue = this.activity.Title;
|
||||
|
||||
if (dateValue != null)
|
||||
{
|
||||
Summary summary = new Summary();
|
||||
summary.Value = dateValue;
|
||||
appoinment.SetValue(summary);
|
||||
}
|
||||
|
||||
// set cat
|
||||
dateValue = this.activity.Type;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Categories category = new Categories();
|
||||
category.AddCategory(dateValue);
|
||||
appoinment.SetValue(category);
|
||||
}
|
||||
|
||||
// set description
|
||||
dateValue = this.activity.Topic;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Description desc = new Description();
|
||||
desc.Value = dateValue;
|
||||
appoinment.SetValue(desc);
|
||||
}
|
||||
|
||||
// set orignazier
|
||||
dateValue = this.activity.LecturerString;
|
||||
if (dateValue != null)
|
||||
{
|
||||
Organizer org = new Organizer();
|
||||
org.Value = dateValue;
|
||||
appoinment.SetValue(org);
|
||||
}
|
||||
}
|
||||
|
||||
// set the startdate
|
||||
dateValue = date.StartDate;
|
||||
start = new DTStart();
|
||||
if (dateValue != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
dtStart = DateTime.Parse(dateValue, german);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dtStart = DateTime.Today;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dtStart = DateTime.Today;
|
||||
}
|
||||
|
||||
dateValue = date.From;
|
||||
if (dateValue != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fromTime = TimeSpan.Parse(dateValue, german);
|
||||
dtStart = dtStart.Add(fromTime);
|
||||
duration = fromTime;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
start.Value = dtStart;
|
||||
appoinment.SetValue(start);
|
||||
|
||||
// set the end date
|
||||
dateValue = date.EndDate;
|
||||
end = new DTEnd();
|
||||
if (dateValue != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
dtEnd = DateTime.Parse(dateValue, german);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dtEnd = DateTime.Today;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dtEnd = DateTime.Today;
|
||||
}
|
||||
|
||||
dateValue = date.To;
|
||||
if (dateValue != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
toTime = TimeSpan.Parse(dateValue, german);
|
||||
dtEnd = dtEnd.Add(toTime);
|
||||
duration = toTime - duration;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
end.Value = dtEnd;
|
||||
appoinment.SetValue(end);
|
||||
|
||||
// set the duration
|
||||
CampusAppWP8.Utility.ICSProperties.Duration icsDuration = new Utility.ICSProperties.Duration();
|
||||
icsDuration.Value = duration;
|
||||
appoinment.SetValue(icsDuration);
|
||||
|
||||
// set the RRule
|
||||
rRule = new RecurrenceRule();
|
||||
rRule.Value.Add(new Tuple<string, List<string>>(ICSValue.FREQ, new List<string>() { ICSValueValue.WEEKLY }));
|
||||
|
||||
// set by the week
|
||||
dateValue = date.WeekDay;
|
||||
if (dateValue != null)
|
||||
{
|
||||
DayOfWeek weekDay = Wp8StringManager.ToDayofWeek(dateValue, german);
|
||||
rRule.Value.Add(new Tuple<string, List<string>>(ICSValue.BY_DAY, new List<string>() { ICSValueValue.ToICSWeekDay(weekDay) }));
|
||||
}
|
||||
|
||||
// set interval
|
||||
dateValue = date.Interval;
|
||||
if (dateValue != null)
|
||||
{
|
||||
string lowVal = dateValue.ToLower();
|
||||
if (lowVal.Contains("a") ^ lowVal.Contains("b"))
|
||||
{
|
||||
rRule.Value.Add(new Tuple<string, List<string>>(ICSValue.INTERVAL, new List<string>() { "2" }));
|
||||
}
|
||||
}
|
||||
|
||||
appoinment.SetValue(rRule);
|
||||
|
||||
return appoinment;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace CampusAppWP8.Utility
|
||||
public class ICSDesc
|
||||
{
|
||||
private string name = string.Empty;
|
||||
|
||||
|
||||
public ICSDesc()
|
||||
{
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace CampusAppWP8.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public bool Is(string tag)
|
||||
public bool Is(string tag)
|
||||
{
|
||||
return this.name.Equals(tag);
|
||||
}
|
||||
@@ -41,14 +41,15 @@ namespace CampusAppWP8.Utility
|
||||
public class ICSParamDesc : ICSDesc
|
||||
{
|
||||
private List<string> types = null;
|
||||
|
||||
public ICSParamDesc(string name, string[] typeList) : base()
|
||||
|
||||
public ICSParamDesc(string name, string[] typeList)
|
||||
: base()
|
||||
{
|
||||
this.Name = name;
|
||||
|
||||
if((typeList != null) && (typeList.Length > 0))
|
||||
if ((typeList != null) && (typeList.Length > 0))
|
||||
{
|
||||
this.types = new List<string>();
|
||||
this.types = new List<string>();
|
||||
this.types.AddRange(types);
|
||||
}
|
||||
}
|
||||
@@ -75,11 +76,12 @@ namespace CampusAppWP8.Utility
|
||||
{
|
||||
private List<ICSElemDesc> subs = null;
|
||||
|
||||
public ICSValueDesc(string name, ICSElemDesc[] elemList) : base()
|
||||
public ICSValueDesc(string name, ICSElemDesc[] elemList)
|
||||
: base()
|
||||
{
|
||||
this.Name = name;
|
||||
|
||||
if((elemList != null) && (elemList.Length > 0))
|
||||
if ((elemList != null) && (elemList.Length > 0))
|
||||
{
|
||||
this.subs = new List<ICSElemDesc>();
|
||||
this.subs.AddRange(elemList);
|
||||
@@ -146,11 +148,12 @@ namespace CampusAppWP8.Utility
|
||||
private List<ICSValueDesc> value = null;
|
||||
private Type objType;
|
||||
|
||||
public ICSElemDesc(Type t, ICSValueDesc[] valueList) : base()
|
||||
public ICSElemDesc(Type t, ICSValueDesc[] valueList)
|
||||
: base()
|
||||
{
|
||||
this.objType = t;
|
||||
this.Name = (this.CreateObj() as ICSClasses.Interface).GetName();
|
||||
|
||||
|
||||
if ((valueList != null) && (valueList.Length > 0))
|
||||
{
|
||||
this.value = new List<ICSValueDesc>();
|
||||
@@ -221,7 +224,7 @@ namespace CampusAppWP8.Utility
|
||||
object retValue = this.CreateObj();
|
||||
|
||||
(retValue as ICSClasses.Interface).Set(valueString, paramString);
|
||||
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
@@ -450,7 +453,7 @@ namespace CampusAppWP8.Utility
|
||||
{
|
||||
|
||||
public const string BEGIN = "BEGIN";
|
||||
public const string END = "END";
|
||||
public const string END = "END";
|
||||
|
||||
// Calendar Components
|
||||
public const string VCALENDAR = "VCALENDAR";
|
||||
@@ -462,7 +465,7 @@ namespace CampusAppWP8.Utility
|
||||
public const string METHOD = "METHOD";
|
||||
// 0-*
|
||||
public const string X_WR_CALNAME = "X-WR-CALNAME";
|
||||
|
||||
|
||||
// Event Component
|
||||
public const string VEVENT = "VEVENT";
|
||||
// 1-1
|
||||
@@ -523,7 +526,7 @@ namespace CampusAppWP8.Utility
|
||||
// DT_MODIFIED
|
||||
public const string TIME_ZONE_URL = "TZURL";
|
||||
// one of both MUST occure: 1-*
|
||||
|
||||
|
||||
// Time Zone: Standardc/Daylightc
|
||||
public const string STANDARD = "STANDARD";
|
||||
public const string DAYLIGHT = "DAYLIGHT";
|
||||
@@ -570,14 +573,14 @@ namespace CampusAppWP8.Utility
|
||||
// REPEAT
|
||||
// 0-*
|
||||
// ATTACH
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ???
|
||||
|
||||
|
||||
// public const string RELATED_TO = "RELATED-TO";
|
||||
public const string SEQUENCE = "SEQUENCE";
|
||||
}
|
||||
@@ -585,7 +588,7 @@ namespace CampusAppWP8.Utility
|
||||
public class ICSParam
|
||||
{
|
||||
// see http://tools.ietf.org/html/rfc5545 3.2.
|
||||
|
||||
|
||||
public const string ALT_REPRESENTATION = "ALTREP";
|
||||
public const string COMMON_NAME = "CN";
|
||||
public const string CALENDAR_USER_TYPE = "CUTYPE";
|
||||
@@ -730,12 +733,39 @@ namespace CampusAppWP8.Utility
|
||||
public const string DATE = "DATE";
|
||||
public const string DATE_TIME = "DATE-TIME";
|
||||
// ...
|
||||
public const string DAY_SU = "SU";
|
||||
public const string DAY_SU = "SU";
|
||||
public const string DAY_MO = "MO";
|
||||
public const string DAY_TU = "TU";
|
||||
public const string DAY_WE = "WE";
|
||||
public const string DAY_TH = "TH";
|
||||
public const string DAY_FR = "FR";
|
||||
public const string DAY_SA = "SA";
|
||||
|
||||
/// <summary> Converts a day to the ics week day. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="day"> The day. </param>
|
||||
/// <returns> day as a string. </returns>
|
||||
public static string ToICSWeekDay(DayOfWeek day)
|
||||
{
|
||||
switch (day)
|
||||
{
|
||||
case DayOfWeek.Sunday:
|
||||
return ICSValueValue.DAY_SU;
|
||||
case DayOfWeek.Monday:
|
||||
return ICSValueValue.DAY_MO;
|
||||
case DayOfWeek.Tuesday:
|
||||
return ICSValueValue.DAY_TU;
|
||||
case DayOfWeek.Wednesday:
|
||||
return ICSValueValue.DAY_WE;
|
||||
case DayOfWeek.Thursday:
|
||||
return ICSValueValue.DAY_TH;
|
||||
case DayOfWeek.Friday:
|
||||
return ICSValueValue.DAY_FR;
|
||||
case DayOfWeek.Saturday:
|
||||
return ICSValueValue.DAY_SA;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility
|
||||
{
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using CampusAppWP8.Resources;
|
||||
|
||||
/// <summary> Class provides some special StringMethods. </summary>
|
||||
|
||||
@@ -210,6 +210,28 @@ namespace CampusAppWPortalLib8.Model.Lecture
|
||||
this.CourseString = DefaultStringManager.RemoveNewLine(result);
|
||||
}
|
||||
|
||||
/// <summary> Gets a date. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="id"> The identifier. </param>
|
||||
/// <returns> The date. </returns>
|
||||
public LectureDate GetDate(string id)
|
||||
{
|
||||
if (this.Dates == null || id == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (LectureDate date in this.Dates)
|
||||
{
|
||||
if (id.Equals(date.Id))
|
||||
{
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using CampusAppWPortalLib8.Resources;
|
||||
|
||||
@@ -18,6 +19,9 @@ namespace CampusAppWPortalLib8.Utility
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The german culture. </summary>
|
||||
public static readonly CultureInfo GermanCulture = new CultureInfo("de-DE");
|
||||
|
||||
/// <summary> Patter for Html-Tags. </summary>
|
||||
private static readonly string HtmlTagPattern = "<.*?>";
|
||||
|
||||
@@ -127,7 +131,7 @@ namespace CampusAppWPortalLib8.Utility
|
||||
/// <returns> the id if it was found it in the string otherwise null. </returns>
|
||||
public static string FilterPlaceIdinQRResultString(string qrcodeResult)
|
||||
{
|
||||
if (qrcodeResult == null)
|
||||
if (qrcodeResult == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -197,18 +201,18 @@ namespace CampusAppWPortalLib8.Utility
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Count character.</summary>
|
||||
/// <remarks>Fiedler, 27.08.2013.</remarks>
|
||||
/// <param name="str">input string.</param>
|
||||
/// <param name="c">The character.</param>
|
||||
/// <returns>The total number of the specified character in the string.</returns>
|
||||
/// <summary> Count a certain character. </summary>
|
||||
/// <remarks> Fiedler, 27.08.2013. </remarks>
|
||||
/// <param name="str"> input string. </param>
|
||||
/// <param name="c"> The character. </param>
|
||||
/// <returns> The total number of the specified character in the string. </returns>
|
||||
public static int CountChar(string str, char c)
|
||||
{
|
||||
int retValue = 0;
|
||||
|
||||
foreach(char tc in str)
|
||||
foreach (char tc in str)
|
||||
{
|
||||
if(tc.Equals(c) == true)
|
||||
if (tc.Equals(c) == true)
|
||||
{
|
||||
retValue++;
|
||||
}
|
||||
@@ -216,6 +220,48 @@ namespace CampusAppWPortalLib8.Utility
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Converts this object to a day of the week. </summary>
|
||||
/// <remarks> Stubbfel, 19.11.2013. </remarks>
|
||||
/// <param name="inputDay"> The input day. </param>
|
||||
/// <param name="culture"> The culture. </param>
|
||||
/// <returns> The given data converted to a DayOfWeek. </returns>
|
||||
public static DayOfWeek ToDayofWeek(string inputDay, CultureInfo culture)
|
||||
{
|
||||
if (inputDay == null || culture == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inputDay = inputDay.Trim().ToLower();
|
||||
string[] days = culture.DateTimeFormat.DayNames;
|
||||
|
||||
int i = 0;
|
||||
foreach (string day in days)
|
||||
{
|
||||
if (inputDay.Equals(day.ToLower()))
|
||||
{
|
||||
return (DayOfWeek)i;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// look for AbbreviatedDayNames
|
||||
days = culture.DateTimeFormat.AbbreviatedDayNames;
|
||||
i = 0;
|
||||
foreach (string day in days)
|
||||
{
|
||||
if (inputDay.Equals(day.ToLower()))
|
||||
{
|
||||
return (DayOfWeek)i;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user