Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to show/hide columns + add last sessions column #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions BoolToWidthConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace Playlist
{
public class BoolToWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isVisible = (bool)value;
return isVisible ? double.NaN : 0; // 'double.NaN' allows the column to auto-size
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
12 changes: 7 additions & 5 deletions Playlist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Playlist</RootNamespace>
<AssemblyName>Playlist</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,11 +32,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GongSolutions.WPF.DragDrop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=91f1945125b7a587, processorArchitecture=MSIL">
<HintPath>packages\gong-wpf-dragdrop.2.4.1\lib\net462\GongSolutions.WPF.DragDrop.dll</HintPath>
<Reference Include="GongSolutions.WPF.DragDrop, Version=3.0.0.0, Culture=neutral, PublicKeyToken=91f1945125b7a587, processorArchitecture=MSIL">
<HintPath>packages\gong-wpf-dragdrop.3.2.1\lib\net48\GongSolutions.WPF.DragDrop.dll</HintPath>
</Reference>
<Reference Include="Playnite.SDK, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\PlayniteSDK.6.0.0-preview3\lib\net462\Playnite.SDK.dll</HintPath>
<Reference Include="Playnite.SDK, Version=6.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\PlayniteSDK.6.11.0\lib\net462\Playnite.SDK.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand All @@ -51,6 +52,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="BoolToWidthConverter.cs" />
<Compile Include="PlaylistViewModel.cs" />
<Compile Include="Playlist.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
17 changes: 14 additions & 3 deletions PlaylistView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:local="clr-namespace:Playlist"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="600">

<UserControl.Resources>
<local:BoolToWidthConverter x:Key="BoolToWidthConverter" />
<Style x:Key="noGamesText" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}">
<!-- Show instructions if no games in playlist -->
<Setter Property="Visibility" Value="Hidden" />
Expand Down Expand Up @@ -202,6 +204,14 @@

<ListView.View>
<GridView>
<GridView.ColumnHeaderContextMenu>
<ContextMenu Name="HeaderMenu">
<MenuItem Header="{DynamicResource LOCNameLabel}" IsChecked="{Binding IsNameColumnVisible, Mode=TwoWay}" IsCheckable="True"/>
<MenuItem Header="{DynamicResource LOCTimePlayed}" IsChecked="{Binding IsPlaytimeColumnVisible, Mode=TwoWay}" IsCheckable="True"/>
<MenuItem Header="{DynamicResource LOCCompletionStatus}" IsChecked="{Binding IsCompletionStatusColumnVisible, Mode=TwoWay}" IsCheckable="True"/>
<MenuItem Header="{DynamicResource LOCLastPlayedLabel}" IsChecked="{Binding IsLastActivityColumnVisible, Mode=TwoWay}" IsCheckable="True"/>
</ContextMenu>
</GridView.ColumnHeaderContextMenu>
<GridViewColumn Header="" Width="55">
<GridViewColumn.CellTemplate>
<DataTemplate>
Expand All @@ -219,9 +229,10 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource LOCNameLabel}" Width="500" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Width="150" Header="{DynamicResource LOCTimePlayed}" DisplayMemberBinding="{Binding Playtime, Converter={StaticResource PlayTimeToStringConverter}}"/>
<GridViewColumn Width="150" Header="{DynamicResource LOCCompletionStatus}" DisplayMemberBinding="{Binding CompletionStatus}" />
<GridViewColumn Header="{DynamicResource LOCNameLabel}" DisplayMemberBinding="{Binding Name}" Width="{Binding IsNameColumnVisible, Converter={StaticResource BoolToWidthConverter}}" />
<GridViewColumn Header="{DynamicResource LOCTimePlayed}" DisplayMemberBinding="{Binding Playtime, Converter={StaticResource PlayTimeToStringConverter}}" Width="{Binding IsPlaytimeColumnVisible, Converter={StaticResource BoolToWidthConverter}}" />
<GridViewColumn Header="{DynamicResource LOCCompletionStatus}" DisplayMemberBinding="{Binding CompletionStatus}" Width="{Binding IsCompletionStatusColumnVisible, Converter={StaticResource BoolToWidthConverter}}" />
<GridViewColumn Header="{DynamicResource LOCLastPlayedLabel}" DisplayMemberBinding="{Binding LastActivity}" Width="{Binding IsLastActivityColumnVisible, Converter={StaticResource BoolToWidthConverter}}" />
</GridView>
</ListView.View>
</ListView>
Expand Down
48 changes: 48 additions & 0 deletions PlaylistViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,54 @@ public class PlaylistViewModel : ObservableObject

public RelayCommand<Game> ShowGameInLibraryCommand { get; }

private bool _isNameColumnVisible = true;

public bool IsNameColumnVisible
{
get => _isNameColumnVisible;
set
{
_isNameColumnVisible = value;
OnPropertyChanged(nameof(IsNameColumnVisible));
}
}

private bool _isPlaytimeColumnVisible = true;

public bool IsPlaytimeColumnVisible
{
get => _isPlaytimeColumnVisible;
set
{
_isPlaytimeColumnVisible = value;
OnPropertyChanged(nameof(IsPlaytimeColumnVisible));
}
}

private bool _isCompletionStatusColumnVisible = true;

public bool IsCompletionStatusColumnVisible
{
get => _isCompletionStatusColumnVisible;
set
{
_isCompletionStatusColumnVisible = value;
OnPropertyChanged(nameof(IsCompletionStatusColumnVisible));
}
}

private bool _isLastActivityColumnVisible = true;

public bool IsLastActivityColumnVisible
{
get => _isLastActivityColumnVisible;
set
{
_isLastActivityColumnVisible = value;
OnPropertyChanged(nameof(IsLastActivityColumnVisible));
}
}

public IEnumerable<KeyValuePair<CompletionStatus, RelayCommand<IEnumerable<object>>>> CompletionStatusCommands
{
get
Expand Down
4 changes: 2 additions & 2 deletions packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="gong-wpf-dragdrop" version="2.4.1" targetFramework="net462" />
<package id="PlayniteSDK" version="6.0.0-preview3" targetFramework="net462" />
<package id="gong-wpf-dragdrop" version="3.2.1" targetFramework="net48" />
<package id="PlayniteSDK" version="6.11.0" targetFramework="net48" />
</packages>