diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 00d78264..e0f3e904 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -91,6 +91,39 @@ namespace CampusAppWP8 } return default(T); } + + /// + /// Method save any object to the IsolatedStorage + /// + /// key of the object + /// value of the object, if value == null => remove key + public static void SaveToAppState(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 LoadFromAppState(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 63d3a82e..3d9378d5 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -109,6 +109,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs index 32bbbbea..8f5b171e 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs @@ -82,6 +82,12 @@ namespace CampusAppWP8.Model.Lecture [XmlElement("modul")] public LectureModule Modul { get; set; } + /// + /// Gets or sets LectureTitel + /// + [XmlElement("titel")] + public string Title { get; set; } + /// /// Gets or sets the lecturers /// diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs new file mode 100644 index 00000000..ca79f582 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs @@ -0,0 +1,242 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Lecture +{ + using System.Collections.Generic; + using System.Runtime.Serialization; + using CampusAppWP8.Model.Utility; + using CampusAppWP8.Resources; + + /// + /// Model for the LecturePage + /// + [DataContract] + public class LecturePageModel + { + #region Members + + /// + /// List for the courses of the BTU + /// + /// + /// need to be extend to full list + /// + private List courseList; + + /// + /// List of the degrees + /// + private List degreeList; + + /// + /// List of the semester + /// + private List semesterList; + + /// + /// List for the number of semester + /// + private List numberList; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public LecturePageModel() + { + } + #endregion + + #region Proberty + + /// + /// Gets or sets the selected course index + /// + [DataMember] + public int SelectCourseIndex { get; set; } + + /// + /// Gets or sets the selected degree index + /// + [DataMember] + public int SelectDegreeIndex { get; set; } + + /// + /// Gets or sets the selected semester-index + /// + [DataMember] + public int SelectSemesterIndex { get; set; } + + /// + /// Gets or sets the selected from-index + /// + [DataMember] + public int SelectFromIndex { get; set; } + + /// + /// Gets or sets the selected to-index + /// + [DataMember] + public int SelectToIndex { get; set; } + + /// + /// Gets List for the courses of the BTU + /// + public List CourseList + { + get + { + return this.courseList; + } + } + + /// + /// Gets List of the degrees + /// + public List DegreeList + { + get + { + return this.degreeList; + } + } + + /// + /// Gets List of the semester + /// + public List SemesterList + { + get + { + return this.semesterList; + } + } + + /// + /// Gets List for the number of semester + /// + public List NumberList + { + get + { + return this.numberList; + } + } + #endregion + + #region Methods + + #region public + + /// + /// Load all ListPickerLists + /// + public void LoadLists() + { + this.LoadCourseList(); + this.LoadDegreeList(); + this.LoadNumberList(); + this.LoadSemesterList(); + } + + #endregion + + #region private + + /// + /// Load the NumberList + /// + private void LoadNumberList() + { + this.numberList = new List(); + this.numberList.Add(new ListPickerItemModel() { Text = "1", Value = "1" }); + this.numberList.Add(new ListPickerItemModel() { Text = "2", Value = "2" }); + this.numberList.Add(new ListPickerItemModel() { Text = "3", Value = "3" }); + this.numberList.Add(new ListPickerItemModel() { Text = "4", Value = "4" }); + } + + /// + /// Load the SemesterList + /// + private void LoadSemesterList() + { + this.semesterList = new List(); + this.semesterList.Add(new ListPickerItemModel() { Text = "SoSe 13", Value = "20131" }); + this.semesterList.Add(new ListPickerItemModel() { Text = "WiSe 13/14", Value = "20132" }); + this.semesterList.Add(new ListPickerItemModel() { Text = "SoSe 14", Value = "20131" }); + } + + /// + /// Load the DegreeList + /// + private void LoadDegreeList() + { + this.degreeList = new List(); + this.degreeList.Add(new ListPickerItemModel() { Text = AppResources.Degree_Bachelor, Value = "82" }); + this.degreeList.Add(new ListPickerItemModel() { Text = AppResources.Degree_Master, Value = "88" }); + this.degreeList.Add(new ListPickerItemModel() { Text = AppResources.Degree_Diploma, Value = "11" }); + } + + /// + /// Load the DegreeList + /// + private void LoadCourseList() + { + this.courseList = new List(); + this.courseList.Add(new ListPickerItemModel() { Text = "Architektur", Value = "013" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Bauingenieurwesen", Value = "017" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Betriebswirtschaftslehre", Value = "021" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Wirtschaftsrecht für Technologieunternehmen", Value = "042" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Elektrotechnik", Value = "048" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Informatik ", Value = "079" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Maschinenbau", Value = "104" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Mathematik", Value = "105" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Physik ", Value = "128" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Wirtschaftsingenieurwesen", Value = "179" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Wirtschaftswissenschaften ", Value = "184" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Biomedizinische Gerätetechnik ", Value = "215" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Verfahrenstechnik", Value = "226" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Wirtschaftsmathematik ", Value = "276" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Kultur und Technik ", Value = "711" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Physik der Halbleiter-Technologie", Value = "744" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Angewandte Mathematik ", Value = "749" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Technologie- und Innovationsmanagement", Value = "764" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Stadt- und Regionalplanung", Value = "766" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Informations- und Medientechnik ", Value = "767" }); + this.courseList.Add(new ListPickerItemModel() { Text = "World Heritage Studies", Value = "768" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Umweltingenieurwesen und Verfahrenstechnik", Value = "770" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Environmental and Resource Management", Value = "771" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Landnutzung und Wasserbewirtschaftung", Value = "772" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Bauen und Erhalten", Value = "773" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Umweltingenieurwesen", Value = "774" }); + this.courseList.Add(new ListPickerItemModel() { Text = "eBusiness", Value = "794" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Civil Engineering", Value = "798" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Structural Engineering", Value = "799" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Electrical Power Engineering ", Value = "800" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Euro Hydroinformatics and Water Management", Value = "841" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Technologien Biogener Rohstoffe", Value = "842" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Environmental Technologies", Value = "843" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Process Engineering and Plant Design", Value = "844" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Architekturvermittlung", Value = "845" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Nachwachsende Rohstoffe und Erneuerbare Energien", Value = "851" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Energieträger aus Biomasse und Abfällen", Value = "852" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Power Engineering", Value = "853" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Verfahrenstechnik - Prozess- und Anlagentechnik", Value = "857" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Architektur.Studium.Generale", Value = "858" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Verarbeitungstechnologien der Werkstoffe", Value = "860" }); + this.courseList.Add(new ListPickerItemModel() { Text = "Forensic Sciences and Engineering", Value = "871" }); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index 2ba1e36c..95c960be 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.Lecture using System; using System.Collections.Generic; using System.Windows; + using System.Windows.Media.Imaging; using System.Windows.Navigation; using CampusAppWP8.Feed.Lecture; using CampusAppWP8.Model.Lecture; @@ -17,14 +18,14 @@ namespace CampusAppWP8.Pages.Lecture using CampusAppWP8.Resources; using CampusAppWP8.Utility; using Microsoft.Phone.Controls; - using System.Windows.Media; - using System.Windows.Media.Imaging; /// /// Class for the LecturePage /// public partial class LecturePage : PhoneApplicationPage { + #region Member + /// /// actual LectureAPI /// @@ -36,106 +37,120 @@ namespace CampusAppWP8.Pages.Lecture /// /// need to be extend to full list /// - private List courseList = new List() - { - new ListPickerItemModel() - { - Text = "Architektur", Value = "013" - }, - new ListPickerItemModel() - { - Text = "Bauingenieurwesen", Value = "017" - }, - new ListPickerItemModel() - { - Text = "Betriebswirtschaftslehre", Value = "021" - } - }; + private LecturePageModel pageModel; - /// - /// List of the degrees - /// - private List degreeList = new List() - { - new ListPickerItemModel() - { - Text = AppResources.Degree_Bachelor, Value = "82" - }, - new ListPickerItemModel() - { - Text = AppResources.Degree_Master, Value = "88" - }, - new ListPickerItemModel() - { - Text = AppResources.Degree_Diploma, Value = "11" - } - }; - - /// - /// List of the semester - /// - private List semesterList = new List() - { - new ListPickerItemModel() - { - Text = "SoSe 13", Value = "20131" - }, - new ListPickerItemModel() - { - Text = "WiSe 13/14", Value = "20132" - }, - new ListPickerItemModel() - { - Text = "SoSe 14", Value = "20141" - } - }; - - /// - /// List for the number of semester - /// - private List numberList = new List() - { - new ListPickerItemModel() - { - Text = "1", Value = "1" - }, - new ListPickerItemModel() - { - Text = "2", Value = "2" - }, - new ListPickerItemModel() - { - Text = "3", Value = "3" - }, - new ListPickerItemModel() - { - Text = "4", Value = "4" - } - }; + #endregion + #region Constructor /// /// Initializes a new instance of the class. /// public LecturePage() { this.InitializeComponent(); + this.LoadPageModel(); this.SetupListPickers(); if ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible) { - this.SearchButtonImg.Source = new BitmapImage(new Uri("/Assets/icons/search_159_dark.png",UriKind.Relative)); + this.SearchButtonImg.Source = new BitmapImage(new Uri("/Assets/icons/search_159_dark.png", UriKind.Relative)); } } + #endregion + + #region methods + + #region protected + /// + /// Methods overrides the OnNavigatedFrom-Method + /// + /// some NavigationEventArgs + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode) + { + // delete all models + App.SaveToIsolatedStorage(Constants.IsolatedStorage_LecturePageModel, null); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_LectureModel, null); + } + else + { + this.StoreSelectedIndex(); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_LecturePageModel, this.pageModel); + } + + base.OnNavigatedFrom(e); + } + + #endregion + + #region private + + /// + /// Load the PageModel + /// + private void LoadPageModel() + { + this.pageModel = new LecturePageModel(); + this.pageModel.LoadLists(); + } + /// /// Method sets the ItemSource of the ListPickers /// private void SetupListPickers() { - this.Course.ItemsSource = this.courseList; - this.Degree.ItemsSource = this.degreeList; - this.From.ItemsSource = this.numberList; - this.To.ItemsSource = this.numberList; - this.Semester.ItemsSource = this.semesterList; + this.Course.ItemsSource = this.pageModel.CourseList; + this.Degree.ItemsSource = this.pageModel.DegreeList; + this.From.ItemsSource = this.pageModel.NumberList; + this.To.ItemsSource = this.pageModel.NumberList; + this.Semester.ItemsSource = this.pageModel.SemesterList; + + // load values from last request + LecturePageModel lastPageModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LecturePageModel); + if (lastPageModel != null) + { + this.SetLastSelectedIndex(lastPageModel); + } + + this.SetSelectedIndex(); + } + + /// + /// Method set the last selected index of the ListPickers + /// + /// Last PageModel + private void SetLastSelectedIndex(LecturePageModel lastPageModel) + { + this.pageModel.SelectCourseIndex = lastPageModel.SelectCourseIndex; + this.pageModel.SelectDegreeIndex = lastPageModel.SelectDegreeIndex; + this.pageModel.SelectFromIndex = lastPageModel.SelectFromIndex; + this.pageModel.SelectToIndex = lastPageModel.SelectToIndex; + this.pageModel.SelectSemesterIndex = lastPageModel.SelectSemesterIndex; + } + + /// + /// Method set the last selected index of the ListPickers + /// + private void SetSelectedIndex() + { + this.Course.SelectedIndex = this.pageModel.SelectCourseIndex; + this.Degree.SelectedIndex = this.pageModel.SelectDegreeIndex; + this.Semester.SelectedIndex = this.pageModel.SelectSemesterIndex; + this.From.SelectedIndex = this.pageModel.SelectFromIndex; + this.To.SelectedIndex = this.pageModel.SelectToIndex; + } + + /// + /// Method store the actual selectIndex to the models + /// + private void StoreSelectedIndex() + { + this.pageModel.SelectCourseIndex = this.Course.SelectedIndex; + this.pageModel.SelectDegreeIndex = this.Degree.SelectedIndex; + this.pageModel.SelectSemesterIndex = this.Semester.SelectedIndex; + this.pageModel.SelectFromIndex = this.From.SelectedIndex; + this.pageModel.SelectToIndex = this.To.SelectedIndex; } /// @@ -186,5 +201,9 @@ namespace CampusAppWP8.Pages.Lecture Uri url = new Uri(Constants.PathLecture_ResultPage, UriKind.Relative); NavigationService.Navigate(url); } + + #endregion + + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml index 04b6ada9..dfea3521 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml @@ -38,7 +38,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml index 187ffc38..cac704bf 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml @@ -33,7 +33,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs index 6486db91..fbb9157a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml.cs @@ -20,11 +20,6 @@ namespace CampusAppWP8.Pages.Lecture /// public partial class ResultPage : PhoneApplicationPage { - /// - /// Reference of the button which was lastClicked - /// - private Button lastClickedButton; - /// /// Initializes a new instance of the class. /// @@ -39,8 +34,15 @@ namespace CampusAppWP8.Pages.Lecture /// Arguments of navigation protected override void OnNavigatedTo(NavigationEventArgs e) { - LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LectureModel); - this.ResultList.ItemsSource = list.Activities; + LectureList list = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LectureModel); + if (list == null) + { + Uri url = new Uri(Constants.PathLecture_LecturePage, UriKind.Relative); + NavigationService.Navigate(url); + return; + } + + this.ResultList.ItemsSource = list.Activities; base.OnNavigatedTo(e); } @@ -53,15 +55,14 @@ namespace CampusAppWP8.Pages.Lecture { Button button = (Button)sender; StackPanel parent = (StackPanel)button.Parent; - if (this.lastClickedButton != null && !this.lastClickedButton.Equals(button)) - { - this.HideOptions(parent); - } - this.lastClickedButton = button; - Button link = (Button)parent.FindName("Link"); Button details = (Button)parent.FindName("Details"); + if (link.Tag == null) + { + link.IsEnabled = false; + } + this.ToogleVisibility(link); this.ToogleVisibility(details); } diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index f6d9df87..de490af5 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -69,6 +69,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_LecturePageModel ähnelt. + /// + internal static string IsolatedStorage_LecturePageModel { + get { + return ResourceManager.GetString("IsolatedStorage_LecturePageModel", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die lsf_auszug ähnelt. /// @@ -150,6 +159,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/LecturePage.xaml ähnelt. + /// + internal static string PathLecture_LecturePage { + get { + return ResourceManager.GetString("PathLecture_LecturePage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/ModulWebPage.xaml ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 3549c065..51ff2160 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -168,4 +168,10 @@ http://www.zv.tu-cottbus.de/LSFveranst/LSF4 + + IsolatedStorage_LecturePageModel + + + /Pages/Lecture/LecturePage.xaml + \ No newline at end of file