Skip to content

Commit

Permalink
fix: hunt log tab section
Browse files Browse the repository at this point in the history
DorielRivalet committed Jun 9, 2023
1 parent ed9d5dc commit 3e1a2d0
Showing 2 changed files with 36 additions and 72 deletions.
80 changes: 32 additions & 48 deletions MHFZ_Overlay/ConfigWindow.xaml
Original file line number Diff line number Diff line change
@@ -2191,55 +2191,39 @@
<RowDefinition Height="50"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Name="SortBy" SelectedIndex="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto"/>
<ComboBox Grid.Column="1" Name="SortDir" SelectedIndex="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto"/>
<ComboBox Grid.Column="2" SelectionChanged="FilterBox_SelectionChanged" Name="FilterBox" SelectedIndex="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto"/>
</Grid>
<ListView x:Name="MyList" Grid.Row="1" HorizontalAlignment="Stretch" VirtualizingStackPanel.IsVirtualizing="True">
<!--<ListView.Resources>
<DataTemplate x:Key="Templ">
<TextBlock Text="{Binding}" Foreground="{StaticResource Text}" Background="Transparent" Width="32"/>
</DataTemplate>
<Style x:Key="HeaderStyle" TargetType="GridViewColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource Text}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Width" Value="32"/>
</Style>
</ListView.Resources>-->
<ListView.View>
<GridView x:Name="GridViewElement">

<GridView.Columns>
<GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}"/>

<!--https://stackoverflow.com/a/42022875/18859245-->
<GridViewColumn Header="Image">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding MonsterImage}" Width="32" Height="32"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="Hunted" DisplayMemberBinding="{Binding Hunted}"/>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>


<ComboBox Width="Auto" SelectionChanged="FilterBox_SelectionChanged" Name="FilterBox" SelectedIndex="0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<ui:DataGrid x:Name="HuntLogDataGrid" Grid.Row="1" HorizontalAlignment="Stretch" AutoGenerateColumns="False" IsReadOnly="True">
<DataGrid.ColumnHeaderStyle>
<StaticResource ResourceKey="DefaultDataGridColumnHeaderStyle"/>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding ID}"/>
<DataGridTemplateColumn Header="Image">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding MonsterImage}" Width="48" Height="48" HorizontalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Name" Binding="{Binding Name}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Hunted" Binding="{Binding Hunted}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</ui:DataGrid>
</Grid>

</DockPanel>
</Grid>
</TabItem>
28 changes: 4 additions & 24 deletions MHFZ_Overlay/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -477,18 +477,6 @@ public int GetHuntedCount(int id)
}
}

public void SortList()
{
var SortProperty = SortBy.SelectedItem.ToString();
var SortDirection = SortDir.SelectedItem.ToString() == "Ascending" ? ListSortDirection.Ascending : ListSortDirection.Descending;
MyList.Items.SortDescriptions[0] = new SortDescription(SortProperty, SortDirection);
}

private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SortList();
}

private IReadOnlyList<MonsterInfo> monsterInfos = Dictionary.MonsterInfoList.MonsterInfoIDs;

/// <summary>
@@ -539,18 +527,10 @@ public ConfigWindow(MainWindow mainWindow)
Monsters[i].Hunted = GetHuntedCount(Monsters[i].ID);
}

MyList.ItemsSource = Monsters;
SortBy.ItemsSource = new string[] { "ID", "Name", "Hunted" };
SortDir.ItemsSource = Enum.GetNames<ListSortDirection>();

SortBy.SelectionChanged += SelectionChanged;
SortDir.SelectionChanged += SelectionChanged;

MyList.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));

HuntLogDataGrid.ItemsSource = Monsters;
HuntLogDataGrid.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
FilterBox.ItemsSource = new string[] { "All", "Large Monster", "Small Monster" };

MyList.Items.Filter = MonsterFilterAll;
HuntLogDataGrid.Items.Filter = MonsterFilterAll;

//// See: https://stackoverflow.com/questions/22285866/why-relaycommand
//// Or use MVVM Light to obtain RelayCommand.
@@ -984,7 +964,7 @@ private void BtnImageFile_Click(object sender, RoutedEventArgs e)

private void FilterBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MyList.Items.Filter = GetFilter();
HuntLogDataGrid.Items.Filter = GetFilter();
}

// on generate csv button click

0 comments on commit 3e1a2d0

Please sign in to comment.