add functionsetting,tagsetting, timetamlbe setting

This commit is contained in:
stubbfel
2013-11-25 14:37:07 +01:00
parent e6bd2c3df2
commit 7e0a7b25ef
15 changed files with 357 additions and 79 deletions

View File

@@ -133,7 +133,11 @@
<Compile Include="Model\Person\PersonWp8Model.cs" />
<Compile Include="Model\Setting\AppSettings.cs" />
<Compile Include="Model\Setting\BTUTagHandlerTypes.cs" />
<Compile Include="Model\Setting\BTUTagSetting.cs" />
<Compile Include="Model\Setting\FunctionSettings.cs" />
<Compile Include="Model\Setting\ISetting.cs" />
<Compile Include="Model\Setting\TagHandlerListPickerItemListModel.cs" />
<Compile Include="Model\Setting\TimeTableSetting.cs" />
<Compile Include="Model\Setting\UserProfilModel.cs" />
<Compile Include="Model\TimeTable\AppointmentListModel.cs" />
<Compile Include="Model\TimeTable\AppointmentModel.cs" />

View File

@@ -13,25 +13,34 @@ namespace CampusAppWP8.Model.Setting
/// <summary> Model for settings of the app. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
public class AppSettings
public class AppSettings : ISetting
{
#region member
private static MensaSetting mensaSetting = new MensaSetting();
/// <summary> The mensa setting. </summary>
private static FunctionSettings functionSetting = new FunctionSettings();
/// <summary> The tag setting. </summary>
private static BTUTagSetting tagSetting = new BTUTagSetting();
#endregion
#region Property
public MensaSetting MensaSetting
/// <summary> Gets or sets the tag setting. </summary>
/// <value> The tag setting. </value>
public FunctionSettings FunctionSettings
{
get
{
return AppSettings.mensaSetting;
return AppSettings.functionSetting;
}
set
set
{
if (value != AppSettings.mensaSetting)
if (AppSettings.functionSetting != value)
{
AppSettings.mensaSetting = value;
AppSettings.functionSetting = value;
}
}
}
@@ -141,21 +150,32 @@ namespace CampusAppWP8.Model.Setting
}
}
/// <summary> Gets or sets the tag default handler. </summary>
/// <value> The tag default handler. </value>
public BTUTagDefaultHandler TagDefaultHandler
#endregion
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public void SetSettingToDefault()
{
get
// set Deploynumber
int appDeploy;
bool parseResult = int.TryParse(Constants.DeploymentNumber, out appDeploy);
if (parseResult)
{
return App.LoadFromAppState<BTUTagDefaultHandler>(Constants.AppSetting_BTUTagDefaultHandler);
this.DeploymentNumber = appDeploy;
}
set
{
App.SaveToAppState<BTUTagDefaultHandler>(Constants.AppSetting_BTUTagDefaultHandler, value);
}
this.DevMode = false;
this.GeoWatchEnable = false;
this.InitApp = false;
this.OnlyWifi = false;
this.UniNetwork = false;
this.WifiEnable = false;
this.FunctionSettings.SetSettingToDefault();
}
#endregion
}
}

View File

@@ -0,0 +1,42 @@
using CampusAppWP8.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CampusAppWP8.Model.Setting
{
public class BTUTagSetting : ISetting
{
#region property
/// <summary> Gets or sets the tag default handler. </summary>
/// <value> The tag default handler. </value>
public BTUTagDefaultHandler TagDefaultHandler
{
get
{
return App.LoadFromAppState<BTUTagDefaultHandler>(Constants.AppSetting_BTUTagDefaultHandler);
}
set
{
App.SaveToAppState<BTUTagDefaultHandler>(Constants.AppSetting_BTUTagDefaultHandler, value);
}
}
#endregion
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public void SetSettingToDefault()
{
this.TagDefaultHandler = BTUTagDefaultHandler.InfoPage;
}
#endregion
}
}

View File

@@ -0,0 +1,93 @@
using CampusAppWP8.Pages.Setting;
using CampusAppWP8.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CampusAppWP8.Model.Setting
{
public class FunctionSettings : ISetting
{
#region member
/// <summary> The mensa setting. </summary>
private static MensaSetting mensaSetting = new MensaSetting();
/// <summary> The tag setting. </summary>
private static BTUTagSetting tagSetting = new BTUTagSetting();
/// <summary> The time table setting. </summary>
private static TimeTableSetting timeTableSetting = new TimeTableSetting();
#endregion
#region Property
/// <summary> Gets or sets the time table setting. </summary>
/// <value> The time table setting. </value>
public static TimeTableSetting TimeTableSetting
{
get
{
return FunctionSettings.timeTableSetting;
}
set
{
FunctionSettings.timeTableSetting = value;
}
}
/// <summary> Gets or sets the tag setting. </summary>
/// <value> The tag setting. </value>
public BTUTagSetting TagSetting
{
get
{
return FunctionSettings.tagSetting;
}
set
{
if (FunctionSettings.tagSetting != value)
{
FunctionSettings.tagSetting = value;
}
}
}
/// <summary> Gets or sets the mensa setting. </summary>
/// <value> The mensa setting. </value>
public MensaSetting MensaSetting
{
get
{
return FunctionSettings.mensaSetting;
}
set
{
if (value != FunctionSettings.mensaSetting)
{
FunctionSettings.mensaSetting = value;
}
}
}
#endregion
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public void SetSettingToDefault()
{
this.TagSetting.SetSettingToDefault();
this.MensaSetting.SetSettingToDefault();
}
#endregion
}
}

View File

@@ -0,0 +1,18 @@
//-----------------------------------------------------------------------
// <copyright file="ISetting.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>25.11.2013</date>
// <summary>Declares the ISetting interface</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8.Model.Setting
{
/// <summary> Interface for setting. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public interface ISetting
{
/// <summary> Sets setting to default. </summary>
void SetSettingToDefault();
}
}

View File

@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------
// <copyright file="TimeTableSetting.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>25.11.2013</date>
// <summary>Implements the time table setting class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8.Model.Setting
{
/// <summary> A time table setting. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <seealso cref="T:CampusAppWP8.Model.Setting.ISetting"/>
public class TimeTableSetting : ISetting
{
#region Property
#endregion
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <seealso cref="M:CampusAppWP8.Model.Setting.ISetting.SetSettingToDefault()"/>
public void SetSettingToDefault()
{
}
#endregion
}
}

View File

@@ -8,14 +8,14 @@
//-----------------------------------------------------------------------
namespace CampusAppWP8.Model.Setting
{
using System;
using System.Xml.Serialization;
using CampusAppWP8.Resources;
using CampusAppWPortalLib8.Model.Settings;
/// <summary> Model for the profile of an user. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
[XmlRoot("root")]
public class UserProfilModel
public class UserProfilModel : ISetting
{
#region Members
@@ -116,6 +116,24 @@ namespace CampusAppWP8.Model.Setting
#region Methods
#region public
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public void SetSettingToDefault()
{
// set Deploynumber
this.Course = 0;
this.DefaultCampus = Campus.CB_MAIN;
this.Degree = DegreeType.BACHELOR;
this.Role = RoleType.STUDENT;
this.Semester = this.CalcCurrentSemester();
}
#endregion
#region private
/// <summary> Methods check if a value could be a valid semester. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
/// <param name="possibleSemester"> value which has to be checked. </param>
@@ -144,6 +162,30 @@ namespace CampusAppWP8.Model.Setting
return true;
}
/// <summary> Calculates the current semester. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <returns> The calculated current semester. </returns>
private int CalcCurrentSemester()
{
DateTime now = DateTime.Now;
int result = 0;
result = now.Year * 10;
if (now.Month < 10)
{
result += 1;
}
else
{
result += 2;
}
return result;
}
#endregion
#endregion
}
}

View File

@@ -33,7 +33,7 @@ namespace CampusAppWP8.Pages.BTTTag
InitializeComponent();
this.taghandlerModel = new TagHandlerListPickerItemListModel();
this.TagHandler.ItemsSource = this.taghandlerModel.List;
int tagselIndex = this.taghandlerModel.GetIndexOrDefault(Settings.AppSetting.TagDefaultHandler.ToString());
int tagselIndex = this.taghandlerModel.GetIndexOrDefault(Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler.ToString());
this.TagHandler.SelectedIndex = tagselIndex;
}
@@ -48,7 +48,7 @@ namespace CampusAppWP8.Pages.BTTTag
{
if (NavigationMode.Back == e.NavigationMode)
{
Settings.AppSetting.TagDefaultHandler = (CampusAppWP8.Model.Setting.BTUTagDefaultHandler)Enum.Parse(typeof(CampusAppWP8.Model.Setting.BTUTagDefaultHandler), ((CampusAppWPortalLib8.Model.Utility.ListPickerItemModel)this.TagHandler.SelectedItem).Value);
Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler = (CampusAppWP8.Model.Setting.BTUTagDefaultHandler)Enum.Parse(typeof(CampusAppWP8.Model.Setting.BTUTagDefaultHandler), ((CampusAppWPortalLib8.Model.Utility.ListPickerItemModel)this.TagHandler.SelectedItem).Value);
}
}

View File

@@ -251,7 +251,7 @@ namespace CampusAppWP8.Pages.Dev
else
{
string qrContent = result.Text;
switch (Settings.AppSetting.TagDefaultHandler)
switch (Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler)
{
case BTUTagDefaultHandler.CampusMap:
this.GoToCampusMappage(qrContent);

View File

@@ -45,9 +45,6 @@ namespace CampusAppWP8.Pages.Setting
{
int oldIndex = App.LoadFromIsolatedStorage<int>(Constants.IsolatedStorage_GeneralSettingPageIndex);
this.GeneralSettingPivot.SelectedIndex = oldIndex;
}
}

View File

@@ -1,20 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.Resources;
using CampusAppWP8.Model.Setting;
//-----------------------------------------------------------------------
// <copyright file="FunctionSettingPage.xaml.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>25.11.2013</date>
// <summary>Implements the function setting page.xaml class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8.Pages.Setting
{
using System;
using System.Windows;
using System.Windows.Navigation;
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Resources;
using Microsoft.Phone.Controls;
/// <summary> A function setting page. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <seealso cref="T:Microsoft.Phone.Controls.PhoneApplicationPage"/>
public partial class FunctionSettingPage : PhoneApplicationPage
{
#region Member
/// <summary> The TagHandler model. </summary>
private TagHandlerListPickerItemListModel taghandlerModel;
@@ -22,15 +27,17 @@ namespace CampusAppWP8.Pages.Setting
#region Constructor
/// <summary> Initializes a new instance of the FunctionSettingPage class. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public FunctionSettingPage()
{
InitializeComponent();
this.InitializeComponent();
this.taghandlerModel = new TagHandlerListPickerItemListModel();
this.TagHandler.ItemsSource = this.taghandlerModel.List;
int tagselIndex = this.taghandlerModel.GetIndexOrDefault(Settings.AppSetting.TagDefaultHandler.ToString());
int tagselIndex = this.taghandlerModel.GetIndexOrDefault(Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler.ToString());
this.TagHandler.SelectedIndex = tagselIndex;
this.AtomMensaToggle.IsChecked = Settings.AppSetting.MensaSetting.AtomMensaSelection;
this.AtomMensaToggle.IsChecked = Settings.AppSetting.FunctionSettings.MensaSetting.AtomMensaSelection;
}
#endregion
@@ -50,12 +57,12 @@ namespace CampusAppWP8.Pages.Setting
if (NavigationMode.New == e.NavigationMode && NavigationContext.QueryString.TryGetValue(Constants.Param_FunctionSetting_Index, out functionIndex))
{
this.SetSelecetPivotItem(functionIndex);
this.SetSelectedPivotItem(functionIndex);
}
else
{
string oldIndex = App.LoadFromIsolatedStorage<string>(Constants.IsolatedStorage_FunctionSettingPageIndex);
this.SetSelecetPivotItem(oldIndex);
this.SetSelectedPivotItem(oldIndex);
}
}
@@ -64,8 +71,8 @@ namespace CampusAppWP8.Pages.Setting
/// <seealso cref="M:System.Windows.Controls.Page.OnNavigatedFrom(NavigationEventArgs)"/>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
Settings.AppSetting.TagDefaultHandler = (CampusAppWP8.Model.Setting.BTUTagDefaultHandler)Enum.Parse(typeof(CampusAppWP8.Model.Setting.BTUTagDefaultHandler), ((CampusAppWPortalLib8.Model.Utility.ListPickerItemModel)this.TagHandler.SelectedItem).Value);
Settings.AppSetting.MensaSetting.AtomMensaSelection = this.AtomMensaToggle.IsChecked.Value;
Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler = (CampusAppWP8.Model.Setting.BTUTagDefaultHandler)Enum.Parse(typeof(CampusAppWP8.Model.Setting.BTUTagDefaultHandler), ((CampusAppWPortalLib8.Model.Utility.ListPickerItemModel)this.TagHandler.SelectedItem).Value);
Settings.AppSetting.FunctionSettings.MensaSetting.AtomMensaSelection = this.AtomMensaToggle.IsChecked.Value;
if (NavigationMode.Back == e.NavigationMode)
{
@@ -85,7 +92,10 @@ namespace CampusAppWP8.Pages.Setting
#region private
private void SetSelecetPivotItem(string itemTag)
/// <summary> Sets selected pivot item. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <param name="itemTag"> The item tag. </param>
private void SetSelectedPivotItem(string itemTag)
{
if (itemTag != null)
{
@@ -99,8 +109,8 @@ namespace CampusAppWP8.Pages.Setting
}
}
}
this.SettingFunctionPivot.SelectedIndex = 0;
this.SettingFunctionPivot.SelectedIndex = 0;
}
#endregion

View File

@@ -1,11 +1,24 @@
using CampusAppWP8.Resources;
//-----------------------------------------------------------------------
// <copyright file="MensaSetting.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>25.11.2013</date>
// <summary>Implements the mensa setting class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8.Pages.Setting
{
public class MensaSetting
using CampusAppWP8.Model.Setting;
using CampusAppWP8.Resources;
/// <summary> A mensa setting. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public class MensaSetting : ISetting
{
#region Property
/// <summary> Gets or sets a value indicating whether the atom mensa selection. </summary>
/// <value> true if atom mensa selection, false if not. </value>
public bool AtomMensaSelection
{
get
@@ -20,5 +33,16 @@ namespace CampusAppWP8.Pages.Setting
}
#endregion
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public void SetSettingToDefault()
{
// set Deploynumber
this.AtomMensaSelection = true;
}
#endregion
}
}

View File

@@ -56,22 +56,17 @@ namespace CampusAppWP8.Pages
TimeTable.TimeTable.InitFeed();
if (!Settings.AppSetting.InitApp)
{
this.InitPlaceFile();
this.initCourseList = new CourseFeed();
this.initCourseList.OnLoaded += new CourseFeed.OnIO(this.StoreCourseFeed);
this.initCourseList.LoadData();
Settings.SetSettingToDefault();
this.ShowOptIns();
Settings.AppSetting.InitApp = true;
int appDeploy;
bool parseResult = int.TryParse(Constants.DeploymentNumber, out appDeploy);
if (parseResult)
{
Settings.AppSetting.DeploymentNumber = appDeploy;
}
}
}
@@ -275,7 +270,7 @@ namespace CampusAppWP8.Pages
}
else
{
switch (Settings.AppSetting.TagDefaultHandler)
switch (Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler)
{
case BTUTagDefaultHandler.CampusMap:
this.GoToCampusMappage(nfcContent);

View File

@@ -1,39 +1,34 @@
//-----------------------------------------------------------------------
// <copyright file="Settings.cs" company="BTU/IIT">
// Company copyright tag.
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>stubbfel</author>
// <sience>23.07.2013</sience>
//----------------------------------------------------------------------
// <author>Stubbfel</author>
// <date>25.11.2013</date>
// <summary>Implements the settings class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWP8
{
using CampusAppWP8.Model.Setting;
/// <summary>
/// Class handle all setting (files)
/// </summary>
/// <summary> Class handle all setting (files) </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
/// <seealso cref="T:CampusAppWP8.Model.Setting.ISetting"/>
public static class Settings
{
#region Member
/// <summary>
/// reference of the user-profile-file
/// </summary>
/// <summary> reference of the user-profile-file. </summary>
private static UserProfilModel userProfil = new UserProfilModel();
/// <summary>
/// reference of the appSettings
/// </summary>
/// <summary> reference of the appSettings. </summary>
private static AppSettings appSetting = new AppSettings();
#endregion
#region Property
/// <summary>
/// Gets or sets the user-profile-file
/// </summary>
/// <summary> Gets or sets the user-profile-file. </summary>
/// <value> The user profile. </value>
public static UserProfilModel UserProfil
{
get
@@ -50,9 +45,8 @@ namespace CampusAppWP8
}
}
/// <summary>
/// Gets or sets the AppSetting
/// </summary>
/// <summary> Gets or sets the AppSetting. </summary>
/// <value> The application setting. </value>
public static AppSettings AppSetting
{
get
@@ -73,6 +67,13 @@ namespace CampusAppWP8
#region method
/// <summary> Sets setting to default. </summary>
/// <remarks> Stubbfel, 25.11.2013. </remarks>
public static void SetSettingToDefault()
{
Settings.AppSetting.SetSettingToDefault();
Settings.UserProfil.SetSettingToDefault();
}
#endregion
}

View File

@@ -169,7 +169,7 @@ namespace CampusAppWP8.Utility.Lui.Tiles
{
string path;
string name = "NFC -> ";
switch (Settings.AppSetting.TagDefaultHandler)
switch (Settings.AppSetting.FunctionSettings.TagSetting.TagDefaultHandler)
{
case BTUTagDefaultHandler.CampusMap:
path = Constants.PathCampusmap_Campusmap;