mv userprofil to isalated storage

This commit is contained in:
stubbfel
2013-08-08 15:15:15 +02:00
parent c301f908ad
commit 8fc22539be
12 changed files with 85 additions and 189 deletions

View File

@@ -1,18 +1,15 @@
using CampusAppWP8.File.Setting;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO.IsolatedStorage;
using System.Threading;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Navigation;
using Windows.Devices.Geolocation;
namespace CampusAppWP8
@@ -143,18 +140,7 @@ namespace CampusAppWP8
/// </summary>
private void LoadSettings()
{
UserProfilFile userFile;
userFile = Settings.UserProfil;
if (userFile.Model == null)
{
userFile.onLoaded += new UserProfilFile.OnLoaded(this.UserSettingsLoaded);
userFile.LoadData();
}
else
{
this.UserSettingsLoaded();
}
this.UserSettingsLoaded();
Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPosition));
thread.Start();
}
@@ -164,9 +150,9 @@ namespace CampusAppWP8
/// </summary>
private void UserSettingsLoaded()
{
if (Settings.UserProfil.Model == null)
if (Settings.UserProfil == null)
{
Settings.UserProfil.Model = new UserProfilModel();
Settings.UserProfil = new UserProfilModel();
}
}
@@ -175,7 +161,7 @@ namespace CampusAppWP8
private void Application_Activated(object sender, ActivatedEventArgs e)
{
this.LoadSettings();
}
// Code, der ausgeführt werden soll, wenn die Anwendung deaktiviert wird (in den Hintergrund gebracht wird)

View File

@@ -99,7 +99,6 @@
</Compile>
<Compile Include="Feed\Departments\DepartmentFavoriteFeed.cs" />
<Compile Include="Const.cs" />
<Compile Include="File\Setting\UserProfilFile.cs" />
<Compile Include="Model\GeoDb\PlaceModel.cs" />
<Compile Include="Model\GeoDb\SpsModel.cs" />
<Compile Include="Model\Mensa\MealModel.cs" />
@@ -445,7 +444,9 @@
<HintPath>..\packages\SharpZipLib-WP7.0.86.0.518\lib\sl4-windowsphone71\SharpZipLib.WindowsPhone7.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="File\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,67 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="UserProfilFile.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>23.07.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.File.Setting
{
using System.IO;
using CampusAppWP8.Model;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Resources;
/// <summary>
/// Class for handle the user-profile-file
/// </summary>
public class UserProfilFile : XmlModel<UserProfilModel>
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="UserProfilFile" /> class.
/// </summary>
public UserProfilFile()
: base(ModelType.File, Constants.FileProfil_User)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
}
// Constructor
#endregion
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnLoad(UserProfilModel model, FileInfo info)
{
if (model == null)
{
return true;
}
return false;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(UserProfilModel model, FileInfo info)
{
if (model != null && !model.HasChanged())
{
return true;
}
return false;
}
}
}

View File

@@ -256,7 +256,7 @@ namespace CampusAppWP8.Model.Lecture
{
this.LoadFromNumberList();
this.LoadToNumberList();
UserProfilModel userModel = Settings.UserProfil.Model;
UserProfilModel userModel = Settings.UserProfil;
this.selectCourseIndex = this.courseList.GetIndexOrDefault(((int)userModel.Course).ToString().PadLeft(3, '0'));
this.selectDegreeIndex = this.degreeList.GetIndexOrDefault(((int)userModel.Degree).ToString());
this.selectSemesterIndex = this.semesterList.GetIndexOrDefault(((int)userModel.Semester).ToString());

View File

@@ -33,41 +33,6 @@ namespace CampusAppWP8.Model.Setting
/// </summary>
private static readonly int MaxCourseNumber = int.Parse(Constants.Valid_MaxCourseNumber);
/// <summary>
/// constant for the default value of a semester
/// </summary>
private static readonly int DefaultSemester = int.Parse(Constants.Setting_DefaultSemester);
/// <summary>
/// constant for the default value of a courseNumber
/// </summary>
private static readonly int DefaultCourseNumber = int.Parse(Constants.Setting_DefaultCourseNumber);
/// <summary>
/// Flag which indicates that any properties has been changed
/// </summary>
private bool changed = false;
/// <summary>
/// Gets or Sets the course of the user
/// </summary>
private int course = UserProfilModel.DefaultCourseNumber;
/// <summary>
/// Gets or Sets the role of the user
/// </summary>
private RoleType role = RoleType.STUDENT;
/// <summary>
/// Gets or Sets the degree of the user
/// </summary>
private DegreeType degree = DegreeType.BACHELOR;
/// <summary>
/// Gets or Sets the semester of the user
/// </summary>
private int semester = UserProfilModel.DefaultSemester;
#endregion
#region Enums
@@ -114,20 +79,18 @@ namespace CampusAppWP8.Model.Setting
/// <summary>
/// Gets or sets the course of the user
/// </summary>
[XmlElement("Course")]
public int Course
{
get
{
return this.course;
return App.LoadFromAppState<int>(Constants.UserSettings_Course);
}
set
{
if (value != this.course && this.ValditateCourse(value))
if (this.ValditateCourse(value))
{
this.course = value;
this.changed = true;
App.SaveToAppState<int>(Constants.UserSettings_Course, value);
}
}
}
@@ -135,62 +98,50 @@ namespace CampusAppWP8.Model.Setting
/// <summary>
/// Gets or sets the role of the user
/// </summary>
[XmlElement("Role")]
public RoleType Role
{
get
{
return this.role;
return App.LoadFromAppState<RoleType>(Constants.UserSettings_Role);
}
set
{
if (value != this.role)
{
this.role = value;
this.changed = true;
}
App.SaveToAppState<RoleType>(Constants.UserSettings_Role, value);
}
}
/// <summary>
/// Gets or sets the degree of the user
/// </summary>
[XmlElement("Degere")]
public DegreeType Degree
{
get
{
return this.degree;
return App.LoadFromAppState<DegreeType>(Constants.UserSettings_Degree);
}
set
{
if (value != this.degree)
{
this.degree = value;
this.changed = true;
}
App.SaveToAppState<DegreeType>(Constants.UserSettings_Degree, value);
}
}
/// <summary>
/// Gets or sets the semester of the user
/// </summary>
[XmlElement("Semseter")]
public int Semester
{
get
{
return this.semester;
return App.LoadFromAppState<int>(Constants.UserSettings_Semester);
}
set
{
if (value != this.semester && this.ValditateSemester(value))
if (this.ValditateSemester(value))
{
this.semester = value;
this.changed = true;
App.SaveToAppState<int>(Constants.UserSettings_Semester, value);
}
}
}
@@ -198,27 +149,6 @@ namespace CampusAppWP8.Model.Setting
#region Methods
#region public
/// <summary>
/// Method return the changed flag
/// </summary>
/// <param name="reset"> if is true, set changed flag to false, otherwise do nothing (bypass)</param>
/// <returns>return true, if any properties has changed, otherwise false</returns>
public bool HasChanged(bool reset = true)
{
bool result = this.changed;
if (reset)
{
this.changed = false;
}
return result;
}
#endregion
#region private
/// <summary>

View File

@@ -7,12 +7,12 @@
//----------------------------------------------------------------------
namespace CampusAppWP8.Pages.Setting
{
using System;
using System.Windows.Navigation;
using CampusAppWP8.File.Setting;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Model.Utility;
using CampusAppWP8.Utility;
using Microsoft.Phone.Controls;
using System;
using System.Windows.Navigation;
/// <summary>
/// Class for the UserProfilePage
@@ -22,7 +22,7 @@ namespace CampusAppWP8.Pages.Setting
/// <summary>
/// Reference of the profileFile
/// </summary>
private UserProfilFile userFile;
private UserProfilModel userProfil;
/// <summary>
/// Initializes a new instance of the <see cref="UserProfil" /> class.
@@ -30,7 +30,7 @@ namespace CampusAppWP8.Pages.Setting
public UserProfil()
{
this.InitializeComponent();
this.userFile = Settings.UserProfil;
this.userProfil = Settings.UserProfil;
this.SetupListPickers();
}
@@ -62,10 +62,10 @@ namespace CampusAppWP8.Pages.Setting
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());
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());
}
/// <summary>
@@ -75,11 +75,10 @@ namespace CampusAppWP8.Pages.Setting
{
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();
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);
}
catch (Exception e)
{

View File

@@ -33,7 +33,7 @@ namespace CampusAppWP8.Pages
menuItem1.Text = AppResources.Setting_UserProfilAppBarTitle;
}
if (Settings.AppSetting.InitApp)
if (!Settings.AppSetting.InitApp)
{
this.ShowOptIns();
Settings.AppSetting.InitApp = true;

View File

@@ -214,7 +214,7 @@ namespace CampusAppWP8.Resources {
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Dürfen Positionsdaten enhober und verwendet werdet? ähnelt.
/// Sucht eine lokalisierte Zeichenfolge, die Dürfen Positionsdaten enhoben und verwendet werden? ähnelt.
/// </summary>
public static string GeoWatch_OptInText {
get {

View File

@@ -363,6 +363,6 @@
<value>Ortung</value>
</data>
<data name="GeoWatch_OptInText" xml:space="preserve">
<value>Dürfen Positionsdaten enhober und verwendet werdet?</value>
<value>Dürfen Positionsdaten enhoben und verwendet werden?</value>
</data>
</root>

View File

@@ -726,6 +726,42 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die UserSettings.Course ähnelt.
/// </summary>
public static string UserSettings_Course {
get {
return ResourceManager.GetString("UserSettings_Course", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die UserSettings.Degree ähnelt.
/// </summary>
public static string UserSettings_Degree {
get {
return ResourceManager.GetString("UserSettings_Degree", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die UserSettings.Role ähnelt.
/// </summary>
public static string UserSettings_Role {
get {
return ResourceManager.GetString("UserSettings_Role", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die UserSettings.Semester ähnelt.
/// </summary>
public static string UserSettings_Semester {
get {
return ResourceManager.GetString("UserSettings_Semester", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die 20121 ähnelt.
/// </summary>

View File

@@ -351,4 +351,16 @@
<data name="UrlSpsService" xml:space="preserve">
<value>http://141.43.76.140/service/sps</value>
</data>
<data name="UserSettings_Course" xml:space="preserve">
<value>UserSettings.Course</value>
</data>
<data name="UserSettings_Degree" xml:space="preserve">
<value>UserSettings.Degree</value>
</data>
<data name="UserSettings_Role" xml:space="preserve">
<value>UserSettings.Role</value>
</data>
<data name="UserSettings_Semester" xml:space="preserve">
<value>UserSettings.Semester</value>
</data>
</root>

View File

@@ -8,7 +8,6 @@
namespace CampusAppWP8
{
using CampusAppWP8.File.Setting;
using CampusAppWP8.Model.Setting;
/// <summary>
@@ -19,7 +18,7 @@ namespace CampusAppWP8
/// <summary>
/// reference of the user-profile-file
/// </summary>
private static UserProfilFile userProfil = new UserProfilFile();
private static UserProfilModel userProfil = new UserProfilModel();
/// <summary>
/// reference of the appSettings
@@ -29,7 +28,7 @@ namespace CampusAppWP8
/// <summary>
/// Gets or sets the user-profile-file
/// </summary>
public static UserProfilFile UserProfil
public static UserProfilModel UserProfil
{
get
{