diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 719b97bc..00d78264 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using CampusAppWP8.Resources; +using System.IO.IsolatedStorage; namespace CampusAppWP8 @@ -59,6 +60,37 @@ namespace CampusAppWP8 } } + /// + /// Method save any object to the IsolatedStorage + /// + /// key of the object + /// value of the object, if value == null => remove key + public static void SaveToIsolatedStorage(string key, T value) + { + IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings; + isolatedStore.Remove(key); + if (value != null) + { + isolatedStore.Add(key, value); + } + + isolatedStore.Save(); + } + + /// + /// Method load any object to the IsolatedStorage + /// + /// key of the object + public static T LoadFromIsolatedStorage(string key) + { + IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings; + + if(isolatedStore.Contains(key)) { + object value = isolatedStore[key]; + return (T)value; + } + return default(T); + } // Code, der beim Starten der Anwendung ausgeführt werden soll (z. B. über "Start") // Dieser Code wird beim Reaktivieren der Anwendung nicht ausgeführt private void Application_Launching(object sender, LaunchingEventArgs e) diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 268876d8..880f1859 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -122,8 +122,14 @@ - - Results.xaml + + ModulWebPage.xaml + + + ResultDetailPage.xaml + + + ResultPage.xaml MensaPage.xaml @@ -179,7 +185,15 @@ Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs index 8bf99472..3c178b2d 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs @@ -1,4 +1,5 @@ -using System; +using CampusAppWP8.Utility; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -10,6 +11,12 @@ namespace CampusAppWP8.Model.Lecture { public class LectureActivity { + #region + private ObservableCollection lecturer; + private string lecturerString; + private string courseString; + private string topic; + #endregion #region Constructor /// @@ -24,7 +31,10 @@ namespace CampusAppWP8.Model.Lecture #region Proberty [XmlElement("art")] - public string Type{ get; set; } + public string Type { get; set; } + + [XmlAttribute("id")] + public int Id { get; set; } [XmlElement("semester")] public int Semester { get; set; } @@ -36,7 +46,49 @@ namespace CampusAppWP8.Model.Lecture public LectureModul Modul { get; set; } [XmlElement("lehrperson")] - public ObservableCollection Lecturer { get; set; } + public ObservableCollection Lecturer { + get + { + return lecturer; + } + set + { + if (value != lecturer) + { + lecturer = value; + } + } + } + + public string LecturerString { + get + { + return this.lecturerString; + } + set + { + if (value != this.lecturerString) + { + this.lecturerString = value; + } + } + } + + public string CourseString + { + get + { + return this.courseString; + } + set + { + if (value != this.courseString) + { + this.courseString = value; + } + } + } + [XmlElement("studiengang")] public ObservableCollection Course { get; set; } @@ -44,6 +96,45 @@ namespace CampusAppWP8.Model.Lecture [XmlElement("termin")] public ObservableCollection Dates { get; set; } + [XmlElement("zugeordnete_einrichtung")] + public string Department { get; set; } + + [XmlElement("lehrinhalt")] + public string Topic + { + get + { + return topic; + } + set + { + if (value != topic) + { + topic = StringManager.StripHTML(value); + } + } + } + #endregion + + public void createLectureString() + { + string result = string.Empty; + foreach (LectureLecturer tmpLecturer in Lecturer) + { + result += tmpLecturer.ToString() + "\n"; + } + this.LecturerString = result.TrimEnd('\n'); + } + + public void createCourseString() + { + string result = string.Empty; + foreach (LectureCourse course in Course) + { + result += course.Title + "\n"; + } + this.CourseString = result.TrimEnd('\n'); + } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureLecturer.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureLecturer.cs index 04990c7f..c0cc8b42 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureLecturer.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureLecturer.cs @@ -23,5 +23,24 @@ namespace CampusAppWP8.Model.Lecture [XmlAttribute("zustaendigkeit")] public string Responsibility { get; set; } + + public override string ToString() + { + string result = string.Empty; + + if (!Title.Equals(string.Empty)) + { + result += Title + " "; + } + + result += FirstName + " "; + result += LastName + " "; + + if (!Responsibility.Equals(string.Empty)) + { + result += "(" + Responsibility + ") "; + } + return result; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureList.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureList.cs index ac8e3fda..6dff6569 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureList.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureList.cs @@ -7,8 +7,11 @@ //---------------------------------------------------------------------- namespace CampusAppWP8.Model.Lecture { + using System.Collections.Generic; using System.Collections.ObjectModel; using System.Xml.Serialization; + using System.Linq; + [XmlRoot("lsf_auszug")] public class LectureList { @@ -28,9 +31,18 @@ namespace CampusAppWP8.Model.Lecture [XmlArray("veranstaltungsliste")] [XmlArrayItem("veranstaltung")] - public ObservableCollection Activity { get; set; } + public ObservableCollection Activities { get; set; } #endregion + #region Methods + + public LectureActivity GetActivity(int id) + { + LectureActivity activity = Activities.Where(p => p.Id == id).First(); + return activity; + } + #endregion + } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModul.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModul.cs index febfec0f..883f763f 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModul.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureModul.cs @@ -7,6 +7,7 @@ //---------------------------------------------------------------------- namespace CampusAppWP8.Model.Lecture { + using CampusAppWP8.Resources; using System; using System.Xml.Serialization; public class LectureModul @@ -61,7 +62,7 @@ namespace CampusAppWP8.Model.Lecture private void createUrl() { - this.url = new Uri("https://www.tu-cottbus.de/modul/" + number.ToString()); + this.url = new Uri(Constants.UrlLectureModulBaseAddr + number.ToString()); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/Results.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml similarity index 72% rename from CampusAppWP8/CampusAppWP8/Pages/Lecture/Results.xaml rename to CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml index 119c3071..607d04b8 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/Results.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml @@ -1,5 +1,5 @@  - - - - - - - + - \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs new file mode 100644 index 00000000..989f0b51 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ModulWebPage.xaml.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 11.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Pages.Lecture +{ + using System; + using System.Windows.Navigation; + using CampusAppWP8.Resources; + using Microsoft.Phone.Controls; + + /// + /// Class for the page which shows Webpages from the BaseAddress + /// + public partial class ModulWebPage : PhoneApplicationPage + { + /// + /// Initializes a new instance of the class. + /// + public ModulWebPage() + { + this.InitializeComponent(); + } + + /// + /// Override the OnNavigatedTo method + /// + /// Arguments of navigation + protected override void OnNavigatedTo(NavigationEventArgs e) + { + if (NavigationContext.QueryString.ContainsKey(Constants.ParamLectureModulNumber)) + { + string number = NavigationContext.QueryString[Constants.ParamLectureModulNumber]; + this.WebmailBrowser.Navigate(new Uri(Constants.UrlLectureModulBaseAddr + number, UriKind.Absolute)); + } + + base.OnNavigatedTo(e); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml new file mode 100644 index 00000000..04b6ada9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs new file mode 100644 index 00000000..6a404776 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 11.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Pages.Lecture +{ + using System.Windows.Navigation; + using CampusAppWP8.Model.Lecture; + using CampusAppWP8.Resources; + using Microsoft.Phone.Controls; + + /// + /// Class for the page which shows details of an activity + /// + public partial class ResultDetailPage : PhoneApplicationPage + { + /// + /// Initializes a new instance of the class. + /// + public ResultDetailPage() + { + this.InitializeComponent(); + } + + /// + /// Override the OnNavigatedTo method + /// + /// Arguments of navigation + protected override void OnNavigatedTo(NavigationEventArgs e) + { + if (NavigationContext.QueryString.ContainsKey(Constants.ParamLectureActivityId)) + { + string activityId = NavigationContext.QueryString[Constants.ParamLectureActivityId]; + this.LoadActivity(int.Parse(activityId)); + } + + base.OnNavigatedTo(e); + } + + /// + /// Method load a certain Activity from the model + /// + /// id of the activity + private void LoadActivity(int activityId) + { + LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorageLectureModel); + if (list != null) + { + LectureActivity activity = list.GetActivity(activityId); + activity.createLectureString(); + activity.createCourseString(); + this.ContentPanel.DataContext = activity; + } + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml new file mode 100644 index 00000000..187ffc38 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + +