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 ||
|
if (e.Message == PassStoreFileException.ContentHMACMismatch.Message ||
|
||||||
e.Message == PassStoreFileException.InvalidBeginMarker.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 ||
|
} else if (e.Message == PassStoreFileException.UnexpectedEndOfFile.Message ||
|
||||||
e.Message == PassStoreFileException.IncorrectMagicNumber.Message ||
|
e.Message == PassStoreFileException.IncorrectMagicNumber.Message ||
|
||||||
e.Message == PassStoreFileException.InvalidCryptoHeader.Message ||
|
e.Message == PassStoreFileException.InvalidCryptoHeader.Message ||
|
||||||
e.Message == PassStoreFileException.InvalidPassStoreEntry.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)
|
} 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
|
} else
|
||||||
{
|
{
|
||||||
await parent.ShowErrorPopup("Unknown password store unlock error");
|
await parent.ShowErrorPopup("Unknown unlock error", "Password store error");
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(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 DateTime _timerStart;
|
||||||
private string _lockTimerDisplay = string.Empty;
|
private string _lockTimerDisplay = string.Empty;
|
||||||
|
|
||||||
public Func<string, Task> ShowErrorPopup;
|
public Func<string, string, Task> ShowErrorPopup;
|
||||||
|
|
||||||
public object CurrentPage
|
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"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="KeyKeeper.Views.ErrorDialog"
|
x:Class="KeyKeeper.Views.ErrorDialog"
|
||||||
Width="350" Height="120"
|
Width="400" Height="180"
|
||||||
Background="White"
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Background="#F9F9F9"
|
||||||
CanResize="False"
|
CanResize="False"
|
||||||
Title="Error">
|
Title="Access Error"
|
||||||
|
TransparencyLevelHint="AcrylicBlur"
|
||||||
|
ExtendClientAreaToDecorationsHint="True">
|
||||||
|
|
||||||
<Grid Margin="10" RowDefinitions="*,Auto">
|
<Grid Margin="20" RowDefinitions="*, Auto">
|
||||||
<TextBlock x:Name="MessageText"
|
<!-- Main Content -->
|
||||||
Grid.Row="0"
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Spacing="15" VerticalAlignment="Center">
|
||||||
Foreground="Red"
|
<!-- Error Icon (Material Design Style) -->
|
||||||
FontSize="18"
|
<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"
|
||||||
TextWrapping="Wrap" />
|
Fill="#E74C3C"
|
||||||
<Button Grid.Row="1"
|
Width="40" Height="40"
|
||||||
Content="OK"
|
Stretch="Uniform" />
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Margin="0,10,0,0"
|
<StackPanel VerticalAlignment="Center" Width="280">
|
||||||
Click="Ok_Click"
|
<TextBlock x:Name="MessageTitle"
|
||||||
Background="#aaa" />
|
FontWeight="Bold"
|
||||||
<Grid.Styles>
|
FontSize="16"
|
||||||
<Style Selector="Button /template/ ContentPresenter">
|
Foreground="#333"
|
||||||
<Setter Property="Foreground" Value="#333" />
|
Margin="0,0,0,4"/>
|
||||||
</Style>
|
<TextBlock x:Name="MessageText"
|
||||||
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
Foreground="#666"
|
||||||
<Setter Property="Background" Value="#ccc" />
|
FontSize="14"
|
||||||
<Setter Property="Foreground" Value="#444" />
|
TextWrapping="Wrap"
|
||||||
</Style>
|
LineHeight="20"/>
|
||||||
</Grid.Styles>
|
</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>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace KeyKeeper.Views;
|
namespace KeyKeeper.Views;
|
||||||
|
|
||||||
public partial class ErrorDialog : Window
|
public partial class ErrorDialog : Window
|
||||||
{
|
{
|
||||||
public ErrorDialog(string message)
|
public ErrorDialog(string message, string title = "Oops! Something went wrong")
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
MinWidth = 400;
|
|
||||||
MinHeight = 200;
|
|
||||||
MessageText.Text = message;
|
MessageText.Text = message;
|
||||||
|
MessageTitle.Text = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Ok_Click(object sender, RoutedEventArgs e)
|
private void Ok_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
protected override void OnOpened(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnOpened(e);
|
||||||
|
OkButton.Focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ public partial class RepositoryWindow : Window
|
|||||||
MinHeight = 500;
|
MinHeight = 500;
|
||||||
|
|
||||||
DataContext = model;
|
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