UserProfil.xaml.cs CampusAppWP8::Pages::Setting::UserProfil CampusAppWP8::Pages::Setting //----------------------------------------------------------------------- //<copyrightfile="UserProfil.xaml.cs"company="BTU/IIT"> //Companycopyrighttag. //</copyright> //<author>stubbfel</author> //<sience>23.07.2013</sience> //---------------------------------------------------------------------- namespaceCampusAppWP8.Pages.Setting { usingSystem; usingSystem.Windows; usingSystem.Windows.Navigation; usingCampusAppWP8.Model.Setting; usingCampusAppWP8.Model.Utility; usingCampusAppWPortalLib8.Utility; usingMicrosoft.Phone.Controls; publicpartialclassUserProfil:PhoneApplicationPage { #regionMember privateUserProfilModeluserProfil; privateCourseListPickerItemListModelcourseList; #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.ProgressBar.Visibility=Visibility.Visible; this.courseList=newCourseListPickerItemListModel(); this.courseList.OnLoaded+=newCourseListPickerItemListModel.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.ProgressBar.Visibility=Visibility.Collapsed; } privatevoidSaveProfile() { try { this.userProfil.Course=int.Parse(((ListPickerItemModel)this.Course.SelectedItem).Value); this.userProfil.Degree=(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.DegreeType),((ListPickerItemModel)this.Degree.SelectedItem).Value); this.userProfil.Semester=int.Parse(((ListPickerItemModel)this.Semster.SelectedItem).Value); this.userProfil.Role=(CampusAppWP8.Model.Setting.UserProfilModel.RoleType)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.RoleType),((ListPickerItemModel)this.Role.SelectedItem).Value); this.userProfil.DefaultCampus=(CampusAppWP8.Model.Setting.UserProfilModel.Campus)Enum.Parse(typeof(CampusAppWP8.Model.Setting.UserProfilModel.Campus),((ListPickerItemModel)this.Campus.SelectedItem).Value); } catch(Exceptione) { Logger.LogException(e); } } #endregion #endregion } }