Skip to content

Commit

Permalink
Search is WORKING, but lots of binding warnings which are slowing it …
Browse files Browse the repository at this point in the history
…down, must be looked at
  • Loading branch information
pekempy committed Oct 26, 2018
1 parent 325fa73 commit ac88059
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 39 deletions.
10 changes: 2 additions & 8 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,8 @@ public void RefreshGames()
public void LoadSettings()
{
//Theme Light or Dark
if (Settings.Default.theme.ToString() == "Dark")
{
ThemeAssist.SetTheme(Application.Current.MainWindow, BaseTheme.Dark);
}
else if (Settings.Default.theme.ToString() == "Light")
{
ThemeAssist.SetTheme(Application.Current.MainWindow, BaseTheme.Light);
}
if (Settings.Default.theme.ToString() == "Dark") { ThemeAssist.SetTheme(Application.Current.MainWindow, BaseTheme.Dark); }
else if (Settings.Default.theme.ToString() == "Light") { ThemeAssist.SetTheme(Application.Current.MainWindow, BaseTheme.Light); }
}
}
}
18 changes: 11 additions & 7 deletions Views/BannerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
xmlns:Models="clr-namespace:GameLauncher.Models"
xmlns:ViewModels="clr-namespace:GameLauncher.ViewModels"
mc:Ignorable="d"
xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
d:DataContext="{d:DesignInstance Type=ViewModels:BannerViewModel}"
d:DesignHeight="300"
d:DesignWidth="300">

<UserControl.Resources>
<CollectionViewSource x:Key="GameListCVS"
Source="{Binding BannerView}">
Source="{Binding BannerView}"
CollectionViewType="{x:Type dat:ListCollectionView}"
Filter="GameSearch">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Title" />
</CollectionViewSource.SortDescriptions>
Expand Down Expand Up @@ -60,6 +63,7 @@
<!-- Search text -->
<TextBox
x:Name="GameSearchBar"
TextChanged="SearchString_TextChanged"
MinWidth="150"
Margin="8,0,0,0"
VerticalAlignment="Center"
Expand Down Expand Up @@ -102,14 +106,14 @@
Height="100"
Margin="10 5 10 0">
<Grid>
<Image Source="{Binding Banner}"
<Image Source="{Binding Banner, FallbackValue='Missing element'}"
Height="100"
Width="290"
Stretch="Fill" />
<TextBlock Background="Black"
Opacity="0.6" Margin="0,80,0,0"
FontSize="12" />
<TextBlock Text="{Binding Title}"
<TextBlock Text="{Binding Title, FallbackValue='Missing element'}"
Height="Auto"
Width="Auto"
Margin="10,80,32,0"
Expand All @@ -118,7 +122,7 @@
<Button Width="300"
Height="100"
Style="{StaticResource MaterialDesignFlatButton}"
Tag="{Binding Path}"
Tag="{Binding Path, FallbackValue='Missing element'}"
Click="LaunchButton_OnClick"
Opacity="0.1" />

Expand All @@ -137,7 +141,7 @@
<StackPanel>
<!-- Link Button -->
<Button Click="GameLink_OnClick"
Tag="{Binding Link}">
Tag="{Binding Link, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Earth"
VerticalAlignment="Center" />
Expand All @@ -147,7 +151,7 @@
</Button>
<!-- Edit Button -->
<Button Click="EditGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Pencil"
VerticalAlignment="Center" />
Expand All @@ -157,7 +161,7 @@
</Button>
<!-- Delete Button -->
<Button Click="DeleteGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Delete"
VerticalAlignment="Center" />
Expand Down
22 changes: 22 additions & 0 deletions Views/BannerView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using GameLauncher.Models;
using GameLauncher.ViewModels;

namespace GameLauncher.Views
Expand Down Expand Up @@ -47,5 +49,25 @@ private void DeleteGame_OnClick(object sender, RoutedEventArgs e)
ModifyFile.RemoveGameFromFile(((Button)sender).Tag);
MainWindow.RefreshGames();
}

private void SearchString_TextChanged(object sender, TextChangedEventArgs e)
{
RefreshList();
}

private void RefreshList()
{
CollectionViewSource GameListCVS = (CollectionViewSource)FindResource("GameListCVS");
if (GameListCVS != null)
GameListCVS.View.Refresh();
}

private void GameSearch(object sender, FilterEventArgs e)
{
if (e.Item is GameList)
e.Accepted = (e.Item as GameList).Title.ToUpper().Contains(GameSearchBar.Text.ToUpper());
else
e.Accepted = true;
}
}
}
20 changes: 12 additions & 8 deletions Views/ListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
xmlns:ViewModels="clr-namespace:GameLauncher.ViewModels"
xmlns:Models="clr-namespace:GameLauncher.Models"
x:Class="GameLauncher.Views.ListView"
xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
d:DataContext="{d:DesignInstance Type=ViewModels:ListViewModel}"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<UserControl.Resources>
<CollectionViewSource x:Key="GameListCVS"
Source="{Binding ListView}">
Source="{Binding ListView}"
CollectionViewType="{x:Type dat:ListCollectionView}"
Filter="GameSearch">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Title" />
</CollectionViewSource.SortDescriptions>
Expand Down Expand Up @@ -49,6 +52,7 @@
<!-- Search text -->
<TextBox
x:Name="GameSearchBar"
TextChanged="SearchString_TextChanged"
MinWidth="150"
Margin="8,0,0,0"
VerticalAlignment="Center"
Expand Down Expand Up @@ -91,28 +95,28 @@
Grid.RowSpan="2"
HorizontalAlignment="Left"
Stretch="Fill"
Source="{Binding Icon, Mode=OneWay}" />
Source="{Binding Icon, Mode=OneWay, FallbackValue='Missing element'}" />
<!-- Game Title-->
<Label x:Name="GameTitle"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="85,1,0,45"
FontSize="20"
Content="{Binding Title, Mode=OneWay}" />
Content="{Binding Title, Mode=OneWay, FallbackValue='Missing element'}" />
<!-- Game Genres -->
<Label x:Name="GameGenre"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Margin="86,32,0,0"
FontSize="10"
Content="{Binding Genre, Mode=OneWay}"
Content="{Binding Genre, Mode=OneWay, FallbackValue='Missing element'}"
materialDesign:ColorZoneAssist.Mode="Accent" />

<!-- Game Launcher -->
<Button Style="{StaticResource MaterialDesignFlatButton}"
x:Name="GameLauncher"
Click="LaunchButton_OnClick"
Tag="{Binding Path, Mode=OneWay}"
Tag="{Binding Path, Mode=OneWay, FallbackValue='Missing element'}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Height="80"
Expand All @@ -133,7 +137,7 @@
<StackPanel>
<!-- Link Button -->
<Button Click="GameLink_OnClick"
Tag="{Binding Link}">
Tag="{Binding Link, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Earth"
VerticalAlignment="Center" />
Expand All @@ -143,7 +147,7 @@
</Button>
<!-- Edit Button -->
<Button Click="EditGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Pencil"
VerticalAlignment="Center" />
Expand All @@ -153,7 +157,7 @@
</Button>
<!-- Delete Button -->
<Button Click="DeleteGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Delete"
VerticalAlignment="Center" />
Expand Down
22 changes: 22 additions & 0 deletions Views/ListView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using GameLauncher.Models;
using GameLauncher.ViewModels;

namespace GameLauncher.Views
Expand Down Expand Up @@ -47,5 +49,25 @@ private void DeleteGame_OnClick(object sender, RoutedEventArgs e)
ModifyFile.RemoveGameFromFile(((Button)sender).Tag);
MainWindow.RefreshGames();
}

private void SearchString_TextChanged(object sender, TextChangedEventArgs e)
{
RefreshList();
}

private void RefreshList()
{
CollectionViewSource GameListCVS = (CollectionViewSource)FindResource("GameListCVS");
if (GameListCVS != null)
GameListCVS.View.Refresh();
}

private void GameSearch(object sender, FilterEventArgs e)
{
if (e.Item is GameList)
e.Accepted = (e.Item as GameList).Title.ToUpper().Contains(GameSearchBar.Text.ToUpper());
else
e.Accepted = true;
}
}
}
21 changes: 11 additions & 10 deletions Views/PosterView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<UserControl.Resources>
<CollectionViewSource x:Key="GameListCVS"
Source="{Binding PosterViewOC}"
CollectionViewType="{x:Type dat:ListCollectionView}">
CollectionViewType="{x:Type dat:ListCollectionView}"
Filter="GameSearch">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Title" />
</CollectionViewSource.SortDescriptions>
Expand Down Expand Up @@ -61,14 +62,14 @@
<!-- Search text -->
<TextBox
x:Name="GameSearchBar"
TextChanged="SearchString_TextChanged"
MinWidth="150"
Margin="8,0,0,0"
VerticalAlignment="Center"
materialDesign:HintAssist.Hint="Please search..."
materialDesign:TextFieldAssist.DecorationVisibility="Collapsed"
BorderThickness="0"
FontSize="11"
TextChanged="searchString" />
FontSize="11" />
<!-- "send" button -->
<Button VerticalAlignment="Center" Style="{DynamicResource MaterialDesignToolButton}"
x:Name="GameSearchSend">
Expand Down Expand Up @@ -109,14 +110,14 @@
<RowDefinition Height="5*" />
<RowDefinition />
</Grid.RowDefinitions>
<Image Source="{Binding Poster}"
<Image Source="{Binding Poster, FallbackValue=null}"
Height="220"
Width="180"
Stretch="Fill" />
<Button Width="180"
Height="220"
Style="{StaticResource MaterialDesignFlatButton}"
Tag="{Binding Path}"
Tag="{Binding Path, FallbackValue='Missing element'}"
Click="LaunchButton_OnClick"
Opacity="0.1" />
<!-- stackpanel for the button -->
Expand All @@ -125,10 +126,10 @@
HorizontalAlignment="Left"
VerticalAlignment="Bottom" Grid.RowSpan="2">
<WrapPanel Width="180">
<Button Name="PosterGameTitle"
<Button x:Name="PosterGameTitle"
Width="180"
Style="{StaticResource MaterialDesignFlatAccentButton}"
Content="{Binding Title}"
Content="{Binding Title, FallbackValue='Missing element'}"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
HorizontalContentAlignment="Left" />
Expand All @@ -147,7 +148,7 @@
<StackPanel>
<!-- Link Button -->
<Button Click="GameLink_OnClick"
Tag="{Binding Link}">
Tag="{Binding Link, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Earth"
VerticalAlignment="Center" />
Expand All @@ -157,7 +158,7 @@
</Button>
<!-- Edit Button -->
<Button Click="EditGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Pencil"
VerticalAlignment="Center" />
Expand All @@ -167,7 +168,7 @@
</Button>
<!-- Delete Button -->
<Button Click="DeleteGame_OnClick"
Tag="{Binding Guid}">
Tag="{Binding Guid, FallbackValue='Missing element'}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Delete"
VerticalAlignment="Center" />
Expand Down
19 changes: 17 additions & 2 deletions Views/PosterView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,24 @@ private void DeleteGame_OnClick(object sender, RoutedEventArgs e)
MainWindow.RefreshGames();
}

private void searchString(object sender, TextChangedEventArgs e)
private void SearchString_TextChanged(object sender, TextChangedEventArgs e)
{
Console.WriteLine(GameSearchBar.Text);
RefreshList();
}

private void RefreshList()
{
CollectionViewSource GameListCVS = (CollectionViewSource)FindResource("GameListCVS");
if (GameListCVS != null)
GameListCVS.View.Refresh();
}

private void GameSearch(object sender, FilterEventArgs e)
{
if (e.Item is GameList)
e.Accepted = (e.Item as GameList).Title.ToUpper().Contains(GameSearchBar.Text.ToUpper());
else
e.Accepted = true;
}
}
}
Loading

0 comments on commit ac88059

Please sign in to comment.