fitler by tilte and insert noresultmessage box
This commit is contained in:
@@ -52,6 +52,24 @@ namespace CampusAppWP8.Model.Lecture
|
||||
return activity;
|
||||
}
|
||||
|
||||
/// <summary>Filter by course string.</summary>
|
||||
/// <remarks>Stubbfel, 10.09.2013.</remarks>
|
||||
/// <param name="filter">Specifies the filter.</param>
|
||||
public void FilterByCourseTitle(string filter)
|
||||
{
|
||||
ObservableCollection<LectureActivity> filteredCollection = new ObservableCollection<LectureActivity>();
|
||||
filter = filter.Trim().ToLower();
|
||||
foreach (LectureActivity activity in this.Activities)
|
||||
{
|
||||
activity.CreateCourseString();
|
||||
if (activity.Title.ToLower().Contains(filter))
|
||||
{
|
||||
filteredCollection.Add(activity);
|
||||
}
|
||||
}
|
||||
|
||||
this.Activities = filteredCollection;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Api.Lecture;
|
||||
@@ -17,6 +18,7 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility.Lui.MessageBoxes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the LecturePage
|
||||
@@ -63,7 +65,7 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
#region methods
|
||||
|
||||
#region protected
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Methods overrides the OnNavigatedFrom-Method
|
||||
/// </summary>
|
||||
@@ -198,6 +200,11 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// </summary>
|
||||
private void ApiIsReady()
|
||||
{
|
||||
string query = this.ActivtyName.Text;
|
||||
if (!query.Equals(string.Empty))
|
||||
{
|
||||
this.api.Model.FilterByCourseTitle(query);
|
||||
}
|
||||
App.SaveToIsolatedStorage<LectureList>(Constants.IsolatedStorage_LectureModel, this.api.Model);
|
||||
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Uri url = new Uri(Constants.PathLecture_ResultPage, UriKind.Relative);
|
||||
|
||||
@@ -9,9 +9,11 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Model.Lecture;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility.Lui.MessageBoxes;
|
||||
using Microsoft.Phone.Controls;
|
||||
|
||||
/// <summary>
|
||||
@@ -33,6 +35,7 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// <param name="e">Arguments of navigation</param>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
LectureList list = App.LoadFromIsolatedStorage<LectureList>(Constants.IsolatedStorage_LectureModel);
|
||||
if (list == null)
|
||||
{
|
||||
@@ -41,8 +44,20 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
return;
|
||||
}
|
||||
|
||||
this.ResultList.ItemsSource = list.Activities.OrderByDescending(o => o.Type).ThenBy(o => o.Title).ToList();
|
||||
base.OnNavigatedTo(e);
|
||||
if (list.Activities.Count > 0)
|
||||
{
|
||||
|
||||
this.ResultList.ItemsSource = list.Activities.OrderByDescending(o => o.Type).ThenBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBoxResult result = MessageBoxes.ShowMainModelInfoMessageBox(AppResources.MsgBox_NoResult);
|
||||
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
NavigationService.GoBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,6 +645,24 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Hinweis ähnelt.
|
||||
/// </summary>
|
||||
public static string MsgBox_InfoHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgBox_InfoHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Es gibt keine Ergebnisse zur gestellten Anfrage ähnelt.
|
||||
/// </summary>
|
||||
public static string MsgBox_NoResult {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgBox_NoResult", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die News ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -446,4 +446,10 @@
|
||||
<data name="PlaceNewsApp_Title" xml:space="preserve">
|
||||
<value>Placenews</value>
|
||||
</data>
|
||||
<data name="MsgBox_InfoHeader" xml:space="preserve">
|
||||
<value>Hinweis</value>
|
||||
</data>
|
||||
<data name="MsgBox_NoResult" xml:space="preserve">
|
||||
<value>Es gibt keine Ergebnisse zur gestellten Anfrage</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -33,5 +33,14 @@ namespace CampusAppWP8.Utility.Lui.MessageBoxes
|
||||
{
|
||||
return MessageBox.Show(text, AppResources.MsgBox_ErrorHeader, MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
/// <summary>Shows the main model information message box.</summary>
|
||||
/// <remarks>Stubbfel, 10.09.2013.</remarks>
|
||||
/// <param name="text">custom text for the box.</param>
|
||||
/// <returns>.</returns>
|
||||
public static MessageBoxResult ShowMainModelInfoMessageBox(string text)
|
||||
{
|
||||
return MessageBox.Show(text, AppResources.MsgBox_InfoHeader, MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user