mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Restore Main and Settings Page
Entry and Group delete events converted to commands Code cleanup
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
x:Name="PageRoot"
|
||||
x:Class="ModernKeePass.Views.EntryDetailPage"
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="EntryDetailPage_OnSizeChanged">
|
||||
@@ -538,7 +537,7 @@
|
||||
SaveCommand="{Binding SaveCommand}"
|
||||
MoveCommand="{Binding MoveCommand}"
|
||||
RestoreCommand="{Binding RestoreCommand}"
|
||||
DeleteButtonClick="TopMenu_OnDeleteButtonClick">
|
||||
DeleteCommand="{Binding DeleteCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
|
@@ -1,8 +1,5 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Models;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
@@ -16,14 +13,11 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class EntryDetailPage
|
||||
{
|
||||
private readonly IResourceProxy _resource;
|
||||
public EntryDetailVm Model => (EntryDetailVm) DataContext;
|
||||
|
||||
public EntryDetailPage(): this(App.Services.GetRequiredService<IResourceProxy>()) { }
|
||||
public EntryDetailPage(IResourceProxy resource)
|
||||
public EntryDetailPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_resource = resource;
|
||||
}
|
||||
|
||||
#region Inscription de NavigationHelper
|
||||
@@ -59,36 +53,5 @@ namespace ModernKeePass.Views
|
||||
VisualStateManager.GoToState(this, e.NewSize.Width < 700 ? "Small" : "Large", true);
|
||||
VisualStateManager.GoToState(TopMenu, e.NewSize.Width < 800 ? "Collapsed" : "Overflowed", true);
|
||||
}
|
||||
|
||||
private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Model.IsCurrentEntry)
|
||||
{
|
||||
var isRecycleOnDelete = Model.IsRecycleOnDelete;
|
||||
|
||||
var message = isRecycleOnDelete
|
||||
? _resource.GetResourceValue("EntryRecyclingConfirmation")
|
||||
: _resource.GetResourceValue("EntryDeletingConfirmation");
|
||||
await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message,
|
||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||
_resource.GetResourceValue("EntityDeleteCancelButton"), async a =>
|
||||
{
|
||||
var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted");
|
||||
//ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text);
|
||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||
//NavigationHelper.GoBack();
|
||||
}, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("HistoryDeleteTitle"), _resource.GetResourceValue("HistoryDeleteDescription"),
|
||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||
_resource.GetResourceValue("EntityDeleteCancelButton"), async a =>
|
||||
{
|
||||
//ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text);
|
||||
await Model.DeleteHistory();
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -250,7 +250,7 @@
|
||||
MoveCommand="{Binding MoveCommand}"
|
||||
SortEntriesCommand="{Binding SortEntriesCommand}"
|
||||
SortGroupsCommand="{Binding SortGroupsCommand}"
|
||||
DeleteButtonClick="TopMenu_OnDeleteButtonClick">
|
||||
DeleteCommand="{Binding DeleteCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
|
@@ -120,25 +120,7 @@ namespace ModernKeePass.Views
|
||||
VisualStateManager.GoToState(this, e.NewSize.Width < 800 ? "Small" : "Large", true);
|
||||
VisualStateManager.GoToState(TopMenu, e.NewSize.Width < 800 ? "Collapsed" : "Overflowed", true);
|
||||
}
|
||||
|
||||
private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var isRecycleOnDelete = Model.IsRecycleOnDelete;
|
||||
|
||||
var message = isRecycleOnDelete
|
||||
? _resource.GetResourceValue("GroupRecyclingConfirmation")
|
||||
: _resource.GetResourceValue("GroupDeletingConfirmation");
|
||||
var text = isRecycleOnDelete ? _resource.GetResourceValue("GroupRecycled") : _resource.GetResourceValue("GroupDeleted");
|
||||
await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message,
|
||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||
_resource.GetResourceValue("EntityDeleteCancelButton"), async a =>
|
||||
{
|
||||
//ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||
//NavigationHelper.GoBack();
|
||||
}, null);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -10,17 +10,20 @@
|
||||
x:Name="PageRoot"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<viewModels:MainVm x:Key="ViewModel"/>
|
||||
<CollectionViewSource
|
||||
x:Name="MenuItemsSource"
|
||||
Source="{Binding MainMenuItems}"
|
||||
IsSourceGrouped="True" />
|
||||
</Page.Resources>
|
||||
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</Page.Background>
|
||||
<Page.DataContext>
|
||||
<viewModels:MainVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||
<Grid.Resources>
|
||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MainMenuItems}" IsSourceGrouped="True" />
|
||||
</Grid.Resources>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ChildrenTransitions>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition/>
|
||||
|
@@ -13,7 +13,7 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class MainPage
|
||||
{
|
||||
private new MainVm Model => (MainVm)Resources["ViewModel"];
|
||||
public new MainVm Model => (MainVm)DataContext;
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
|
@@ -10,16 +10,16 @@
|
||||
x:Class="ModernKeePass.Views.SettingsPage"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<viewModels:SettingsVm x:Key="ViewModel"/>
|
||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" IsSourceGrouped="True" />
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:SettingsVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</Page.Background>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||
<Grid.Resources>
|
||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" IsSourceGrouped="True" />
|
||||
</Grid.Resources>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ChildrenTransitions>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition/>
|
||||
|
@@ -12,7 +12,7 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class SettingsPage
|
||||
{
|
||||
private new SettingsVm Model => (SettingsVm)Resources["ViewModel"];
|
||||
public new SettingsVm Model => (SettingsVm)DataContext;
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
|
@@ -4,9 +4,6 @@ using Windows.Storage.Pickers;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using Messages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
@@ -29,13 +26,9 @@ namespace ModernKeePass.Views.UserControls
|
||||
typeof(OpenDatabaseUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public OpenDatabaseUserControl() : this(App.Services.GetRequiredService<IMessenger>()) { }
|
||||
|
||||
public OpenDatabaseUserControl(IMessenger messenger)
|
||||
public OpenDatabaseUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
messenger.Register<DatabaseClosedMessage>(this, async action => await Model.OpenDatabase(DatabaseFilePath));
|
||||
}
|
||||
|
||||
private async void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
|
Reference in New Issue
Block a user