mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07:00
[GUI] Make categories collapsible in channel list (#354)
This commit is contained in:
parent
b405052fd6
commit
2c3b461d49
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Data;
|
||||||
using DiscordChatExporter.Domain.Discord;
|
using DiscordChatExporter.Domain.Discord;
|
||||||
using DiscordChatExporter.Domain.Discord.Models;
|
using DiscordChatExporter.Domain.Discord.Models;
|
||||||
using DiscordChatExporter.Domain.Exceptions;
|
using DiscordChatExporter.Domain.Exceptions;
|
||||||
|
|
@ -42,9 +44,34 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
|
|
||||||
public Guild? SelectedGuild { get; set; }
|
public Guild? SelectedGuild { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? AvailableChannels => SelectedGuild != null
|
|
||||||
? GuildChannelMap?[SelectedGuild]
|
//Here for Legacy Purposes
|
||||||
: null;
|
public IReadOnlyList<Channel>? AvailableChannelsList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SelectedGuild != null ? GuildChannelMap?[SelectedGuild] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollectionView? AvailableChannels
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var result = SelectedGuild != null ? GuildChannelMap?[SelectedGuild] : null;
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
var GroupedResults = CollectionViewSource.GetDefaultView(result);
|
||||||
|
GroupedResults.GroupDescriptions.Clear();
|
||||||
|
GroupedResults.SortDescriptions.Clear();
|
||||||
|
GroupedResults.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
|
||||||
|
GroupedResults.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Descending));
|
||||||
|
return GroupedResults;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? SelectedChannels { get; set; }
|
public IReadOnlyList<Channel>? SelectedChannels { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,37 @@
|
||||||
<i:Interaction.Behaviors>
|
<i:Interaction.Behaviors>
|
||||||
<behaviors:ChannelMultiSelectionListBoxBehavior SelectedItems="{Binding SelectedChannels}" />
|
<behaviors:ChannelMultiSelectionListBoxBehavior SelectedItems="{Binding SelectedChannels}" />
|
||||||
</i:Interaction.Behaviors>
|
</i:Interaction.Behaviors>
|
||||||
|
<ListBox.GroupStyle>
|
||||||
|
<GroupStyle>
|
||||||
|
<GroupStyle.Panel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<VirtualizingStackPanel Orientation="Vertical" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</GroupStyle.Panel>
|
||||||
|
<GroupStyle.ContainerStyle>
|
||||||
|
<Style TargetType="{x:Type GroupItem}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate>
|
||||||
|
<Expander
|
||||||
|
Padding="0"
|
||||||
|
BorderThickness="0"
|
||||||
|
IsExpanded="False">
|
||||||
|
<ItemsPresenter />
|
||||||
|
<Expander.Header>
|
||||||
|
<Run
|
||||||
|
FontWeight="Bold"
|
||||||
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
|
Text="{Binding Name, Mode=OneWay}" />
|
||||||
|
</Expander.Header>
|
||||||
|
</Expander>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</GroupStyle.ContainerStyle>
|
||||||
|
</GroupStyle>
|
||||||
|
</ListBox.GroupStyle>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid Margin="-8" Background="Transparent">
|
<Grid Margin="-8" Background="Transparent">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue