mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 19:26:57 -04:00
Add a dialog that shows when export completes
This commit is contained in:
parent
8afe9852fb
commit
efae0e99b8
11 changed files with 126 additions and 5 deletions
|
@ -20,6 +20,7 @@ namespace DiscordChatExporter
|
|||
SimpleIoc.Default.Register<IErrorViewModel, ErrorViewModel>(true);
|
||||
SimpleIoc.Default.Register<IMainViewModel, MainViewModel>(true);
|
||||
SimpleIoc.Default.Register<ISettingsViewModel, SettingsViewModel>(true);
|
||||
SimpleIoc.Default.Register<IExportDoneViewModel, ExportDoneViewModel>(true);
|
||||
|
||||
// Load settings
|
||||
ServiceLocator.Current.GetInstance<ISettingsService>().Load();
|
||||
|
@ -34,5 +35,6 @@ namespace DiscordChatExporter
|
|||
public IErrorViewModel ErrorViewModel => ServiceLocator.Current.GetInstance<IErrorViewModel>();
|
||||
public IMainViewModel MainViewModel => ServiceLocator.Current.GetInstance<IMainViewModel>();
|
||||
public ISettingsViewModel SettingsViewModel => ServiceLocator.Current.GetInstance<ISettingsViewModel>();
|
||||
public IExportDoneViewModel ExportDoneViewModel => ServiceLocator.Current.GetInstance<IExportDoneViewModel>();
|
||||
}
|
||||
}
|
|
@ -86,6 +86,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Exceptions\UnathorizedException.cs" />
|
||||
<Compile Include="Messages\ShowErrorMessage.cs" />
|
||||
<Compile Include="Messages\ShowExportDoneMessage.cs" />
|
||||
<Compile Include="Messages\ShowSettingsMessage.cs" />
|
||||
<Compile Include="Models\AttachmentType.cs" />
|
||||
<Compile Include="Models\ChannelChatLog.cs" />
|
||||
|
@ -93,10 +94,15 @@
|
|||
<Compile Include="ViewModels\ErrorViewModel.cs" />
|
||||
<Compile Include="ViewModels\IErrorViewModel.cs" />
|
||||
<Compile Include="ViewModels\ISettingsViewModel.cs" />
|
||||
<Compile Include="ViewModels\IExportDoneViewModel.cs" />
|
||||
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
||||
<Compile Include="ViewModels\ExportDoneViewModel.cs" />
|
||||
<Compile Include="Views\ErrorDialog.ammy.cs">
|
||||
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ExportDoneDialog.ammy.cs">
|
||||
<DependentUpon>ExportDoneDialog.ammy</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\SettingsDialog.ammy.cs">
|
||||
<DependentUpon>SettingsDialog.ammy</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -110,6 +116,11 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
||||
</Page>
|
||||
<Page Include="Views\ExportDoneDialog.g.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<DependentUpon>ExportDoneDialog.ammy</DependentUpon>
|
||||
</Page>
|
||||
<Page Include="Views\MainWindow.g.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -163,6 +174,7 @@
|
|||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Views\ErrorDialog.ammy" />
|
||||
<None Include="Views\ExportDoneDialog.ammy" />
|
||||
<None Include="Views\MainWindow.ammy" />
|
||||
<None Include="Views\SettingsDialog.ammy" />
|
||||
</ItemGroup>
|
||||
|
|
12
DiscordChatExporter/Messages/ShowExportDoneMessage.cs
Normal file
12
DiscordChatExporter/Messages/ShowExportDoneMessage.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace DiscordChatExporter.Messages
|
||||
{
|
||||
public class ShowExportDoneMessage
|
||||
{
|
||||
public string FilePath { get; }
|
||||
|
||||
public ShowExportDoneMessage(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
}
|
||||
}
|
||||
}
|
28
DiscordChatExporter/ViewModels/ExportDoneViewModel.cs
Normal file
28
DiscordChatExporter/ViewModels/ExportDoneViewModel.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Diagnostics;
|
||||
using DiscordChatExporter.Messages;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
|
||||
namespace DiscordChatExporter.ViewModels
|
||||
{
|
||||
public class ExportDoneViewModel : ViewModelBase, IExportDoneViewModel
|
||||
{
|
||||
private string _filePath;
|
||||
|
||||
// Commands
|
||||
public RelayCommand OpenCommand { get; }
|
||||
|
||||
public ExportDoneViewModel()
|
||||
{
|
||||
MessengerInstance.Register<ShowExportDoneMessage>(this, m => _filePath = m.FilePath);
|
||||
|
||||
// Commands
|
||||
OpenCommand = new RelayCommand(Open);
|
||||
}
|
||||
|
||||
private void Open()
|
||||
{
|
||||
Process.Start(_filePath);
|
||||
}
|
||||
}
|
||||
}
|
9
DiscordChatExporter/ViewModels/IExportDoneViewModel.cs
Normal file
9
DiscordChatExporter/ViewModels/IExportDoneViewModel.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
|
||||
namespace DiscordChatExporter.ViewModels
|
||||
{
|
||||
public interface IExportDoneViewModel
|
||||
{
|
||||
RelayCommand OpenCommand { get; }
|
||||
}
|
||||
}
|
|
@ -171,6 +171,9 @@ namespace DiscordChatExporter.ViewModels
|
|||
|
||||
// Export
|
||||
_exportService.Export(sfd.FileName, chatLog, _settingsService.Theme);
|
||||
|
||||
// Show dialog
|
||||
MessengerInstance.Send(new ShowExportDoneMessage(sfd.FileName));
|
||||
}
|
||||
catch (UnathorizedException)
|
||||
{
|
||||
|
|
|
@ -7,18 +7,18 @@ UserControl "DiscordChatExporter.Views.ErrorDialog" {
|
|||
StackPanel {
|
||||
// Message
|
||||
TextBlock {
|
||||
Margin: 8
|
||||
Margin: 16
|
||||
FontSize: 16
|
||||
HorizontalAlignment: Center
|
||||
TextWrapping: WrapWithOverflow
|
||||
Text: bind Message
|
||||
}
|
||||
|
||||
// OK
|
||||
Button {
|
||||
Margin: 8
|
||||
Command: DialogHost.CloseDialogCommand
|
||||
Content: "OK"
|
||||
Margin: 8
|
||||
HorizontalAlignment: Right
|
||||
Style: resource dyn "MaterialDesignFlatButton"
|
||||
}
|
||||
}
|
||||
|
|
37
DiscordChatExporter/Views/ExportDoneDialog.ammy
Normal file
37
DiscordChatExporter/Views/ExportDoneDialog.ammy
Normal file
|
@ -0,0 +1,37 @@
|
|||
using MaterialDesignThemes.Wpf
|
||||
|
||||
UserControl "DiscordChatExporter.Views.ExportDoneDialog" {
|
||||
DataContext: bind ExportDoneViewModel from $resource Container
|
||||
Width: 250
|
||||
|
||||
StackPanel {
|
||||
// Message
|
||||
TextBlock {
|
||||
Margin: 16
|
||||
FontSize: 16
|
||||
TextWrapping: WrapWithOverflow
|
||||
Text: "Finished exporting chat log"
|
||||
}
|
||||
|
||||
// Buttons
|
||||
@StackPanelHorizontal {
|
||||
HorizontalAlignment: Right
|
||||
|
||||
// Open
|
||||
Button {
|
||||
Command: bind OpenCommand
|
||||
Content: "OPEN IT"
|
||||
Margin: 8
|
||||
Style: resource dyn "MaterialDesignFlatButton"
|
||||
}
|
||||
|
||||
// Dismiss
|
||||
Button {
|
||||
Command: DialogHost.CloseDialogCommand
|
||||
Content: "DISMISS"
|
||||
Margin: 8
|
||||
Style: resource dyn "MaterialDesignFlatButton"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
DiscordChatExporter/Views/ExportDoneDialog.ammy.cs
Normal file
16
DiscordChatExporter/Views/ExportDoneDialog.ammy.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiscordChatExporter.Views
|
||||
{
|
||||
public partial class ExportDoneDialog
|
||||
{
|
||||
public ExportDoneDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ namespace DiscordChatExporter.Views
|
|||
|
||||
Messenger.Default.Register<ShowErrorMessage>(this, m => DialogHost.Show(new ErrorDialog()).Forget());
|
||||
Messenger.Default.Register<ShowSettingsMessage>(this, m => DialogHost.Show(new SettingsDialog()).Forget());
|
||||
Messenger.Default.Register<ShowExportDoneMessage>(this, m => DialogHost.Show(new ExportDoneDialog()).Forget());
|
||||
}
|
||||
|
||||
public void TokenTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -7,9 +7,9 @@ UserControl "DiscordChatExporter.Views.SettingsDialog" {
|
|||
StackPanel {
|
||||
// Theme
|
||||
ComboBox {
|
||||
Margin: 16
|
||||
HintAssist.Hint: "Theme"
|
||||
HintAssist.IsFloating: true
|
||||
Margin: 8
|
||||
IsReadOnly: true
|
||||
ItemsSource: bind AvailableThemes
|
||||
SelectedItem: bind Theme
|
||||
|
@ -17,9 +17,10 @@ UserControl "DiscordChatExporter.Views.SettingsDialog" {
|
|||
|
||||
// Save
|
||||
Button {
|
||||
Margin: 8
|
||||
Command: DialogHost.CloseDialogCommand
|
||||
Content: "SAVE"
|
||||
Margin: 8
|
||||
HorizontalAlignment: Right
|
||||
Style: resource dyn "MaterialDesignFlatButton"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue