diff --git a/CampusAppWP8/CampusAppWP8/App.xaml b/CampusAppWP8/CampusAppWP8/App.xaml index 1d6fd99b..443e964d 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml +++ b/CampusAppWP8/CampusAppWP8/App.xaml @@ -13,6 +13,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 5bb47375..b5ddfcdb 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -10,6 +10,7 @@ using System.IO.IsolatedStorage; using System.Threading; using System.Windows; using System.Windows.Markup; +using System.Windows.Media; using System.Windows.Navigation; @@ -157,6 +158,19 @@ namespace CampusAppWP8 Settings.AppSetting.InitApp = false; } + Color appColor = ((SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]).Color; + if (!Settings.AppSetting.DisplaySetting.PhoneAccentColor.Equals(appColor)) + { + if (Settings.AppSetting.DisplaySetting.AppAccentColor.Equals(Settings.AppSetting.DisplaySetting.PhoneAccentColor)) + { + Settings.AppSetting.DisplaySetting.AppAccentColor = appColor; + } + Settings.AppSetting.DisplaySetting.PhoneAccentColor = appColor; + } + + appColor = Settings.AppSetting.DisplaySetting.AppAccentColor; + Utilities.SwitchAccentColor(appColor); + this.UserSettingsLoaded(); Settings.AppSetting.NetworkSetting.UniNetwork = Utilities.IsUniNetworkAvailable(); diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 0fbc7b96..201e7c1d 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -134,6 +134,7 @@ + @@ -144,6 +145,8 @@ + + FunctionSettingPage.xaml @@ -542,6 +545,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs index e4f482f8..1224cdcb 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs @@ -26,10 +26,30 @@ namespace CampusAppWP8.Model.Setting /// The locating setting. private static LocatingSetting locatingSetting = new LocatingSetting(); + private static DisplaySetting displaySetting = new DisplaySetting(); + #endregion #region Property + /// Gets or sets the display setting. + /// The display setting. + public DisplaySetting DisplaySetting + { + get + { + return AppSettings.displaySetting; + } + + set + { + if (AppSettings.displaySetting != value) + { + AppSettings.displaySetting = value; + } + } + } + /// Gets or sets the locating setting. /// The locating setting. public LocatingSetting LocatingSetting @@ -150,6 +170,7 @@ namespace CampusAppWP8.Model.Setting this.FunctionSettings.SetSettingToDefault(); this.NetworkSetting.SetSettingToDefault(); this.LocatingSetting.SetSettingToDefault(); + this.DisplaySetting.SetSettingToDefault(); } #endregion } diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/DisplaySetting.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/DisplaySetting.cs new file mode 100644 index 00000000..3416267f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/DisplaySetting.cs @@ -0,0 +1,64 @@ +using CampusAppWP8.Resources; +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 26.11.2013 +// Implements the display setting class +//----------------------------------------------------------------------- +using System.Windows.Media; + +namespace CampusAppWP8.Model.Setting +{ + /// A display setting. + /// Stubbfel, 26.11.2013. + /// + public class DisplaySetting : ISetting + { + #region property + + /// Gets or sets the color of the application accent. + /// The color of the application accent. + public Color AppAccentColor + { + get + { + return App.LoadFromAppState(Constants.Setting_AppAccentColor); + } + + set + { + App.SaveToAppState(Constants.Setting_AppAccentColor, value); + } + } + + /// Gets or sets the color of the phone accent. + /// The color of the phone accent. + public Color PhoneAccentColor + { + get + { + return App.LoadFromAppState(Constants.Setting_PhoneAccentColor); + } + + set + { + App.SaveToAppState(Constants.Setting_PhoneAccentColor, value); + } + } + + #endregion + + #region method + + /// Sets setting to default. + /// Stubbfel, 25.11.2013. + /// + public void SetSettingToDefault() + { + this.AppAccentColor = this.PhoneAccentColor; + } + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/AppAccentColorListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/AppAccentColorListPickerItemListModel.cs new file mode 100644 index 00000000..45d8364c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/AppAccentColorListPickerItemListModel.cs @@ -0,0 +1,91 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 26.11.2013 +// Implements the application accent color list picker item list model class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using System.Windows.Media; + using CampusAppWP8.Resources; + + /// A data Model for the application accent color list picker item list. + /// Stubbfel, 26.11.2013. + /// + public class AppAccentColorListPickerItemListModel : CampusAppWPortalLib8.Model.Utility.ListPickerItemListTemplateModel + { + #region member + + /// The faculty 1 color. + private static readonly SolidColorBrush Faculty1Color = (SolidColorBrush)App.Current.Resources[Constants.Brush_Faculty1]; + + /// The faculty 2 color. + private static readonly SolidColorBrush Faculty2Color = (SolidColorBrush)App.Current.Resources[Constants.Brush_Faculty2]; + + /// The faculty 3 color. + private static readonly SolidColorBrush Faculty3Color = (SolidColorBrush)App.Current.Resources[Constants.Brush_Faculty3]; + + /// The faculty 4 color. + private static readonly SolidColorBrush Faculty4Color = (SolidColorBrush)App.Current.Resources[Constants.Brush_Faculty4]; + + /// The faculty 5 color. + private static readonly SolidColorBrush Faculty5Color = (SolidColorBrush)App.Current.Resources[Constants.Brush_Faculty5]; + + /// The faculty. + private readonly string faculty = CampusAppWPortalLib8.Resources.AppResources.Faculty; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the AppAccentColorListPickerItemListModel class. + /// + /// Stubbfel, 26.11.2013. + public AppAccentColorListPickerItemListModel() + : base() + { + this.LoadList(); + } + + #endregion + + #region Method + + /// Gets index or default. + /// Stubbfel, 27.11.2013. + /// The value. + /// The index or default. + public override int GetIndexOrDefault(SolidColorBrush value) + { + int index = 0; + foreach (ColorListPickerItemModel brush in this.List) + { + if (brush.Value.Color.Equals(value.Color)) + { + break; + } + + index++; + } + + return index; + } + + /// Loads the list. + /// Stubbfel, 26.11.2013. + protected override void LoadList() + { + this.AddItem(new ColorListPickerItemModel(new SolidColorBrush(Settings.AppSetting.DisplaySetting.PhoneAccentColor), CampusAppWP8.Resources.AppResources.AccentColor)); + this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.Faculty1Color, this.faculty + " 1")); + this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.Faculty2Color, this.faculty + " 2")); + this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.Faculty3Color, this.faculty + " 3")); + this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.Faculty4Color, this.faculty + " 4")); + this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.Faculty5Color, this.faculty + " 5")); + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/ColorListPickerItemModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/ColorListPickerItemModel.cs new file mode 100644 index 00000000..21e6587b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/ColorListPickerItemModel.cs @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 26.11.2013 +// Implements the color list picker item model class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Model.Utility +{ + using System.Windows.Media; + + /// A data Model for the color list picker item. + /// Stubbfel, 26.11.2013. + /// + public class ColorListPickerItemModel : CampusAppWPortalLib8.Model.Utility.ListPickerItemTemplateModel + { + /// Initializes a new instance of the ColorListPickerItemModel class. + /// Stubbfel, 26.11.2013. + public ColorListPickerItemModel() + : base() + { + } + + /// Initializes a new instance of the ColorListPickerItemModel class. + /// Stubbfel, 26.11.2013. + /// The value. + /// The text. + public ColorListPickerItemModel(SolidColorBrush value, string text) + : base(value, text) + { + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml index 6762f89b..8cf1bb9d 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml @@ -69,7 +69,29 @@ - + + + + + + + + + + + + + + + + + + + + + + Class for the AppSettingPage. /// Stubbfel, 15.10.2013. /// + /// public partial class AppSettingPage : PhoneApplicationPage, IRefreshingPage { + #region member + + /// List of colors of the application accents. + private readonly AppAccentColorListPickerItemListModel appAccentColors = new AppAccentColorListPickerItemListModel(); + + #endregion + #region Constructor /// Initializes a new instance of the class. @@ -25,6 +36,7 @@ namespace CampusAppWP8.Pages.Setting public AppSettingPage() { this.InitializeComponent(); + this.AccentColorPicker.ItemsSource = this.appAccentColors.List; this.LoadSettings(); } @@ -44,6 +56,7 @@ namespace CampusAppWP8.Pages.Setting #endregion #region protected + /// Override the OnNavigatedTo method. /// Stubbfel, 15.10.2013. /// @@ -78,12 +91,14 @@ namespace CampusAppWP8.Pages.Setting #endregion #region private + /// Loads the settings. /// Stubbfel, 25.11.2013. private void LoadSettings() { this.GeoWatchToggle.IsChecked = Settings.AppSetting.LocatingSetting.GeoWatchEnable; this.OnlyWiFiToggle.IsChecked = Settings.AppSetting.NetworkSetting.OnlyWifi; + this.AccentColorPicker.SelectedIndex = this.appAccentColors.GetIndexOrDefault(new SolidColorBrush(Settings.AppSetting.DisplaySetting.AppAccentColor)); } /// Saves the settings. @@ -104,6 +119,21 @@ namespace CampusAppWP8.Pages.Setting this.LoadSettings(); } + /// Event handler. Called by AccentColorPicker for selection changed events. + /// Stubbfel, 26.11.2013. + /// Source of the event. + /// Selection changed event information. + private void AccentColorPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) + { + if (e.AddedItems.Count == 1 && e.RemovedItems.Count == 1) + { + int selectedIndex = this.AccentColorPicker.SelectedIndex; + Color newColor = this.appAccentColors.List[selectedIndex].Value.Color; + Utilities.SwitchAccentColor(newColor); + Settings.AppSetting.DisplaySetting.AppAccentColor = newColor; + } + } + #endregion #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index 8f103089..ed3ee63b 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -27,6 +27,7 @@ namespace CampusAppWP8.Pages using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using Windows.Networking.Proximity; + using System.Windows.Media; /// Class for the StartPage. /// Stubbfel, 15.10.2013. @@ -75,7 +76,7 @@ namespace CampusAppWP8.Pages #region protected - /// Methods overrides the OnNavigatedTo-Method. + /// Methods overrides the OnNavigatedTo-Method. /// Stubbfel, 15.10.2013. /// protected override void OnNavigatedTo(NavigationEventArgs e) @@ -84,7 +85,7 @@ namespace CampusAppWP8.Pages if (device != null) { this.ndefId = this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler); - } + } } /// Methods overrides the OnNavigatedFrom-Method. @@ -123,7 +124,7 @@ namespace CampusAppWP8.Pages /// Stubbfel, 15.10.2013. /// Caller of the function. /// some EventArgs. - private void NFCButton_Click(object sender,RoutedEventArgs e) + private void NFCButton_Click(object sender, RoutedEventArgs e) { MessageBoxes.ShowMainModelInfoMessageBox(AppResources.ScarNfc_Search); } diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 034721f2..f339bccb 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -60,6 +60,24 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Akzentfarbe ähnelt. + /// + public static string AccentColor { + get { + return ResourceManager.GetString("AccentColor", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Akzentfarbe-Auswahl ähnelt. + /// + public static string AccentColorPicker { + get { + return ResourceManager.GetString("AccentColorPicker", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Hinzufügen ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 711c1ded..eb852176 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -662,4 +662,10 @@ Mensa + + Akzentfarbe + + + Akzentfarbe-Auswahl + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 5f02e256..d4bcab11 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -678,4 +678,46 @@ MensaDefaultCampus + + AppAccentColor + + + PhoneAccentColor + + + FacultyBrush1 + + + FacultyBrush2 + + + FacultyBrush3 + + + FacultyBrush4 + + + FacultyBrush5 + + + PhoneAccentBrush + + + FacultyColor1 + + + FacultyColor2 + + + FacultyColor3 + + + FacultyColor4 + + + FacultyColor5 + + + PhoneAccentColor + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4b3fe01c..cd451231 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -204,6 +204,60 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyBrush1 ähnelt. + /// + public static string Brush_Faculty1 { + get { + return ResourceManager.GetString("Brush_Faculty1", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyBrush2 ähnelt. + /// + public static string Brush_Faculty2 { + get { + return ResourceManager.GetString("Brush_Faculty2", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyBrush3 ähnelt. + /// + public static string Brush_Faculty3 { + get { + return ResourceManager.GetString("Brush_Faculty3", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyBrush4 ähnelt. + /// + public static string Brush_Faculty4 { + get { + return ResourceManager.GetString("Brush_Faculty4", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyBrush5 ähnelt. + /// + public static string Brush_Faculty5 { + get { + return ResourceManager.GetString("Brush_Faculty5", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die PhoneAccentBrush ähnelt. + /// + public static string Brush_PhoneAccent { + get { + return ResourceManager.GetString("Brush_PhoneAccent", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die BTU-CampusApp ähnelt. /// @@ -222,6 +276,60 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyColor1 ähnelt. + /// + public static string Color_Faculty1 { + get { + return ResourceManager.GetString("Color_Faculty1", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyColor2 ähnelt. + /// + public static string Color_Faculty2 { + get { + return ResourceManager.GetString("Color_Faculty2", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyColor3 ähnelt. + /// + public static string Color_Faculty3 { + get { + return ResourceManager.GetString("Color_Faculty3", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyColor4 ähnelt. + /// + public static string Color_Faculty4 { + get { + return ResourceManager.GetString("Color_Faculty4", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die FacultyColor5 ähnelt. + /// + public static string Color_Faculty5 { + get { + return ResourceManager.GetString("Color_Faculty5", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die PhoneAccentColor ähnelt. + /// + public static string Color_PhoneAccent { + get { + return ResourceManager.GetString("Color_PhoneAccent", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die 8 ähnelt. /// @@ -1383,6 +1491,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die AppAccentColor ähnelt. + /// + public static string Setting_AppAccentColor { + get { + return ResourceManager.GetString("Setting_AppAccentColor", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die AppSetting ähnelt. /// @@ -1482,6 +1599,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die PhoneAccentColor ähnelt. + /// + public static string Setting_PhoneAccentColor { + get { + return ResourceManager.GetString("Setting_PhoneAccentColor", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die UserSetting ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Styles/UniColors.xaml b/CampusAppWP8/CampusAppWP8/Styles/UniColors.xaml new file mode 100644 index 00000000..24581267 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Styles/UniColors.xaml @@ -0,0 +1,16 @@ + + + #d20078 + #0050a0 + #009bd2 + #a5c300 + #ff9900 + #d20078 + #0050a0 + #009bd2 + #a5c300 + #ff9900 + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index 70a4f339..ba9a0eb1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -445,6 +445,31 @@ namespace CampusAppWP8.Utility obj.SelectedIndex = -1; } } + + /// Switch color. + /// Stubbfel, 26.11.2013. + /// The ressource key. + /// The new color. + public static void SwitchColor(string ressourceKey, Color newColor) + { + SolidColorBrush oldColor = App.Current.Resources[ressourceKey] as SolidColorBrush; + + if (oldColor == null || oldColor.Color.Equals(newColor)) + { + return; + } + App.Current.Resources.Remove(ressourceKey); + App.Current.Resources.Add(ressourceKey, newColor); + } + + /// Switch accent color. + /// Stubbfel, 26.11.2013. + /// The new color. + public static void SwitchAccentColor(Color newColor) + { + Utilities.SwitchColor(Constants.Color_PhoneAccent, newColor); + ((SolidColorBrush)App.Current.Resources[Constants.Brush_PhoneAccent]).Color = newColor; + } #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index addae01f..5e642a15 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -91,7 +91,9 @@ + + diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs index 5630e72a..9350c817 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -70,6 +70,10 @@ namespace CampusAppWPortalLib8.Model.Mensa /// The canteen. public PriceCanteenModel GetCanteen(Campus campus) { + if (campus == Campus.CB_NORTH) + { + return this.GetCanteen((int)Campus.CB_MAIN - 1); + } return this.GetCanteen((int)campus - 1); } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/CampusListPickerItemListModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/CampusListPickerItemListModel.cs index 810cd1be..86907d6b 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/CampusListPickerItemListModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/CampusListPickerItemListModel.cs @@ -40,7 +40,7 @@ namespace CampusAppWPortalLib8.Model.Utility { if (userSettings) { - this.AddItem(new ListPickerItemModel(((int)CampusAppWPortalLib8.Model.Settings.Campus.UserSettingCampus).ToString(), AppResources.Campus_UserSetting); + this.AddItem(new ListPickerItemModel(((int)CampusAppWPortalLib8.Model.Settings.Campus.UserSettingCampus).ToString(), AppResources.Campus_UserSetting)); } this.AddItem(new ListPickerItemModel(((int)CampusAppWPortalLib8.Model.Settings.Campus.CB_MAIN).ToString(), AppResources.Campus_CBMain)); diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListModel.cs index 8373f3a3..cfa96f3e 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListModel.cs @@ -12,15 +12,8 @@ namespace CampusAppWPortalLib8.Model.Utility /// Class for a List of ListPickerItems. /// Stubbfel, 15.10.2013. - public class ListPickerItemListModel + public class ListPickerItemListModel : ListPickerItemListTemplateModel { - #region Members - - /// reference of the itemList. - private List list; - - #endregion - #region Constructor /// @@ -28,109 +21,10 @@ namespace CampusAppWPortalLib8.Model.Utility /// /// Stubbfel, 15.10.2013. public ListPickerItemListModel() + : base() { - this.list = new List(); } #endregion - - #region Property - - /// Gets or sets the ItemList. - /// The list. - 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. - /// Stubbfel, 15.10.2013. - /// 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. - /// Stubbfel, 15.10.2013. - /// 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. - /// Stubbfel, 15.10.2013. - /// new item of the list. - public void AddItem(ListPickerItemModel item) - { - this.list.Add(item); - } - - /// remove an item. - /// Stubbfel, 15.10.2013. - /// 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. - /// Stubbfel, 15.10.2013. - /// 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 protected - - /// Method load an default list. - /// load an empty list. - protected virtual void LoadList() - { - return; - } - - #endregion - - #endregion } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListTemplateModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListTemplateModel.cs new file mode 100644 index 00000000..ba1742a1 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemListTemplateModel.cs @@ -0,0 +1,135 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 26.11.2013 +// Implements the list picker item list template model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Utility +{ + using System.Collections.Generic; + + /// A data Model for the list picker item list template. + /// Stubbfel, 26.11.2013. + /// Generic type parameter. + public class ListPickerItemListTemplateModel + { + #region Members + + /// reference of the itemList. + private List> list; + + #endregion + + #region Constructor + + /// Initializes a new instance of the ListPickerItemListTemplateModel class. + /// Stubbfel, 26.11.2013. + public ListPickerItemListTemplateModel() + { + this.list = new List>(); + } + + #endregion + + #region Property + + /// Gets or sets the ItemList. + /// The list. + 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. + /// Stubbfel, 15.10.2013. + /// a certain value. + /// return index of value or default(0) + public virtual int GetIndexOrDefault(T value) + { + int index = 0; + int i = 0; + foreach (ListPickerItemTemplateModel item in this.list) + { + if (item.Value.Equals(value)) + { + index = i; + break; + } + + i++; + } + + return index; + } + + /// add an new item to the list. + /// Stubbfel, 15.10.2013. + /// value of the item. + /// text of the item. + public void AddItem(T value, string text) + { + this.AddItem(new ListPickerItemTemplateModel(value, text)); + } + + /// add an new item to the list. + /// Stubbfel, 15.10.2013. + /// new item of the list. + public void AddItem(ListPickerItemTemplateModel item) + { + this.list.Add(item); + } + + /// remove an item. + /// Stubbfel, 15.10.2013. + /// value of the item. + /// text of the item. + /// true if removing was successful, otherwise false. + public bool RemoveItem(T value, string text) + { + return this.RemoveItem(new ListPickerItemTemplateModel(value, text)); + } + + /// remove an item. + /// Stubbfel, 15.10.2013. + /// item which has to be remove. + /// true if removing was successful, otherwise false. + public bool RemoveItem(ListPickerItemTemplateModel item) + { + return this.list.Remove(item); + } + + #endregion + + #region protected + + /// Method load an default list. + /// load an empty list. + protected virtual void LoadList() + { + return; + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemModel.cs index 0984aa42..bc8a6d17 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemModel.cs @@ -10,7 +10,7 @@ namespace CampusAppWPortalLib8.Model.Utility { /// Model for the ListPickerItems. /// Stubbfel, 15.10.2013. - public class ListPickerItemModel + public class ListPickerItemModel : ListPickerItemTemplateModel { #region Constructor @@ -19,6 +19,7 @@ namespace CampusAppWPortalLib8.Model.Utility /// /// Stubbfel, 15.10.2013. public ListPickerItemModel() + : base() { } @@ -29,23 +30,10 @@ namespace CampusAppWPortalLib8.Model.Utility /// string for the value property of an item. /// string for the text property of an item. public ListPickerItemModel(string value, string text) + : base(value, text) { - this.Value = value; - this.Text = text; } #endregion - - #region Property - - /// Gets or sets the Value of an Item. - /// The value. - public string Value { get; set; } - - /// Gets or sets the Text (caption) of an Item. - /// The text. - public string Text { get; set; } - - #endregion } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemTemplateModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemTemplateModel.cs new file mode 100644 index 00000000..1ac959bd --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/ListPickerItemTemplateModel.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Stubbfel +// 26.11.2013 +// Implements the list picker item template model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Utility +{ + /// A data Model for the list picker item template. + /// Stubbfel, 26.11.2013. + /// Generic type parameter. + public class ListPickerItemTemplateModel + { + #region Constructor + + /// Initializes a new instance of the ListPickerItemTemplateModel class. + /// Stubbfel, 26.11.2013. + public ListPickerItemTemplateModel() + { + } + + /// Initializes a new instance of the ListPickerItemTemplateModel class. + /// Stubbfel, 26.11.2013. + /// The value. + /// The text. + public ListPickerItemTemplateModel(V value, string text) + { + this.Value = value; + this.Text = text; + } + + #endregion + + #region Property + + /// Gets or sets the Value of an Item. + /// The value. + public V Value { get; set; } + + /// Gets or sets the Text (caption) of an Item. + /// The text. + public string Text { get; set; } + + #endregion + } +}