mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
OpenDatabaseUserControl works
This commit is contained in:
@@ -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