From efde9931c94d652896194cdbaf6f93d4148c1b0a Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Fri, 7 Aug 2020 21:00:43 +0300 Subject: [PATCH] Refactor & optimize changes in last commit --- DiscordChatExporter.Gui/App.xaml | 83 +++++++++++++++++++ .../ViewModels/RootViewModel.cs | 33 +------- DiscordChatExporter.Gui/Views/RootView.xaml | 46 +++++----- 3 files changed, 111 insertions(+), 51 deletions(-) diff --git a/DiscordChatExporter.Gui/App.xaml b/DiscordChatExporter.Gui/App.xaml index d22bbc8..e7a9e15 100644 --- a/DiscordChatExporter.Gui/App.xaml +++ b/DiscordChatExporter.Gui/App.xaml @@ -136,6 +136,89 @@ + + + \ No newline at end of file diff --git a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs index e82fa6c..75a9fb5 100644 --- a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs @@ -1,10 +1,8 @@ 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; @@ -44,34 +42,9 @@ namespace DiscordChatExporter.Gui.ViewModels public Guild? SelectedGuild { get; set; } - - //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? AvailableChannels => SelectedGuild != null + ? GuildChannelMap?[SelectedGuild] + : null; public IReadOnlyList? SelectedChannels { get; set; } diff --git a/DiscordChatExporter.Gui/Views/RootView.xaml b/DiscordChatExporter.Gui/Views/RootView.xaml index e2a9c41..7072d2c 100644 --- a/DiscordChatExporter.Gui/Views/RootView.xaml +++ b/DiscordChatExporter.Gui/Views/RootView.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:behaviors="clr-namespace:DiscordChatExporter.Gui.Behaviors" + xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" @@ -23,6 +24,17 @@ + + + + + + + + + + + @@ -253,35 +265,29 @@ + TextSearch.TextPath="Model.Name" + VirtualizingPanel.IsVirtualizingWhenGrouping="True"> - - - - -