From 2c3b461d495706ff85204038d769a2e7e4f57179 Mon Sep 17 00:00:00 2001 From: CarJem Generations Date: Fri, 7 Aug 2020 12:42:59 -0400 Subject: [PATCH] [GUI] Make categories collapsible in channel list (#354) --- .../ViewModels/RootViewModel.cs | 33 +++++++++++++++++-- DiscordChatExporter.Gui/Views/RootView.xaml | 31 +++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs index 75a9fb5..e82fa6c 100644 --- a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.ComponentModel; using System.Threading; using System.Threading.Tasks; +using System.Windows.Data; using DiscordChatExporter.Domain.Discord; using DiscordChatExporter.Domain.Discord.Models; using DiscordChatExporter.Domain.Exceptions; @@ -42,9 +44,34 @@ namespace DiscordChatExporter.Gui.ViewModels public Guild? SelectedGuild { get; set; } - public IReadOnlyList? AvailableChannels => SelectedGuild != null - ? GuildChannelMap?[SelectedGuild] - : null; + + //Here for Legacy Purposes + public IReadOnlyList? 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? SelectedChannels { get; set; } diff --git a/DiscordChatExporter.Gui/Views/RootView.xaml b/DiscordChatExporter.Gui/Views/RootView.xaml index 84b4728..e2a9c41 100644 --- a/DiscordChatExporter.Gui/Views/RootView.xaml +++ b/DiscordChatExporter.Gui/Views/RootView.xaml @@ -259,6 +259,37 @@ + + + + + + + + + + + +