mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 19:26:57 -04:00
Refactor & optimize changes in last commit
This commit is contained in:
parent
2c3b461d49
commit
efde9931c9
3 changed files with 111 additions and 51 deletions
|
@ -136,6 +136,89 @@
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Default MD Expander is incredibly slow (https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/1307) -->
|
||||||
|
<Style BasedOn="{StaticResource MaterialDesignExpander}" TargetType="{x:Type Expander}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Expander">
|
||||||
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
||||||
|
<DockPanel Background="{TemplateBinding Background}">
|
||||||
|
<ToggleButton
|
||||||
|
Name="HeaderSite"
|
||||||
|
BorderThickness="0"
|
||||||
|
Content="{TemplateBinding Header}"
|
||||||
|
ContentStringFormat="{TemplateBinding HeaderStringFormat}"
|
||||||
|
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||||
|
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
|
||||||
|
Cursor="Hand"
|
||||||
|
DockPanel.Dock="Top"
|
||||||
|
Focusable="False"
|
||||||
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
IsTabStop="False"
|
||||||
|
Opacity=".87"
|
||||||
|
Style="{StaticResource MaterialDesignExpanderDownHeaderStyle}"
|
||||||
|
TextElement.FontSize="15" />
|
||||||
|
<Border
|
||||||
|
Name="ContentSite"
|
||||||
|
DockPanel.Dock="Bottom"
|
||||||
|
Visibility="Collapsed">
|
||||||
|
<StackPanel
|
||||||
|
Name="ContentPanel"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||||||
|
<ContentPresenter
|
||||||
|
Name="PART_Content"
|
||||||
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||||
|
Focusable="False" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsExpanded" Value="true">
|
||||||
|
<Setter TargetName="ContentSite" Property="Visibility" Value="Visible" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ExpandDirection" Value="Right">
|
||||||
|
<Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Left" />
|
||||||
|
<Setter TargetName="ContentSite" Property="DockPanel.Dock" Value="Right" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Orientation" Value="Horizontal" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Height" Value="Auto" />
|
||||||
|
<Setter TargetName="HeaderSite" Property="Style" Value="{StaticResource MaterialDesignExpanderRightHeaderStyle}" />
|
||||||
|
</Trigger>
|
||||||
|
|
||||||
|
<Trigger Property="ExpandDirection" Value="Left">
|
||||||
|
<Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Right" />
|
||||||
|
<Setter TargetName="ContentSite" Property="DockPanel.Dock" Value="Left" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Orientation" Value="Horizontal" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Height" Value="Auto" />
|
||||||
|
<Setter TargetName="HeaderSite" Property="Style" Value="{StaticResource MaterialDesignExpanderLeftHeaderStyle}" />
|
||||||
|
</Trigger>
|
||||||
|
|
||||||
|
<Trigger Property="ExpandDirection" Value="Up">
|
||||||
|
<Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Bottom" />
|
||||||
|
<Setter TargetName="ContentSite" Property="DockPanel.Dock" Value="Top" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Orientation" Value="Vertical" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Width" Value="Auto" />
|
||||||
|
<Setter TargetName="HeaderSite" Property="Style" Value="{StaticResource MaterialDesignExpanderUpHeaderStyle}" />
|
||||||
|
</Trigger>
|
||||||
|
|
||||||
|
<Trigger Property="ExpandDirection" Value="Down">
|
||||||
|
<Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Top" />
|
||||||
|
<Setter TargetName="ContentSite" Property="DockPanel.Dock" Value="Bottom" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Orientation" Value="Vertical" />
|
||||||
|
<Setter TargetName="ContentPanel" Property="Width" Value="Auto" />
|
||||||
|
<Setter TargetName="HeaderSite" Property="Style" Value="{StaticResource MaterialDesignExpanderDownHeaderStyle}" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
</s:ApplicationLoader>
|
</s:ApplicationLoader>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
|
@ -1,10 +1,8 @@
|
||||||
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;
|
||||||
|
@ -44,34 +42,9 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
|
|
||||||
public Guild? SelectedGuild { get; set; }
|
public Guild? SelectedGuild { get; set; }
|
||||||
|
|
||||||
|
public IReadOnlyList<Channel>? AvailableChannels => SelectedGuild != null
|
||||||
//Here for Legacy Purposes
|
? GuildChannelMap?[SelectedGuild]
|
||||||
public IReadOnlyList<Channel>? AvailableChannelsList
|
: null;
|
||||||
{
|
|
||||||
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; }
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:behaviors="clr-namespace:DiscordChatExporter.Gui.Behaviors"
|
xmlns:behaviors="clr-namespace:DiscordChatExporter.Gui.Behaviors"
|
||||||
|
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
||||||
xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters"
|
xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
|
@ -23,6 +24,17 @@
|
||||||
<Window.TaskbarItemInfo>
|
<Window.TaskbarItemInfo>
|
||||||
<TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding ProgressManager.Progress}" />
|
<TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding ProgressManager.Progress}" />
|
||||||
</Window.TaskbarItemInfo>
|
</Window.TaskbarItemInfo>
|
||||||
|
<Window.Resources>
|
||||||
|
<CollectionViewSource x:Key="AvailableChannelsViewSource" Source="{Binding AvailableChannels, Mode=OneWay}">
|
||||||
|
<CollectionViewSource.GroupDescriptions>
|
||||||
|
<PropertyGroupDescription PropertyName="Category" />
|
||||||
|
</CollectionViewSource.GroupDescriptions>
|
||||||
|
<CollectionViewSource.SortDescriptions>
|
||||||
|
<componentModel:SortDescription Direction="Ascending" PropertyName="Category" />
|
||||||
|
</CollectionViewSource.SortDescriptions>
|
||||||
|
</CollectionViewSource>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
<materialDesign:DialogHost SnackbarMessageQueue="{Binding Notifications}" Style="{DynamicResource MaterialDesignEmbeddedDialogHost}">
|
<materialDesign:DialogHost SnackbarMessageQueue="{Binding Notifications}" Style="{DynamicResource MaterialDesignEmbeddedDialogHost}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -253,35 +265,29 @@
|
||||||
<Border Grid.Column="1">
|
<Border Grid.Column="1">
|
||||||
<ListBox
|
<ListBox
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
ItemsSource="{Binding AvailableChannels}"
|
ItemsSource="{Binding Source={StaticResource AvailableChannelsViewSource}}"
|
||||||
SelectionMode="Extended"
|
SelectionMode="Extended"
|
||||||
TextSearch.TextPath="Model.Name">
|
TextSearch.TextPath="Model.Name"
|
||||||
|
VirtualizingPanel.IsVirtualizingWhenGrouping="True">
|
||||||
<i:Interaction.Behaviors>
|
<i:Interaction.Behaviors>
|
||||||
<behaviors:ChannelMultiSelectionListBoxBehavior SelectedItems="{Binding SelectedChannels}" />
|
<behaviors:ChannelMultiSelectionListBoxBehavior SelectedItems="{Binding SelectedChannels}" />
|
||||||
</i:Interaction.Behaviors>
|
</i:Interaction.Behaviors>
|
||||||
<ListBox.GroupStyle>
|
<ListBox.GroupStyle>
|
||||||
<GroupStyle>
|
<GroupStyle>
|
||||||
<GroupStyle.Panel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<VirtualizingStackPanel Orientation="Vertical" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</GroupStyle.Panel>
|
|
||||||
<GroupStyle.ContainerStyle>
|
<GroupStyle.ContainerStyle>
|
||||||
<Style TargetType="{x:Type GroupItem}">
|
<Style TargetType="{x:Type GroupItem}">
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate>
|
<ControlTemplate d:DataContext="{x:Type CollectionViewGroup}">
|
||||||
<Expander
|
<Expander
|
||||||
|
Margin="0"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
BorderThickness="0"
|
Background="Transparent"
|
||||||
|
BorderBrush="{DynamicResource DividerBrush}"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
Header="{Binding Name}"
|
||||||
IsExpanded="False">
|
IsExpanded="False">
|
||||||
<ItemsPresenter />
|
<ItemsPresenter />
|
||||||
<Expander.Header>
|
|
||||||
<Run
|
|
||||||
FontWeight="Bold"
|
|
||||||
Foreground="{DynamicResource SecondaryTextBrush}"
|
|
||||||
Text="{Binding Name, Mode=OneWay}" />
|
|
||||||
</Expander.Header>
|
|
||||||
</Expander>
|
</Expander>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
@ -309,16 +315,14 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Kind="Pound" />
|
Kind="Pound" />
|
||||||
|
|
||||||
<!-- Channel category / name -->
|
<!-- Channel name -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="3,8,8,8"
|
Margin="3,8,8,8"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="14">
|
FontSize="14"
|
||||||
<Run Foreground="{DynamicResource SecondaryTextBrush}" Text="{Binding Category, Mode=OneWay}" />
|
Foreground="{DynamicResource PrimaryTextBrush}"
|
||||||
<Run Text="/" />
|
Text="{Binding Name, Mode=OneWay}" />
|
||||||
<Run Foreground="{DynamicResource PrimaryTextBrush}" Text="{Binding Name, Mode=OneWay}" />
|
|
||||||
</TextBlock>
|
|
||||||
|
|
||||||
<!-- Is selected checkmark -->
|
<!-- Is selected checkmark -->
|
||||||
<materialDesign:PackIcon
|
<materialDesign:PackIcon
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue