add listpicker
This commit is contained in:
@@ -145,6 +145,8 @@
|
||||
<Compile Include="Model\Setting\UserProfilModel.cs" />
|
||||
<Compile Include="Model\TimeTable\AppointmentListModel.cs" />
|
||||
<Compile Include="Model\TimeTable\AppointmentModel.cs" />
|
||||
<Compile Include="Model\Utility\AppAccentColorListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\ColorListPickerItemModel.cs" />
|
||||
<Compile Include="Pages\Setting\FunctionSettingPage.xaml.cs">
|
||||
<DependentUpon>FunctionSettingPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AppAccentColorListPickerItemListModel.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>26.11.2013</date>
|
||||
// <summary>Implements the application accent color list picker item list model class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.Utility
|
||||
{
|
||||
|
||||
using CampusAppWPortalLib8.Resources;
|
||||
using System.Windows.Media;
|
||||
|
||||
/// <summary> A data Model for the application accent color list picker item list. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWPortalLib8.Model.Utility.ListPickerItemListTemplateModel{System.Windows.Media.Color}"/>
|
||||
public class AppAccentColorListPickerItemListModel : CampusAppWPortalLib8.Model.Utility.ListPickerItemListTemplateModel<SolidColorBrush>
|
||||
{
|
||||
#region member
|
||||
|
||||
/// <summary> The faculty 1 color. </summary>
|
||||
private static readonly SolidColorBrush faculty1Color = (SolidColorBrush)App.Current.Resources["FacultyBrush1"];
|
||||
|
||||
/// <summary> The faculty 2 color. </summary>
|
||||
private static readonly SolidColorBrush faculty2Color = (SolidColorBrush)App.Current.Resources["FacultyBrush2"];
|
||||
|
||||
/// <summary> The faculty 3 color. </summary>
|
||||
private static readonly SolidColorBrush faculty3Color = (SolidColorBrush)App.Current.Resources["FacultyBrush3"];
|
||||
|
||||
/// <summary> The faculty 4 color. </summary>
|
||||
private static readonly SolidColorBrush faculty4Color = (SolidColorBrush)App.Current.Resources["FacultyBrush4"];
|
||||
|
||||
/// <summary> The faculty 5 color. </summary>
|
||||
private static readonly SolidColorBrush faculty5Color = (SolidColorBrush)App.Current.Resources["FacultyBrush5"];
|
||||
|
||||
/// <summary> The faculty. </summary>
|
||||
private readonly string faculty = AppResources.Faculty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AppAccentColorListPickerItemListModel class.
|
||||
/// </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
public AppAccentColorListPickerItemListModel()
|
||||
: base()
|
||||
{
|
||||
this.LoadList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Loads the list. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
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, faculty + " 3"));
|
||||
this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.faculty4Color, faculty + " 4"));
|
||||
this.AddItem(new ColorListPickerItemModel(AppAccentColorListPickerItemListModel.faculty5Color, faculty + " 5"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ColorListPickerItemModel.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>26.11.2013</date>
|
||||
// <summary>Implements the color list picker item model class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.Utility
|
||||
{
|
||||
using System.Windows.Media;
|
||||
|
||||
/// <summary> A data Model for the color list picker item. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWPortalLib8.Model.Utility.ListPickerItemTemplateModel{System.Windows.Media.Color}"/>
|
||||
public class ColorListPickerItemModel : CampusAppWPortalLib8.Model.Utility.ListPickerItemTemplateModel<SolidColorBrush>
|
||||
{
|
||||
/// <summary> Initializes a new instance of the ColorListPickerItemModel class. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
public ColorListPickerItemModel()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the ColorListPickerItemModel class. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <param name="value"> The value. </param>
|
||||
/// <param name="text"> The text. </param>
|
||||
public ColorListPickerItemModel(SolidColorBrush value, string text)
|
||||
: base(value, text)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,29 @@
|
||||
</phone:PivotItem>
|
||||
<phone:PivotItem
|
||||
Header="{Binding Path=LocalizedResources.Setting_Display_Short, Source={StaticResource LocalizedStrings}}">
|
||||
|
||||
<StackPanel >
|
||||
<TextBlock
|
||||
Text="{Binding Path=LocalizedResources.AccentColor, Source={StaticResource LocalizedStrings}}" Style="{StaticResource SettingLabel}"/>
|
||||
<!-- Listpicket of courses -->
|
||||
<toolkit:ListPicker Name="AccentColorPicker" FullModeHeader="{Binding Path=LocalizedResources.AccentColorPicker, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Center" SelectionChanged="AccentColorPicker_SelectionChanged">
|
||||
<toolkit:ListPicker.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle Fill="{Binding Value}" Height="24" Width="24" Stroke="Black"/>
|
||||
<TextBlock Text="{Binding Text}" Margin="12,0,0,0"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</toolkit:ListPicker.ItemTemplate>
|
||||
<toolkit:ListPicker.FullModeItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,12,0,0">
|
||||
<Rectangle Fill="{Binding Value}" Height="48" Width="48" Stroke="Black"/>
|
||||
<TextBlock Text="{Binding Text}" Style="{StaticResource PhoneTextGroupHeaderStyle}" TextWrapping="Wrap" Margin="24,0,0,0"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</toolkit:ListPicker.FullModeItemTemplate>
|
||||
</toolkit:ListPicker>
|
||||
</StackPanel>
|
||||
</phone:PivotItem>
|
||||
|
||||
<phone:PivotItem
|
||||
|
||||
@@ -12,12 +12,23 @@ namespace CampusAppWP8.Pages.Setting
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Resources;
|
||||
using Microsoft.Phone.Controls;
|
||||
using CampusAppWP8.Model.Utility;
|
||||
using System.Windows.Media;
|
||||
using CampusAppWP8.Utility;
|
||||
|
||||
/// <summary> Class for the AppSettingPage. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <seealso cref="T:Microsoft.Phone.Controls.PhoneApplicationPage"/>
|
||||
public partial class AppSettingPage : PhoneApplicationPage, IRefreshingPage
|
||||
{
|
||||
|
||||
#region member
|
||||
|
||||
/// <summary> List of colors of the application accents. </summary>
|
||||
private readonly AppAccentColorListPickerItemListModel appAccentColors = new AppAccentColorListPickerItemListModel();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the <see cref="AppSettingPage" /> class. </summary>
|
||||
@@ -25,6 +36,7 @@ namespace CampusAppWP8.Pages.Setting
|
||||
public AppSettingPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.AccentColorPicker.ItemsSource = this.appAccentColors.List;
|
||||
this.LoadSettings();
|
||||
}
|
||||
|
||||
@@ -84,6 +96,7 @@ namespace CampusAppWP8.Pages.Setting
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary> Saves the settings. </summary>
|
||||
@@ -104,6 +117,20 @@ namespace CampusAppWP8.Pages.Setting
|
||||
this.LoadSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler. Called by AccentColorPicker for selection changed events.
|
||||
/// </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Selection changed event information. </param>
|
||||
private void AccentColorPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
int selectedIndex = this.AccentColorPicker.SelectedIndex;
|
||||
Color newColor = this.appAccentColors.List[selectedIndex].Value.Color;
|
||||
Utilities.SwitchAccentColor(newColor);
|
||||
Settings.AppSetting.DisplaySetting.AppAccentColor = newColor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -60,6 +60,24 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Akzentfarbe ähnelt.
|
||||
/// </summary>
|
||||
public static string AccentColor {
|
||||
get {
|
||||
return ResourceManager.GetString("AccentColor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Akzentfarbe-Auswahl ähnelt.
|
||||
/// </summary>
|
||||
public static string AccentColorPicker {
|
||||
get {
|
||||
return ResourceManager.GetString("AccentColorPicker", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Hinzufügen ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -662,4 +662,10 @@
|
||||
<data name="Setting_Mensa" xml:space="preserve">
|
||||
<value>Mensa</value>
|
||||
</data>
|
||||
<data name="AccentColor" xml:space="preserve">
|
||||
<value>Akzentfarbe</value>
|
||||
</data>
|
||||
<data name="AccentColorPicker" xml:space="preserve">
|
||||
<value>Akzentfarbe-Auswahl</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -3,10 +3,14 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:System="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<Color x:Key="Faculty1">#d20078</Color>
|
||||
<Color x:Key="Faculty2">#0050a0</Color>
|
||||
<Color x:Key="Faculty3">#009bd2</Color>
|
||||
<Color x:Key="Faculty4">#a5c300</Color>
|
||||
<Color x:Key="Faculty5">#ff9900</Color>
|
||||
|
||||
<Color x:Key="FacultyColor1">#d20078</Color>
|
||||
<Color x:Key="FacultyColor2">#0050a0</Color>
|
||||
<Color x:Key="FacultyColor3">#009bd2</Color>
|
||||
<Color x:Key="FacultyColor4">#a5c300</Color>
|
||||
<Color x:Key="FacultyColor5">#ff9900</Color>
|
||||
<SolidColorBrush x:Key="FacultyBrush1">#d20078</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="FacultyBrush2">#0050a0</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="FacultyBrush3">#009bd2</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="FacultyBrush4">#a5c300</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="FacultyBrush5">#ff9900</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
@@ -459,8 +459,7 @@ namespace CampusAppWP8.Utility
|
||||
return;
|
||||
}
|
||||
App.Current.Resources.Remove(ressourceKey);
|
||||
App.Current.Resources.Add(ressourceKey, newColor);
|
||||
((SolidColorBrush)App.Current.Resources[ressourceKey]).Color = newColor;
|
||||
App.Current.Resources.Add(ressourceKey, newColor);
|
||||
}
|
||||
|
||||
/// <summary> Switch accent color. </summary>
|
||||
@@ -468,7 +467,8 @@ namespace CampusAppWP8.Utility
|
||||
/// <param name="newColor"> The new color. </param>
|
||||
public static void SwitchAccentColor(Color newColor)
|
||||
{
|
||||
Utilities.SwitchColor("PhoneAccentBrush", newColor);
|
||||
Utilities.SwitchColor("PhoneAccentColor", newColor);
|
||||
((SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]).Color = newColor;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -91,7 +91,9 @@
|
||||
<Compile Include="Model\Utility\DegreeListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\GeoMapPoint.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemListTemplateModel.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemModel.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemTemplateModel.cs" />
|
||||
<Compile Include="Model\Utility\MapPoint.cs" />
|
||||
<Compile Include="Model\Utility\RoleListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\SemesterListPickerItemListModel.cs">
|
||||
|
||||
@@ -70,6 +70,10 @@ namespace CampusAppWPortalLib8.Model.Mensa
|
||||
/// <returns> The canteen. </returns>
|
||||
public PriceCanteenModel GetCanteen(Campus campus)
|
||||
{
|
||||
if (campus == Campus.CB_NORTH)
|
||||
{
|
||||
return this.GetCanteen((int)Campus.CB_MAIN - 1);
|
||||
}
|
||||
return this.GetCanteen((int)campus - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -12,15 +12,8 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
|
||||
/// <summary> Class for a List of ListPickerItems. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public class ListPickerItemListModel
|
||||
public class ListPickerItemListModel : ListPickerItemListTemplateModel<string>
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> reference of the itemList. </summary>
|
||||
private List<ListPickerItemModel> list;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
@@ -28,109 +21,10 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
/// </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public ListPickerItemListModel()
|
||||
: base()
|
||||
{
|
||||
this.list = new List<ListPickerItemModel>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary> Gets or sets the ItemList. </summary>
|
||||
/// <value> The list. </value>
|
||||
public List<ListPickerItemModel> List
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.list;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.list)
|
||||
{
|
||||
this.list = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary> Method return a the Index of an item which has a certain value. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> a certain value. </param>
|
||||
/// <returns> return index of value or default(0) </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> add an new item to the list. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> value of the item. </param>
|
||||
/// <param name="text"> text of the item. </param>
|
||||
public void AddItem(string value, string text)
|
||||
{
|
||||
this.AddItem(new ListPickerItemModel(value, text));
|
||||
}
|
||||
|
||||
/// <summary> add an new item to the list. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="item"> new item of the list. </param>
|
||||
public void AddItem(ListPickerItemModel item)
|
||||
{
|
||||
this.list.Add(item);
|
||||
}
|
||||
|
||||
/// <summary> remove an item. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> value of the item. </param>
|
||||
/// <param name="text"> text of the item. </param>
|
||||
/// <returns> true if removing was successful, otherwise false. </returns>
|
||||
public bool RemoveItem(string value, string text)
|
||||
{
|
||||
return this.RemoveItem(new ListPickerItemModel(value, text));
|
||||
}
|
||||
|
||||
/// <summary> remove an item. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="item"> item which has to be remove. </param>
|
||||
/// <returns> true if removing was successful, otherwise false. </returns>
|
||||
public bool RemoveItem(ListPickerItemModel item)
|
||||
{
|
||||
return this.list.Remove(item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected
|
||||
|
||||
/// <summary> Method load an default list. </summary>
|
||||
/// <remarks> load an empty list. </remarks>
|
||||
protected virtual void LoadList()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ListPickerItemListTemplateModel.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>26.11.2013</date>
|
||||
// <summary>Implements the list picker item list template model class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Model.Utility
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary> A data Model for the list picker item list template. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <typeparam name="T"> Generic type parameter. </typeparam>
|
||||
public class ListPickerItemListTemplateModel<T>
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> reference of the itemList. </summary>
|
||||
private List<ListPickerItemTemplateModel<T>> list;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the ListPickerItemListTemplateModel class. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
public ListPickerItemListTemplateModel()
|
||||
{
|
||||
this.list = new List<ListPickerItemTemplateModel<T>>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary> Gets or sets the ItemList. </summary>
|
||||
/// <value> The list. </value>
|
||||
public List<ListPickerItemTemplateModel<T>> List
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.list;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.list)
|
||||
{
|
||||
this.list = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary> Method return a the Index of an item which has a certain value. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> a certain value. </param>
|
||||
/// <returns> return index of value or default(0) </returns>
|
||||
public virtual int GetIndexOrDefault(T value)
|
||||
{
|
||||
int index = 0;
|
||||
int i = 0;
|
||||
foreach (ListPickerItemTemplateModel<T> item in this.list)
|
||||
{
|
||||
if (item.Value.Equals(value))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/// <summary> add an new item to the list. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> value of the item. </param>
|
||||
/// <param name="text"> text of the item. </param>
|
||||
public void AddItem(T value, string text)
|
||||
{
|
||||
this.AddItem(new ListPickerItemTemplateModel<T>(value, text));
|
||||
}
|
||||
|
||||
/// <summary> add an new item to the list. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="item"> new item of the list. </param>
|
||||
public void AddItem(ListPickerItemTemplateModel<T> item)
|
||||
{
|
||||
this.list.Add(item);
|
||||
}
|
||||
|
||||
/// <summary> remove an item. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="value"> value of the item. </param>
|
||||
/// <param name="text"> text of the item. </param>
|
||||
/// <returns> true if removing was successful, otherwise false. </returns>
|
||||
public bool RemoveItem(T value, string text)
|
||||
{
|
||||
return this.RemoveItem(new ListPickerItemTemplateModel<T>(value, text));
|
||||
}
|
||||
|
||||
/// <summary> remove an item. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="item"> item which has to be remove. </param>
|
||||
/// <returns> true if removing was successful, otherwise false. </returns>
|
||||
public bool RemoveItem(ListPickerItemTemplateModel<T> item)
|
||||
{
|
||||
return this.list.Remove(item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected
|
||||
|
||||
/// <summary> Method load an default list. </summary>
|
||||
/// <remarks> load an empty list. </remarks>
|
||||
protected virtual void LoadList()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
{
|
||||
/// <summary> Model for the ListPickerItems. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public class ListPickerItemModel
|
||||
public class ListPickerItemModel : ListPickerItemTemplateModel<string>
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
/// </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
public ListPickerItemModel()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,23 +30,10 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
/// <param name="value"> string for the value property of an item. </param>
|
||||
/// <param name="text"> string for the text property of an item. </param>
|
||||
public ListPickerItemModel(string value, string text)
|
||||
: base(value, text)
|
||||
{
|
||||
this.Value = value;
|
||||
this.Text = text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary> Gets or sets the Value of an Item. </summary>
|
||||
/// <value> The value. </value>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the Text (caption) of an Item. </summary>
|
||||
/// <value> The text. </value>
|
||||
public string Text { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ListPickerItemTemplateModel.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>26.11.2013</date>
|
||||
// <summary>Implements the list picker item template model class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Model.Utility
|
||||
{
|
||||
/// <summary> A data Model for the list picker item template. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <typeparam name="V"> Generic type parameter. </typeparam>
|
||||
public class ListPickerItemTemplateModel<V>
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the ListPickerItemTemplateModel class. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
public ListPickerItemTemplateModel()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the ListPickerItemTemplateModel class. </summary>
|
||||
/// <remarks> Stubbfel, 26.11.2013. </remarks>
|
||||
/// <param name="value"> The value. </param>
|
||||
/// <param name="text"> The text. </param>
|
||||
public ListPickerItemTemplateModel(V value, string text)
|
||||
{
|
||||
this.Value = value;
|
||||
this.Text = text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary> Gets or sets the Value of an Item. </summary>
|
||||
/// <value> The value. </value>
|
||||
public V Value { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the Text (caption) of an Item. </summary>
|
||||
/// <value> The text. </value>
|
||||
public string Text { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user