mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-02 02:52:09 +03:00
add the method to RepositoryWindow.axaml.cs
This commit is contained in:
@@ -30,6 +30,45 @@ public partial class RepositoryWindow: Window
|
||||
base.OnOpened(e);
|
||||
}
|
||||
|
||||
private async void RepositoryWindow_Closing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
if (allowClose || closeConfirmationShown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DataContext is RepositoryWindowViewModel checkVm &&
|
||||
checkVm.CurrentPage is UnlockedRepositoryViewModel unlockedVm &&
|
||||
!unlockedVm.HasUnsavedChanges)
|
||||
{
|
||||
allowClose = true;
|
||||
return;
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
closeConfirmationShown = true;
|
||||
|
||||
var dialog = new CloseConfirmationDialog();
|
||||
var result = await dialog.ShowDialog<CloseConfirmationResult?>(this);
|
||||
|
||||
closeConfirmationShown = false;
|
||||
|
||||
if (result == null || result == CloseConfirmationResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == CloseConfirmationResult.Save &&
|
||||
DataContext is RepositoryWindowViewModel vm &&
|
||||
vm.CurrentPage is UnlockedRepositoryViewModel pageVm)
|
||||
{
|
||||
pageVm.Save();
|
||||
}
|
||||
|
||||
allowClose = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private async void AddEntryButton_Click(object sender, RoutedEventArgs args)
|
||||
{
|
||||
if (DataContext is RepositoryWindowViewModel vm_ && vm_.CurrentPage is UnlockedRepositoryViewModel vm)
|
||||
|
||||
Reference in New Issue
Block a user