Add partition by file size (#497)

This commit is contained in:
Andrew Kolos
2021-04-12 06:50:32 -04:00
committed by GitHub
parent ad3655396f
commit eb89ea5b40
23 changed files with 331 additions and 22 deletions

View File

@@ -0,0 +1,27 @@
using DiscordChatExporter.Core.Exporting;
using DiscordChatExporter.Gui.Internal;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace DiscordChatExporter.Gui.Converters
{
[ValueConversion(typeof(ExportFormat), typeof(string))]
public class PartitionFormatToStringConverter : IValueConverter
{
public static PartitionFormatToStringConverter Instance { get; } = new();
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is PartitionFormat partitionFormatValue)
return partitionFormatValue.GetDisplayName();
return default(string);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}
}

View File

@@ -0,0 +1,33 @@
using DiscordChatExporter.Gui.Internal;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace DiscordChatExporter.Gui.Converters
{
[ValueConversion(typeof(DateTimeOffset?), typeof(DateTime?))]
public class PartitionFormatToTextBoxHintConverter : IValueConverter
{
public static PartitionFormatToTextBoxHintConverter Instance { get; } = new();
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is PartitionFormat partitionFormat)
return partitionFormat switch
{
PartitionFormat.FileSize => "MB per partition",
PartitionFormat.MessageCount => "Messages per partition",
_ => default(string)
};
return default(DateTime?);
}
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,33 @@
using DiscordChatExporter.Gui.Internal;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace DiscordChatExporter.Gui.Converters
{
[ValueConversion(typeof(DateTimeOffset?), typeof(DateTime?))]
public class PartitionFormatToTooltipConverter : IValueConverter
{
public static PartitionFormatToTextBoxHintConverter Instance { get; } = new();
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is PartitionFormat partitionFormat)
return partitionFormat switch
{
PartitionFormat.FileSize => "Split output into partitions close to this file size",
PartitionFormat.MessageCount => "Split output into partitions limited to this number of messages",
_ => default(string)
};
return default(DateTime?);
}
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}