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.Navigation; usingCampusAppWP8.Model.Setting; usingCampusAppWP8.Model.Utility; usingCampusAppWP8.Utility; usingMicrosoft.Phone.Controls; publicpartialclassUserProfil:PhoneApplicationPage { privateUserProfilModeluserProfil; publicUserProfil() { this.InitializeComponent(); this.userProfil=Settings.UserProfil; this.SetupListPickers(); } protectedoverridevoidOnNavigatedFrom(NavigationEventArgse) { if(NavigationMode.Back==e.NavigationMode) { this.SaveProfile(); } } privatevoidSetupListPickers() { CourseListPickerItemListModelcourseList=newCourseListPickerItemListModel(); DegreeListPickerItemListModeldegreeList=newDegreeListPickerItemListModel(); SemesterListPickerItemListModelsemesterList=newSemesterListPickerItemListModel(); RoleListPickerItemListModelroleList=newRoleListPickerItemListModel(); CampusListPickerItemListModelcampusList=newCampusListPickerItemListModel(); this.Course.ItemsSource=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=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()); } 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); } } } }