Hamburger button state is now correct (no more double clicks) but it's a bit hacky

Changed Help tooltip location in New Database Settings page
Suggest Save As when opening DB when another is opened and there is a save error
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-05 16:59:49 +02:00
parent 5ce0262318
commit 8fb468358e
13 changed files with 48 additions and 54 deletions

View File

@@ -75,12 +75,12 @@ namespace ModernKeePass
Resuming += OnResuming;
UnhandledException += OnUnhandledException;
_messenger.Register<SaveErrorMessage>(this, async message => await HandelSaveError(message.Message));
_messenger.Register<SaveErrorMessage>(this, async message => await HandleSaveError(message));
}
private async Task HandelSaveError(string message)
private async Task HandleSaveError(SaveErrorMessage message)
{
_notification.Show(_resource.GetResourceValue("MessageDialogSaveErrorTitle"), message);
_notification.Show(_resource.GetResourceValue("MessageDialogSaveErrorTitle"), message?.Message);
var database = await _mediator.Send(new GetDatabaseQuery());
var file = await _file.CreateFile($"{database.Name} - copy",
Domain.Common.Constants.Extensions.Kdbx,

View File

@@ -513,7 +513,7 @@
<data name="SettingsSaveDatabaseSuspendDesc.Text" xml:space="preserve">
<value>This settings is generally recommended. If you enable it, database will automatically be saved on application suspension and closing, provided your database is less than 1MB big. Saving bigger databases may take too long and Windows may then forcibly kill the app before saving is finished, resulting in your changes not being saved.</value>
</data>
<data name="NewGroupTextBox" xml:space="preserve">
<data name="NewGroupTextBox.ButtonTooltip" xml:space="preserve">
<value>New group name</value>
</data>
</root>

View File

@@ -492,9 +492,6 @@
<data name="NewImportFormat.Text" xml:space="preserve">
<value>Format</value>
</data>
<data name="NewImportFormatHelp.Text" xml:space="preserve">
<value>Le fichier CSV doit être formatté de la façon suivante: Nom du compte;Login;Mot de passe:URL;Commentaires</value>
</data>
<data name="CloseButton.Content" xml:space="preserve">
<value>Fermer sans sauvegarder</value>
</data>
@@ -516,7 +513,7 @@
<data name="CompositeKeyConfirmPassword.PlaceholderText" xml:space="preserve">
<value>Confirmer le mot de passe</value>
</data>
<data name="NewGroupTextBox" xml:space="preserve">
<data name="NewGroupTextBox.ButtonTooltip" xml:space="preserve">
<value>Nom du groupe</value>
</data>
</root>

View File

@@ -183,8 +183,8 @@ namespace ModernKeePass.ViewModels
}
catch (SaveException exception)
{
// TODO: Implement save as
_notification.Show(exception.Source, exception.Message);
MessengerInstance.Send(new SaveErrorMessage { Message = exception.Message });
return;
}
}

View File

@@ -268,12 +268,22 @@
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="TopMenuGroup">
<VisualStateGroup x:Name="PageLayout">
<VisualState x:Name="Small">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="AddEntryTextBlock" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HamburgerMenu" Storyboard.TargetProperty="IsOpen">
<DiscreteObjectKeyFrame KeyTime="0" Value="False"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Medium">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HamburgerMenu" Storyboard.TargetProperty="IsOpen">
<DiscreteObjectKeyFrame KeyTime="0" Value="False"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Large">
@@ -281,6 +291,9 @@
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="AddEntryTextBlock" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HamburgerMenu" Storyboard.TargetProperty="IsOpen">
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>

View File

@@ -1,7 +1,4 @@
using System;
using System.Linq;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage.Streams;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

View File

@@ -6,15 +6,14 @@
xmlns:viewModels="using:ModernKeePass.ViewModels"
x:Class="ModernKeePass.Views.AboutPage"
mc:Ignorable="d">
<Page.DataContext>
<viewModels:AboutVm/>
</Page.DataContext>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0">
<Run Text="{Binding Name}"/>
<Run Text="version"/>
<Run Text="{Binding Name}" />
<Run Text="version" />
<Run Text="{Binding Version}" />
</TextBlock>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
@@ -23,7 +22,7 @@
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
<Run x:Uid="AboutHomepage" />
<Hyperlink NavigateUri="https://wismna.github.io/ModernKeePass/">
<Run Text="https://wismna.github.io/ModernKeePass/"/>
<Run Text="https://wismna.github.io/ModernKeePass/" />
</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0">

View File

@@ -20,10 +20,10 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Import" Style="{StaticResource SubheaderTextBlockStyle}" />
<HyperlinkButton Grid.Column="0" Grid.Row="1" Content="Select file..." Style="{StaticResource MainColorHyperlinkButton}" Click="ImportFileButton_OnClick" />
<HyperlinkButton Grid.Column="0" Grid.Row="1" Content="Select file..." />
<StackPanel Grid.Column="1" Grid.Row="1" >
<TextBlock Text="Format" Style="{StaticResource BodyTextBlockStyle}" Margin="0,0,0,10" />
<ComboBox Style="{StaticResource MainColorComboBox}">
<ComboBox>
<ComboBoxItem>CSV</ComboBoxItem>
</ComboBox>
</StackPanel>
@@ -32,6 +32,6 @@
<RadioButton GroupName="ImportDestination" Content="New database" />
<RadioButton GroupName="ImportDestination" Content="Currently opened database" />
</StackPanel>
<Button Grid.Column="3" Grid.Row="1" Content="Import" Style="{StaticResource MainColorButton}" />
<Button Grid.Column="3" Grid.Row="1" Content="Import" />
</Grid>
</Page>

View File

@@ -1,8 +1,4 @@
using System;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Views
{
@@ -15,21 +11,5 @@ namespace ModernKeePass.Views
{
InitializeComponent();
}
private async void ImportFileButton_OnClick(object sender, RoutedEventArgs e)
{
var picker =
new FileOpenPicker
{
ViewMode = PickerViewMode.List,
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
};
picker.FileTypeFilter.Add(".csv");
// Application now has read/write access to the picked file
var file = await picker.PickSingleFileAsync().AsTask();
if (file == null) return;
}
}
}

View File

@@ -13,18 +13,12 @@
</StackPanel.Resources>
<TextBlock x:Uid="SettingsNewDatabaseDesc" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
<ToggleSwitch x:Uid="SettingsNewDatabaseSample" IsOn="{Binding IsCreateSample, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsNewDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="1" ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding DatabaseFormatVersion, Mode=TwoWay}" DisplayMemberPath="DisplayText" />
<Button Grid.Column="2" Style="{StaticResource TextBlockButtonStyle}">
<StackPanel Orientation="Horizontal" Margin="5,20,0,10">
<TextBlock x:Uid="SettingsNewDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" />
<Button Style="{StaticResource TextBlockButtonStyle}" Foreground="{StaticResource ButtonPointerOverForegroundThemeBrush}" Margin="0,-2,0,0">
<SymbolIcon Symbol="Help" RenderTransformOrigin="0.5,0.5">
<SymbolIcon.RenderTransform>
<CompositeTransform ScaleX="0.7" ScaleY="0.7"/>
<CompositeTransform ScaleX="0.6" ScaleY="0.6"/>
</SymbolIcon.RenderTransform>
</SymbolIcon>
<Button.Flyout>
@@ -33,6 +27,7 @@
</Flyout>
</Button.Flyout>
</Button>
</Grid>
</StackPanel>
<ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding DatabaseFormatVersion, Mode=TwoWay}" DisplayMemberPath="DisplayText" />
</StackPanel>
</Page>

View File

@@ -60,7 +60,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<ToggleButton Style="{StaticResource HamburgerToggleButton}" Unchecked="ToggleButton_OnUnchecked">
<ToggleButton Style="{StaticResource HamburgerToggleButton}" IsChecked="{Binding IsOpen, ElementName=UserControl}" Unchecked="ToggleButton_OnUnchecked">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Checked">
<core:GoToStateAction StateName="Expanded" />

View File

@@ -99,6 +99,18 @@ namespace ModernKeePass.Views.UserControls
typeof(HamburgerMenuUserControl),
new PropertyMetadata(-1, (o, args) => { }));
public bool IsOpen
{
get { return (bool)GetValue(IsOpenProperty); }
set { SetValue(IsOpenProperty, value); }
}
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register(
nameof(IsOpen),
typeof(bool),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
public ICommand ActionButtonCommand
{
get { return (ICommand)GetValue(ActionButtonCommandProperty); }

View File

@@ -78,6 +78,7 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<interactivity:Interaction.Behaviors>
<!-- TODO: Correct the Runtime template binding error (even though it is actually working as intended) -->
<core:DataTriggerBehavior Binding="{Binding IsError}" Value="True">
<core:GoToStateAction StateName="Error"/>
</core:DataTriggerBehavior>