Update Gress

This commit is contained in:
Oleksii Holub 2022-02-16 14:30:26 +02:00
parent 51cc132e5d
commit 36b4a45f3a
8 changed files with 117 additions and 97 deletions

View file

@ -14,6 +14,7 @@ using DiscordChatExporter.Core.Exceptions;
using DiscordChatExporter.Core.Exporting; using DiscordChatExporter.Core.Exporting;
using DiscordChatExporter.Core.Exporting.Filtering; using DiscordChatExporter.Core.Exporting.Filtering;
using DiscordChatExporter.Core.Exporting.Partitioning; using DiscordChatExporter.Core.Exporting.Partitioning;
using Gress;
namespace DiscordChatExporter.Cli.Commands.Base; namespace DiscordChatExporter.Cli.Commands.Base;
@ -78,8 +79,7 @@ public abstract class ExportCommandBase : TokenCommandBase
{ {
try try
{ {
await progressContext.StartTaskAsync( await progressContext.StartTaskAsync($"{channel.Category.Name} / {channel.Name}",
$"{channel.Category.Name} / {channel.Name}",
async progress => async progress =>
{ {
var guild = await Discord.GetGuildAsync(channel.GuildId, innerCancellationToken); var guild = await Discord.GetGuildAsync(channel.GuildId, innerCancellationToken);
@ -98,7 +98,11 @@ public abstract class ExportCommandBase : TokenCommandBase
DateFormat DateFormat
); );
await Exporter.ExportChannelAsync(request, progress, innerCancellationToken); await Exporter.ExportChannelAsync(
request,
progress.ToPercentageBased(),
innerCancellationToken
);
} }
); );
} }

View file

@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CliFx" Version="2.2.1" /> <PackageReference Include="CliFx" Version="2.2.1" />
<PackageReference Include="Spectre.Console" Version="0.43.0" /> <PackageReference Include="Spectre.Console" Version="0.43.0" />
<PackageReference Include="Gress" Version="1.2.0" /> <PackageReference Include="Gress" Version="2.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -12,6 +12,7 @@ using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Exceptions; using DiscordChatExporter.Core.Exceptions;
using DiscordChatExporter.Core.Utils; using DiscordChatExporter.Core.Utils;
using DiscordChatExporter.Core.Utils.Extensions; using DiscordChatExporter.Core.Utils.Extensions;
using Gress;
using JsonExtensions.Http; using JsonExtensions.Http;
using JsonExtensions.Reading; using JsonExtensions.Reading;
@ -273,7 +274,7 @@ public class DiscordClient
Snowflake channelId, Snowflake channelId,
Snowflake? after = null, Snowflake? after = null,
Snowflake? before = null, Snowflake? before = null,
IProgress<double>? progress = null, IProgress<Percentage>? progress = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default) [EnumeratorCancellation] CancellationToken cancellationToken = default)
{ {
// Get the last message in the specified range. // Get the last message in the specified range.
@ -322,16 +323,13 @@ public class DiscordClient
var exportedDuration = (message.Timestamp - firstMessage.Timestamp).Duration(); var exportedDuration = (message.Timestamp - firstMessage.Timestamp).Duration();
var totalDuration = (lastMessage.Timestamp - firstMessage.Timestamp).Duration(); var totalDuration = (lastMessage.Timestamp - firstMessage.Timestamp).Duration();
if (totalDuration > TimeSpan.Zero) progress.Report(Percentage.FromFraction(
{ // Avoid division by zero if all messages have the exact same timestamp
progress.Report(exportedDuration / totalDuration); // (which may be the case if there's only one message in the channel)
} totalDuration > TimeSpan.Zero
// Avoid division by zero if all messages have the exact same timestamp ? exportedDuration / totalDuration
// (which may be the case if there's only one message in the channel) : 1
else ));
{
progress.Report(1);
}
} }
yield return message; yield return message;

View file

@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Gress" Version="2.0.1" />
<PackageReference Include="JsonExtensions" Version="1.2.0" /> <PackageReference Include="JsonExtensions" Version="1.2.0" />
<PackageReference Include="MiniRazor.CodeGen" Version="2.2.0" /> <PackageReference Include="MiniRazor.CodeGen" Version="2.2.0" />
<PackageReference Include="Polly" Version="7.2.3" /> <PackageReference Include="Polly" Version="7.2.3" />

View file

@ -8,6 +8,7 @@ using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Discord.Data.Common; using DiscordChatExporter.Core.Discord.Data.Common;
using DiscordChatExporter.Core.Exceptions; using DiscordChatExporter.Core.Exceptions;
using DiscordChatExporter.Core.Utils.Extensions; using DiscordChatExporter.Core.Utils.Extensions;
using Gress;
namespace DiscordChatExporter.Core.Exporting; namespace DiscordChatExporter.Core.Exporting;
@ -19,7 +20,7 @@ public class ChannelExporter
public async ValueTask ExportChannelAsync( public async ValueTask ExportChannelAsync(
ExportRequest request, ExportRequest request,
IProgress<double>? progress = null, IProgress<Percentage>? progress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
// Build context // Build context

View file

@ -13,7 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Gress" Version="1.2.0" /> <PackageReference Include="Gress" Version="2.0.1" />
<PackageReference Include="MaterialDesignColors" Version="2.0.4" /> <PackageReference Include="MaterialDesignColors" Version="2.0.4" />
<PackageReference Include="MaterialDesignThemes" Version="4.3.0" /> <PackageReference Include="MaterialDesignThemes" Version="4.3.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />

View file

@ -13,6 +13,7 @@ using DiscordChatExporter.Gui.Utils;
using DiscordChatExporter.Gui.ViewModels.Dialogs; using DiscordChatExporter.Gui.ViewModels.Dialogs;
using DiscordChatExporter.Gui.ViewModels.Framework; using DiscordChatExporter.Gui.ViewModels.Framework;
using Gress; using Gress;
using Gress.Completable;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;
@ -25,11 +26,13 @@ public class RootViewModel : Screen
private readonly SettingsService _settingsService; private readonly SettingsService _settingsService;
private readonly UpdateService _updateService; private readonly UpdateService _updateService;
private readonly AutoResetProgressMuxer _progressMuxer;
private DiscordClient? _discord; private DiscordClient? _discord;
public ISnackbarMessageQueue Notifications { get; } = new SnackbarMessageQueue(TimeSpan.FromSeconds(5)); public SnackbarMessageQueue Notifications { get; } = new(TimeSpan.FromSeconds(5));
public IProgressManager ProgressManager { get; } = new ProgressManager(); public ProgressContainer<Percentage> Progress { get; } = new();
public bool IsBusy { get; private set; } public bool IsBusy { get; private set; }
@ -62,17 +65,14 @@ public class RootViewModel : Screen
DisplayName = $"{App.Name} v{App.VersionString}"; DisplayName = $"{App.Name} v{App.VersionString}";
// Update busy state when progress manager changes _progressMuxer = Progress.CreateMuxer().WithAutoReset();
ProgressManager.Bind(o => o.IsActive, (_, _) =>
IsBusy = ProgressManager.IsActive this.Bind(o => o.IsBusy, (_, _) =>
IsProgressIndeterminate = IsBusy && Progress.Current.Fraction is <= 0 or >= 1
); );
ProgressManager.Bind(o => o.IsActive, (_, _) => Progress.Bind(o => o.Current, (_, _) =>
IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress is <= 0 or >= 1 IsProgressIndeterminate = IsBusy && Progress.Current.Fraction is <= 0 or >= 1
);
ProgressManager.Bind(o => o.Progress, (_, _) =>
IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress is <= 0 or >= 1
); );
} }
@ -147,7 +147,8 @@ public class RootViewModel : Screen
public async void PopulateGuildsAndChannels() public async void PopulateGuildsAndChannels()
{ {
using var operation = ProgressManager.CreateOperation(); IsBusy = true;
var progress = _progressMuxer.CreateInput();
try try
{ {
@ -183,6 +184,11 @@ public class RootViewModel : Screen
await _dialogManager.ShowDialogAsync(dialog); await _dialogManager.ShowDialogAsync(dialog);
} }
finally
{
progress.ReportCompletion();
IsBusy = false;
}
} }
public bool CanExportChannels => public bool CanExportChannels =>
@ -194,6 +200,8 @@ public class RootViewModel : Screen
public async void ExportChannels() public async void ExportChannels()
{ {
IsBusy = true;
try try
{ {
if (_discord is null || SelectedGuild is null || SelectedChannels is null || !SelectedChannels.Any()) if (_discord is null || SelectedGuild is null || SelectedChannels is null || !SelectedChannels.Any())
@ -205,18 +213,22 @@ public class RootViewModel : Screen
var exporter = new ChannelExporter(_discord); var exporter = new ChannelExporter(_discord);
var operations = ProgressManager.CreateOperations(dialog.Channels!.Count); var progresses = Enumerable
.Range(0, dialog.Channels!.Count)
.Select(_ => _progressMuxer.CreateInput())
.ToArray();
var successfulExportCount = 0; var successfulExportCount = 0;
await Parallel.ForEachAsync( await Parallel.ForEachAsync(
dialog.Channels.Zip(operations), dialog.Channels.Zip(progresses),
new ParallelOptions new ParallelOptions
{ {
MaxDegreeOfParallelism = Math.Max(1, _settingsService.ParallelLimit) MaxDegreeOfParallelism = Math.Max(1, _settingsService.ParallelLimit)
}, },
async (tuple, cancellationToken) => async (tuple, cancellationToken) =>
{ {
var (channel, operation) = tuple; var (channel, progress) = tuple;
try try
{ {
@ -234,7 +246,7 @@ public class RootViewModel : Screen
_settingsService.DateFormat _settingsService.DateFormat
); );
await exporter.ExportChannelAsync(request, operation, cancellationToken); await exporter.ExportChannelAsync(request, progress, cancellationToken);
Interlocked.Increment(ref successfulExportCount); Interlocked.Increment(ref successfulExportCount);
} }
@ -244,7 +256,7 @@ public class RootViewModel : Screen
} }
finally finally
{ {
operation.Dispose(); progress.ReportCompletion();
} }
} }
); );
@ -262,5 +274,9 @@ public class RootViewModel : Screen
await _dialogManager.ShowDialogAsync(dialog); await _dialogManager.ShowDialogAsync(dialog);
} }
finally
{
IsBusy = false;
}
} }
} }

View file

@ -1,7 +1,16 @@
<Window <Window
Background="{DynamicResource MaterialDesignPaper}"
FocusManager.FocusedElement="{Binding ElementName=TokenValueTextBox}"
Height="550"
Icon="/DiscordChatExporter;component/favicon.ico"
MinWidth="325"
Style="{DynamicResource MaterialDesignRoot}"
Width="600"
WindowStartupLocation="CenterScreen"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
mc:Ignorable="d"
x:Class="DiscordChatExporter.Gui.Views.RootView" x:Class="DiscordChatExporter.Gui.Views.RootView"
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:behaviors="clr-namespace:DiscordChatExporter.Gui.Behaviors" xmlns:behaviors="clr-namespace:DiscordChatExporter.Gui.Behaviors"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters" xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters"
@ -11,21 +20,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet" xmlns:s="https://github.com/canton7/Stylet"
xmlns:viewModels="clr-namespace:DiscordChatExporter.Gui.ViewModels" xmlns:viewModels="clr-namespace:DiscordChatExporter.Gui.ViewModels"
Width="600" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Height="550"
MinWidth="325"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
Background="{DynamicResource MaterialDesignPaper}"
FocusManager.FocusedElement="{Binding ElementName=TokenValueTextBox}"
Icon="/DiscordChatExporter;component/favicon.ico"
Style="{DynamicResource MaterialDesignRoot}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.TaskbarItemInfo> <Window.TaskbarItemInfo>
<TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding ProgressManager.Progress}" /> <TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding Progress.Current.Fraction}" />
</Window.TaskbarItemInfo> </Window.TaskbarItemInfo>
<Window.Resources> <Window.Resources>
<CollectionViewSource x:Key="AvailableChannelsViewSource" Source="{Binding AvailableChannels, Mode=OneWay}"> <CollectionViewSource Source="{Binding AvailableChannels, Mode=OneWay}" x:Key="AvailableChannelsViewSource">
<CollectionViewSource.GroupDescriptions> <CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Category.Name" /> <PropertyGroupDescription PropertyName="Category.Name" />
</CollectionViewSource.GroupDescriptions> </CollectionViewSource.GroupDescriptions>
@ -46,7 +46,7 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Toolbar --> <!-- Toolbar -->
<Grid Grid.Row="0" Background="{DynamicResource MaterialDesignDarkBackground}"> <Grid Background="{DynamicResource MaterialDesignDarkBackground}" Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -54,8 +54,8 @@
<!-- Token and pull data button --> <!-- Token and pull data button -->
<materialDesign:Card <materialDesign:Card
Grid.Row="0"
Grid.Column="0" Grid.Column="0"
Grid.Row="0"
Margin="12,12,0,12"> Margin="12,12,0,12">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -66,74 +66,74 @@
<!-- Token icon --> <!-- Token icon -->
<materialDesign:PackIcon <materialDesign:PackIcon
Foreground="{DynamicResource PrimaryHueMidBrush}"
Grid.Column="0" Grid.Column="0"
Width="24"
Height="24" Height="24"
Kind="Password"
Margin="8" Margin="8"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{DynamicResource PrimaryHueMidBrush}" Width="24" />
Kind="Password" />
<!-- Token value --> <!-- Token value -->
<TextBox <TextBox
x:Name="TokenValueTextBox" BorderThickness="0"
FontSize="16"
Grid.Column="1" Grid.Column="1"
Margin="0,6,6,8" Margin="0,6,6,8"
Text="{Binding Token, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
materialDesign:HintAssist.Hint="Token" materialDesign:HintAssist.Hint="Token"
materialDesign:TextFieldAssist.DecorationVisibility="Hidden" materialDesign:TextFieldAssist.DecorationVisibility="Hidden"
materialDesign:TextFieldAssist.TextBoxViewMargin="0,0,2,0" materialDesign:TextFieldAssist.TextBoxViewMargin="0,0,2,0"
BorderThickness="0" x:Name="TokenValueTextBox" />
FontSize="16"
Text="{Binding Token, UpdateSourceTrigger=PropertyChanged}" />
<!-- Pull data button --> <!-- Pull data button -->
<Button <Button
Command="{s:Action PopulateGuildsAndChannels}"
Grid.Column="2" Grid.Column="2"
IsDefault="True"
Margin="0,6,6,6" Margin="0,6,6,6"
Padding="4" Padding="4"
Command="{s:Action PopulateGuildsAndChannels}"
IsDefault="True"
Style="{DynamicResource MaterialDesignFlatButton}" Style="{DynamicResource MaterialDesignFlatButton}"
ToolTip="Pull available guilds and channels (Enter)"> ToolTip="Pull available guilds and channels (Enter)">
<materialDesign:PackIcon <materialDesign:PackIcon
Width="24"
Height="24" Height="24"
Kind="ArrowRight" /> Kind="ArrowRight"
Width="24" />
</Button> </Button>
</Grid> </Grid>
</materialDesign:Card> </materialDesign:Card>
<!-- Settings button --> <!-- Settings button -->
<Button <Button
Command="{s:Action ShowSettings}"
Foreground="{DynamicResource MaterialDesignDarkForeground}"
Grid.Column="1" Grid.Column="1"
Margin="6" Margin="6"
Padding="4" Padding="4"
Command="{s:Action ShowSettings}"
Foreground="{DynamicResource MaterialDesignDarkForeground}"
Style="{DynamicResource MaterialDesignFlatButton}" Style="{DynamicResource MaterialDesignFlatButton}"
ToolTip="Settings"> ToolTip="Settings">
<Button.Resources> <Button.Resources>
<SolidColorBrush x:Key="MaterialDesignFlatButtonClick" Color="#4C4C4C" /> <SolidColorBrush Color="#4C4C4C" x:Key="MaterialDesignFlatButtonClick" />
</Button.Resources> </Button.Resources>
<materialDesign:PackIcon <materialDesign:PackIcon
Width="24"
Height="24" Height="24"
Kind="Settings" /> Kind="Settings"
Width="24" />
</Button> </Button>
</Grid> </Grid>
<!-- Progress bar --> <!-- Progress bar -->
<ProgressBar <ProgressBar
Grid.Row="1"
Background="{DynamicResource MaterialDesignDarkBackground}" Background="{DynamicResource MaterialDesignDarkBackground}"
Grid.Row="1"
IsIndeterminate="{Binding IsProgressIndeterminate}" IsIndeterminate="{Binding IsProgressIndeterminate}"
Value="{Binding ProgressManager.Progress, Mode=OneWay}" /> Value="{Binding Progress.Current.Fraction, Mode=OneWay}" />
<!-- Content --> <!-- Content -->
<Grid <Grid
Grid.Row="2"
Background="{DynamicResource MaterialDesignCardBackground}" Background="{DynamicResource MaterialDesignCardBackground}"
Grid.Row="2"
IsEnabled="{Binding IsBusy, Converter={x:Static converters:InverseBoolConverter.Instance}}"> IsEnabled="{Binding IsBusy, Converter={x:Static converters:InverseBoolConverter.Instance}}">
<Grid.Resources> <Grid.Resources>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
@ -143,7 +143,7 @@
<!-- Placeholder / usage instructions --> <!-- Placeholder / usage instructions -->
<Grid Visibility="{Binding AvailableGuilds, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}"> <Grid Visibility="{Binding AvailableGuilds, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<TextBlock Margin="32,16" FontSize="14"> <TextBlock FontSize="14" Margin="32,16">
<Run FontSize="18" Text="Please provide authentication token to continue" /> <Run FontSize="18" Text="Please provide authentication token to continue" />
<LineBreak /> <LineBreak />
<LineBreak /> <LineBreak />
@ -151,9 +151,9 @@
<!-- User token --> <!-- User token -->
<InlineUIContainer> <InlineUIContainer>
<materialDesign:PackIcon <materialDesign:PackIcon
Margin="1,0,0,-2"
Foreground="{DynamicResource PrimaryHueMidBrush}" Foreground="{DynamicResource PrimaryHueMidBrush}"
Kind="Account" /> Kind="Account"
Margin="1,0,0,-2" />
</InlineUIContainer> </InlineUIContainer>
<Run FontSize="16" Text="Authenticate using your personal account" /> <Run FontSize="16" Text="Authenticate using your personal account" />
<LineBreak /> <LineBreak />
@ -199,9 +199,9 @@
<!-- Bot token --> <!-- Bot token -->
<InlineUIContainer> <InlineUIContainer>
<materialDesign:PackIcon <materialDesign:PackIcon
Margin="1,0,0,-2"
Foreground="{DynamicResource PrimaryHueMidBrush}" Foreground="{DynamicResource PrimaryHueMidBrush}"
Kind="Robot" /> Kind="Robot"
Margin="1,0,0,-2" />
</InlineUIContainer> </InlineUIContainer>
<Run FontSize="16" Text="Authenticate as a bot" /> <Run FontSize="16" Text="Authenticate as a bot" />
<LineBreak /> <LineBreak />
@ -235,9 +235,9 @@
<!-- Guilds --> <!-- Guilds -->
<Border <Border
Grid.Column="0"
BorderBrush="{DynamicResource MaterialDesignDivider}" BorderBrush="{DynamicResource MaterialDesignDivider}"
BorderThickness="0,0,1,0"> BorderThickness="0,0,1,0"
Grid.Column="0">
<ListBox <ListBox
ItemsSource="{Binding AvailableGuilds}" ItemsSource="{Binding AvailableGuilds}"
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"
@ -246,24 +246,24 @@
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid <Grid
Margin="-8"
Background="Transparent" Background="Transparent"
Cursor="Hand" Cursor="Hand"
Margin="-8"
ToolTip="{Binding Name}"> ToolTip="{Binding Name}">
<!-- Guild icon placeholder --> <!-- Guild icon placeholder -->
<Ellipse <Ellipse
Width="48" Fill="{DynamicResource MaterialDesignDivider}"
Height="48" Height="48"
Margin="12,4,12,4" Margin="12,4,12,4"
Fill="{DynamicResource MaterialDesignDivider}" /> Width="48" />
<!-- Guild icon --> <!-- Guild icon -->
<Ellipse <Ellipse
Width="48"
Height="48" Height="48"
Margin="12,4,12,4" Margin="12,4,12,4"
Stroke="{DynamicResource MaterialDesignDivider}" Stroke="{DynamicResource MaterialDesignDivider}"
StrokeThickness="1"> StrokeThickness="1"
Width="48">
<Ellipse.Fill> <Ellipse.Fill>
<ImageBrush ImageSource="{Binding IconUrl}" /> <ImageBrush ImageSource="{Binding IconUrl}" />
</Ellipse.Fill> </Ellipse.Fill>
@ -293,13 +293,13 @@
<Setter.Value> <Setter.Value>
<ControlTemplate d:DataContext="{x:Type CollectionViewGroup}"> <ControlTemplate d:DataContext="{x:Type CollectionViewGroup}">
<Expander <Expander
Margin="0"
Padding="0"
Background="Transparent" Background="Transparent"
BorderBrush="{DynamicResource MaterialDesignDivider}" BorderBrush="{DynamicResource MaterialDesignDivider}"
BorderThickness="0,0,0,1" BorderThickness="0,0,0,1"
Header="{Binding Name}" Header="{Binding Name}"
IsExpanded="False"> IsExpanded="False"
Margin="0"
Padding="0">
<ItemsPresenter /> <ItemsPresenter />
</Expander> </Expander>
</ControlTemplate> </ControlTemplate>
@ -311,7 +311,7 @@
</ListBox.GroupStyle> </ListBox.GroupStyle>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Margin="-8" Background="Transparent"> <Grid Background="Transparent" Margin="-8">
<Grid.InputBindings> <Grid.InputBindings>
<MouseBinding Command="{s:Action ExportChannels}" MouseAction="LeftDoubleClick" /> <MouseBinding Command="{s:Action ExportChannels}" MouseAction="LeftDoubleClick" />
</Grid.InputBindings> </Grid.InputBindings>
@ -324,27 +324,27 @@
<!-- Channel icon --> <!-- Channel icon -->
<materialDesign:PackIcon <materialDesign:PackIcon
Grid.Column="0" Grid.Column="0"
Kind="Pound"
Margin="16,7,0,6" Margin="16,7,0,6"
VerticalAlignment="Center" VerticalAlignment="Center" />
Kind="Pound" />
<!-- Channel name --> <!-- Channel name -->
<TextBlock <TextBlock
FontSize="14"
Grid.Column="1" Grid.Column="1"
Margin="3,8,8,8" Margin="3,8,8,8"
VerticalAlignment="Center" Text="{Binding Name, Mode=OneWay}"
FontSize="14" VerticalAlignment="Center" />
Text="{Binding Name, Mode=OneWay}" />
<!-- Is selected checkmark --> <!-- Is selected checkmark -->
<materialDesign:PackIcon <materialDesign:PackIcon
Grid.Column="2" Grid.Column="2"
Width="24"
Height="24" Height="24"
Kind="Check"
Margin="8,0" Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Kind="Check" Visibility="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
Visibility="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" /> Width="24" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
@ -354,16 +354,16 @@
<!-- Export button --> <!-- Export button -->
<Button <Button
Margin="32,24"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Command="{s:Action ExportChannels}" Command="{s:Action ExportChannels}"
HorizontalAlignment="Right"
Margin="32,24"
Style="{DynamicResource MaterialDesignFloatingActionAccentButton}" Style="{DynamicResource MaterialDesignFloatingActionAccentButton}"
VerticalAlignment="Bottom"
Visibility="{Binding CanExportChannels, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"> Visibility="{Binding CanExportChannels, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<materialDesign:PackIcon <materialDesign:PackIcon
Width="32"
Height="32" Height="32"
Kind="Download" /> Kind="Download"
Width="32" />
</Button> </Button>
<!-- Notifications snackbar --> <!-- Notifications snackbar -->