add settings to appload

This commit is contained in:
stubbfel
2013-07-25 12:45:56 +02:00
parent 88320657e9
commit a3014d04c8
8 changed files with 57 additions and 12 deletions

View File

@@ -8,6 +8,8 @@ using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.Resources;
using System.IO.IsolatedStorage;
using CampusAppWP8.File.Setting;
using CampusAppWP8.Model.Setting;
namespace CampusAppWP8
@@ -128,13 +130,36 @@ namespace CampusAppWP8
// Dieser Code wird beim Reaktivieren der Anwendung nicht ausgeführt
private void Application_Launching(object sender, LaunchingEventArgs e)
{
this.LoadSettings();
}
private void LoadSettings()
{
UserProfilFile userFile;
userFile = Settings.UserProfil;
if (userFile.Model == null)
{
userFile.onLoaded += new UserProfilFile.OnLoaded(this.UserSettingsLoaded);
userFile.LoadData();
}
else
{
this.UserSettingsLoaded();
}
}
private void UserSettingsLoaded()
{
if (Settings.UserProfil.Model == null)
{
Settings.UserProfil.Model = new UserProfilModel();
}
}
// Code, der ausgeführt werden soll, wenn die Anwendung aktiviert wird (in den Vordergrund gebracht wird)
// Dieser Code wird beim ersten Starten der Anwendung nicht ausgeführt
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

@@ -23,15 +23,11 @@ namespace CampusAppWP8.File.Setting
/// Initializes a new instance of the <see cref="UserProfilFile" /> class.
/// </summary>
/// <param name="autoLoad">automatic loading of the data</param>
public UserProfilFile(bool autoLoad = false)
public UserProfilFile()
: base(ModelType.File, Constants.FileProfil_User)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
if (autoLoad)
{
this.LoadData();
}
}
// Constructor

View File

@@ -41,7 +41,7 @@ namespace CampusAppWP8.Model.Setting
/// <summary>
/// constant for the default value of a courseNumber
/// </summary>
private static readonly int DefaultCourseNumber = int.Parse(Constants.Setting_DefaultSemester);
private static readonly int DefaultCourseNumber = int.Parse(Constants.Setting_DefaultCourseNumber);
/// <summary>
/// Flag which indicates that any properties has been changed
@@ -51,7 +51,7 @@ namespace CampusAppWP8.Model.Setting
/// <summary>
/// Gets or Sets the course of the user
/// </summary>
private int course;
private int course = UserProfilModel.DefaultCourseNumber;
/// <summary>
/// Gets or Sets the role of the user

View File

@@ -43,7 +43,7 @@
<Border BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="0,2,0,0" Grid.Row="0">
<StackPanel >
<TextBlock Text="{Binding Path=LocalizedResources.Setting_UserCourse, Source={StaticResource LocalizedStrings}}"/>
<TextBlock Name="Test" Text="{Binding Path=LocalizedResources.Setting_UserCourse, Source={StaticResource LocalizedStrings}}"/>
<!-- Listpicket of courses -->
<toolkit:ListPicker Name="Course" ExpansionMode="FullScreenOnly" FullModeHeader="{Binding Path=LocalizedResources.LectureApp_ListPickerHeaderCourse, Source={StaticResource LocalizedStrings}}" >
<toolkit:ListPicker.ItemTemplate>

View File

@@ -7,14 +7,26 @@ using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.File.Setting;
namespace CampusAppWP8.Pages.Setting
{
public partial class UserProfil : PhoneApplicationPage
{
UserProfilFile userFile;
public UserProfil()
{
InitializeComponent();
userFile = Settings.UserProfil;
this.SetupListPickers();
}
private void SetupListPickers()
{
Test.Text = userFile.Model.Course.ToString();
}
}
}

View File

@@ -138,7 +138,7 @@
<!-- <Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" /> -->
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized" Opacity="0.75" >
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized" StateChanged="ApplicationBar_StateChanged" Opacity="0.5" >
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Setting" Click="ApplicationBarMenuItem_Click"/>
</shell:ApplicationBar.MenuItems>

View File

@@ -85,5 +85,17 @@ namespace CampusAppWP8.Pages
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;
}
}
}
}

View File

@@ -13,12 +13,12 @@ namespace CampusAppWP8
/// <summary>
/// Class handle all setting (files)
/// </summary>
public class Settings
public static class Settings
{
/// <summary>
/// reference of the user-profile-file
/// </summary>
private static UserProfilFile userProfil = new UserProfilFile(true);
private static UserProfilFile userProfil = new UserProfilFile();
/// <summary>
/// Gets or sets the user-profile-file