mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
OpenDatabaseUserControl works
This commit is contained in:
@@ -221,8 +221,11 @@ namespace ModernKeePass
|
||||
{
|
||||
ToastNotificationHelper.ShowErrorToast(exception);
|
||||
}
|
||||
await SuspensionManager.SaveAsync().ConfigureAwait(false);
|
||||
deferral.Complete();
|
||||
finally
|
||||
{
|
||||
await SuspensionManager.SaveAsync().ConfigureAwait(false);
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -165,7 +165,7 @@
|
||||
<data name="CompositeKeyNewKeyFileTooltip.Content" xml:space="preserve">
|
||||
<value>Create new key file</value>
|
||||
</data>
|
||||
<data name="CompositeKeyOpenButton.ButtonLabel" xml:space="preserve">
|
||||
<data name="OpenDatabaseControlButton.Content" xml:space="preserve">
|
||||
<value>Open</value>
|
||||
</data>
|
||||
<data name="CompositeKeyPassword.PlaceholderText" xml:space="preserve">
|
||||
|
@@ -165,7 +165,7 @@
|
||||
<data name="CompositeKeyNewKeyFileTooltip.Content" xml:space="preserve">
|
||||
<value>Créer un nouveau fichier de clé</value>
|
||||
</data>
|
||||
<data name="CompositeKeyOpenButton.ButtonLabel" xml:space="preserve">
|
||||
<data name="OpenDatabaseControlButton.Content" xml:space="preserve">
|
||||
<value>Ouvrir</value>
|
||||
</data>
|
||||
<data name="CompositeKeyPassword.PlaceholderText" xml:space="preserve">
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<userControls:OpenDatabaseUserControl x:Uid="CompositeKeyOpenButton" DatabaseFilePath="{Binding Token}">
|
||||
<userControls:OpenDatabaseUserControl DatabaseFilePath="{Binding Token}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="DatabaseOpened">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
||||
|
@@ -43,7 +43,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{Binding Name}" Padding="5,0,0,0" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
|
||||
<userControls:OpenDatabaseUserControl Grid.Row="2" x:Uid="CompositeKeyOpenButton" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" DatabaseFilePath="{Binding Token}">
|
||||
<userControls:OpenDatabaseUserControl Grid.Row="2" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" DatabaseFilePath="{Binding Token}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="DatabaseOpening">
|
||||
<core:CallMethodAction TargetObject="{Binding}" MethodName="UpdateAccessTime" />
|
||||
|
@@ -1,14 +1,14 @@
|
||||
<UserControl
|
||||
x:Class="ModernKeePass.Views.UserControls.OpenDatabaseUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d" >
|
||||
x:Class="ModernKeePass.Views.UserControls.OpenDatabaseUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<converters:DiscreteIntToSolidColorBrushConverter x:Key="DiscreteIntToSolidColorBrushConverter"/>
|
||||
<converters:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter"/>
|
||||
@@ -38,18 +38,19 @@
|
||||
</PasswordBox>
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding HasKeyFile, Mode=TwoWay}" />
|
||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0"
|
||||
Content="{Binding KeyFileText, Mode=OneWay}"
|
||||
IsEnabled="{Binding HasKeyFile, Mode=OneWay}"
|
||||
Content="{Binding KeyFileText}"
|
||||
IsEnabled="{Binding HasKeyFile}"
|
||||
Click="KeyFileButton_Click"
|
||||
Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<Button Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
|
||||
Content="{Binding ButtonLabel, ElementName=UserControl}"
|
||||
x:Name="OpenButton"
|
||||
x:Uid="OpenDatabaseControlButton"
|
||||
Click="OpenButton_OnClick"
|
||||
IsEnabled="{Binding IsValid}"
|
||||
Style="{StaticResource MainColorButton}" />
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Height="Auto" FontSize="14" FontWeight="Light"
|
||||
Text="{Binding Status, Mode=OneWay}"
|
||||
Foreground="{Binding StatusType, Mode=OneWay, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}"
|
||||
Visibility="{Binding Status, Mode=OneWay, Converter={StaticResource EmptyStringToVisibilityConverter}}" />
|
||||
Text="{Binding Status}"
|
||||
Foreground="{Binding StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}"
|
||||
Visibility="{Binding Status, Converter={StaticResource EmptyStringToVisibilityConverter}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
@@ -26,18 +26,6 @@ namespace ModernKeePass.Views.UserControls
|
||||
private readonly IResourceProxy _resource;
|
||||
public OpenDatabaseControlVm Model => Grid.DataContext as OpenDatabaseControlVm;
|
||||
|
||||
public string ButtonLabel
|
||||
{
|
||||
get { return (string)GetValue(ButtonLabelProperty); }
|
||||
set { SetValue(ButtonLabelProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonLabelProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(ButtonLabel),
|
||||
typeof(string),
|
||||
typeof(OpenDatabaseUserControl),
|
||||
new PropertyMetadata("OK", (o, args) => { }));
|
||||
|
||||
public string DatabaseFilePath
|
||||
{
|
||||
get { return (string)GetValue(DatabaseFilePathProperty); }
|
||||
@@ -121,14 +109,14 @@ namespace ModernKeePass.Views.UserControls
|
||||
|
||||
private async Task OpenDatabase()
|
||||
{
|
||||
var oldLabel = ButtonLabel;
|
||||
ButtonLabel = _resource.GetResourceValue("CompositeKeyOpening");
|
||||
var oldLabel = OpenButton.Content;
|
||||
OpenButton.Content = _resource.GetResourceValue("CompositeKeyOpening");
|
||||
if (await Dispatcher.RunTaskAsync(async () => await Model.OpenDatabase(DatabaseFilePath)))
|
||||
{
|
||||
DatabaseOpened?.Invoke(this, new PasswordEventArgs(Model.RootGroupId));
|
||||
}
|
||||
|
||||
ButtonLabel = oldLabel;
|
||||
OpenButton.Content = oldLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,19 @@ namespace ModernKeePass.Views.UserControls
|
||||
public sealed partial class UpdateCredentialsUserControl
|
||||
{
|
||||
public UpdateCredentialsViewModel ViewModel => Grid.DataContext as UpdateCredentialsViewModel;
|
||||
|
||||
public string ButtonLabel
|
||||
{
|
||||
get { return (string)GetValue(ButtonLabelProperty); }
|
||||
set { SetValue(ButtonLabelProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonLabelProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(ButtonLabel),
|
||||
typeof(string),
|
||||
typeof(UpdateCredentialsUserControl),
|
||||
new PropertyMetadata("OK", (o, args) => { }));
|
||||
|
||||
public string DatabaseFilePath
|
||||
{
|
||||
get { return (string) GetValue(DatabaseFilePathProperty); }
|
||||
|
Reference in New Issue
Block a user