diff --git a/DiscordChatExporter/Container.cs b/DiscordChatExporter/Container.cs index 3fcf05d..7cf8ae5 100644 --- a/DiscordChatExporter/Container.cs +++ b/DiscordChatExporter/Container.cs @@ -12,9 +12,9 @@ namespace DiscordChatExporter ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); // Services - SimpleIoc.Default.Register(true); - SimpleIoc.Default.Register(true); - SimpleIoc.Default.Register(true); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); // View models SimpleIoc.Default.Register(true); diff --git a/DiscordChatExporter/Services/ExportService.cs b/DiscordChatExporter/Services/ExportService.cs index f0f9bde..e9c2b81 100644 --- a/DiscordChatExporter/Services/ExportService.cs +++ b/DiscordChatExporter/Services/ExportService.cs @@ -12,10 +12,18 @@ namespace DiscordChatExporter.Services { public partial class ExportService : IExportService { + private readonly ISettingsService _settingsService; + + public ExportService(ISettingsService settingsService) + { + _settingsService = settingsService; + } + public void Export(string filePath, ChannelChatLog channelChatLog, Theme theme) { var doc = GetTemplate(); var style = GetStyle(theme); + var dateFormat = _settingsService.DateFormat; // Set theme var themeHtml = doc.GetElementbyId("theme"); @@ -61,7 +69,7 @@ namespace DiscordChatExporter.Services messageRightHtml.AppendChild(HtmlNode.CreateNode($"{authorName}")); // Date - var timeStamp = HtmlDocument.HtmlEncode(messageGroup.TimeStamp.ToString("g")); + var timeStamp = HtmlDocument.HtmlEncode(messageGroup.TimeStamp.ToString(dateFormat)); messageRightHtml.AppendChild(HtmlNode.CreateNode($"{timeStamp}")); // Individual messages @@ -80,7 +88,7 @@ namespace DiscordChatExporter.Services { contentHtml.AppendChild( HtmlNode.CreateNode( - $"(edited)")); + $"(edited)")); } } @@ -150,7 +158,7 @@ namespace DiscordChatExporter.Services private static string NormalizeFileSize(long fileSize) { - string[] units = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; + string[] units = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; double size = fileSize; var unit = 0; diff --git a/DiscordChatExporter/Services/ISettingsService.cs b/DiscordChatExporter/Services/ISettingsService.cs index 2138eaf..5479fb1 100644 --- a/DiscordChatExporter/Services/ISettingsService.cs +++ b/DiscordChatExporter/Services/ISettingsService.cs @@ -6,6 +6,7 @@ namespace DiscordChatExporter.Services { string Token { get; set; } Theme Theme { get; set; } + string DateFormat { get; set; } void Load(); void Save(); diff --git a/DiscordChatExporter/Services/SettingsService.cs b/DiscordChatExporter/Services/SettingsService.cs index 965ba06..bb5ba92 100644 --- a/DiscordChatExporter/Services/SettingsService.cs +++ b/DiscordChatExporter/Services/SettingsService.cs @@ -7,6 +7,7 @@ namespace DiscordChatExporter.Services { public string Token { get; set; } public Theme Theme { get; set; } + public string DateFormat { get; set; } = "dd-MMM-yy hh:mm"; public SettingsService() { diff --git a/DiscordChatExporter/ViewModels/SettingsViewModel.cs b/DiscordChatExporter/ViewModels/SettingsViewModel.cs index 94caff0..4de5070 100644 --- a/DiscordChatExporter/ViewModels/SettingsViewModel.cs +++ b/DiscordChatExporter/ViewModels/SettingsViewModel.cs @@ -19,6 +19,12 @@ namespace DiscordChatExporter.ViewModels set => _settingsService.Theme = value; } + public string DateFormat + { + get => _settingsService.DateFormat; + set => _settingsService.DateFormat = value; + } + public SettingsViewModel(ISettingsService settingsService) { _settingsService = settingsService; diff --git a/DiscordChatExporter/Views/SettingsDialog.ammy b/DiscordChatExporter/Views/SettingsDialog.ammy index 834cfbc..8d00b1a 100644 --- a/DiscordChatExporter/Views/SettingsDialog.ammy +++ b/DiscordChatExporter/Views/SettingsDialog.ammy @@ -7,7 +7,7 @@ UserControl "DiscordChatExporter.Views.SettingsDialog" { StackPanel { // Theme ComboBox { - Margin: 16 + Margin: "16 16 16 8" HintAssist.Hint: "Theme" HintAssist.IsFloating: true IsReadOnly: true @@ -15,6 +15,15 @@ UserControl "DiscordChatExporter.Views.SettingsDialog" { SelectedItem: bind Theme } + // Date format + TextBox { + Margin: "16 8 16 8" + HintAssist.Hint: "Date format" + HintAssist.IsFloating: true + Text: bind DateFormat + } + + // Save Button { Margin: 8