diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 30b3410b..847a75fc 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -98,7 +98,18 @@ + + + + + + + + + UserProfil.xaml + + @@ -290,6 +301,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs b/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs new file mode 100644 index 00000000..64dc798b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/File/Setting/UserProfilFile.cs @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.File.Setting +{ + using System.IO; + using CampusAppWP8.Model; + using CampusAppWP8.Model.Setting; + using CampusAppWP8.Resources; + + /// + /// Class for handle the user-profile-file + /// + public class UserProfilFile : XmlModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public UserProfilFile() + : base(ModelType.File, Constants.FileProfil_User) + { + this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad); + this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave); + } + + // Constructor + #endregion + + /// + /// Method implement CheckIsFileUpToDate()-Method . + /// + /// model object + /// file info object + /// true, if file is up-to-date, otherwise false + private bool CheckIsFileUpToDateOnLoad(UserProfilModel model, FileInfo info) + { + if (model == null) + { + return true; + } + + return false; + } + + /// + /// Method implement CheckIsFileUpToDate()-Method . + /// + /// model object + /// file info object + /// true, if file is up-to-date, otherwise false + private bool CheckIsFileUpToDateOnSave(UserProfilModel model, FileInfo info) + { + if (model != null && !model.HasChanged()) + { + return true; + } + + return false; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs new file mode 100644 index 00000000..59eac750 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/UserProfilModel.cs @@ -0,0 +1,258 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Setting +{ + using System.Xml.Serialization; + using CampusAppWP8.Resources; + + /// + /// Model for the profile of an user + /// + [XmlRoot("root")] + public class UserProfilModel + { + #region Members + + /// + /// constant for the first validate semester + /// + private static readonly int FirstSemester = int.Parse(Constants.Valid_FirstSemseter); + + /// + /// constant for the last validate semester + /// + private static readonly int LastSemester = int.Parse(Constants.Valid_LastSemseter); + + /// + /// constant for the max. number of a validate course + /// + private static readonly int MaxCourseNumber = int.Parse(Constants.Valid_MaxCourseNumber); + + /// + /// constant for the default value of a semester + /// + private static readonly int DefaultSemester = int.Parse(Constants.Setting_DefaultSemester); + + /// + /// constant for the default value of a courseNumber + /// + private static readonly int DefaultCourseNumber = int.Parse(Constants.Setting_DefaultCourseNumber); + + /// + /// Flag which indicates that any properties has been changed + /// + private bool changed = false; + + /// + /// Gets or Sets the course of the user + /// + private int course = UserProfilModel.DefaultCourseNumber; + + /// + /// Gets or Sets the role of the user + /// + private RoleType role = RoleType.STUDENT; + + /// + /// Gets or Sets the degree of the user + /// + private DegreeType degree = DegreeType.BACHELOR; + + /// + /// Gets or Sets the semester of the user + /// + private int semester = UserProfilModel.DefaultSemester; + + #endregion + + #region Enums + /// + /// Specifies the degrees. + /// + public enum DegreeType + { + /// + /// bachelor degree + /// + BACHELOR = 82, + + /// + /// master degree + /// + MASTER = 88, + + /// + /// diploma degree + /// + DIPLOM = 11 + } + + /// + /// Specifies the role of the user. + /// + public enum RoleType + { + /// + /// for students (01). + /// + STUDENT = 1, + + /// + /// for staffs (10). + /// + STAFF = 2, + } + + #endregion + + #region Proberties + /// + /// Gets or sets the course of the user + /// + [XmlElement("Course")] + public int Course + { + get + { + return this.course; + } + + set + { + if (value != this.course && this.ValditateCourse(value)) + { + this.course = value; + this.changed = true; + } + } + } + + /// + /// Gets or sets the role of the user + /// + [XmlElement("Role")] + public RoleType Role + { + get + { + return this.role; + } + + set + { + if (value != this.role) + { + this.role = value; + this.changed = true; + } + } + } + + /// + /// Gets or sets the degree of the user + /// + [XmlElement("Degere")] + public DegreeType Degree + { + get + { + return this.degree; + } + + set + { + if (value != this.degree) + { + this.degree = value; + this.changed = true; + } + } + } + + /// + /// Gets or sets the semester of the user + /// + [XmlElement("Semseter")] + public int Semester + { + get + { + return this.semester; + } + + set + { + if (value != this.semester && this.ValditateSemester(value)) + { + this.semester = value; + this.changed = true; + } + } + } + #endregion + + #region Methods + + #region public + + /// + /// Method return the changed flag + /// + /// if is true, set changed flag to false, otherwise do nothing (bypass) + /// return true, if any properties has changed, otherwise false + public bool HasChanged(bool reset = true) + { + bool result = this.changed; + + if (reset) + { + this.changed = false; + } + + return result; + } + + #endregion + + #region private + + /// + /// Methods check if a value could be a valid semester + /// + /// value which has to be checked + /// true if it is an valid semester, otherwise false + private bool ValditateSemester(int possibleSemester) + { + if (possibleSemester < UserProfilModel.FirstSemester || possibleSemester > UserProfilModel.LastSemester) + { + return false; + } + + return true; + } + + /// + /// Methods check if a value could be a valid course + /// + /// value which has to be checked + /// true if it is an valid course, otherwise false + private bool ValditateCourse(int possibleCourse) + { + if (possibleCourse > UserProfilModel.MaxCourseNumber) + { + return false; + } + + return true; + } + + #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 new file mode 100644 index 00000000..19e997bb --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/DegreeListPickerItemListModel.cs @@ -0,0 +1,46 @@ +// +// Company copyright tag.List +// +// stubbfel +// 25.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using CampusAppWP8.Resources; + + /// + /// This Class creates a list of degrees + /// + public class DegreeListPickerItemListModel : ListPickerItemListModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public DegreeListPickerItemListModel() + : base() + { + } + + #endregion + + #region Method + + #region private + + /// + /// Overrides the LoadList-Method + /// + protected override void LoadList() + { + this.AddItem(new ListPickerItemModel(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.BACHELOR).ToString(), AppResources.Degree_Bachelor)); + this.AddItem(new ListPickerItemModel(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.MASTER).ToString(), AppResources.Degree_Master)); + this.AddItem(new ListPickerItemModel(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.DIPLOM).ToString(), AppResources.Degree_Diploma)); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs new file mode 100644 index 00000000..5cb196fb --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemListModel.cs @@ -0,0 +1,148 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag.List +// +// stubbfel +// 25.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using System.Collections.Generic; + + /// + /// Class for a List of ListPickerItems + /// + public class ListPickerItemListModel + { + #region Members + + /// + /// reference of the itemList + /// + private List list; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public ListPickerItemListModel() + { + this.list = new List(); + this.LoadList(); + } + + #endregion + + #region Property + + /// + /// Gets or sets the ItemList + /// + public List List + { + get + { + return this.list; + } + + set + { + if (value != this.list) + { + this.list = value; + } + } + } + + #endregion + + #region Method + + #region public + + /// + /// Method return a the Index of an item which has a certain value + /// + /// a certain value + /// return index of value or default(0) + public virtual int GetIndexOrDefault(string value) + { + int index = 0; + int i = 0; + foreach (ListPickerItemModel item in this.list) + { + if (item.Value.Equals(value)) + { + index = i; + break; + } + + i++; + } + + return index; + } + + /// + /// 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)); + } + + /// + /// add an new item to the list + /// + /// new item of the list + public void AddItem(ListPickerItemModel item) + { + this.list.Add(item); + } + + /// + /// 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)); + } + + /// + /// 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); + } + + #endregion + + #region private + + /// + /// Method load an default list + /// + /// + /// load an empty list + /// + protected virtual void LoadList() + { + return; + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs index f5e6cba8..5dceec55 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/ListPickerItemModel.cs @@ -12,6 +12,24 @@ namespace CampusAppWP8.Model.Utility /// public class ListPickerItemModel { + /// + /// Initializes a new instance of the class. + /// + public ListPickerItemModel() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// string for the value property of an item + /// string for the text property of an item + public ListPickerItemModel(string value, string text) + { + 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 new file mode 100644 index 00000000..72aac6b8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/RoleListPickerItemListModel.cs @@ -0,0 +1,45 @@ +// +// Company copyright tag.List +// +// stubbfel +// 25.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using CampusAppWP8.Resources; + + /// + /// Class for the RoleList + /// + public class RoleListPickerItemListModel : ListPickerItemListModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public RoleListPickerItemListModel() + : base() + { + } + + #endregion + + #region Method + + #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)); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs new file mode 100644 index 00000000..bd6e2159 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/SemesterListPickerItemListModel.cs @@ -0,0 +1,46 @@ +// +// Company copyright tag.List +// +// stubbfel +// 25.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using CampusAppWP8.Resources; + + /// + /// Class for the SemesterList + /// + public class SemesterListPickerItemListModel : ListPickerItemListModel + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public SemesterListPickerItemListModel() + : base() + { + } + + #endregion + + #region Method + + #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")); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs index ffb56040..e606f082 100644 --- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs @@ -38,6 +38,7 @@ namespace CampusAppWP8.Model public XmlModel(ModelType modelType, string sourceName) : base(modelType, sourceName) { + this.ValidRootName = Constants.XMLRootElementName; } /// diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index 6d9b5f85..53f8cf73 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -101,11 +101,11 @@ namespace CampusAppWP8.Pages.Lecture /// private void SetupListPickers() { - this.Course.ItemsSource = this.pageModel.CourseList; - this.Degree.ItemsSource = this.pageModel.DegreeList; - this.From.ItemsSource = this.pageModel.FromNumberList; - this.To.ItemsSource = this.pageModel.ToNumberList; - this.Semester.ItemsSource = this.pageModel.SemesterList; + this.Course.ItemsSource = this.pageModel.CourseList.List; + this.Degree.ItemsSource = this.pageModel.DegreeList.List; + this.From.ItemsSource = this.pageModel.FromNumberList.List; + this.To.ItemsSource = this.pageModel.ToNumberList.List; + this.Semester.ItemsSource = this.pageModel.SemesterList.List; // load values from last request LecturePageModel lastPageModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_LecturePageModel); @@ -218,7 +218,7 @@ namespace CampusAppWP8.Pages.Lecture this.pageModel.SelectDegreeIndex = this.Degree.SelectedIndex; this.pageModel.LoadFromNumberList(); - this.From.ItemsSource = this.pageModel.FromNumberList; + this.From.ItemsSource = this.pageModel.FromNumberList.List; } /// @@ -236,7 +236,7 @@ namespace CampusAppWP8.Pages.Lecture this.pageModel.SelectDegreeIndex = this.Degree.SelectedIndex; this.pageModel.SelectFromIndex = this.From.SelectedIndex; this.pageModel.LoadToNumberList(); - this.To.ItemsSource = this.pageModel.ToNumberList; + this.To.ItemsSource = this.pageModel.ToNumberList.List; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml new file mode 100644 index 00000000..0db945a9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs new file mode 100644 index 00000000..f5ab784a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------- +// +// 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 + { + /// + /// Reference of the profileFile + /// + private UserProfilFile userFile; + + /// + /// Initializes a new instance of the class. + /// + public UserProfil() + { + this.InitializeComponent(); + this.userFile = Settings.UserProfil; + + this.SetupListPickers(); + } + + /// + /// Override the OnNavigatedFrom method + /// + /// Arguments of navigation + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode) + { + this.SaveProfile(); + } + } + + /// + /// Method sets the ItemSource of the ListPickers + /// + private void SetupListPickers() + { + CourseListPickerItemListModel courseList = new CourseListPickerItemListModel(); + DegreeListPickerItemListModel degreeList = new DegreeListPickerItemListModel(); + SemesterListPickerItemListModel semesterList = new SemesterListPickerItemListModel(); + RoleListPickerItemListModel roleList = new RoleListPickerItemListModel(); + + this.Course.ItemsSource = courseList.List; + this.Degree.ItemsSource = degreeList.List; + this.Semster.ItemsSource = semesterList.List; + this.Role.ItemsSource = roleList.List; + + this.Course.SelectedIndex = courseList.GetIndexOrDefault(this.userFile.Model.Course.ToString().PadLeft(3, '0')); + this.Degree.SelectedIndex = degreeList.GetIndexOrDefault(((int)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 + { + 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) + { + Logger.LogException(e); + } + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index 42dc15ff..22cd2213 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -137,5 +137,11 @@ - + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index eaa6d530..c6f84e3c 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -13,6 +13,7 @@ namespace CampusAppWP8.Pages using System.Windows.Navigation; using CampusAppWP8.Resources; using Microsoft.Phone.Controls; + using Microsoft.Phone.Shell; /// /// Class for the StartPage @@ -25,6 +26,11 @@ namespace CampusAppWP8.Pages public StartPage() { this.InitializeComponent(); + ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem; + if (menuItem1 != null) + { + menuItem1.Text = AppResources.Setting_UserProfilAppBarTitle; + } } /// @@ -74,10 +80,22 @@ namespace CampusAppWP8.Pages } } - private void OpenDepartmentApp(object sender, RoutedEventArgs e) + private void ApplicationBarMenuItem_Click(object sender, EventArgs e) { - Uri url = new Uri(Constants.PathDepartment_DepartmentIndexPage, UriKind.Relative); + Uri url = new Uri(Constants.PathSetting_User, UriKind.Relative); NavigationService.Navigate(url); } + + private void ApplicationBar_StateChanged(object sender, ApplicationBarStateChangedEventArgs e) + { + if (e.IsMenuVisible) + { + ApplicationBar.Opacity = 0.99; + } + else + { + ApplicationBar.Opacity = 0.5; + } + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index a51dd3a1..9e14041b 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -573,6 +573,78 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Mitarbeiter ähnelt. + /// + public static string Setting_RoleStaff { + get { + return ResourceManager.GetString("Setting_RoleStaff", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Student ähnelt. + /// + public static string Setting_RoleStudent { + get { + return ResourceManager.GetString("Setting_RoleStudent", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Profileinstellungen ähnelt. + /// + public static string Setting_User { + get { + return ResourceManager.GetString("Setting_User", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt. + /// + public static string Setting_UserCourse { + get { + return ResourceManager.GetString("Setting_UserCourse", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Abschluss ähnelt. + /// + public static string Setting_UserDegree { + get { + return ResourceManager.GetString("Setting_UserDegree", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Profileinstellungen ähnelt. + /// + public static string Setting_UserProfilAppBarTitle { + get { + return ResourceManager.GetString("Setting_UserProfilAppBarTitle", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Rolle ähnelt. + /// + public static string Setting_UserRole { + get { + return ResourceManager.GetString("Setting_UserRole", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Semster ähnelt. + /// + public static string Setting_UserSemester { + get { + return ResourceManager.GetString("Setting_UserSemester", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Freitag ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 1272c78b..350cd768 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -320,4 +320,28 @@ Aktualisieren + + Profileinstellungen + + + Studiengang + + + Abschluss + + + Profileinstellungen + + + Rolle + + + Semster + + + Mitarbeiter + + + Student + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 03c0063d..479a1426 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -132,6 +132,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die user.xml ähnelt. + /// + public static string FileProfil_User { + get { + return ResourceManager.GetString("FileProfil_User", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die StudentCouncils.xml ähnelt. /// @@ -438,6 +447,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Setting/UserProfil.xaml ähnelt. + /// + public static string PathSetting_User { + get { + return ResourceManager.GetString("PathSetting_User", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/StudentCouncil/StudentCouncilPage.xaml ähnelt. /// @@ -447,6 +465,24 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 767 ähnelt. + /// + public static string Setting_DefaultCourseNumber { + get { + return ResourceManager.GetString("Setting_DefaultCourseNumber", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 20131 ähnelt. + /// + public static string Setting_DefaultSemester { + get { + return ResourceManager.GetString("Setting_DefaultSemester", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die ToggleContent ähnelt. /// @@ -555,6 +591,33 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 20121 ähnelt. + /// + public static string Valid_FirstSemseter { + get { + return ResourceManager.GetString("Valid_FirstSemseter", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 20502 ähnelt. + /// + public static string Valid_LastSemseter { + get { + return ResourceManager.GetString("Valid_LastSemseter", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 999 ähnelt. + /// + public static string Valid_MaxCourseNumber { + get { + return ResourceManager.GetString("Valid_MaxCourseNumber", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index af5239ef..699b6984 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -284,5 +284,25 @@ IsolatedStorage_OpeninghoursModel + + user.xml + + + /Pages/Setting/UserProfil.xaml + + + 767 + + + 20131 + + + 20121 + + + 20502 + + + 999 \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Settings.cs b/CampusAppWP8/CampusAppWP8/Settings.cs new file mode 100644 index 00000000..efb0f5b6 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Settings.cs @@ -0,0 +1,42 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 23.07.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8 +{ + using CampusAppWP8.File.Setting; + + /// + /// Class handle all setting (files) + /// + public static class Settings + { + /// + /// reference of the user-profile-file + /// + private static UserProfilFile userProfil = new UserProfilFile(); + + /// + /// Gets or sets the user-profile-file + /// + public static UserProfilFile UserProfil + { + get + { + return Settings.userProfil; + } + + set + { + if (value != Settings.userProfil) + { + Settings.userProfil = value; + } + } + } + } +}