Skip to content

Commit

Permalink
Added simple country filter radiobuttons to the games library (can be…
Browse files Browse the repository at this point in the history
… hidden in settings) - #77
  • Loading branch information
Asnivor committed Mar 13, 2017
1 parent d087b19 commit 6a7fa14
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 30 deletions.
4 changes: 2 additions & 2 deletions MedLaunch/Classes/DbEF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ public static string ReturnYear(string str)


// update game data for games datagrid including search
public static void GetGames(DataGrid datagrid, int systemId, string search)
public static void GetGames(DataGrid datagrid, int systemId, string search, CountryFilter countryFilter)
{
// get the full dataset from application
App _App = ((App)Application.Current);
//List<DataGridGamesView> allGames = _App.GamesList.AllGames;

var result = GameListBuilder.Filter(systemId, search);
var result = GameListBuilder.Filter(systemId, search, countryFilter);
}


Expand Down
29 changes: 28 additions & 1 deletion MedLaunch/Classes/GamesLibrary/GameListBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static List<DataGridGamesView> RemoveHidden(List<DataGridGamesView> resul
}
}

public static List<DataGridGamesView> Filter(int systemId, string search)
public static List<DataGridGamesView> Filter(int systemId, string search, CountryFilter countryFilter)
{
List<DataGridGamesView> results = new List<DataGridGamesView>();
App _App = ((App)Application.Current);
Expand Down Expand Up @@ -224,6 +224,25 @@ where GSystem.GetSystemId(g.System) == systemId
break;
}

// narrow search based on country/region filter
switch (countryFilter)
{
case CountryFilter.EUR:
results = results.Where(a => a.Country != null && a.Country.ToUpper().Contains("EU")).ToList();
break;

case CountryFilter.JPN:
results = results.Where(a => a.Country != null && a.Country.ToUpper().Contains("J")).ToList();
break;

case CountryFilter.USA:
results = results.Where(a => a.Country != null && a.Country.ToUpper().Contains("US")).ToList();
break;

default:
break;
}

// now we have results based on the system filter - process file search
List<DataGridGamesView> srch = DoSearch(results, search);

Expand Down Expand Up @@ -450,4 +469,12 @@ public List<DataGridGamesView> Search (string SearchString)
}
*/
}

public enum CountryFilter
{
ALL,
USA,
EUR,
JPN
}
}
2 changes: 1 addition & 1 deletion MedLaunch/Classes/IO/DiscUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static string GetPSXSerial(string path)
// start by checking sector 23 (as most discs seem to have system.cfg there
byte[] data = di.GetPSXSerialNumber(lba);
// take first 32 bytes
byte[] data32 = data.ToList().Take(32).ToArray();
byte[] data32 = data.ToList().Take(46).ToArray();

string sS = System.Text.Encoding.Default.GetString(data32);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ public static void RefreshGamesLibrary()
string tbText = tbFilterDatagrid.Text;

// get all grouped radio buttons
List<RadioButton> buttons = UIHandler.GetLogicalChildCollection<RadioButton>(grdGameLibrary);
List<RadioButton> buttons = UIHandler.GetLogicalChildCollection<RadioButton>(grdGameLibrary).Where(a => !a.Name.StartsWith("srcFilter")).ToList();

foreach (RadioButton but in buttons)
{
Expand Down
32 changes: 31 additions & 1 deletion MedLaunch/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,36 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBox Grid.Row="0" x:Name="tbFilterDatagrid" Text="" TextChanged="tbFilterDatagrid_TextChanged" Controls:TextBoxHelper.ClearTextButton="True"
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBox Grid.Row="0" Grid.Column="0" x:Name="tbFilterDatagrid" Text="" TextChanged="tbFilterDatagrid_TextChanged" Controls:TextBoxHelper.ClearTextButton="True"
Controls:TextBoxHelper.Watermark="Dynamic Search" />
<Border Grid.Row="0" Grid.Column="1" Name="CountryFilterBrd">
<UniformGrid Columns="4" Background="{DynamicResource ControlBackgroundBrush}">
<Viewbox Height="12">
<RadioButton Name="srcFilterALL" Margin="5,0,5,0" GroupName="filters" Checked="srcFilter_Checked">ALL</RadioButton>
</Viewbox>
<Viewbox Height="12">
<RadioButton Name="srcFilterUSA" Margin="5,0,5,0" GroupName="filters" Checked="srcFilter_Checked">USA</RadioButton>
</Viewbox>
<Viewbox Height="12">
<RadioButton Name="srcFilterEUR" Margin="5,0,5,0" GroupName="filters" Checked="srcFilter_Checked">EUR</RadioButton>
</Viewbox>
<Viewbox Height="12">
<RadioButton Name="srcFilterJPN" Margin="5,0,5,0" GroupName="filters" Checked="srcFilter_Checked">JPN</RadioButton>
</Viewbox>

</UniformGrid>
</Border>

</Grid>



<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" />


Expand Down Expand Up @@ -9961,6 +9989,8 @@

<Button Content="Modify Library Column Visibility" Click="MenuItemColumn_Click" Grid.Row="1" Grid.ColumnSpan="2" />

<CheckBox Grid.Row="2" Grid.ColumnSpan="2" Content="Hide Country Filter" x:Name="chkHideCountryFilter" Checked="chkHideCountryFilter_Checked" Unchecked="chkHideCountryFilter_Unchecked" />

<CheckBox x:Name="chkshowGLYear" Grid.ColumnSpan="2" Grid.Row="1" Checked="chkshowGLYear_Checked" Unchecked="chkshowGLYear_Unchecked">
Show grid YEAR column
</CheckBox>
Expand Down
Loading

0 comments on commit 6a7fa14

Please sign in to comment.