diff --git a/Deploy/Prepare.ps1 b/Deploy/Prepare.ps1 index 1a1fb61..e53101f 100644 --- a/Deploy/Prepare.ps1 +++ b/Deploy/Prepare.ps1 @@ -1,3 +1,5 @@ New-Item "$PSScriptRoot\bin" -ItemType Directory -Force -$files = Get-ChildItem -Path "$PSScriptRoot\..\DiscordChatExporter\bin\Release\*" -Include "*.exe", "*.dll", "*.config" +$files = @() +$files += Get-ChildItem -Path "$PSScriptRoot\..\DiscordChatExporter.Gui\bin\Release\*" -Include "*.exe", "*.dll", "*.config" +$files += Get-ChildItem -Path "$PSScriptRoot\..\DiscordChatExporter.Cli\bin\Release\net45\*" -Include "*.exe", "*.dll", "*.config" $files | Compress-Archive -DestinationPath "$PSScriptRoot\bin\DiscordChatExporter.zip" -Force \ No newline at end of file diff --git a/DiscordChatExporter.Cli/CliOptions.cs b/DiscordChatExporter.Cli/CliOptions.cs new file mode 100644 index 0000000..0a58b1d --- /dev/null +++ b/DiscordChatExporter.Cli/CliOptions.cs @@ -0,0 +1,24 @@ +using System; +using DiscordChatExporter.Core.Models; + +namespace DiscordChatExporter.Cli +{ + public class CliOptions + { + public string Token { get; set; } + + public string ChannelId { get; set; } + + public ExportFormat ExportFormat { get; set; } + + public string FilePath { get; set; } + + public DateTime? From { get; set; } + + public DateTime? To { get; set; } + + public string DateFormat { get; set; } + + public int MessageGroupLimit { get; set; } + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Cli/Container.cs b/DiscordChatExporter.Cli/Container.cs new file mode 100644 index 0000000..164e3b5 --- /dev/null +++ b/DiscordChatExporter.Cli/Container.cs @@ -0,0 +1,37 @@ +using DiscordChatExporter.Cli.ViewModels; +using DiscordChatExporter.Core.Services; +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; + +namespace DiscordChatExporter.Cli +{ + public class Container + { + public IMainViewModel MainViewModel => Resolve(); + public ISettingsService SettingsService => Resolve(); + + private T Resolve(string key = null) + { + return ServiceLocator.Current.GetInstance(key); + } + + public void Init() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Reset(); + + // Services + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + + // View models + SimpleIoc.Default.Register(true); + } + + public void Cleanup() + { + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj new file mode 100644 index 0000000..00fd470 --- /dev/null +++ b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj @@ -0,0 +1,24 @@ + + + + Exe + net45 + 2.3 + Tyrrrz + Copyright (c) 2017-2018 Alexey Golub + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DiscordChatExporter.Cli/FodyWeavers.xml b/DiscordChatExporter.Cli/FodyWeavers.xml new file mode 100644 index 0000000..c6e1b7c --- /dev/null +++ b/DiscordChatExporter.Cli/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DiscordChatExporter.Cli/Program.cs b/DiscordChatExporter.Cli/Program.cs new file mode 100644 index 0000000..fd356a6 --- /dev/null +++ b/DiscordChatExporter.Cli/Program.cs @@ -0,0 +1,83 @@ +using System; +using System.Reflection; +using DiscordChatExporter.Core.Models; +using Fclp; + +namespace DiscordChatExporter.Cli +{ + public static class Program + { + private static readonly Container Container = new Container(); + + private static CliOptions ParseOptions(string[] args) + { + var argsParser = new FluentCommandLineParser(); + + var settings = Container.SettingsService; + + argsParser.Setup(o => o.Token).As('t', "token").Required(); + argsParser.Setup(o => o.ChannelId).As('c', "channel").Required(); + argsParser.Setup(o => o.ExportFormat).As('f', "format").SetDefault(ExportFormat.HtmlDark); + argsParser.Setup(o => o.FilePath).As('o', "output").SetDefault(null); + argsParser.Setup(o => o.From).As("datefrom").SetDefault(null); + argsParser.Setup(o => o.To).As("dateto").SetDefault(null); + argsParser.Setup(o => o.DateFormat).As("dateformat").SetDefault(settings.DateFormat); + argsParser.Setup(o => o.MessageGroupLimit).As("grouplimit").SetDefault(settings.MessageGroupLimit); + + var parsed = argsParser.Parse(args); + + // Show help if no arguments + if (parsed.EmptyArgs) + { + var version = Assembly.GetExecutingAssembly().GetName().Version; + Console.WriteLine($"=== Discord Chat Exporter (Command Line Interface) v{version} ==="); + Console.WriteLine(); + Console.WriteLine("[-t] [--token] Discord authorization token."); + Console.WriteLine("[-c] [--channel] Discord channel ID."); + Console.WriteLine("[-f] [--format] Export format (PlainText/HtmlDark/HtmlLight). Optional."); + Console.WriteLine("[-o] [--output] Output file path. Optional."); + Console.WriteLine(" [--datefrom] Limit to messages after this date. Optional."); + Console.WriteLine(" [--dateto] Limit to messages before this date. Optional."); + Console.WriteLine(" [--dateformat] Date format. Optional."); + Console.WriteLine(" [--grouplimit] Message group limit. Optional."); + Environment.Exit(0); + } + // Show error if there are any + else if (parsed.HasErrors) + { + Console.Error.Write(parsed.ErrorText); + Environment.Exit(-1); + } + + return argsParser.Object; + } + + public static void Main(string[] args) + { + // Init container + Container.Init(); + + // Parse options + var options = ParseOptions(args); + + // Inject some settings + var settings = Container.SettingsService; + settings.DateFormat = options.DateFormat; + settings.MessageGroupLimit = options.MessageGroupLimit; + + // Export + var vm = Container.MainViewModel; + vm.ExportAsync( + options.Token, + options.ChannelId, + options.FilePath, + options.ExportFormat, + options.From, + options.To).GetAwaiter().GetResult(); + + // Cleanup container + Container.Cleanup(); + Console.WriteLine("Export complete."); + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Cli/ViewModels/IMainViewModel.cs b/DiscordChatExporter.Cli/ViewModels/IMainViewModel.cs new file mode 100644 index 0000000..55b26d1 --- /dev/null +++ b/DiscordChatExporter.Cli/ViewModels/IMainViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Threading.Tasks; +using DiscordChatExporter.Core.Models; + +namespace DiscordChatExporter.Cli.ViewModels +{ + public interface IMainViewModel + { + Task ExportAsync(string token, string channelId, string filePath, ExportFormat format, DateTime? from, + DateTime? to); + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Cli/ViewModels/MainViewModel.cs b/DiscordChatExporter.Cli/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..715261e --- /dev/null +++ b/DiscordChatExporter.Cli/ViewModels/MainViewModel.cs @@ -0,0 +1,53 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using DiscordChatExporter.Core.Models; +using DiscordChatExporter.Core.Services; +using Tyrrrz.Extensions; + +namespace DiscordChatExporter.Cli.ViewModels +{ + public class MainViewModel : IMainViewModel + { + private readonly IDataService _dataService; + private readonly IMessageGroupService _messageGroupService; + private readonly IExportService _exportService; + + public MainViewModel(IDataService dataService, IMessageGroupService messageGroupService, + IExportService exportService) + { + _dataService = dataService; + _messageGroupService = messageGroupService; + _exportService = exportService; + } + + public async Task ExportAsync(string token, string channelId, string filePath, ExportFormat format, DateTime? from, + DateTime? to) + { + // Get channel and guild + var channel = await _dataService.GetChannelAsync(token, channelId); + var guild = channel.GuildId == Guild.DirectMessages.Id + ? Guild.DirectMessages + : await _dataService.GetGuildAsync(token, channel.GuildId); + + // Generate file path if not set + if (filePath.IsBlank()) + { + filePath = $"{guild} - {channel}.{format.GetFileExtension()}" + .Replace(Path.GetInvalidFileNameChars(), '_'); + } + + // Get messages + var messages = await _dataService.GetChannelMessagesAsync(token, channelId, from, to); + + // Group them + var messageGroups = _messageGroupService.GroupMessages(messages); + + // Create log + var log = new ChannelChatLog(guild, channel, messageGroups, messages.Count); + + // Export + await _exportService.ExportAsync(format, filePath, log); + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj new file mode 100644 index 0000000..75b697b --- /dev/null +++ b/DiscordChatExporter.Core/DiscordChatExporter.Core.csproj @@ -0,0 +1,22 @@ + + + + net45 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DiscordChatExporter/Exceptions/HttpErrorStatusCodeException.cs b/DiscordChatExporter.Core/Exceptions/HttpErrorStatusCodeException.cs similarity index 85% rename from DiscordChatExporter/Exceptions/HttpErrorStatusCodeException.cs rename to DiscordChatExporter.Core/Exceptions/HttpErrorStatusCodeException.cs index 6cb562a..dd4d90f 100644 --- a/DiscordChatExporter/Exceptions/HttpErrorStatusCodeException.cs +++ b/DiscordChatExporter.Core/Exceptions/HttpErrorStatusCodeException.cs @@ -1,7 +1,7 @@ using System; using System.Net; -namespace DiscordChatExporter.Exceptions +namespace DiscordChatExporter.Core.Exceptions { public class HttpErrorStatusCodeException : Exception { diff --git a/DiscordChatExporter.Core/Internal/AssemblyHelper.cs b/DiscordChatExporter.Core/Internal/AssemblyHelper.cs new file mode 100644 index 0000000..053518f --- /dev/null +++ b/DiscordChatExporter.Core/Internal/AssemblyHelper.cs @@ -0,0 +1,23 @@ +using System.IO; +using System.Reflection; +using System.Resources; + +namespace DiscordChatExporter.Core.Internal +{ + internal static class AssemblyHelper + { + public static string GetResourceString(string resourcePath) + { + var assembly = Assembly.GetExecutingAssembly(); + var stream = assembly.GetManifestResourceStream(resourcePath); + if (stream == null) + throw new MissingManifestResourceException($"Could not find resource [{resourcePath}]."); + + using (stream) + using (var reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter/Models/Attachment.cs b/DiscordChatExporter.Core/Models/Attachment.cs similarity index 91% rename from DiscordChatExporter/Models/Attachment.cs rename to DiscordChatExporter.Core/Models/Attachment.cs index ff71fa7..e6acb3e 100644 --- a/DiscordChatExporter/Models/Attachment.cs +++ b/DiscordChatExporter.Core/Models/Attachment.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public class Attachment { diff --git a/DiscordChatExporter/Models/AttachmentType.cs b/DiscordChatExporter.Core/Models/AttachmentType.cs similarity index 61% rename from DiscordChatExporter/Models/AttachmentType.cs rename to DiscordChatExporter.Core/Models/AttachmentType.cs index 2444ff5..5dc8ec5 100644 --- a/DiscordChatExporter/Models/AttachmentType.cs +++ b/DiscordChatExporter.Core/Models/AttachmentType.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public enum AttachmentType { diff --git a/DiscordChatExporter/Models/Channel.cs b/DiscordChatExporter.Core/Models/Channel.cs similarity index 63% rename from DiscordChatExporter/Models/Channel.cs rename to DiscordChatExporter.Core/Models/Channel.cs index 43568d1..6888e5b 100644 --- a/DiscordChatExporter/Models/Channel.cs +++ b/DiscordChatExporter.Core/Models/Channel.cs @@ -1,18 +1,21 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public partial class Channel { public string Id { get; } + public string GuildId { get; } + public string Name { get; } public string Topic { get; } public ChannelType Type { get; } - public Channel(string id, string name, string topic, ChannelType type) + public Channel(string id, string guildId, string name, string topic, ChannelType type) { Id = id; + GuildId = guildId; Name = name; Topic = topic; Type = type; @@ -28,7 +31,7 @@ { public static Channel CreateDeletedChannel(string id) { - return new Channel(id, "deleted-channel", null, ChannelType.GuildTextChat); + return new Channel(id, null, "deleted-channel", null, ChannelType.GuildTextChat); } } } \ No newline at end of file diff --git a/DiscordChatExporter/Models/ChannelChatLog.cs b/DiscordChatExporter.Core/Models/ChannelChatLog.cs similarity index 93% rename from DiscordChatExporter/Models/ChannelChatLog.cs rename to DiscordChatExporter.Core/Models/ChannelChatLog.cs index 81c6d2d..befbd10 100644 --- a/DiscordChatExporter/Models/ChannelChatLog.cs +++ b/DiscordChatExporter.Core/Models/ChannelChatLog.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public class ChannelChatLog { diff --git a/DiscordChatExporter/Models/ChannelType.cs b/DiscordChatExporter.Core/Models/ChannelType.cs similarity index 77% rename from DiscordChatExporter/Models/ChannelType.cs rename to DiscordChatExporter.Core/Models/ChannelType.cs index 0ada6bf..a7e7f20 100644 --- a/DiscordChatExporter/Models/ChannelType.cs +++ b/DiscordChatExporter.Core/Models/ChannelType.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public enum ChannelType { diff --git a/DiscordChatExporter/Models/ExportFormat.cs b/DiscordChatExporter.Core/Models/ExportFormat.cs similarity index 68% rename from DiscordChatExporter/Models/ExportFormat.cs rename to DiscordChatExporter.Core/Models/ExportFormat.cs index acac9cb..726fd9d 100644 --- a/DiscordChatExporter/Models/ExportFormat.cs +++ b/DiscordChatExporter.Core/Models/ExportFormat.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public enum ExportFormat { diff --git a/DiscordChatExporter/Models/Extensions.cs b/DiscordChatExporter.Core/Models/Extensions.cs similarity index 81% rename from DiscordChatExporter/Models/Extensions.cs rename to DiscordChatExporter.Core/Models/Extensions.cs index ef0893b..0f021f2 100644 --- a/DiscordChatExporter/Models/Extensions.cs +++ b/DiscordChatExporter.Core/Models/Extensions.cs @@ -1,6 +1,6 @@ using System; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public static class Extensions { @@ -13,7 +13,7 @@ namespace DiscordChatExporter.Models if (format == ExportFormat.HtmlLight) return "html"; - throw new NotImplementedException(); + throw new ArgumentOutOfRangeException(nameof(format)); } public static string GetDisplayName(this ExportFormat format) @@ -25,7 +25,7 @@ namespace DiscordChatExporter.Models if (format == ExportFormat.HtmlLight) return "HTML (Light)"; - throw new NotImplementedException(); + throw new ArgumentOutOfRangeException(nameof(format)); } } } \ No newline at end of file diff --git a/DiscordChatExporter/Models/Guild.cs b/DiscordChatExporter.Core/Models/Guild.cs similarity index 95% rename from DiscordChatExporter/Models/Guild.cs rename to DiscordChatExporter.Core/Models/Guild.cs index 61d4438..ef39b39 100644 --- a/DiscordChatExporter/Models/Guild.cs +++ b/DiscordChatExporter.Core/Models/Guild.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Tyrrrz.Extensions; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public partial class Guild { diff --git a/DiscordChatExporter/Models/Message.cs b/DiscordChatExporter.Core/Models/Message.cs similarity index 69% rename from DiscordChatExporter/Models/Message.cs rename to DiscordChatExporter.Core/Models/Message.cs index aff310b..18b1aa4 100644 --- a/DiscordChatExporter/Models/Message.cs +++ b/DiscordChatExporter.Core/Models/Message.cs @@ -1,12 +1,14 @@ using System; using System.Collections.Generic; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public class Message { public string Id { get; } + public string ChannelId { get; } + public MessageType Type { get; } public User Author { get; } @@ -25,13 +27,14 @@ namespace DiscordChatExporter.Models public IReadOnlyList MentionedChannels { get; } - public Message(string id, MessageType type, User author, - DateTime timeStamp, DateTime? editedTimeStamp, - string content, IReadOnlyList attachments, - IReadOnlyList mentionedUsers, IReadOnlyList mentionedRoles, - IReadOnlyList mentionedChannels) + public Message(string id, string channelId, MessageType type, + User author, DateTime timeStamp, + DateTime? editedTimeStamp, string content, + IReadOnlyList attachments, IReadOnlyList mentionedUsers, + IReadOnlyList mentionedRoles, IReadOnlyList mentionedChannels) { Id = id; + ChannelId = channelId; Type = type; Author = author; TimeStamp = timeStamp; diff --git a/DiscordChatExporter/Models/MessageGroup.cs b/DiscordChatExporter.Core/Models/MessageGroup.cs similarity index 91% rename from DiscordChatExporter/Models/MessageGroup.cs rename to DiscordChatExporter.Core/Models/MessageGroup.cs index a55a51e..cbb6538 100644 --- a/DiscordChatExporter/Models/MessageGroup.cs +++ b/DiscordChatExporter.Core/Models/MessageGroup.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public class MessageGroup { diff --git a/DiscordChatExporter/Models/MessageType.cs b/DiscordChatExporter.Core/Models/MessageType.cs similarity index 83% rename from DiscordChatExporter/Models/MessageType.cs rename to DiscordChatExporter.Core/Models/MessageType.cs index 8ad4490..9cfc75e 100644 --- a/DiscordChatExporter/Models/MessageType.cs +++ b/DiscordChatExporter.Core/Models/MessageType.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public enum MessageType { diff --git a/DiscordChatExporter/Models/Role.cs b/DiscordChatExporter.Core/Models/Role.cs similarity index 91% rename from DiscordChatExporter/Models/Role.cs rename to DiscordChatExporter.Core/Models/Role.cs index 55b031c..4fb2f98 100644 --- a/DiscordChatExporter/Models/Role.cs +++ b/DiscordChatExporter.Core/Models/Role.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public partial class Role { diff --git a/DiscordChatExporter/Models/User.cs b/DiscordChatExporter.Core/Models/User.cs similarity index 95% rename from DiscordChatExporter/Models/User.cs rename to DiscordChatExporter.Core/Models/User.cs index 44812fa..a0797ed 100644 --- a/DiscordChatExporter/Models/User.cs +++ b/DiscordChatExporter.Core/Models/User.cs @@ -1,6 +1,6 @@ using Tyrrrz.Extensions; -namespace DiscordChatExporter.Models +namespace DiscordChatExporter.Core.Models { public class User { diff --git a/DiscordChatExporter/Resources/ExportService/DarkTheme.css b/DiscordChatExporter.Core/Resources/ExportService/DarkTheme.css similarity index 100% rename from DiscordChatExporter/Resources/ExportService/DarkTheme.css rename to DiscordChatExporter.Core/Resources/ExportService/DarkTheme.css diff --git a/DiscordChatExporter/Resources/ExportService/LightTheme.css b/DiscordChatExporter.Core/Resources/ExportService/LightTheme.css similarity index 100% rename from DiscordChatExporter/Resources/ExportService/LightTheme.css rename to DiscordChatExporter.Core/Resources/ExportService/LightTheme.css diff --git a/DiscordChatExporter/Services/DataService.cs b/DiscordChatExporter.Core/Services/DataService.cs similarity index 91% rename from DiscordChatExporter/Services/DataService.cs rename to DiscordChatExporter.Core/Services/DataService.cs index 11ecc2c..06abb35 100644 --- a/DiscordChatExporter/Services/DataService.cs +++ b/DiscordChatExporter.Core/Services/DataService.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; -using DiscordChatExporter.Exceptions; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Exceptions; +using DiscordChatExporter.Core.Models; using Newtonsoft.Json.Linq; using Tyrrrz.Extensions; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public partial class DataService : IDataService, IDisposable { @@ -51,6 +51,7 @@ namespace DiscordChatExporter.Services { // Get basic data var id = token["id"].Value(); + var guildId = token["guild_id"]?.Value(); var type = (ChannelType) token["type"].Value(); var topic = token["topic"]?.Value(); @@ -58,6 +59,7 @@ namespace DiscordChatExporter.Services string name; if (type.IsEither(ChannelType.DirectTextChat, ChannelType.DirectGroupTextChat)) { + guildId = Guild.DirectMessages.Id; var recipients = token["recipients"].Select(ParseUser); name = recipients.Select(r => r.Name).JoinToString(", "); } @@ -66,13 +68,14 @@ namespace DiscordChatExporter.Services name = token["name"].Value(); } - return new Channel(id, name, topic, type); + return new Channel(id, guildId, name, topic, type); } private Message ParseMessage(JToken token) { // Get basic data var id = token["id"].Value(); + var channelId = token["channel_id"].Value(); var timeStamp = token["timestamp"].Value(); var editedTimeStamp = token["edited_timestamp"]?.Value(); var content = token["content"].Value(); @@ -132,7 +135,7 @@ namespace DiscordChatExporter.Services .Select(i => _channelCache.GetOrDefault(i) ?? Channel.CreateDeletedChannel(id)) .ToArray(); - return new Message(id, type, author, timeStamp, editedTimeStamp, content, attachments, + return new Message(id, channelId, type, author, timeStamp, editedTimeStamp, content, attachments, mentionedUsers, mentionedRoles, mentionedChannels); } @@ -168,6 +171,23 @@ namespace DiscordChatExporter.Services return guild; } + public async Task GetChannelAsync(string token, string channelId) + { + // Form request url + var url = $"{ApiRoot}/channels/{channelId}?token={token}"; + + // Get response + var content = await GetStringAsync(url); + + // Parse + var channel = ParseChannel(JToken.Parse(content)); + + // Add channel to cache + _channelCache[channel.Id] = channel; + + return channel; + } + public async Task> GetGuildChannelsAsync(string token, string guildId) { // Form request url diff --git a/DiscordChatExporter/Services/ExportService.cs b/DiscordChatExporter.Core/Services/ExportService.cs similarity index 97% rename from DiscordChatExporter/Services/ExportService.cs rename to DiscordChatExporter.Core/Services/ExportService.cs index f578653..16ae1d0 100644 --- a/DiscordChatExporter/Services/ExportService.cs +++ b/DiscordChatExporter.Core/Services/ExportService.cs @@ -4,10 +4,11 @@ using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Internal; +using DiscordChatExporter.Core.Models; using Tyrrrz.Extensions; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public partial class ExportService : IExportService { @@ -179,12 +180,12 @@ namespace DiscordChatExporter.Services } if (format == ExportFormat.HtmlDark) { - var css = Program.GetResourceString("DiscordChatExporter.Resources.ExportService.DarkTheme.css"); + var css = AssemblyHelper.GetResourceString("DiscordChatExporter.Core.Resources.ExportService.DarkTheme.css"); return ExportAsHtmlAsync(filePath, log, css); } if (format == ExportFormat.HtmlLight) { - var css = Program.GetResourceString("DiscordChatExporter.Resources.ExportService.LightTheme.css"); + var css = AssemblyHelper.GetResourceString("DiscordChatExporter.Core.Resources.ExportService.LightTheme.css"); return ExportAsHtmlAsync(filePath, log, css); } diff --git a/DiscordChatExporter/Services/IDataService.cs b/DiscordChatExporter.Core/Services/IDataService.cs similarity index 78% rename from DiscordChatExporter/Services/IDataService.cs rename to DiscordChatExporter.Core/Services/IDataService.cs index 3d037b7..524d286 100644 --- a/DiscordChatExporter/Services/IDataService.cs +++ b/DiscordChatExporter.Core/Services/IDataService.cs @@ -1,14 +1,16 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public interface IDataService { Task GetGuildAsync(string token, string guildId); + Task GetChannelAsync(string token, string channelId); + Task> GetGuildChannelsAsync(string token, string guildId); Task> GetUserGuildsAsync(string token); diff --git a/DiscordChatExporter/Services/IExportService.cs b/DiscordChatExporter.Core/Services/IExportService.cs similarity index 66% rename from DiscordChatExporter/Services/IExportService.cs rename to DiscordChatExporter.Core/Services/IExportService.cs index e405aa0..c8713f9 100644 --- a/DiscordChatExporter/Services/IExportService.cs +++ b/DiscordChatExporter.Core/Services/IExportService.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public interface IExportService { diff --git a/DiscordChatExporter/Services/IMessageGroupService.cs b/DiscordChatExporter.Core/Services/IMessageGroupService.cs similarity index 67% rename from DiscordChatExporter/Services/IMessageGroupService.cs rename to DiscordChatExporter.Core/Services/IMessageGroupService.cs index 5739ea4..5b5d8f6 100644 --- a/DiscordChatExporter/Services/IMessageGroupService.cs +++ b/DiscordChatExporter.Core/Services/IMessageGroupService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public interface IMessageGroupService { diff --git a/DiscordChatExporter/Services/ISettingsService.cs b/DiscordChatExporter.Core/Services/ISettingsService.cs similarity index 75% rename from DiscordChatExporter/Services/ISettingsService.cs rename to DiscordChatExporter.Core/Services/ISettingsService.cs index 3f04e73..8031a3b 100644 --- a/DiscordChatExporter/Services/ISettingsService.cs +++ b/DiscordChatExporter.Core/Services/ISettingsService.cs @@ -1,6 +1,6 @@ -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public interface ISettingsService { diff --git a/DiscordChatExporter/Services/MessageGroupService.cs b/DiscordChatExporter.Core/Services/MessageGroupService.cs similarity index 95% rename from DiscordChatExporter/Services/MessageGroupService.cs rename to DiscordChatExporter.Core/Services/MessageGroupService.cs index 7559f01..0ef2e3c 100644 --- a/DiscordChatExporter/Services/MessageGroupService.cs +++ b/DiscordChatExporter.Core/Services/MessageGroupService.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public class MessageGroupService : IMessageGroupService { diff --git a/DiscordChatExporter/Services/SettingsService.cs b/DiscordChatExporter.Core/Services/SettingsService.cs similarity index 87% rename from DiscordChatExporter/Services/SettingsService.cs rename to DiscordChatExporter.Core/Services/SettingsService.cs index 5e0e021..923757f 100644 --- a/DiscordChatExporter/Services/SettingsService.cs +++ b/DiscordChatExporter.Core/Services/SettingsService.cs @@ -1,7 +1,7 @@ -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; using Tyrrrz.Settings; -namespace DiscordChatExporter.Services +namespace DiscordChatExporter.Core.Services { public class SettingsService : SettingsManager, ISettingsService { diff --git a/DiscordChatExporter/App.ammy b/DiscordChatExporter.Gui/App.ammy similarity index 98% rename from DiscordChatExporter/App.ammy rename to DiscordChatExporter.Gui/App.ammy index 848164c..c279ece 100644 --- a/DiscordChatExporter/App.ammy +++ b/DiscordChatExporter.Gui/App.ammy @@ -1,4 +1,4 @@ -Application "DiscordChatExporter.App" { +Application "DiscordChatExporter.Gui.App" { StartupUri: "Views/MainWindow.g.xaml" Startup: App_Startup Exit: App_Exit diff --git a/DiscordChatExporter/App.ammy.cs b/DiscordChatExporter.Gui/App.ammy.cs similarity index 73% rename from DiscordChatExporter/App.ammy.cs rename to DiscordChatExporter.Gui/App.ammy.cs index d511a98..8a2c3e2 100644 --- a/DiscordChatExporter/App.ammy.cs +++ b/DiscordChatExporter.Gui/App.ammy.cs @@ -1,9 +1,11 @@ using System.Windows; -namespace DiscordChatExporter +namespace DiscordChatExporter.Gui { public partial class App { + private Container Container => (Container) Resources["Container"]; + private void App_Startup(object sender, StartupEventArgs e) { Container.Init(); diff --git a/DiscordChatExporter/Container.cs b/DiscordChatExporter.Gui/Container.cs similarity index 55% rename from DiscordChatExporter/Container.cs rename to DiscordChatExporter.Gui/Container.cs index 8d7a9e4..1e6a335 100644 --- a/DiscordChatExporter/Container.cs +++ b/DiscordChatExporter.Gui/Container.cs @@ -1,24 +1,36 @@ -using DiscordChatExporter.Services; -using DiscordChatExporter.ViewModels; +using DiscordChatExporter.Core.Services; +using DiscordChatExporter.Gui.ViewModels; using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; -namespace DiscordChatExporter +namespace DiscordChatExporter.Gui { public class Container { - public static void Init() + public IErrorViewModel ErrorViewModel => Resolve(); + public IExportDoneViewModel ExportDoneViewModel => Resolve(); + public IExportSetupViewModel ExportSetupViewModel => Resolve(); + public IMainViewModel MainViewModel => Resolve(); + public ISettingsViewModel SettingsViewModel => Resolve(); + + private T Resolve(string key = null) { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + return ServiceLocator.Current.GetInstance(key); + } - // Settings - SimpleIoc.Default.Register(); - ServiceLocator.Current.GetInstance().Load(); + public void Init() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Reset(); // Services SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + + // Load settings + Resolve().Load(); // View models SimpleIoc.Default.Register(true); @@ -28,16 +40,10 @@ namespace DiscordChatExporter SimpleIoc.Default.Register(true); } - public static void Cleanup() + public void Cleanup() { - // Settings + // Save settings ServiceLocator.Current.GetInstance().Save(); } - - public IErrorViewModel ErrorViewModel => ServiceLocator.Current.GetInstance(); - public IExportDoneViewModel ExportDoneViewModel => ServiceLocator.Current.GetInstance(); - public IExportSetupViewModel ExportSetupViewModel => ServiceLocator.Current.GetInstance(); - public IMainViewModel MainViewModel => ServiceLocator.Current.GetInstance(); - public ISettingsViewModel SettingsViewModel => ServiceLocator.Current.GetInstance(); } } \ No newline at end of file diff --git a/DiscordChatExporter/DiscordChatExporter.csproj b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj similarity index 82% rename from DiscordChatExporter/DiscordChatExporter.csproj rename to DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj index fc66117..cd9303e 100644 --- a/DiscordChatExporter/DiscordChatExporter.csproj +++ b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj @@ -6,7 +6,7 @@ AnyCPU {732A67AF-93DE-49DF-B10F-FD74710B7863} WinExe - DiscordChatExporter + DiscordChatExporter.Gui DiscordChatExporter v4.6.1 512 @@ -38,10 +38,17 @@ ..\favicon.ico + + + ..\packages\Ammy.WPF.1.2.87\lib\net40\AmmySidekick.dll + + ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll + False + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll @@ -60,9 +67,6 @@ ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll - - ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - @@ -73,32 +77,19 @@ 4.0 - - ..\packages\Tyrrrz.Extensions.1.4.1\lib\net45\Tyrrrz.Extensions.dll - - - ..\packages\Tyrrrz.Settings.1.3.0\lib\net45\Tyrrrz.Settings.dll + + ..\packages\Tyrrrz.Extensions.1.5.0\lib\net45\Tyrrrz.Extensions.dll - - - - - - - - - - @@ -148,19 +139,7 @@ App.ammy - - - - - - - - - - - - @@ -197,14 +176,16 @@ - + - - + + {707c0cd0-a7e0-4cab-8db9-07a45cb87377} + DiscordChatExporter.Core + - + @@ -213,5 +194,9 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/DiscordChatExporter.Gui/FodyWeavers.xml b/DiscordChatExporter.Gui/FodyWeavers.xml new file mode 100644 index 0000000..c6e1b7c --- /dev/null +++ b/DiscordChatExporter.Gui/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DiscordChatExporter/Messages/ShowErrorMessage.cs b/DiscordChatExporter.Gui/Messages/ShowErrorMessage.cs similarity index 79% rename from DiscordChatExporter/Messages/ShowErrorMessage.cs rename to DiscordChatExporter.Gui/Messages/ShowErrorMessage.cs index 3499cfc..51bce1e 100644 --- a/DiscordChatExporter/Messages/ShowErrorMessage.cs +++ b/DiscordChatExporter.Gui/Messages/ShowErrorMessage.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Messages +namespace DiscordChatExporter.Gui.Messages { public class ShowErrorMessage { diff --git a/DiscordChatExporter/Messages/ShowExportDoneMessage.cs b/DiscordChatExporter.Gui/Messages/ShowExportDoneMessage.cs similarity index 81% rename from DiscordChatExporter/Messages/ShowExportDoneMessage.cs rename to DiscordChatExporter.Gui/Messages/ShowExportDoneMessage.cs index 1181e6b..7e9fc2f 100644 --- a/DiscordChatExporter/Messages/ShowExportDoneMessage.cs +++ b/DiscordChatExporter.Gui/Messages/ShowExportDoneMessage.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Messages +namespace DiscordChatExporter.Gui.Messages { public class ShowExportDoneMessage { diff --git a/DiscordChatExporter/Messages/ShowExportSetupMessage.cs b/DiscordChatExporter.Gui/Messages/ShowExportSetupMessage.cs similarity index 76% rename from DiscordChatExporter/Messages/ShowExportSetupMessage.cs rename to DiscordChatExporter.Gui/Messages/ShowExportSetupMessage.cs index 827a075..380c849 100644 --- a/DiscordChatExporter/Messages/ShowExportSetupMessage.cs +++ b/DiscordChatExporter.Gui/Messages/ShowExportSetupMessage.cs @@ -1,6 +1,6 @@ -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Messages +namespace DiscordChatExporter.Gui.Messages { public class ShowExportSetupMessage { diff --git a/DiscordChatExporter/Messages/ShowSettingsMessage.cs b/DiscordChatExporter.Gui/Messages/ShowSettingsMessage.cs similarity index 52% rename from DiscordChatExporter/Messages/ShowSettingsMessage.cs rename to DiscordChatExporter.Gui/Messages/ShowSettingsMessage.cs index e6cf6a7..61c35d9 100644 --- a/DiscordChatExporter/Messages/ShowSettingsMessage.cs +++ b/DiscordChatExporter.Gui/Messages/ShowSettingsMessage.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Messages +namespace DiscordChatExporter.Gui.Messages { public class ShowSettingsMessage { diff --git a/DiscordChatExporter/Messages/StartExportMessage.cs b/DiscordChatExporter.Gui/Messages/StartExportMessage.cs similarity index 87% rename from DiscordChatExporter/Messages/StartExportMessage.cs rename to DiscordChatExporter.Gui/Messages/StartExportMessage.cs index 2f1e528..bfda1c6 100644 --- a/DiscordChatExporter/Messages/StartExportMessage.cs +++ b/DiscordChatExporter.Gui/Messages/StartExportMessage.cs @@ -1,7 +1,7 @@ using System; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; -namespace DiscordChatExporter.Messages +namespace DiscordChatExporter.Gui.Messages { public class StartExportMessage { diff --git a/DiscordChatExporter.Gui/Program.cs b/DiscordChatExporter.Gui/Program.cs new file mode 100644 index 0000000..8cd4a46 --- /dev/null +++ b/DiscordChatExporter.Gui/Program.cs @@ -0,0 +1,17 @@ +using System; +using AmmySidekick; + +namespace DiscordChatExporter.Gui +{ + public static class Program + { + [STAThread] + public static void Main() + { + var app = new App(); + app.InitializeComponent(); + RuntimeUpdateHandler.Register(app, $"/{Ammy.GetAssemblyName(app)};component/App.g.xaml"); + app.Run(); + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter/Properties/AssemblyInfo.cs b/DiscordChatExporter.Gui/Properties/AssemblyInfo.cs similarity index 100% rename from DiscordChatExporter/Properties/AssemblyInfo.cs rename to DiscordChatExporter.Gui/Properties/AssemblyInfo.cs diff --git a/DiscordChatExporter/Properties/Resources.Designer.cs b/DiscordChatExporter.Gui/Properties/Resources.Designer.cs similarity index 83% rename from DiscordChatExporter/Properties/Resources.Designer.cs rename to DiscordChatExporter.Gui/Properties/Resources.Designer.cs index 072dcee..3223eab 100644 --- a/DiscordChatExporter/Properties/Resources.Designer.cs +++ b/DiscordChatExporter.Gui/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace DiscordChatExporter.Properties -{ - - +namespace DiscordChatExporter.Gui.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,51 +19,43 @@ namespace DiscordChatExporter.Properties // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DiscordChatExporter.Properties.Resources", typeof(Resources).Assembly); + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DiscordChatExporter.Gui.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/DiscordChatExporter/Properties/Resources.resx b/DiscordChatExporter.Gui/Properties/Resources.resx similarity index 100% rename from DiscordChatExporter/Properties/Resources.resx rename to DiscordChatExporter.Gui/Properties/Resources.resx diff --git a/DiscordChatExporter/ViewModels/ErrorViewModel.cs b/DiscordChatExporter.Gui/ViewModels/ErrorViewModel.cs similarity index 80% rename from DiscordChatExporter/ViewModels/ErrorViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/ErrorViewModel.cs index daac0cd..bb0f9c9 100644 --- a/DiscordChatExporter/ViewModels/ErrorViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/ErrorViewModel.cs @@ -1,7 +1,7 @@ -using DiscordChatExporter.Messages; +using DiscordChatExporter.Gui.Messages; using GalaSoft.MvvmLight; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public class ErrorViewModel : ViewModelBase, IErrorViewModel { diff --git a/DiscordChatExporter/ViewModels/ExportDoneViewModel.cs b/DiscordChatExporter.Gui/ViewModels/ExportDoneViewModel.cs similarity index 88% rename from DiscordChatExporter/ViewModels/ExportDoneViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/ExportDoneViewModel.cs index 0dc5fb6..ced3f81 100644 --- a/DiscordChatExporter/ViewModels/ExportDoneViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/ExportDoneViewModel.cs @@ -1,9 +1,9 @@ using System.Diagnostics; -using DiscordChatExporter.Messages; +using DiscordChatExporter.Gui.Messages; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public class ExportDoneViewModel : ViewModelBase, IExportDoneViewModel { diff --git a/DiscordChatExporter/ViewModels/ExportSetupViewModel.cs b/DiscordChatExporter.Gui/ViewModels/ExportSetupViewModel.cs similarity index 94% rename from DiscordChatExporter/ViewModels/ExportSetupViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/ExportSetupViewModel.cs index a9bdef6..2441787 100644 --- a/DiscordChatExporter/ViewModels/ExportSetupViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/ExportSetupViewModel.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using DiscordChatExporter.Messages; -using DiscordChatExporter.Models; -using DiscordChatExporter.Services; +using DiscordChatExporter.Core.Models; +using DiscordChatExporter.Core.Services; +using DiscordChatExporter.Gui.Messages; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; using Tyrrrz.Extensions; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public class ExportSetupViewModel : ViewModelBase, IExportSetupViewModel { diff --git a/DiscordChatExporter/ViewModels/IErrorViewModel.cs b/DiscordChatExporter.Gui/ViewModels/IErrorViewModel.cs similarity index 62% rename from DiscordChatExporter/ViewModels/IErrorViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/IErrorViewModel.cs index 21a2780..46d893b 100644 --- a/DiscordChatExporter/ViewModels/IErrorViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/IErrorViewModel.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public interface IErrorViewModel { diff --git a/DiscordChatExporter/ViewModels/IExportDoneViewModel.cs b/DiscordChatExporter.Gui/ViewModels/IExportDoneViewModel.cs similarity index 75% rename from DiscordChatExporter/ViewModels/IExportDoneViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/IExportDoneViewModel.cs index 6ed4b46..717bab4 100644 --- a/DiscordChatExporter/ViewModels/IExportDoneViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/IExportDoneViewModel.cs @@ -1,6 +1,6 @@ using GalaSoft.MvvmLight.CommandWpf; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public interface IExportDoneViewModel { diff --git a/DiscordChatExporter/ViewModels/IExportSetupViewModel.cs b/DiscordChatExporter.Gui/ViewModels/IExportSetupViewModel.cs similarity index 84% rename from DiscordChatExporter/ViewModels/IExportSetupViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/IExportSetupViewModel.cs index 8107730..a0d58c7 100644 --- a/DiscordChatExporter/ViewModels/IExportSetupViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/IExportSetupViewModel.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; using GalaSoft.MvvmLight.CommandWpf; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public interface IExportSetupViewModel { diff --git a/DiscordChatExporter/ViewModels/IMainViewModel.cs b/DiscordChatExporter.Gui/ViewModels/IMainViewModel.cs similarity index 87% rename from DiscordChatExporter/ViewModels/IMainViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/IMainViewModel.cs index 68d71ef..e5e66b4 100644 --- a/DiscordChatExporter/ViewModels/IMainViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/IMainViewModel.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using DiscordChatExporter.Models; +using DiscordChatExporter.Core.Models; using GalaSoft.MvvmLight.CommandWpf; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public interface IMainViewModel { diff --git a/DiscordChatExporter/ViewModels/ISettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs similarity index 73% rename from DiscordChatExporter/ViewModels/ISettingsViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs index fc331ce..a3929f9 100644 --- a/DiscordChatExporter/ViewModels/ISettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/ISettingsViewModel.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public interface ISettingsViewModel { diff --git a/DiscordChatExporter/ViewModels/MainViewModel.cs b/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs similarity index 97% rename from DiscordChatExporter/ViewModels/MainViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/MainViewModel.cs index 2473bcf..0b222e7 100644 --- a/DiscordChatExporter/ViewModels/MainViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; -using DiscordChatExporter.Exceptions; -using DiscordChatExporter.Messages; -using DiscordChatExporter.Models; -using DiscordChatExporter.Services; +using DiscordChatExporter.Core.Exceptions; +using DiscordChatExporter.Core.Models; +using DiscordChatExporter.Core.Services; +using DiscordChatExporter.Gui.Messages; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; using Tyrrrz.Extensions; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public class MainViewModel : ViewModelBase, IMainViewModel { diff --git a/DiscordChatExporter/ViewModels/SettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs similarity index 88% rename from DiscordChatExporter/ViewModels/SettingsViewModel.cs rename to DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs index 585ab09..09713fc 100644 --- a/DiscordChatExporter/ViewModels/SettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/SettingsViewModel.cs @@ -1,8 +1,8 @@ -using DiscordChatExporter.Services; +using DiscordChatExporter.Core.Services; using GalaSoft.MvvmLight; using Tyrrrz.Extensions; -namespace DiscordChatExporter.ViewModels +namespace DiscordChatExporter.Gui.ViewModels { public class SettingsViewModel : ViewModelBase, ISettingsViewModel { diff --git a/DiscordChatExporter/Views/ErrorDialog.ammy b/DiscordChatExporter.Gui/Views/ErrorDialog.ammy similarity index 88% rename from DiscordChatExporter/Views/ErrorDialog.ammy rename to DiscordChatExporter.Gui/Views/ErrorDialog.ammy index f1830d2..48dddbd 100644 --- a/DiscordChatExporter/Views/ErrorDialog.ammy +++ b/DiscordChatExporter.Gui/Views/ErrorDialog.ammy @@ -1,6 +1,6 @@ using MaterialDesignThemes.Wpf -UserControl "DiscordChatExporter.Views.ErrorDialog" { +UserControl "DiscordChatExporter.Gui.Views.ErrorDialog" { DataContext: bind ErrorViewModel from $resource Container Width: 250 diff --git a/DiscordChatExporter/Views/ErrorDialog.ammy.cs b/DiscordChatExporter.Gui/Views/ErrorDialog.ammy.cs similarity index 75% rename from DiscordChatExporter/Views/ErrorDialog.ammy.cs rename to DiscordChatExporter.Gui/Views/ErrorDialog.ammy.cs index 5967585..a21413e 100644 --- a/DiscordChatExporter/Views/ErrorDialog.ammy.cs +++ b/DiscordChatExporter.Gui/Views/ErrorDialog.ammy.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Views +namespace DiscordChatExporter.Gui.Views { public partial class ErrorDialog { diff --git a/DiscordChatExporter/Views/ExportDoneDialog.ammy b/DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy similarity index 92% rename from DiscordChatExporter/Views/ExportDoneDialog.ammy rename to DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy index 1d46fa8..0bdb705 100644 --- a/DiscordChatExporter/Views/ExportDoneDialog.ammy +++ b/DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy @@ -1,6 +1,6 @@ using MaterialDesignThemes.Wpf -UserControl "DiscordChatExporter.Views.ExportDoneDialog" { +UserControl "DiscordChatExporter.Gui.Views.ExportDoneDialog" { DataContext: bind ExportDoneViewModel from $resource Container Width: 250 diff --git a/DiscordChatExporter/Views/ExportDoneDialog.ammy.cs b/DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy.cs similarity index 90% rename from DiscordChatExporter/Views/ExportDoneDialog.ammy.cs rename to DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy.cs index 22f9284..fb5dfa4 100644 --- a/DiscordChatExporter/Views/ExportDoneDialog.ammy.cs +++ b/DiscordChatExporter.Gui/Views/ExportDoneDialog.ammy.cs @@ -1,7 +1,7 @@ using System.Windows; using MaterialDesignThemes.Wpf; -namespace DiscordChatExporter.Views +namespace DiscordChatExporter.Gui.Views { public partial class ExportDoneDialog { diff --git a/DiscordChatExporter/Views/ExportSetupDialog.ammy b/DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy similarity index 94% rename from DiscordChatExporter/Views/ExportSetupDialog.ammy rename to DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy index 1ad0ec2..b1b4d88 100644 --- a/DiscordChatExporter/Views/ExportSetupDialog.ammy +++ b/DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy @@ -1,7 +1,7 @@ -using DiscordChatExporter.Models +using DiscordChatExporter.Core.Models using MaterialDesignThemes.Wpf -UserControl "DiscordChatExporter.Views.ExportSetupDialog" { +UserControl "DiscordChatExporter.Gui.Views.ExportSetupDialog" { DataContext: bind ExportSetupViewModel from $resource Container Width: 325 diff --git a/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs b/DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy.cs similarity index 90% rename from DiscordChatExporter/Views/ExportSetupDialog.ammy.cs rename to DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy.cs index 7f0d629..8b72f72 100644 --- a/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs +++ b/DiscordChatExporter.Gui/Views/ExportSetupDialog.ammy.cs @@ -1,10 +1,10 @@ using System.Windows; -using DiscordChatExporter.Models; -using DiscordChatExporter.ViewModels; +using DiscordChatExporter.Core.Models; +using DiscordChatExporter.Gui.ViewModels; using MaterialDesignThemes.Wpf; using Microsoft.Win32; -namespace DiscordChatExporter.Views +namespace DiscordChatExporter.Gui.Views { public partial class ExportSetupDialog { diff --git a/DiscordChatExporter/Views/MainWindow.ammy b/DiscordChatExporter.Gui/Views/MainWindow.ammy similarity index 99% rename from DiscordChatExporter/Views/MainWindow.ammy rename to DiscordChatExporter.Gui/Views/MainWindow.ammy index 56b8621..2368ad8 100644 --- a/DiscordChatExporter/Views/MainWindow.ammy +++ b/DiscordChatExporter.Gui/Views/MainWindow.ammy @@ -1,7 +1,7 @@ using MaterialDesignThemes.Wpf using MaterialDesignThemes.Wpf.Transitions -Window "DiscordChatExporter.Views.MainWindow" { +Window "DiscordChatExporter.Gui.Views.MainWindow" { Title: "DiscordChatExporter" Width: 600 Height: 550 diff --git a/DiscordChatExporter/Views/MainWindow.ammy.cs b/DiscordChatExporter.Gui/Views/MainWindow.ammy.cs similarity index 91% rename from DiscordChatExporter/Views/MainWindow.ammy.cs rename to DiscordChatExporter.Gui/Views/MainWindow.ammy.cs index 9821a90..9cca4ea 100644 --- a/DiscordChatExporter/Views/MainWindow.ammy.cs +++ b/DiscordChatExporter.Gui/Views/MainWindow.ammy.cs @@ -1,10 +1,10 @@ using System.Reflection; -using DiscordChatExporter.Messages; +using DiscordChatExporter.Gui.Messages; using GalaSoft.MvvmLight.Messaging; using MaterialDesignThemes.Wpf; using Tyrrrz.Extensions; -namespace DiscordChatExporter.Views +namespace DiscordChatExporter.Gui.Views { public partial class MainWindow { diff --git a/DiscordChatExporter/Views/SettingsDialog.ammy b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy similarity index 91% rename from DiscordChatExporter/Views/SettingsDialog.ammy rename to DiscordChatExporter.Gui/Views/SettingsDialog.ammy index 856c4bf..5c8d68d 100644 --- a/DiscordChatExporter/Views/SettingsDialog.ammy +++ b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy @@ -1,6 +1,6 @@ using MaterialDesignThemes.Wpf -UserControl "DiscordChatExporter.Views.SettingsDialog" { +UserControl "DiscordChatExporter.Gui.Views.SettingsDialog" { DataContext: bind SettingsViewModel from $resource Container Width: 250 diff --git a/DiscordChatExporter/Views/SettingsDialog.ammy.cs b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy.cs similarity index 76% rename from DiscordChatExporter/Views/SettingsDialog.ammy.cs rename to DiscordChatExporter.Gui/Views/SettingsDialog.ammy.cs index 36a3ee6..7683505 100644 --- a/DiscordChatExporter/Views/SettingsDialog.ammy.cs +++ b/DiscordChatExporter.Gui/Views/SettingsDialog.ammy.cs @@ -1,4 +1,4 @@ -namespace DiscordChatExporter.Views +namespace DiscordChatExporter.Gui.Views { public partial class SettingsDialog { diff --git a/DiscordChatExporter/lib.ammy b/DiscordChatExporter.Gui/lib.ammy similarity index 100% rename from DiscordChatExporter/lib.ammy rename to DiscordChatExporter.Gui/lib.ammy diff --git a/DiscordChatExporter/packages.config b/DiscordChatExporter.Gui/packages.config similarity index 65% rename from DiscordChatExporter/packages.config rename to DiscordChatExporter.Gui/packages.config index 1ba795d..c59376e 100644 --- a/DiscordChatExporter/packages.config +++ b/DiscordChatExporter.Gui/packages.config @@ -3,10 +3,10 @@ + + - - - + \ No newline at end of file diff --git a/DiscordChatExporter.sln b/DiscordChatExporter.sln index d2d0590..6965c7d 100644 --- a/DiscordChatExporter.sln +++ b/DiscordChatExporter.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.15 +VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EA305DD5-1F98-415D-B6C4-65053A58F914}" ProjectSection(SolutionItems) = preProject @@ -9,7 +9,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Readme.md = Readme.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordChatExporter", "DiscordChatExporter\DiscordChatExporter.csproj", "{732A67AF-93DE-49DF-B10F-FD74710B7863}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordChatExporter.Gui", "DiscordChatExporter.Gui\DiscordChatExporter.Gui.csproj", "{732A67AF-93DE-49DF-B10F-FD74710B7863}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordChatExporter.Core", "DiscordChatExporter.Core\DiscordChatExporter.Core.csproj", "{707C0CD0-A7E0-4CAB-8DB9-07A45CB87377}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordChatExporter.Cli", "DiscordChatExporter.Cli\DiscordChatExporter.Cli.csproj", "{D08624B6-3081-4BCB-91F8-E9832FACC6CE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +25,14 @@ Global {732A67AF-93DE-49DF-B10F-FD74710B7863}.Debug|Any CPU.Build.0 = Debug|Any CPU {732A67AF-93DE-49DF-B10F-FD74710B7863}.Release|Any CPU.ActiveCfg = Release|Any CPU {732A67AF-93DE-49DF-B10F-FD74710B7863}.Release|Any CPU.Build.0 = Release|Any CPU + {707C0CD0-A7E0-4CAB-8DB9-07A45CB87377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {707C0CD0-A7E0-4CAB-8DB9-07A45CB87377}.Debug|Any CPU.Build.0 = Debug|Any CPU + {707C0CD0-A7E0-4CAB-8DB9-07A45CB87377}.Release|Any CPU.ActiveCfg = Release|Any CPU + {707C0CD0-A7E0-4CAB-8DB9-07A45CB87377}.Release|Any CPU.Build.0 = Release|Any CPU + {D08624B6-3081-4BCB-91F8-E9832FACC6CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D08624B6-3081-4BCB-91F8-E9832FACC6CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D08624B6-3081-4BCB-91F8-E9832FACC6CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D08624B6-3081-4BCB-91F8-E9832FACC6CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DiscordChatExporter/App.config b/DiscordChatExporter/App.config deleted file mode 100644 index 731f6de..0000000 --- a/DiscordChatExporter/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DiscordChatExporter/Program.cs b/DiscordChatExporter/Program.cs deleted file mode 100644 index 27f8439..0000000 --- a/DiscordChatExporter/Program.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using System.Resources; -using AmmySidekick; - -namespace DiscordChatExporter -{ - public static class Program - { - [STAThread] - public static void Main() - { - var app = new App(); - app.InitializeComponent(); - - RuntimeUpdateHandler.Register(app, $"/{Ammy.GetAssemblyName(app)};component/App.g.xaml"); - - app.Run(); - } - - public static string GetResourceString(string resourcePath) - { - var assembly = Assembly.GetExecutingAssembly(); - var stream = assembly.GetManifestResourceStream(resourcePath); - if (stream == null) - throw new MissingManifestResourceException("Could not find resource"); - - using (stream) - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } -} \ No newline at end of file diff --git a/Readme.md b/Readme.md index 4a780d3..69031a0 100644 --- a/Readme.md +++ b/Readme.md @@ -19,6 +19,7 @@ DiscordChatExporter can be used to export message history from a [Discord](https ## Features - Intuitive GUI that displays available guilds and channels +- Command line interface - Date ranges to limit messages - Groups messages by author and time - Exports to a plain text file