Skip to content

Commit

Permalink
Implement exit application command
Browse files Browse the repository at this point in the history
  • Loading branch information
ashotjanibekyan committed May 20, 2024
1 parent a6e1e5b commit 12b8f6e
Showing 6 changed files with 20 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"Avalonia"
]
}
Empty file added log.json
Empty file.
3 changes: 3 additions & 0 deletions src/CrossWikiEditor.Core/Messages/ExitApplicationMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace CrossWikiEditor.Core;

public sealed class ExitApplicationMessage;
Original file line number Diff line number Diff line change
@@ -4,13 +4,10 @@ public sealed partial class FileMenuViewModel(
IViewModelFactory viewModelFactory,
IFileDialogService fileDialogService,
ISettingsService settingsService,
IDialogService dialogService)
IDialogService dialogService,
IMessengerWrapper messenger)
{
[RelayCommand]
private void ResetToDefaultSettings()
{
settingsService.SetCurrentSettings(settingsService.GetDefaultSettings());
}
[RelayCommand] private void ResetToDefaultSettings() => settingsService.SetCurrentSettings(settingsService.GetDefaultSettings());

[RelayCommand]
private async Task OpenSettings()
@@ -31,39 +28,11 @@ private async Task OpenSettings()
}
}

[RelayCommand]
private void SaveSettings()
{
settingsService.SaveCurrentSettings();
}

[RelayCommand]
private void SaveSettingsAs()
{
throw new NotImplementedException();
}

[RelayCommand]
private void SaveSettingsAsDefault()
{
throw new NotImplementedException();
}

[RelayCommand]
private async Task LoginProfiles()
{
await dialogService.ShowDialog<bool>(viewModelFactory.GetProfilesViewModel());
}

[RelayCommand]
private void Logout()
{
throw new NotImplementedException();
}

[RelayCommand]
private void RefreshStatusAndTypos()
{
throw new NotImplementedException();
}
[RelayCommand] private void SaveSettings() => settingsService.SaveCurrentSettings();
[RelayCommand] private void SaveSettingsAs() => throw new NotImplementedException();
[RelayCommand] private void SaveSettingsAsDefault() => throw new NotImplementedException();
[RelayCommand] private async Task LoginProfiles() => await dialogService.ShowDialog<bool>(viewModelFactory.GetProfilesViewModel());
[RelayCommand] private void Logout() => throw new NotImplementedException();
[RelayCommand] private void RefreshStatusAndTypos() => throw new NotImplementedException();
[RelayCommand] private void Exit() => messenger.Send(new ExitApplicationMessage());
}
1 change: 1 addition & 0 deletions src/CrossWikiEditor/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ public override void OnFrameworkInitializationCompleted()
services.AddSingleton<LanguageSpecificRegexes>();
services.AddHttpClient();
ServiceProvider sp = services.BuildServiceProvider();
sp.GetRequiredService<IMessengerWrapper>().Register<ExitApplicationMessage>(this, (r, m) => desktop.Shutdown());
_mainWindow.DataContext = sp.GetRequiredService<MainWindowViewModel>();
desktop.MainWindow = _mainWindow;
}
2 changes: 1 addition & 1 deletion src/CrossWikiEditor/Views/MenuView.axaml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
<MenuItem Header="Log out" Command="{Binding FileMenuViewModel.LogoutCommand}" />
<MenuItem Header="Refresh Status/Typos" Command="{Binding FileMenuViewModel.RefreshStatusAndTyposCommand}" />
<Separator />
<MenuItem Header="Exit" />
<MenuItem Header="Exit" Command="{Binding FileMenuViewModel.ExitCommand}" />
</MenuItem>
<MenuItem Header="View">
<MenuItem Header="Show toolbar" />

0 comments on commit 12b8f6e

Please sign in to comment.