finish #119
This commit is contained in:
@@ -40,9 +40,39 @@ namespace CampusAppWP8.Model.Lecture
|
||||
private List<ListPickerItemModel> semesterList;
|
||||
|
||||
/// <summary>
|
||||
/// List for the number of semester
|
||||
/// List for the number of semester (from)
|
||||
/// </summary>
|
||||
private List<ListPickerItemModel> numberList;
|
||||
private List<ListPickerItemModel> fromNumberList;
|
||||
|
||||
/// <summary>
|
||||
/// List for the number of semester (to)
|
||||
/// </summary>
|
||||
private List<ListPickerItemModel> toNumberList;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the courseIndex
|
||||
/// </summary>
|
||||
private int selectCourseIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the degreeIndex
|
||||
/// </summary>
|
||||
private int selectDegreeIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the semesterIndex
|
||||
/// </summary>
|
||||
private int selectSemesterIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the fromIndex
|
||||
/// </summary>
|
||||
private int selectFromIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the toIndex
|
||||
/// </summary>
|
||||
private int selectToIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -62,31 +92,101 @@ namespace CampusAppWP8.Model.Lecture
|
||||
/// Gets or sets the selected course index
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SelectCourseIndex { get; set; }
|
||||
public int SelectCourseIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectCourseIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.selectCourseIndex && this.courseList != null && value < this.courseList.Count)
|
||||
{
|
||||
this.selectCourseIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected degree index
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SelectDegreeIndex { get; set; }
|
||||
public int SelectDegreeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectDegreeIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.selectDegreeIndex && this.degreeList != null && value < this.degreeList.Count)
|
||||
{
|
||||
this.selectDegreeIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected semester-index
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SelectSemesterIndex { get; set; }
|
||||
public int SelectSemesterIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectSemesterIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.selectSemesterIndex && this.semesterList != null && value < this.semesterList.Count)
|
||||
{
|
||||
this.selectSemesterIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected from-index
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SelectFromIndex { get; set; }
|
||||
public int SelectFromIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectFromIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.selectFromIndex && this.fromNumberList != null && value < this.fromNumberList.Count)
|
||||
{
|
||||
this.selectFromIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected to-index
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int SelectToIndex { get; set; }
|
||||
public int SelectToIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectToIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.selectToIndex && this.toNumberList != null && value < this.toNumberList.Count)
|
||||
{
|
||||
this.selectToIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets List for the courses of the BTU
|
||||
@@ -124,11 +224,22 @@ namespace CampusAppWP8.Model.Lecture
|
||||
/// <summary>
|
||||
/// Gets List for the number of semester
|
||||
/// </summary>
|
||||
public List<ListPickerItemModel> NumberList
|
||||
public List<ListPickerItemModel> FromNumberList
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.numberList;
|
||||
return this.fromNumberList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the NumberList
|
||||
/// </summary>
|
||||
public List<ListPickerItemModel> ToNumberList
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.toNumberList;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -144,7 +255,8 @@ namespace CampusAppWP8.Model.Lecture
|
||||
{
|
||||
this.LoadCourseList();
|
||||
this.LoadDegreeList();
|
||||
this.LoadNumberList();
|
||||
this.LoadFromNumberList();
|
||||
this.LoadToNumberList();
|
||||
this.LoadSemesterList();
|
||||
}
|
||||
|
||||
@@ -155,20 +267,55 @@ namespace CampusAppWP8.Model.Lecture
|
||||
/// <summary>
|
||||
/// Load the NumberList
|
||||
/// </summary>
|
||||
private void LoadNumberList()
|
||||
public void LoadFromNumberList()
|
||||
{
|
||||
this.numberList = new List<ListPickerItemModel>();
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "1", Value = "1" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "2", Value = "2" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "3", Value = "3" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "4", Value = "4" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "5", Value = "5" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "5", Value = "6" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "7", Value = "7" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "8", Value = "8" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "9", Value = "9" });
|
||||
this.numberList.Add(new ListPickerItemModel() { Text = "10", Value = "10" });
|
||||
string selectValue = null;
|
||||
if (this.fromNumberList != null)
|
||||
{
|
||||
selectValue = this.fromNumberList[this.SelectFromIndex].Value;
|
||||
}
|
||||
|
||||
this.fromNumberList = this.CreateNumberList(1, 10);
|
||||
this.SelectFromIndex = this.GetIndexOrDefault(this.fromNumberList, selectValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the NumberList
|
||||
/// </summary>
|
||||
public void LoadToNumberList()
|
||||
{
|
||||
string selectValue = null;
|
||||
if (this.toNumberList != null)
|
||||
{
|
||||
selectValue = this.toNumberList[this.SelectToIndex].Value;
|
||||
}
|
||||
|
||||
this.toNumberList = this.CreateNumberList(this.SelectFromIndex + 1, 10);
|
||||
this.SelectToIndex = this.GetIndexOrDefault(this.toNumberList, selectValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method create a NumberList
|
||||
/// </summary>
|
||||
/// <param name="startvalue">startValue of the list</param>
|
||||
/// <param name="endvalue">endValue of the list</param>
|
||||
/// <returns>return list</returns>
|
||||
private List<ListPickerItemModel> CreateNumberList(int startvalue, int endvalue)
|
||||
{
|
||||
List<ListPickerItemModel> list = new List<ListPickerItemModel>();
|
||||
string degree = this.DegreeList[this.SelectDegreeIndex].Value;
|
||||
|
||||
for (int i = startvalue; i <= endvalue; i++)
|
||||
{
|
||||
if ((i > 4 && "88".Equals(degree)) || (i > 6 && "82".Equals(degree)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
list.Add(new ListPickerItemModel() { Text = i.ToString(), Value = i.ToString() });
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -244,6 +391,29 @@ namespace CampusAppWP8.Model.Lecture
|
||||
this.courseList = this.courseList.OrderBy(o => o.Text).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method return a the Index of an item which has a certain value
|
||||
/// </summary>
|
||||
/// <param name="list">list for items</param>
|
||||
/// <param name="value">a certain value</param>
|
||||
/// <returns>return index of value or default(0)</returns>
|
||||
private int GetIndexOrDefault(List<ListPickerItemModel> list, string value)
|
||||
{
|
||||
int index = 0;
|
||||
int i = 0;
|
||||
foreach (ListPickerItemModel item in list)
|
||||
{
|
||||
if (item.Value.Equals(value))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<StackPanel >
|
||||
<!-- Listpicket of degree-->
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.LectureApp_Degree, Source={StaticResource LocalizedStrings}}"/>
|
||||
<toolkit:ListPicker Name="Degree" ExpansionMode="FullScreenOnly">
|
||||
<toolkit:ListPicker Name="Degree" ExpansionMode="FullScreenOnly" SelectionChanged="DegreeSelectionChanged">
|
||||
<toolkit:ListPicker.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
@@ -100,7 +100,7 @@
|
||||
<!-- Listpicket of semesters(from to) -->
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.LectureApp_Term, Source={StaticResource LocalizedStrings}}"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<toolkit:ListPicker Width="60" Name="From" ExpansionMode="FullScreenOnly">
|
||||
<toolkit:ListPicker Width="60" Name="From" ExpansionMode="FullScreenOnly" SelectionChanged="FromSelectionChanged">
|
||||
<toolkit:ListPicker.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// </remarks>
|
||||
private LecturePageModel pageModel;
|
||||
|
||||
/// <summary>
|
||||
/// flag for initialed page
|
||||
/// </summary>
|
||||
private bool init;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -48,8 +53,10 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
public LecturePage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.init = false;
|
||||
this.LoadPageModel();
|
||||
this.SetupListPickers();
|
||||
this.init = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -98,8 +105,8 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
{
|
||||
this.Course.ItemsSource = this.pageModel.CourseList;
|
||||
this.Degree.ItemsSource = this.pageModel.DegreeList;
|
||||
this.From.ItemsSource = this.pageModel.NumberList;
|
||||
this.To.ItemsSource = this.pageModel.NumberList;
|
||||
this.From.ItemsSource = this.pageModel.FromNumberList;
|
||||
this.To.ItemsSource = this.pageModel.ToNumberList;
|
||||
this.Semester.ItemsSource = this.pageModel.SemesterList;
|
||||
|
||||
// load values from last request
|
||||
@@ -198,6 +205,41 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
NavigationService.Navigate(url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler for changed degree selection
|
||||
/// </summary>
|
||||
/// <param name="sender">sender object</param>
|
||||
/// <param name="e">some args</param>
|
||||
private void DegreeSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!this.init)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pageModel.SelectDegreeIndex = this.Degree.SelectedIndex;
|
||||
this.pageModel.LoadFromNumberList();
|
||||
this.From.ItemsSource = this.pageModel.FromNumberList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler for changed from selection
|
||||
/// </summary>
|
||||
/// <param name="sender">sender object</param>
|
||||
/// <param name="e">some args</param>
|
||||
private void FromSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!this.init)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pageModel.SelectDegreeIndex = this.Degree.SelectedIndex;
|
||||
this.pageModel.SelectFromIndex = this.From.SelectedIndex;
|
||||
this.pageModel.LoadToNumberList();
|
||||
this.To.ItemsSource = this.pageModel.ToNumberList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user