Added search view

This commit is contained in:
2015-12-27 16:02:15 +01:00
parent 429f1b8df3
commit 6643c71824
35 changed files with 594 additions and 39 deletions
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
@@ -0,0 +1,18 @@
using NavCityBreda.Model.Search;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
{
class SearchLandmarkComparer : IComparer<LandmarkResult>
{
public int Compare(LandmarkResult x, LandmarkResult y)
{
if (x.InDescription == y.InDescription)
return x.Name.CompareTo(y.Name);
else if (x.InDescription)
return 1;
else
return -1;
}
}
}
@@ -0,0 +1,18 @@
using NavCityBreda.Model.Search;
using System.Collections.Generic;
namespace NavCityBreda.Helpers.Comparer
{
class SearchRouteComparer : IComparer<RouteResult>
{
public int Compare(RouteResult x, RouteResult y)
{
if (x.InDescription == y.InDescription)
return x.Name.CompareTo(y.Name);
else if (x.InDescription)
return 1;
else
return -1;
}
}
}
@@ -1,4 +1,5 @@
using System;
using NavCityBreda.Model.Object;
using System;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
@@ -8,16 +9,16 @@ namespace NavCityBreda.Helpers.Converter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
Model.Landmark.LandmarkStatus st = (Model.Landmark.LandmarkStatus)value;
Landmark.LandmarkStatus st = (Landmark.LandmarkStatus)value;
switch (st)
{
default:
case Model.Landmark.LandmarkStatus.NOTVISITED:
case Landmark.LandmarkStatus.NOTVISITED:
return Symbol.Cancel;
case Model.Landmark.LandmarkStatus.VISITED:
case Landmark.LandmarkStatus.VISITED:
return Symbol.Accept;
case Model.Landmark.LandmarkStatus.SKIPPED:
case Landmark.LandmarkStatus.SKIPPED:
return Symbol.Forward;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json.Linq;
+18
View File
@@ -312,4 +312,22 @@
<data name="Skipped" xml:space="preserve">
<value>Skipped</value>
</data>
<data name="Search" xml:space="preserve">
<value>Search</value>
</data>
<data name="SearchResults" xml:space="preserve">
<value>Search results</value>
</data>
<data name="SearchTerm" xml:space="preserve">
<value>Search term</value>
</data>
<data name="SearchResultCount" xml:space="preserve">
<value>results</value>
</data>
<data name="SearchDescription" xml:space="preserve">
<value>Search in description</value>
</data>
<data name="SearchResultDescription" xml:space="preserve">
<value>In description</value>
</data>
</root>
+18
View File
@@ -312,4 +312,22 @@
<data name="Skipped" xml:space="preserve">
<value>Overgeslagen</value>
</data>
<data name="Search" xml:space="preserve">
<value>Zoeken</value>
</data>
<data name="SearchResults" xml:space="preserve">
<value>Zoek resultaten</value>
</data>
<data name="SearchTerm" xml:space="preserve">
<value>Zoek term</value>
</data>
<data name="SearchResultCount" xml:space="preserve">
<value>resultaten</value>
</data>
<data name="SearchDescription" xml:space="preserve">
<value>Doorzoek beschrijving</value>
</data>
<data name="SearchResultDescription" xml:space="preserve">
<value>In beschrijving</value>
</data>
</root>
+15 -10
View File
@@ -21,7 +21,7 @@
<Style x:Key="NavText" TargetType="TextBlock">
<Setter Property="FontSize" Value="28" />
<Setter Property="Margin" Value="20,0,0,0" />
<Setter Property="Margin" Value="18,0,0,0" />
</Style>
@@ -57,39 +57,44 @@
</Viewbox>
</RelativePanel>
<!-- http://stackoverflow.com/questions/32108362/uwp-swipe-to-open-splitview-pane-->
<SplitView Grid.Row="1" Name="NavView" DisplayMode="Overlay" OpenPaneLength="275">
<SplitView.Pane>
<RelativePanel Name="MySplitviewPane" VerticalAlignment="Stretch"
<RelativePanel VerticalAlignment="Stretch"
ManipulationMode="TranslateX"
ManipulationCompleted="MySplitviewPane_ManipulationCompleted" Style="{ThemeResource DarkModeFix}">
ManipulationCompleted="Pane_ManipulationCompleted" Style="{ThemeResource DarkModeFix}">
<ListBox RelativePanel.AlignTopWithPanel="True" SelectionMode="Single" Name="NavList" SelectionChanged="NavList_SelectionChanged" Tapped="NavList_Tapped">
<ListBoxItem Name="NavListMap">
<ListBoxItem Name="NavListMap" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE909;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Map}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="NavListRoute">
<ListBoxItem Name="NavListRoute" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE7AD;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Route}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="NavListLandmarks">
<ListBoxItem Name="NavListLandmarks" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE913;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Landmarks}" />
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="NavListHelp">
<ListBoxItem Name="NavListHelp" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE897;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Help}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="NavListSettings">
<ListBoxItem Name="NavListSearch" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE71E;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Search}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="NavListSettings" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
<StackPanel Style="{StaticResource NavStackPanel}">
<TextBlock Style="{StaticResource NavIcon}" Text="&#xE713;"/>
<TextBlock Style="{StaticResource NavText}" Text="{Binding Settings}"/>
@@ -131,7 +136,7 @@
<Frame Name="Frame"/>
<StackPanel ManipulationMode="TranslateX"
ManipulationCompleted="Grid_ManipulationCompleted"
ManipulationCompleted="Content_ManipulationCompleted"
Width="10"
Background="Transparent"
HorizontalAlignment="Left"
+8 -3
View File
@@ -91,7 +91,7 @@ namespace NavCityBreda
NavList.SelectedIndex = 3;
break;
case "settingsview":
NavList.SelectedIndex = 4;
NavList.SelectedIndex = 5;
break;
case "mapview":
NavList.SelectedIndex = 0;
@@ -104,6 +104,9 @@ namespace NavCityBreda
case "landmarkview":
NavList.SelectedIndex = 2;
break;
case "searchview":
NavList.SelectedIndex = 4;
break;
}
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
@@ -131,6 +134,8 @@ namespace NavCityBreda
Frame.Navigate(typeof(LandmarkView));
else if (NavListSettings.IsSelected)
Frame.Navigate(typeof(SettingsView));
else if (NavListSearch.IsSelected)
Frame.Navigate(typeof(SearchView));
else if (NavListRoute.IsSelected)
{
if (App.RouteManager.CurrentRoute == null)
@@ -145,7 +150,7 @@ namespace NavCityBreda
NavView.IsPaneOpen = false;
}
private void Grid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
private void Content_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (e.Cumulative.Translation.X > 20)
{
@@ -153,7 +158,7 @@ namespace NavCityBreda
}
}
private void MySplitviewPane_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
private void Pane_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (e.Cumulative.Translation.X < -20)
{
@@ -1,6 +1,6 @@
using Windows.UI.ViewManagement;
namespace NavCityBreda.Model
namespace NavCityBreda.Model.Object
{
public class Image
{
@@ -6,7 +6,7 @@ using Windows.Foundation;
using Windows.Storage.Streams;
using Windows.UI.Xaml.Controls.Maps;
namespace NavCityBreda.Model
namespace NavCityBreda.Model.Object
{
public class Landmark : Waypoint
{
@@ -7,7 +7,7 @@ using Windows.Devices.Geolocation;
using Windows.Services.Maps;
using Windows.UI.Xaml.Controls.Maps;
namespace NavCityBreda.Model
namespace NavCityBreda.Model.Object
{
public class Route
{
@@ -2,7 +2,7 @@
using Windows.Devices.Geolocation;
using Windows.UI.Xaml.Controls.Maps;
namespace NavCityBreda.Model
namespace NavCityBreda.Model.Object
{
public class Waypoint
{
+1
View File
@@ -1,4 +1,5 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model.Object;
using System;
using System.Collections.Generic;
using System.IO;
@@ -0,0 +1,19 @@
using NavCityBreda.Model.Object;
namespace NavCityBreda.Model.Search
{
public class LandmarkResult
{
public Landmark Landmark;
public string Name { get { return Landmark.Name; } }
public string Details { get; private set; }
public bool InDescription { get; private set; }
public LandmarkResult(Landmark l, string searchdetail, bool indesc)
{
Landmark = l;
Details = searchdetail;
InDescription = indesc;
}
}
}
+19
View File
@@ -0,0 +1,19 @@
using NavCityBreda.Model.Object;
namespace NavCityBreda.Model.Search
{
public class RouteResult
{
public Route Route;
public string Name { get { return Route.Name; } }
public string Details { get; private set; }
public bool InDescription { get; private set; }
public RouteResult(Route r, string searchdetail, bool indesc)
{
Route = r;
Details = searchdetail;
InDescription = indesc;
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using System.Collections.Generic;
namespace NavCityBreda.Model.Search
{
public class SearchResult
{
public List<RouteResult> Routes { get; private set; }
public List<LandmarkResult> Landmarks { get; private set; }
public string SearchTerm { get; private set; }
public int Results { get { return (Routes.Count + Landmarks.Count); } }
public SearchResult(string term)
{
SearchTerm = term;
Routes = new List<RouteResult>();
Landmarks = new List<LandmarkResult>();
}
public void Add(RouteResult r)
{
Routes.Add(r);
}
public void Add(List<RouteResult> r)
{
Routes.AddRange(r);
}
public void Add(LandmarkResult l)
{
Landmarks.Add(l);
}
public void Add(List<LandmarkResult> l)
{
Landmarks.AddRange(l);
}
}
}
+96
View File
@@ -0,0 +1,96 @@
using NavCityBreda.Helpers;
using NavCityBreda.Helpers.Comparer;
using NavCityBreda.Model.Object;
using NavCityBreda.Model.Search;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace NavCityBreda.Model
{
public class SearchHandler
{
public static async Task<SearchResult> Search(string term, bool description)
{
SearchResult rs = await SearchForResults(term, description);
return rs;
}
private static async Task<SearchResult> SearchForResults(string term, bool description)
{
List<RouteResult> rresults = new List<RouteResult>();
List<LandmarkResult> lresults = new List<LandmarkResult>();
SearchResult result = new SearchResult(term);
await Task.Run(() =>
{
//Search routes
foreach(Route r in App.RouteManager.Routes)
{
bool routefound = false;
int landmarksinroutefound = 0;
string landmarks = "";
//Search landmarks
foreach (Landmark l in r.Landmarks)
{
if (l.Name.ToLower().Contains(term.ToLower()))
{
routefound = true;
landmarks += (landmarksinroutefound > 0 ? ", " : "") + l.Name;
landmarksinroutefound++;
LandmarkResult ls = new LandmarkResult(l, "", false);
lresults.Add(ls);
}
else if (description)
{
if (l.Description.ToLower().Contains(term.ToLower()))
{
LandmarkResult ls = new LandmarkResult(l, Util.Loader.GetString("SearchResultDescription"), true);
lresults.Add(ls);
}
}
}
if(routefound)
{
string desc = "";
if (landmarksinroutefound <= 3)
desc = landmarks;
else
desc = landmarksinroutefound + " " + Util.Loader.GetString("Landmarks");
RouteResult rs = new RouteResult(r, desc, true);
rresults.Add(rs);
}
else if (r.Name.ToLower().Contains(term.ToLower()))
{
RouteResult rs = new RouteResult(r, "", false);
rresults.Add(rs);
}
else if(description)
{
if (r.Description.ToLower().Contains(term.ToLower()))
{
RouteResult rs = new RouteResult(r, Util.Loader.GetString("SearchResultDescription"), true);
rresults.Add(rs);
}
}
}
});
rresults.Sort(new SearchRouteComparer());
lresults.Sort(new SearchLandmarkComparer());
result.Add(rresults);
result.Add(lresults);
return result;
}
}
}
+18 -4
View File
@@ -154,6 +154,8 @@
<Compile Include="Helpers\Comparer\LandmarkAlphaReversedComparer.cs" />
<Compile Include="Helpers\Comparer\LandmarkNotVisitedComparer.cs" />
<Compile Include="Helpers\Comparer\LandmarkVisitedComparer.cs" />
<Compile Include="Helpers\Comparer\SearchLandmarkComparer.cs" />
<Compile Include="Helpers\Comparer\SearchRouteComparer.cs" />
<Compile Include="Helpers\Converter\StatusToIconConverter.cs" />
<Compile Include="Helpers\Extensions.cs" />
<Compile Include="Helpers\RouteParser.cs" />
@@ -168,11 +170,15 @@
</Compile>
<Compile Include="Model\CompassTracker.cs" />
<Compile Include="Model\GeoTracker.cs" />
<Compile Include="Model\Image.cs" />
<Compile Include="Model\Landmark.cs" />
<Compile Include="Model\Route.cs" />
<Compile Include="Model\Object\Image.cs" />
<Compile Include="Model\Object\Landmark.cs" />
<Compile Include="Model\Object\Route.cs" />
<Compile Include="Model\RouteManager.cs" />
<Compile Include="Model\Waypoint.cs" />
<Compile Include="Model\SearchHandler.cs" />
<Compile Include="Model\Search\LandmarkResult.cs" />
<Compile Include="Model\Search\RouteResult.cs" />
<Compile Include="Model\Search\SearchResult.cs" />
<Compile Include="Model\Object\Waypoint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\HelpVM.cs" />
<Compile Include="ViewModels\LandmarkDetailVM.cs" />
@@ -181,6 +187,7 @@
<Compile Include="ViewModels\MainPageVM.cs" />
<Compile Include="ViewModels\RouteDetailVM.cs" />
<Compile Include="ViewModels\RouteVM.cs" />
<Compile Include="ViewModels\SearchVM.cs" />
<Compile Include="ViewModels\SettingsVM.cs" />
<Compile Include="ViewModels\TemplateVM.cs" />
<Compile Include="Views\HelpView.xaml.cs">
@@ -198,6 +205,9 @@
<Compile Include="Views\RouteView.xaml.cs">
<DependentUpon>RouteView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SearchView.xaml.cs">
<DependentUpon>SearchView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
@@ -286,6 +296,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SearchView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+1 -1
View File
@@ -1,5 +1,5 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.ViewModels
+1 -1
View File
@@ -1,6 +1,6 @@
using NavCityBreda.Helpers;
using NavCityBreda.Helpers.Comparer;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.ViewModels
+9
View File
@@ -19,6 +19,7 @@ namespace NavCityBreda.ViewModels
NotifyPropertyChanged(nameof(Help));
NotifyPropertyChanged(nameof(Route));
NotifyPropertyChanged(nameof(Landmarks));
NotifyPropertyChanged(nameof(Search));
NotifyPropertyChanged(nameof(Settings));
NotifyPropertyChanged(nameof(Status));
NotifyPropertyChanged(nameof(Source));
@@ -68,6 +69,14 @@ namespace NavCityBreda.ViewModels
}
}
public string Search
{
get
{
return Util.Loader.GetString("Search");
}
}
public string Settings
{
get
+1 -1
View File
@@ -1,5 +1,5 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System;
using System.Collections.Generic;
using Windows.UI.ViewManagement;
+1 -1
View File
@@ -1,5 +1,5 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using System.Collections.Generic;
namespace NavCityBreda.ViewModels
+94
View File
@@ -0,0 +1,94 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model.Search;
using System.Collections.Generic;
namespace NavCityBreda.ViewModels
{
class SearchVM : TemplateVM
{
SearchResult result;
public SearchVM(SearchResult s) : base(Util.Loader.GetString("Search"))
{
result = s;
}
public void Update()
{
App.MainPage.Title = Util.Loader.GetString("Search");
}
protected override void UpdatePropertiesToNewLanguage()
{
NotifyPropertyChanged(nameof(Search));
NotifyPropertyChanged(nameof(Search));
NotifyPropertyChanged(nameof(Search));
NotifyPropertyChanged(nameof(Search));
}
public string SearchTerm
{
get
{
return Util.Loader.GetString("SearchTerm");
}
}
public string Search
{
get
{
return Util.Loader.GetString("Search");
}
}
public string SeachDescription
{
get
{
return Util.Loader.GetString("SearchDescription");
}
}
public string SearchResults
{
get
{
return Util.Loader.GetString("SearchResults");
}
}
public string Settings
{
get
{
return Util.Loader.GetString("Settings");
}
}
public string ResultCount
{
get
{
return result.Results + " " + Util.Loader.GetString("SearchResultCount");
}
}
public List<RouteResult> Routes
{
get
{
return result.Routes;
}
}
public List<LandmarkResult> Landmarks
{
get
{
return result.Landmarks;
}
}
}
}
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using NavCityBreda.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
+1 -1
View File
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using NavCityBreda.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+1
View File
@@ -10,6 +10,7 @@ using Windows.UI.Xaml.Navigation;
using Windows.Devices.Geolocation;
using Windows.UI.Xaml.Controls.Maps;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using Windows.Storage.Streams;
using NavCityBreda.Helpers;
using Windows.UI;
+1 -1
View File
@@ -1,5 +1,5 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using NavCityBreda.ViewModels;
using System;
using System.Threading.Tasks;
+1 -1
View File
@@ -1,4 +1,4 @@
using NavCityBreda.Model;
using NavCityBreda.Model.Object;
using NavCityBreda.ViewModels;
using Windows.UI.Xaml.Controls;
+88
View File
@@ -0,0 +1,88 @@
<Page
x:Class="NavCityBreda.Views.SearchView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:NavCityBreda.Views"
xmlns:convert="using:NavCityBreda.Helpers.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ScrollViewer>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RelativePanel Grid.Row="0" Margin="10">
<TextBox RelativePanel.AlignLeftWithPanel="True" RelativePanel.LeftOf="SearchButton" Name="SearchTerm" PlaceholderText="{Binding SearchTerm}" KeyDown="SearchTerm_KeyDown" />
<Button Name="SearchButton" Click="SearchButton_Click" RelativePanel.AlignRightWithPanel="True" Margin="5,0,0,0">
<StackPanel Orientation="Horizontal">
<SymbolIcon Symbol="Zoom" Margin="0,0,5,0" Name="Icon" />
<ProgressRing Margin="0,0,5,0" Width="20" Height="20" IsActive="False" Visibility="Collapsed" Name="SearchLoading"/>
<TextBlock Text="{Binding Search}" />
</StackPanel>
</Button>
</RelativePanel>
<StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="{Binding Settings}" Style="{StaticResource Header}"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Name="Description" IsChecked="False" Content="{Binding SeachDescription}" />
</Grid>
</StackPanel>
<StackPanel Grid.Row="2" Name="ResultsPanel">
<RelativePanel Margin="10">
<TextBlock Text="{Binding SearchResults}" Style="{StaticResource Header}" RelativePanel.AlignLeftWithPanel="True" Name="ResultHeader"/>
<TextBlock Text="{Binding ResultCount}" FontSize="14" Foreground="Gray" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignBottomWith="ResultHeader"/>
</RelativePanel>
<ListView Name="RouteList" ItemsSource="{Binding Routes}" IsItemClickEnabled="True" ItemClick="RouteList_ItemClick" Margin="0,5,0,0"
ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Disabled">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Margin" Value="0" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,2,0,2">
<TextBlock Text="{Binding Name}" FontSize="20" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Details}" FontSize="14" TextWrapping="WrapWholeWords" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Name="LandmarkList" ItemsSource="{Binding Landmarks}" IsItemClickEnabled="True" ItemClick="LandmarkList_ItemClick" Margin="0,5,0,0"
ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Disabled">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Margin" Value="0" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,2,0,2">
<TextBlock Text="{Binding Name}" FontSize="20" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Details}" FontSize="14" TextWrapping="WrapWholeWords" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
</ScrollViewer>
</Page>
+91
View File
@@ -0,0 +1,91 @@
using NavCityBreda.Helpers;
using NavCityBreda.Model;
using NavCityBreda.Model.Search;
using NavCityBreda.ViewModels;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
namespace NavCityBreda.Views
{
public sealed partial class SearchView : Page
{
SearchVM searchvm;
public SearchView()
{
this.InitializeComponent();
searchvm = new SearchVM(new SearchResult(""));
NavigationCacheMode = NavigationCacheMode.Enabled;
Settings.OnLanguageUpdate += Settings_OnLanguageUpdate;
this.DataContext = searchvm;
}
private void Settings_OnLanguageUpdate(EventArgs e)
{
Search();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
RouteList.SelectedIndex = -1;
LandmarkList.SelectedIndex = -1;
searchvm.Update();
if (e.NavigationMode != NavigationMode.Back)
{
SearchTerm.Text = "";
searchvm = new SearchVM(new SearchResult(""));
this.DataContext = searchvm;
}
}
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
SearchTerm.Text = SearchTerm.Text.Trim();
Search();
}
private async void Search()
{
if (SearchTerm.Text.Length < 1) return;
SearchTerm.IsEnabled = false;
Icon.Visibility = Visibility.Collapsed;
SearchLoading.Visibility = Visibility.Visible;
SearchLoading.IsActive = true;
SearchResult s = await SearchHandler.Search(SearchTerm.Text, (bool)Description.IsChecked);
SearchLoading.IsActive = false;
SearchLoading.Visibility = Visibility.Collapsed;
Icon.Visibility = Visibility.Visible;
SearchTerm.IsEnabled = true;
searchvm = new SearchVM(s);
this.DataContext = searchvm;
}
private void RouteList_ItemClick(object sender, ItemClickEventArgs e)
{
MainPage mp = App.MainPage;
RouteResult r = e.ClickedItem as RouteResult;
mp.Navigate(typeof(RouteDetailView), r.Route);
}
private void LandmarkList_ItemClick(object sender, ItemClickEventArgs e)
{
MainPage mp = App.MainPage;
LandmarkResult l = e.ClickedItem as LandmarkResult;
mp.Navigate(typeof(LandmarkDetailView), l.Landmark);
}
private void SearchTerm_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
SearchButton_Click(this, new RoutedEventArgs());
}
}
}
}