Build hierarchy instead of using Automapper

Add entities before removing them
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-01 12:48:36 +02:00
parent 90c592d7ee
commit 57be6bb917
22 changed files with 84 additions and 77 deletions

View File

@@ -372,7 +372,7 @@
</Style>
</Page.Resources>
<Page.DataContext>
<viewModels:EntryVm />
<viewModels:EntryDetailVm />
</Page.DataContext>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ChildrenTransitions>
@@ -410,7 +410,7 @@
</Style>
</StackPanel.Resources>
<TextBlock x:Uid="EntryLogin" />
<local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" IsEnabled="{Binding IsSelected}">
<local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" LostFocus="Username_OnLostFocus" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" IsEnabled="{Binding IsSelected}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ButtonClick">
<actions:ClipboardAction Text="{Binding UserName}" />

View File

@@ -14,7 +14,7 @@ namespace ModernKeePass.Views
/// </summary>
public sealed partial class EntryDetailPage
{
public EntryVm Model => (EntryVm) DataContext;
public EntryDetailVm Model => (EntryDetailVm) DataContext;
/// <summary>
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
@@ -45,7 +45,7 @@ namespace ModernKeePass.Views
/*if (!(e.Parameter is EntryVm)) return;
DataContext = (EntryVm)e.Parameter;*/
var args = e.Parameter as Application.Entry.Models.EntryVm;
if (args != null) DataContext = new EntryVm(args);
if (args != null) DataContext = new EntryDetailVm(args);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -75,5 +75,10 @@ namespace ModernKeePass.Views
break;
}
}
private async void Username_OnLostFocus(object sender, RoutedEventArgs e)
{
await Model.SetFieldValue(nameof(Model.UserName), ((TextBox) sender).Text);
}
}
}

View File

@@ -19,7 +19,7 @@
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
</Page.Resources>
<Page.DataContext>
<viewModels:GroupVm />
<viewModels:GroupDetailVm />
</Page.DataContext>
<Grid>
<Grid.Resources>

View File

@@ -25,7 +25,7 @@ namespace ModernKeePass.Views
/// process lifetime management
/// </summary>
public NavigationHelper NavigationHelper { get; }
public GroupVm Model => (GroupVm)DataContext;
public GroupDetailVm Model => (GroupDetailVm)DataContext;
public GroupDetailPage()
{
@@ -50,12 +50,12 @@ namespace ModernKeePass.Views
var args = e.Parameter as PasswordEventArgs;
if (args != null)
DataContext = new GroupVm(args.RootGroup);
DataContext = new GroupDetailVm(args.RootGroup);
else
{
var vm = e.Parameter as Application.Group.Models.GroupVm;
if (vm != null)
DataContext = new GroupVm(vm);
DataContext = new GroupDetailVm(vm);
}
}