UserProfil.xaml.cs CampusAppWP8::Pages::Setting::UserProfil CampusAppWP8::Pages::Setting //----------------------------------------------------------------------- //<copyrightfile="UserProfil.xaml.cs"company="BTU/IIT"> //TheMITLicense(MIT).Copyright(c)2013BTU/IIT. //</copyright> //<author>Stubbfel</author> //<date>15.10.2013</date> //<summary>Implementstheuserprofil.xamlclass</summary> //----------------------------------------------------------------------- namespaceCampusAppWP8.Pages.Setting { usingSystem; usingSystem.Windows; usingSystem.Windows.Navigation; usingCampusAppWP8.Model.Setting; usingCampusAppWP8.Model.Utility; usingCampusAppWPortalLib8.Model.Utility; usingCampusAppWPortalLib8.Utility; usingMicrosoft.Phone.Controls; publicpartialclassUserProfil:PhoneApplicationPage { #regionMember privateUserProfilModeluserProfil; privateCourseListPickerItemListWp8ModelcourseList; #endregion #regionConstructor publicUserProfil() { this.InitializeComponent(); this.userProfil=Settings.UserProfil; this.LoadListPicker(); } #endregion #regionMethod #regionprotected protectedoverridevoidOnNavigatedFrom(NavigationEventArgse) { if(NavigationMode.Back==e.NavigationMode) { this.SaveProfile(); } } #endregion #regionprivate privatevoidLoadListPicker() { this.DefHeader.ProgressVisibility=Visibility.Visible; this.courseList=newCourseListPickerItemListWp8Model(); this.courseList.OnLoaded+=newCourseListPickerItemListWp8Model.OnIO(this.SetupListPickers); this.courseList.LoadCourseList(); } privatevoidSetupListPickers() { DegreeListPickerItemListModeldegreeList=newDegreeListPickerItemListModel(); SemesterListPickerItemListModelsemesterList=newSemesterListPickerItemListModel(); RoleListPickerItemListModelroleList=newRoleListPickerItemListModel(); CampusListPickerItemListModelcampusList=newCampusListPickerItemListModel(); this.Course.ItemsSource=this.courseList.List; this.Degree.ItemsSource=degreeList.List; this.Semster.ItemsSource=semesterList.List; this.Role.ItemsSource=roleList.List; this.Campus.ItemsSource=campusList.List; this.Course.SelectedIndex=this.courseList.GetIndexOrDefault(this.userProfil.Course.ToString().PadLeft(3,'0')); this.Degree.SelectedIndex=degreeList.GetIndexOrDefault(((int)this.userProfil.Degree).ToString()); this.Semster.SelectedIndex=semesterList.GetIndexOrDefault(this.userProfil.Semester.ToString()); this.Role.SelectedIndex=roleList.GetIndexOrDefault(this.userProfil.Role.ToString()); this.Campus.SelectedIndex=campusList.GetIndexOrDefault(((int)this.userProfil.DefaultCampus).ToString()); this.DefHeader.ProgressVisibility=Visibility.Collapsed; } privatevoidSaveProfile() { try { this.userProfil.Course=int.Parse(((ListPickerItemModel)this.Course.SelectedItem).Value); this.userProfil.Degree=(CampusAppWPortalLib8.Model.Settings.DegreeType)Enum.Parse(typeof(CampusAppWPortalLib8.Model.Settings.DegreeType),((ListPickerItemModel)this.Degree.SelectedItem).Value); this.userProfil.Semester=int.Parse(((ListPickerItemModel)this.Semster.SelectedItem).Value); this.userProfil.Role=(CampusAppWPortalLib8.Model.Settings.RoleType)Enum.Parse(typeof(CampusAppWPortalLib8.Model.Settings.RoleType),((ListPickerItemModel)this.Role.SelectedItem).Value); this.userProfil.DefaultCampus=(CampusAppWPortalLib8.Model.Settings.Campus)Enum.Parse(typeof(CampusAppWPortalLib8.Model.Settings.Campus),((ListPickerItemModel)this.Campus.SelectedItem).Value); } catch(Exceptione) { Logger.LogException(e); } } #endregion #endregion } }