Skip to content
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
58 changes: 57 additions & 1 deletion Source/ViewModels/GameBadgesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public GameBadgesViewModel(IBackgroundWorkerService backgroundWorkerService, IFi
DialogTitle = "Game Badges";
CanClose = true;

Views = new[]
{
new ViewLookupItem(View.Profile, "Profile"),
new ViewLookupItem(View.FullSize, "Full-size"),
};

_achievements = new ObservableCollection<BadgeViewModel>();
SearchCommand = new DelegateCommand(Search);
ExportCommand = new DelegateCommand<ItemsControl>(Export);
Expand Down Expand Up @@ -204,14 +210,64 @@ internal void LoadGame()
public IEnumerable<BadgeViewModel> Achievements { get { return _achievements; } }
private ObservableCollection<BadgeViewModel> _achievements;

public static readonly ModelProperty ShowHardcoreBorderProperty = ModelProperty.Register(typeof(GameStatsViewModel), "GameId", typeof(bool), false);
public enum View
{
Profile,
FullSize,
}

public class ViewLookupItem
{
public ViewLookupItem(View id, string label)
{
Id = id;
Label = label;
}
public View Id { get; private set; }
public string Label { get; private set; }
}
public IEnumerable<ViewLookupItem> Views { get; private set; }

public static readonly ModelProperty SelectedViewProperty = ModelProperty.Register(typeof(GameBadgesViewModel), "SelectedView", typeof(View), View.Profile, OnSelectedViewChanged);
public View SelectedView
{
get { return (View)GetValue(SelectedViewProperty); }
set { SetValue(SelectedViewProperty, value); }
}

private static void OnSelectedViewChanged(object sender, ModelPropertyChangedEventArgs e)
{
var viewModel = (GameBadgesViewModel)sender;

switch ((View)e.NewValue)
{
default:
viewModel.BadgeSize = 48;
break;
case View.FullSize:
viewModel.BadgeSize = 64;
break;
}
}



public static readonly ModelProperty ShowHardcoreBorderProperty = ModelProperty.Register(typeof(GameBadgesViewModel), "GameId", typeof(bool), false);

public bool ShowHardcoreBorder
{
get { return (bool)GetValue(ShowHardcoreBorderProperty); }
set { SetValue(ShowHardcoreBorderProperty, value); }
}

public static readonly ModelProperty BadgeSizeProperty = ModelProperty.Register(typeof(GameBadgesViewModel), "BadgeSize", typeof(int), 48);
public int BadgeSize
{
get { return (int)GetValue(BadgeSizeProperty); }
private set { SetValue(BadgeSizeProperty, value); }
}


public CommandBase<ItemsControl> ExportCommand { get; private set; }

private void Export(ItemsControl listView)
Expand Down
17 changes: 12 additions & 5 deletions Source/Views/GameBadgesDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@
<ColumnDefinition Width="80" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Row="0" Grid.Column="0" Text="Game ID:" VerticalAlignment="Center" Margin="8,0,0,0" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding GameId}" Height="20" Margin="4,2,4,0" HorizontalContentAlignment="Right" />
<Button Grid.Row="0" Grid.Column="2" Command="{Binding SearchCommand}" Content="Search" Width="60" Margin="2,5,0,4" />
<CheckBox Grid.Row="0" Grid.Column="3" x:Name="showHardcoreBorderCheckBox"
IsChecked="{Binding ShowHardcoreBorder}" Content="Hardcore Border" Margin="40,7,0,4" />
<Button Grid.Row="0" Grid.Column="5" Content="Export" Width="60" Margin="2,5,4,4"
<StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="30,0,0,0">
<TextBlock Text="View:" VerticalAlignment="Center" Margin="0,0,4,0" />
<ComboBox Width="100" x:Name="viewSelectionComboBox" SelectedValue="{Binding SelectedView}"
ItemsSource="{Binding Views}" DisplayMemberPath="Label" SelectedValuePath="Id" />
</StackPanel>
<CheckBox Grid.Row="0" Grid.Column="4" x:Name="showHardcoreBorderCheckBox"
IsChecked="{Binding ShowHardcoreBorder}" Content="Hardcore Border" Margin="10,7,0,4" />
<Button Grid.Row="0" Grid.Column="6" Content="Export" Width="60" Margin="2,5,4,4"
Command="{Binding ExportCommand}" CommandParameter="{Binding ElementName=badgesListView}" />

<ItemsControl Grid.Row="1" Grid.ColumnSpan="6" x:Name="badgesListView"
<ItemsControl Grid.Row="1" Grid.ColumnSpan="7" x:Name="badgesListView"
ItemsSource="{Binding Achievements}" Background="#101012" Margin="4" Padding="8">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
Expand All @@ -55,7 +61,8 @@
</Style.Triggers>
</Style>
</Border.Style>
<Image Source="{Binding Badge}" Width="48" Height="48" />
<Image Source="{Binding Badge}" Width="{Binding ElementName=viewSelectionComboBox, Path=DataContext.BadgeSize}"
Height="{Binding ElementName=viewSelectionComboBox, Path=DataContext.BadgeSize}" />
<Border.ToolTip>
<ToolTip Background="#101012" BorderBrush="#2A2A2A">
<Grid Margin="0,2,4,2">
Expand Down
Loading