diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 3a14e6e9..9c9b665f 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -166,14 +166,12 @@ namespace CampusAppWP8 // Dieser Code wird beim Schließen der Anwendung nicht ausgeführt private void Application_Deactivated(object sender, DeactivatedEventArgs e) { - Settings.UserProfil.SaveData(); } // Code, der beim Schließen der Anwendung ausgeführt wird (z. B. wenn der Benutzer auf "Zurück" klickt) // Dieser Code wird beim Deaktivieren der Anwendung nicht ausgeführt private void Application_Closing(object sender, ClosingEventArgs e) { - Settings.UserProfil.SaveData(); // Sicherstellen, dass der erforderliche Anwendungszustand hier beibehalten wird } diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 923abff0..847a75fc 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -100,10 +100,10 @@ - - - - + + + + UserProfil.xaml diff --git a/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs b/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs index 56013f06..64dc798b 100644 --- a/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs +++ b/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs @@ -22,7 +22,6 @@ namespace CampusAppWP8.File.Setting /// /// Initializes a new instance of the class. /// - /// automatic loading of the data public UserProfilFile() : base(ModelType.File, Constants.FileProfil_User) { diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs index 7b8d7481..815ace1f 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LecturePageModel.cs @@ -27,17 +27,17 @@ namespace CampusAppWP8.Model.Lecture /// /// need to be extend to full list /// - private List courseList; + private CourseListPickerItemListModel courseList; /// /// List of the degrees /// - private List degreeList; + private DegreeListPickerItemListModel degreeList; /// /// List of the semester /// - private List semesterList; + private SemesterListPickerItemListModel semesterList; /// /// List for the number of semester (from) diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs index 38da0528..59eac750 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs @@ -51,7 +51,7 @@ namespace CampusAppWP8.Model.Setting /// /// Gets or Sets the course of the user /// - private int course = UserProfilModel.DefaultCourseNumber; + private int course = UserProfilModel.DefaultCourseNumber; /// /// Gets or Sets the role of the user diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel .cs b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel .cs deleted file mode 100644 index 04631bff..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel .cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Company copyright tag.List -// -// stubbfel -// 25.07.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Model.Utility -{ - using System.Linq; - public class CourseListPickerItemListModel : ListPickerItemListModel - { - #region Constructor - - - /// - /// Initializes a new instance of the class. - /// - public CourseListPickerItemListModel() - : base() - { - } - - #endregion - - #region Method - - #region private - - protected override void LoadList() - { - this.addItem(new ListPickerItemModel("013", "Architektur")); - this.addItem(new ListPickerItemModel("017", "Bauingenieurwesen")); - this.addItem(new ListPickerItemModel("021", "Betriebswirtschaftslehre")); - this.addItem(new ListPickerItemModel("042", "Wirtschaftsrecht für Technologieunternehmen")); - this.addItem(new ListPickerItemModel("048", "Elektrotechnik")); - this.addItem(new ListPickerItemModel("079", "Informatik ")); - this.addItem(new ListPickerItemModel("104", "Maschinenbau")); - this.addItem(new ListPickerItemModel("105", "Mathematik")); - this.addItem(new ListPickerItemModel("128", "Physik ")); - this.addItem(new ListPickerItemModel("179", "Wirtschaftsingenieurwesen")); - this.addItem(new ListPickerItemModel("184", "Wirtschaftswissenschaften ")); - this.addItem(new ListPickerItemModel("215", "Biomedizinische Gerätetechnik ")); - this.addItem(new ListPickerItemModel("226", "Verfahrenstechnik")); - this.addItem(new ListPickerItemModel("276", "Wirtschaftsmathematik ")); - this.addItem(new ListPickerItemModel("711", "Kultur und Technik ")); - this.addItem(new ListPickerItemModel("744", "Physik der Halbleiter-Technologie")); - this.addItem(new ListPickerItemModel("749", "Angewandte Mathematik ")); - this.addItem(new ListPickerItemModel("764", "Technologie- und Innovationsmanagement")); - this.addItem(new ListPickerItemModel("766", "Stadt- und Regionalplanung")); - this.addItem(new ListPickerItemModel("767", "Informations- und Medientechnik ")); - this.addItem(new ListPickerItemModel("768", "World Heritage Studies")); - this.addItem(new ListPickerItemModel("770", "Umweltingenieurwesen und Verfahrenstechnik")); - this.addItem(new ListPickerItemModel("771", "Environmental and Resource Management")); - this.addItem(new ListPickerItemModel("772", "Landnutzung und Wasserbewirtschaftung")); - this.addItem(new ListPickerItemModel("773", "Bauen und Erhalten")); - this.addItem(new ListPickerItemModel("774", "Umweltingenieurwesen")); - this.addItem(new ListPickerItemModel("794", "eBusiness")); - this.addItem(new ListPickerItemModel("798", "Civil Engineering")); - this.addItem(new ListPickerItemModel("799", "Structural Engineering")); - this.addItem(new ListPickerItemModel("800", "Electrical Power Engineering ")); - this.addItem(new ListPickerItemModel("841", "Euro Hydroinformatics and Water Management")); - this.addItem(new ListPickerItemModel("842", "Technologien Biogener Rohstoffe")); - this.addItem(new ListPickerItemModel("843", "Environmental Technologies")); - this.addItem(new ListPickerItemModel("844", "Process Engineering and Plant Design")); - this.addItem(new ListPickerItemModel("845", "Architekturvermittlung")); - this.addItem(new ListPickerItemModel("851", "Nachwachsende Rohstoffe und Erneuerbare Energien")); - this.addItem(new ListPickerItemModel("852", "Energieträger aus Biomasse und Abfällen")); - this.addItem(new ListPickerItemModel("853", "Power Engineering")); - this.addItem(new ListPickerItemModel("857", "Verfahrenstechnik - Prozess- und Anlagentechnik")); - this.addItem(new ListPickerItemModel("858", "Architektur.Studium.Generale")); - this.addItem(new ListPickerItemModel("860", "Verarbeitungstechnologien der Werkstoffe")); - this.addItem(new ListPickerItemModel("871", "Forensic Sciences and Engineering")); - this.List = this.List.OrderBy(o => o.Text).ToList(); - } - - #endregion - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs new file mode 100644 index 00000000..4c85b0f8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs @@ -0,0 +1,86 @@ +// +// Company copyright tag.List +// +// stubbfel +// 25.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using System.Linq; + + /// + /// This is a class for the courseList + /// + public class CourseListPickerItemListModel : ListPickerItemListModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public CourseListPickerItemListModel() + : base() + { + } + + #endregion + + #region Method + + #region private + + /// + /// Overrides the LoadList-Method + /// + protected override void LoadList() + { + this.AddItem(new ListPickerItemModel("013", "Architektur")); + this.AddItem(new ListPickerItemModel("017", "Bauingenieurwesen")); + this.AddItem(new ListPickerItemModel("021", "Betriebswirtschaftslehre")); + this.AddItem(new ListPickerItemModel("042", "Wirtschaftsrecht für Technologieunternehmen")); + this.AddItem(new ListPickerItemModel("048", "Elektrotechnik")); + this.AddItem(new ListPickerItemModel("079", "Informatik ")); + this.AddItem(new ListPickerItemModel("104", "Maschinenbau")); + this.AddItem(new ListPickerItemModel("105", "Mathematik")); + this.AddItem(new ListPickerItemModel("128", "Physik ")); + this.AddItem(new ListPickerItemModel("179", "Wirtschaftsingenieurwesen")); + this.AddItem(new ListPickerItemModel("184", "Wirtschaftswissenschaften ")); + this.AddItem(new ListPickerItemModel("215", "Biomedizinische Gerätetechnik ")); + this.AddItem(new ListPickerItemModel("226", "Verfahrenstechnik")); + this.AddItem(new ListPickerItemModel("276", "Wirtschaftsmathematik ")); + this.AddItem(new ListPickerItemModel("711", "Kultur und Technik ")); + this.AddItem(new ListPickerItemModel("744", "Physik der Halbleiter-Technologie")); + this.AddItem(new ListPickerItemModel("749", "Angewandte Mathematik ")); + this.AddItem(new ListPickerItemModel("764", "Technologie- und Innovationsmanagement")); + this.AddItem(new ListPickerItemModel("766", "Stadt- und Regionalplanung")); + this.AddItem(new ListPickerItemModel("767", "Informations- und Medientechnik ")); + this.AddItem(new ListPickerItemModel("768", "World Heritage Studies")); + this.AddItem(new ListPickerItemModel("770", "Umweltingenieurwesen und Verfahrenstechnik")); + this.AddItem(new ListPickerItemModel("771", "Environmental and Resource Management")); + this.AddItem(new ListPickerItemModel("772", "Landnutzung und Wasserbewirtschaftung")); + this.AddItem(new ListPickerItemModel("773", "Bauen und Erhalten")); + this.AddItem(new ListPickerItemModel("774", "Umweltingenieurwesen")); + this.AddItem(new ListPickerItemModel("794", "eBusiness")); + this.AddItem(new ListPickerItemModel("798", "Civil Engineering")); + this.AddItem(new ListPickerItemModel("799", "Structural Engineering")); + this.AddItem(new ListPickerItemModel("800", "Electrical Power Engineering ")); + this.AddItem(new ListPickerItemModel("841", "Euro Hydroinformatics and Water Management")); + this.AddItem(new ListPickerItemModel("842", "Technologien Biogener Rohstoffe")); + this.AddItem(new ListPickerItemModel("843", "Environmental Technologies")); + this.AddItem(new ListPickerItemModel("844", "Process Engineering and Plant Design")); + this.AddItem(new ListPickerItemModel("845", "Architekturvermittlung")); + this.AddItem(new ListPickerItemModel("851", "Nachwachsende Rohstoffe und Erneuerbare Energien")); + this.AddItem(new ListPickerItemModel("852", "Energieträger aus Biomasse und Abfällen")); + this.AddItem(new ListPickerItemModel("853", "Power Engineering")); + this.AddItem(new ListPickerItemModel("857", "Verfahrenstechnik - Prozess- und Anlagentechnik")); + this.AddItem(new ListPickerItemModel("858", "Architektur.Studium.Generale")); + this.AddItem(new ListPickerItemModel("860", "Verarbeitungstechnologien der Werkstoffe")); + this.AddItem(new ListPickerItemModel("871", "Forensic Sciences and Engineering")); + this.List = this.List.OrderBy(o => o.Text).ToList(); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel .cs b/CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel.cs similarity index 64% rename from CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel .cs rename to CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel.cs index eb0df31b..9fc79af9 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel .cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel.cs @@ -1,4 +1,4 @@ -// +// // Company copyright tag.List // // stubbfel @@ -7,14 +7,16 @@ namespace CampusAppWP8.Model.Utility { using CampusAppWP8.Resources; - using System.Linq; + + /// + /// This Class creates a list of degrees + /// public class DegreeListPickerItemListModel : ListPickerItemListModel { #region Constructor - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public DegreeListPickerItemListModel() : base() @@ -27,11 +29,14 @@ namespace CampusAppWP8.Model.Utility #region private + /// + /// Overrides the LoadList-Method + /// protected override void LoadList() { - this.addItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.BACHELOR.ToString(), AppResources.Degree_Bachelor)); - this.addItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.MASTER.ToString(), AppResources.Degree_Master)); - this.addItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.DIPLOM.ToString(), AppResources.Degree_Diploma)); + this.AddItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.BACHELOR.ToString(), AppResources.Degree_Bachelor)); + this.AddItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.MASTER.ToString(), AppResources.Degree_Master)); + this.AddItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.DIPLOM.ToString(), AppResources.Degree_Diploma)); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs index 8c62b512..5cb196fb 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs @@ -8,17 +8,23 @@ namespace CampusAppWP8.Model.Utility { using System.Collections.Generic; + + /// + /// Class for a List of ListPickerItems + /// public class ListPickerItemListModel { #region Members - List list; + /// + /// reference of the itemList + /// + private List list; #endregion #region Constructor - /// /// Initializes a new instance of the class. /// @@ -32,12 +38,16 @@ namespace CampusAppWP8.Model.Utility #region Property + /// + /// Gets or sets the ItemList + /// public List List { get { return this.list; } + set { if (value != this.list) @@ -58,7 +68,7 @@ namespace CampusAppWP8.Model.Utility /// /// a certain value /// return index of value or default(0) - virtual public int GetIndexOrDefault(string value) + public virtual int GetIndexOrDefault(string value) { int index = 0; int i = 0; @@ -76,23 +86,42 @@ namespace CampusAppWP8.Model.Utility return index; } - public void addItem(string value, string text) + /// + /// add an new item to the list + /// + /// value of the item + /// text of the item + public void AddItem(string value, string text) { - this.addItem(new ListPickerItemModel(value, text)); + this.AddItem(new ListPickerItemModel(value, text)); } - public void addItem(ListPickerItemModel item) + /// + /// add an new item to the list + /// + /// new item of the list + public void AddItem(ListPickerItemModel item) { this.list.Add(item); } - - public bool removeItem(string value, string text) + /// + /// remove an item + /// + /// value of the item + /// text of the item + /// true if removing was successful, otherwise false + public bool RemoveItem(string value, string text) { - return this.removeItem(new ListPickerItemModel(value, text)); + return this.RemoveItem(new ListPickerItemModel(value, text)); } - public bool removeItem(ListPickerItemModel item) + /// + /// remove an item + /// + /// item which has to be remove + /// true if removing was successful, otherwise false + public bool RemoveItem(ListPickerItemModel item) { return this.list.Remove(item); } @@ -101,7 +130,13 @@ namespace CampusAppWP8.Model.Utility #region private - virtual protected void LoadList() + /// + /// Method load an default list + /// + /// + /// load an empty list + /// + protected virtual void LoadList() { return; } diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs index c37e6f29..5dceec55 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs @@ -12,7 +12,6 @@ namespace CampusAppWP8.Model.Utility /// public class ListPickerItemModel { - /// /// Initializes a new instance of the class. /// @@ -30,6 +29,7 @@ namespace CampusAppWP8.Model.Utility this.Value = value; this.Text = text; } + /// /// Gets or sets the Value of an Item /// diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel .cs b/CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel.cs similarity index 63% rename from CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel .cs rename to CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel.cs index daa4b518..72aac6b8 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel .cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel.cs @@ -1,4 +1,4 @@ -// +// // Company copyright tag.List // // stubbfel @@ -7,14 +7,16 @@ namespace CampusAppWP8.Model.Utility { using CampusAppWP8.Resources; - using System.Linq; + + /// + /// Class for the RoleList + /// public class RoleListPickerItemListModel : ListPickerItemListModel { #region Constructor - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public RoleListPickerItemListModel() : base() @@ -27,10 +29,13 @@ namespace CampusAppWP8.Model.Utility #region private + /// + /// Overrides the LoadList-Method + /// protected override void LoadList() { - this.addItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.RoleType.STUDENT.ToString(), AppResources.Setting_RoleStudent)); - this.addItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.RoleType.STAFF.ToString(), AppResources.Setting_RoleStaff)); + this.AddItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.RoleType.STUDENT.ToString(), AppResources.Setting_RoleStudent)); + this.AddItem(new ListPickerItemModel(CampusAppWP8.Model.Setting.UserProfilModel.RoleType.STAFF.ToString(), AppResources.Setting_RoleStaff)); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel .cs b/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs similarity index 61% rename from CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel .cs rename to CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs index 95d47d6f..bd6e2159 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel .cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs @@ -7,14 +7,16 @@ namespace CampusAppWP8.Model.Utility { using CampusAppWP8.Resources; - using System.Linq; + + /// + /// Class for the SemesterList + /// public class SemesterListPickerItemListModel : ListPickerItemListModel { #region Constructor - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public SemesterListPickerItemListModel() : base() @@ -27,11 +29,14 @@ namespace CampusAppWP8.Model.Utility #region private + /// + /// Overrides the LoadList-Method + /// protected override void LoadList() { - this.addItem(new ListPickerItemModel("20131", "SoSe 13")); - this.addItem(new ListPickerItemModel("20132", "WiSe 13/14")); - this.addItem(new ListPickerItemModel("20141", "SoSe 14")); + this.AddItem(new ListPickerItemModel("20131", "SoSe 13")); + this.AddItem(new ListPickerItemModel("20132", "WiSe 13/14")); + this.AddItem(new ListPickerItemModel("20141", "SoSe 14")); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index 37f46e87..6d9b5f85 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -10,13 +10,11 @@ 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; using CampusAppWP8.Model.Utility; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; using Microsoft.Phone.Controls; /// diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs index b55ab3a9..f0b70686 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs @@ -1,45 +1,55 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Navigation; -using Microsoft.Phone.Controls; -using Microsoft.Phone.Shell; -using CampusAppWP8.Model.Setting; -using CampusAppWP8.File.Setting; -using CampusAppWP8.Model.Utility; -using CampusAppWP8.Utility; - +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.07.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Pages.Setting { + using System; + using System.Windows.Navigation; + using CampusAppWP8.File.Setting; + using CampusAppWP8.Model.Utility; + using CampusAppWP8.Utility; + using Microsoft.Phone.Controls; + + /// + /// Class for the UserProfilePage + /// public partial class UserProfil : PhoneApplicationPage { - UserProfilFile userFile; + /// + /// Reference of the profileFile + /// + private UserProfilFile userFile; + + /// + /// Initializes a new instance of the class. + /// public UserProfil() { - InitializeComponent(); - userFile = Settings.UserProfil; + this.InitializeComponent(); + this.userFile = Settings.UserProfil; this.SetupListPickers(); - } - - #region protected - /// /// Override the OnNavigatedFrom method /// /// Arguments of navigation protected override void OnNavigatedFrom(NavigationEventArgs e) { - this.SaveProfile(); + if (NavigationMode.Back == e.NavigationMode) + { + this.SaveProfile(); + } } - #endregion - + /// + /// Method sets the ItemSource of the ListPickers + /// private void SetupListPickers() { CourseListPickerItemListModel courseList = new CourseListPickerItemListModel(); @@ -52,20 +62,24 @@ namespace CampusAppWP8.Pages.Setting this.Semster.ItemsSource = semesterList.List; this.Role.ItemsSource = roleList.List; - this.Course.SelectedIndex = courseList.GetIndexOrDefault(userFile.Model.Course.ToString().PadLeft(3,'0')); - this.Degree.SelectedIndex = degreeList.GetIndexOrDefault(userFile.Model.Degree.ToString()); - this.Semster.SelectedIndex = semesterList.GetIndexOrDefault(userFile.Model.Semester.ToString()); - this.Role.SelectedIndex = roleList.GetIndexOrDefault(userFile.Model.Role.ToString()); + this.Course.SelectedIndex = courseList.GetIndexOrDefault(this.userFile.Model.Course.ToString().PadLeft(3, '0')); + this.Degree.SelectedIndex = degreeList.GetIndexOrDefault(this.userFile.Model.Degree.ToString()); + this.Semster.SelectedIndex = semesterList.GetIndexOrDefault(this.userFile.Model.Semester.ToString()); + this.Role.SelectedIndex = roleList.GetIndexOrDefault(this.userFile.Model.Role.ToString()); } + /// + /// Method save the current profile + /// private void SaveProfile() { try { - userFile.Model.Course = int.Parse(((ListPickerItemModel)this.Course.SelectedItem).Value); - userFile.Model.Degree = (CampusAppWP8.Model.Setting.UserProfilModel.DegreeType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType), ((ListPickerItemModel)this.Degree.SelectedItem).Value); - userFile.Model.Semester = int.Parse(((ListPickerItemModel)this.Semster.SelectedItem).Value); - userFile.Model.Role = (CampusAppWP8.Model.Setting.UserProfilModel.RoleType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.RoleType), ((ListPickerItemModel)this.Role.SelectedItem).Value); + this.userFile.Model.Course = int.Parse(((ListPickerItemModel)this.Course.SelectedItem).Value); + this.userFile.Model.Degree = (CampusAppWP8.Model.Setting.UserProfilModel.DegreeType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType), ((ListPickerItemModel)this.Degree.SelectedItem).Value); + this.userFile.Model.Semester = int.Parse(((ListPickerItemModel)this.Semster.SelectedItem).Value); + this.userFile.Model.Role = (CampusAppWP8.Model.Setting.UserProfilModel.RoleType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.RoleType), ((ListPickerItemModel)this.Role.SelectedItem).Value); + this.userFile.SaveData(); } catch (Exception e) {