mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-09 09:56:32 +03:00
merge branch 'ErrorWindow'
This commit is contained in:
@@ -37,24 +37,24 @@ public partial class LockedRepositoryViewModel : ViewModelBase
|
||||
if (e.Message == PassStoreFileException.ContentHMACMismatch.Message ||
|
||||
e.Message == PassStoreFileException.InvalidBeginMarker.Message)
|
||||
{
|
||||
await parent.ShowErrorPopup("Incorrect password or corrupted file");
|
||||
await parent.ShowErrorPopup("Incorrect password or corrupted file", "Check password");
|
||||
} else if (e.Message == PassStoreFileException.UnexpectedEndOfFile.Message ||
|
||||
e.Message == PassStoreFileException.IncorrectMagicNumber.Message ||
|
||||
e.Message == PassStoreFileException.InvalidCryptoHeader.Message ||
|
||||
e.Message == PassStoreFileException.InvalidPassStoreEntry.Message)
|
||||
{
|
||||
await parent.ShowErrorPopup("Corrupted file");
|
||||
await parent.ShowErrorPopup("Corrupted file", "Password store error");
|
||||
} else if (e.Message == PassStoreFileException.UnsupportedVersion.Message)
|
||||
{
|
||||
await parent.ShowErrorPopup("Unsupported store file version");
|
||||
await parent.ShowErrorPopup("Unsupported store file version", "Password store error");
|
||||
} else
|
||||
{
|
||||
await parent.ShowErrorPopup("Unknown password store unlock error");
|
||||
await parent.ShowErrorPopup("Unknown unlock error", "Password store error");
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
await parent.ShowErrorPopup("Cannot open the password store file");
|
||||
await parent.ShowErrorPopup("Cannot open the password store file", "Password store error");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public partial class RepositoryWindowViewModel : ViewModelBase
|
||||
private DateTime _timerStart;
|
||||
private string _lockTimerDisplay = string.Empty;
|
||||
|
||||
public Func<string, Task> ShowErrorPopup;
|
||||
public Func<string, string, Task> ShowErrorPopup;
|
||||
|
||||
public object CurrentPage
|
||||
{
|
||||
|
||||
@@ -1,31 +1,67 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="KeyKeeper.Views.ErrorDialog"
|
||||
Width="350" Height="120"
|
||||
Background="White"
|
||||
Width="400" Height="180"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="#F9F9F9"
|
||||
CanResize="False"
|
||||
Title="Error">
|
||||
Title="Access Error"
|
||||
TransparencyLevelHint="AcrylicBlur"
|
||||
ExtendClientAreaToDecorationsHint="True">
|
||||
|
||||
<Grid Margin="10" RowDefinitions="*,Auto">
|
||||
<TextBlock x:Name="MessageText"
|
||||
Grid.Row="0"
|
||||
Foreground="Red"
|
||||
FontSize="18"
|
||||
TextWrapping="Wrap" />
|
||||
<Button Grid.Row="1"
|
||||
Content="OK"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,10,0,0"
|
||||
Click="Ok_Click"
|
||||
Background="#aaa" />
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button /template/ ContentPresenter">
|
||||
<Setter Property="Foreground" Value="#333" />
|
||||
</Style>
|
||||
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#ccc" />
|
||||
<Setter Property="Foreground" Value="#444" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Grid Margin="20" RowDefinitions="*, Auto">
|
||||
<!-- Main Content -->
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" Spacing="15" VerticalAlignment="Center">
|
||||
<!-- Error Icon (Material Design Style) -->
|
||||
<Path Data="M12,2C6.47,2 2,6.47 2,12C2,17.53 6.47,22 12,22C17.53,22 22,17.53 22,12C22,6.47 17.53,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z"
|
||||
Fill="#E74C3C"
|
||||
Width="40" Height="40"
|
||||
Stretch="Uniform" />
|
||||
|
||||
<StackPanel VerticalAlignment="Center" Width="280">
|
||||
<TextBlock x:Name="MessageTitle"
|
||||
FontWeight="Bold"
|
||||
FontSize="16"
|
||||
Foreground="#333"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock x:Name="MessageText"
|
||||
Foreground="#666"
|
||||
FontSize="14"
|
||||
TextWrapping="Wrap"
|
||||
LineHeight="20"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Action Button -->
|
||||
<Button Grid.Row="1"
|
||||
x:Name="OkButton"
|
||||
Content="Got it"
|
||||
Click="Ok_Click"
|
||||
IsDefault="True"
|
||||
IsCancel="True"
|
||||
HorizontalAlignment="Right"
|
||||
Padding="25,8"
|
||||
BorderThickness="0"
|
||||
CornerRadius="4"
|
||||
Cursor="Hand">
|
||||
<Button.Styles>
|
||||
<Style Selector="Button">
|
||||
<Setter Property="Background" Value="#E0E0E0"/>
|
||||
<Setter Property="Foreground" Value="#333"/>
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />
|
||||
<BrushTransition Property="Background" Duration="0:0:0.2" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#D5D5D5"/>
|
||||
</Style>
|
||||
<Style Selector="Button:pressed">
|
||||
<Setter Property="RenderTransform" Value="scale(0.95)"/>
|
||||
</Style>
|
||||
</Button.Styles>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace KeyKeeper.Views;
|
||||
|
||||
public partial class ErrorDialog : Window
|
||||
{
|
||||
public ErrorDialog(string message)
|
||||
public ErrorDialog(string message, string title = "Oops! Something went wrong")
|
||||
{
|
||||
InitializeComponent();
|
||||
MinWidth = 400;
|
||||
MinHeight = 200;
|
||||
MessageText.Text = message;
|
||||
MessageTitle.Text = title;
|
||||
}
|
||||
|
||||
private void Ok_Click(object sender, RoutedEventArgs e)
|
||||
private void Ok_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpened(EventArgs e)
|
||||
{
|
||||
base.OnOpened(e);
|
||||
OkButton.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ public partial class RepositoryWindow : Window
|
||||
MinHeight = 500;
|
||||
|
||||
DataContext = model;
|
||||
model.ShowErrorPopup = async (string message) =>
|
||||
model.ShowErrorPopup = async (string message, string title) =>
|
||||
{
|
||||
await new ErrorDialog(message).ShowDialog(this);
|
||||
await new ErrorDialog(message, title).ShowDialog(this);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user