mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP DeleteCommand
WIP DataContexts binding (Main and Settings are broken)
This commit is contained in:
@@ -26,6 +26,7 @@ namespace ModernKeePass
|
|||||||
return nav;
|
return nav;
|
||||||
});
|
});
|
||||||
services.AddSingleton(provider => Messenger.Default);
|
services.AddSingleton(provider => Messenger.Default);
|
||||||
|
services.AddTransient(typeof(IDialogService), typeof(DialogService));
|
||||||
|
|
||||||
services.AddSingleton(provider =>
|
services.AddSingleton(provider =>
|
||||||
{
|
{
|
||||||
|
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using GalaSoft.MvvmLight.Views;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||||
@@ -219,10 +220,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
public RelayCommand GeneratePasswordCommand { get; }
|
public RelayCommand GeneratePasswordCommand { get; }
|
||||||
public RelayCommand MoveCommand { get; }
|
public RelayCommand MoveCommand { get; }
|
||||||
public RelayCommand RestoreCommand { get; }
|
public RelayCommand RestoreCommand { get; }
|
||||||
|
public RelayCommand DeleteCommand { get; }
|
||||||
|
public RelayCommand GoBackCommand { get; }
|
||||||
|
|
||||||
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
private readonly INavigationService _navigation;
|
||||||
private readonly GroupVm _parent;
|
private readonly GroupVm _parent;
|
||||||
private EntryVm _selectedItem;
|
private EntryVm _selectedItem;
|
||||||
private int _selectedIndex;
|
private int _selectedIndex;
|
||||||
@@ -233,11 +237,12 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public EntryDetailVm() { }
|
public EntryDetailVm() { }
|
||||||
|
|
||||||
internal EntryDetailVm(string entryId) : this(entryId, App.Services.GetRequiredService<IMediator>()) { }
|
internal EntryDetailVm(string entryId) : this(entryId, App.Services.GetRequiredService<IMediator>(), App.Services.GetRequiredService<INavigationService>()) { }
|
||||||
|
|
||||||
public EntryDetailVm(string entryId, IMediator mediator)
|
public EntryDetailVm(string entryId, IMediator mediator, INavigationService navigation)
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
|
_navigation = navigation;
|
||||||
SelectedItem = _mediator.Send(new GetEntryQuery { Id = entryId }).GetAwaiter().GetResult();
|
SelectedItem = _mediator.Send(new GetEntryQuery { Id = entryId }).GetAwaiter().GetResult();
|
||||||
_parent = _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId }).GetAwaiter().GetResult();
|
_parent = _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId }).GetAwaiter().GetResult();
|
||||||
History = new ObservableCollection<EntryVm> { SelectedItem };
|
History = new ObservableCollection<EntryVm> { SelectedItem };
|
||||||
@@ -251,6 +256,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
||||||
MoveCommand = new RelayCommand(async () => await Move(_parent), () => _parent != null);
|
MoveCommand = new RelayCommand(async () => await Move(_parent), () => _parent != null);
|
||||||
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
|
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
|
||||||
|
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||||
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AskForDelete()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task GeneratePassword()
|
public async Task GeneratePassword()
|
||||||
|
@@ -8,6 +8,7 @@ using Windows.UI.Xaml.Controls;
|
|||||||
using GalaSoft.MvvmLight.Views;
|
using GalaSoft.MvvmLight.Views;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||||
using ModernKeePass.Application.Database.Models;
|
using ModernKeePass.Application.Database.Models;
|
||||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||||
@@ -92,11 +93,15 @@ namespace ModernKeePass.ViewModels
|
|||||||
public RelayCommand MoveCommand { get; }
|
public RelayCommand MoveCommand { get; }
|
||||||
public RelayCommand CreateEntryCommand { get; }
|
public RelayCommand CreateEntryCommand { get; }
|
||||||
public RelayCommand CreateGroupCommand { get; }
|
public RelayCommand CreateGroupCommand { get; }
|
||||||
|
public RelayCommand DeleteCommand { get; set; }
|
||||||
|
public RelayCommand GoBackCommand { get; set; }
|
||||||
|
|
||||||
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
private readonly IResourceProxy _resource;
|
||||||
private readonly INavigationService _navigation;
|
private readonly INavigationService _navigation;
|
||||||
|
private readonly IDialogService _dialog;
|
||||||
private readonly GroupVm _group;
|
private readonly GroupVm _group;
|
||||||
private readonly GroupVm _parent;
|
private readonly GroupVm _parent;
|
||||||
private bool _isEditMode;
|
private bool _isEditMode;
|
||||||
@@ -104,13 +109,19 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public GroupDetailVm() {}
|
public GroupDetailVm() {}
|
||||||
|
|
||||||
internal GroupDetailVm(string groupId) : this(groupId, App.Services.GetRequiredService<IMediator>(), App.Services.GetRequiredService<INavigationService>())
|
internal GroupDetailVm(string groupId) : this(groupId,
|
||||||
|
App.Services.GetRequiredService<IMediator>(),
|
||||||
|
App.Services.GetRequiredService<IResourceProxy>(),
|
||||||
|
App.Services.GetRequiredService<INavigationService>(),
|
||||||
|
App.Services.GetRequiredService<IDialogService>())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public GroupDetailVm(string groupId, IMediator mediator, INavigationService navigation)
|
public GroupDetailVm(string groupId, IMediator mediator, IResourceProxy resource, INavigationService navigation, IDialogService dialog)
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
|
_resource = resource;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
|
_dialog = dialog;
|
||||||
_group = _mediator.Send(new GetGroupQuery { Id = groupId }).GetAwaiter().GetResult();
|
_group = _mediator.Send(new GetGroupQuery { Id = groupId }).GetAwaiter().GetResult();
|
||||||
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
||||||
{
|
{
|
||||||
@@ -124,12 +135,33 @@ namespace ModernKeePass.ViewModels
|
|||||||
MoveCommand = new RelayCommand(async () => await Move(_parent), () => IsNotRoot);
|
MoveCommand = new RelayCommand(async () => await Move(_parent), () => IsNotRoot);
|
||||||
CreateEntryCommand = new RelayCommand(async () => await AddNewEntry(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
CreateEntryCommand = new RelayCommand(async () => await AddNewEntry(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
||||||
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
||||||
|
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||||
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
|
|
||||||
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
||||||
Entries.CollectionChanged += Entries_CollectionChanged;
|
Entries.CollectionChanged += Entries_CollectionChanged;
|
||||||
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
|
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task AskForDelete()
|
||||||
|
{
|
||||||
|
var message = IsRecycleOnDelete
|
||||||
|
? _resource.GetResourceValue("GroupRecyclingConfirmation")
|
||||||
|
: _resource.GetResourceValue("GroupDeletingConfirmation");
|
||||||
|
|
||||||
|
await _dialog.ShowMessage(message, _resource.GetResourceValue("EntityDeleteTitle"),
|
||||||
|
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||||
|
_resource.GetResourceValue("EntityDeleteCancelButton"),
|
||||||
|
async isOk =>
|
||||||
|
{
|
||||||
|
var text = IsRecycleOnDelete ? _resource.GetResourceValue("GroupRecycled") : _resource.GetResourceValue("GroupDeleted");
|
||||||
|
//ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
||||||
|
await MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||||
|
_navigation.GoBack();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task AddNewGroup(string name = "")
|
public async Task AddNewGroup(string name = "")
|
||||||
{
|
{
|
||||||
var group = await _mediator.Send(new CreateGroupCommand {Name = name, ParentGroup = _group});
|
var group = await _mediator.Send(new CreateGroupCommand {Name = name, ParentGroup = _group});
|
||||||
|
@@ -481,7 +481,7 @@
|
|||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Grid.Column="0"
|
<Button Grid.Column="0"
|
||||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
Command="{Binding GoBackCommand}"
|
||||||
Height="{StaticResource MenuSize}"
|
Height="{StaticResource MenuSize}"
|
||||||
Width="{StaticResource MenuSize}"
|
Width="{StaticResource MenuSize}"
|
||||||
AutomationProperties.Name="Back"
|
AutomationProperties.Name="Back"
|
||||||
@@ -543,10 +543,6 @@
|
|||||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||||
</core:EventTriggerBehavior>
|
</core:EventTriggerBehavior>
|
||||||
<core:EventTriggerBehavior EventName="MoveButtonClick">
|
|
||||||
<core:InvokeCommandAction Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}" />
|
|
||||||
<!--<actions:ToastAction x:Uid="RestoreEntryCommand" Title="{Binding Title}" />-->
|
|
||||||
</core:EventTriggerBehavior>
|
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</userControls:TopMenuUserControl>
|
</userControls:TopMenuUserControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@@ -19,18 +19,11 @@ namespace ModernKeePass.Views
|
|||||||
private readonly IResourceProxy _resource;
|
private readonly IResourceProxy _resource;
|
||||||
public EntryDetailVm Model => (EntryDetailVm) DataContext;
|
public EntryDetailVm Model => (EntryDetailVm) DataContext;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
|
|
||||||
/// gestion de la durée de vie des processus
|
|
||||||
/// </summary>
|
|
||||||
public NavigationHelper NavigationHelper { get; }
|
|
||||||
|
|
||||||
public EntryDetailPage(): this(App.Services.GetRequiredService<IResourceProxy>()) { }
|
public EntryDetailPage(): this(App.Services.GetRequiredService<IResourceProxy>()) { }
|
||||||
public EntryDetailPage(IResourceProxy resource)
|
public EntryDetailPage(IResourceProxy resource)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_resource = resource;
|
_resource = resource;
|
||||||
NavigationHelper = new NavigationHelper(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Inscription de NavigationHelper
|
#region Inscription de NavigationHelper
|
||||||
@@ -46,7 +39,6 @@ namespace ModernKeePass.Views
|
|||||||
|
|
||||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
NavigationHelper.OnNavigatedTo(e);
|
|
||||||
var args = e.Parameter as NavigationItem;
|
var args = e.Parameter as NavigationItem;
|
||||||
if (args != null)
|
if (args != null)
|
||||||
{
|
{
|
||||||
@@ -58,7 +50,6 @@ namespace ModernKeePass.Views
|
|||||||
protected override async void OnNavigatedFrom(NavigationEventArgs e)
|
protected override async void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
await Model.AddHistory();
|
await Model.AddHistory();
|
||||||
NavigationHelper.OnNavigatedFrom(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -85,7 +76,7 @@ namespace ModernKeePass.Views
|
|||||||
var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted");
|
var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted");
|
||||||
//ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text);
|
//ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text);
|
||||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||||
NavigationHelper.GoBack();
|
//NavigationHelper.GoBack();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -193,7 +193,7 @@
|
|||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Grid.Column="0"
|
<Button Grid.Column="0"
|
||||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
Command="{Binding GoBackCommand}"
|
||||||
Height="{StaticResource MenuSize}"
|
Height="{StaticResource MenuSize}"
|
||||||
Width="{StaticResource MenuSize}"
|
Width="{StaticResource MenuSize}"
|
||||||
AutomationProperties.Name="Back"
|
AutomationProperties.Name="Back"
|
||||||
@@ -255,10 +255,6 @@
|
|||||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||||
</core:EventTriggerBehavior>
|
</core:EventTriggerBehavior>
|
||||||
<core:EventTriggerBehavior EventName="MoveButtonClick">
|
|
||||||
<core:InvokeCommandAction Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}" />
|
|
||||||
<!--<actions:ToastAction x:Uid="RestoreGroupCommand" Title="{Binding Title}" />-->
|
|
||||||
</core:EventTriggerBehavior>
|
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</userControls:TopMenuUserControl>
|
</userControls:TopMenuUserControl>
|
||||||
<Button Grid.Column="3" x:Name="SearchButton" Style="{StaticResource NoBorderButtonStyle}" Background="{ThemeResource ToggleButtonBackgroundThemeBrush}" Height="{StaticResource MenuSize}" Padding="25,0,25,0">
|
<Button Grid.Column="3" x:Name="SearchButton" Style="{StaticResource NoBorderButtonStyle}" Background="{ThemeResource ToggleButtonBackgroundThemeBrush}" Height="{StaticResource MenuSize}" Padding="25,0,25,0">
|
||||||
|
@@ -10,7 +10,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Entry.Models;
|
using ModernKeePass.Application.Entry.Models;
|
||||||
using ModernKeePass.Common;
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Events;
|
|
||||||
using ModernKeePass.Models;
|
using ModernKeePass.Models;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
@@ -27,11 +26,6 @@ namespace ModernKeePass.Views
|
|||||||
private readonly IResourceProxy _resource;
|
private readonly IResourceProxy _resource;
|
||||||
private readonly INavigationService _navigation;
|
private readonly INavigationService _navigation;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NavigationHelper is used on each page to aid in navigation and
|
|
||||||
/// process lifetime management
|
|
||||||
/// </summary>
|
|
||||||
public NavigationHelper NavigationHelper { get; }
|
|
||||||
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
||||||
|
|
||||||
public GroupDetailPage(): this (App.Services.GetRequiredService<IResourceProxy>(), App.Services.GetRequiredService<INavigationService>()) { }
|
public GroupDetailPage(): this (App.Services.GetRequiredService<IResourceProxy>(), App.Services.GetRequiredService<INavigationService>()) { }
|
||||||
@@ -40,7 +34,6 @@ namespace ModernKeePass.Views
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_resource = resource;
|
_resource = resource;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
NavigationHelper = new NavigationHelper(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region NavigationHelper registration
|
#region NavigationHelper registration
|
||||||
@@ -56,18 +49,11 @@ namespace ModernKeePass.Views
|
|||||||
///
|
///
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
NavigationHelper.OnNavigatedTo(e);
|
|
||||||
|
|
||||||
var navigationItem = e.Parameter as NavigationItem;
|
var navigationItem = e.Parameter as NavigationItem;
|
||||||
if (navigationItem != null)
|
if (navigationItem != null)
|
||||||
DataContext = new GroupDetailVm(navigationItem.Id) { IsEditMode = navigationItem.IsNew };
|
DataContext = new GroupDetailVm(navigationItem.Id) { IsEditMode = navigationItem.IsNew };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
|
||||||
{
|
|
||||||
NavigationHelper.OnNavigatedFrom(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Event Handlers
|
#region Event Handlers
|
||||||
@@ -149,7 +135,7 @@ namespace ModernKeePass.Views
|
|||||||
{
|
{
|
||||||
//ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
//ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
||||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||||
NavigationHelper.GoBack();
|
//NavigationHelper.GoBack();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,20 +10,17 @@
|
|||||||
x:Name="PageRoot"
|
x:Name="PageRoot"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource
|
<viewModels:MainVm x:Key="ViewModel"/>
|
||||||
x:Name="MenuItemsSource"
|
|
||||||
Source="{Binding MainMenuItems}"
|
|
||||||
IsSourceGrouped="True" />
|
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<Page.Background>
|
<Page.Background>
|
||||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||||
</Page.Background>
|
</Page.Background>
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:MainVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
|
|
||||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||||
|
<Grid.Resources>
|
||||||
|
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MainMenuItems}" IsSourceGrouped="True" />
|
||||||
|
</Grid.Resources>
|
||||||
<Grid.ChildrenTransitions>
|
<Grid.ChildrenTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
<EntranceThemeTransition/>
|
<EntranceThemeTransition/>
|
||||||
|
@@ -13,7 +13,7 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class MainPage
|
public sealed partial class MainPage
|
||||||
{
|
{
|
||||||
public new MainVm Model => (MainVm)DataContext;
|
private new MainVm Model => (MainVm)Resources["ViewModel"];
|
||||||
|
|
||||||
public MainPage()
|
public MainPage()
|
||||||
{
|
{
|
||||||
|
@@ -10,16 +10,16 @@
|
|||||||
x:Class="ModernKeePass.Views.SettingsPage"
|
x:Class="ModernKeePass.Views.SettingsPage"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" IsSourceGrouped="True" />
|
<viewModels:SettingsVm x:Key="ViewModel"/>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:SettingsVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
|
|
||||||
<Page.Background>
|
<Page.Background>
|
||||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||||
</Page.Background>
|
</Page.Background>
|
||||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||||
|
<Grid.Resources>
|
||||||
|
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" IsSourceGrouped="True" />
|
||||||
|
</Grid.Resources>
|
||||||
<Grid.ChildrenTransitions>
|
<Grid.ChildrenTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
<EntranceThemeTransition/>
|
<EntranceThemeTransition/>
|
||||||
|
@@ -12,7 +12,7 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class SettingsPage
|
public sealed partial class SettingsPage
|
||||||
{
|
{
|
||||||
public new SettingsVm Model => (SettingsVm)DataContext;
|
private new SettingsVm Model => (SettingsVm)Resources["ViewModel"];
|
||||||
|
|
||||||
public SettingsPage()
|
public SettingsPage()
|
||||||
{
|
{
|
||||||
|
@@ -14,12 +14,10 @@
|
|||||||
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
|
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
|
||||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||||
|
<listItems:SettingsDatabaseVm x:Key="ViewModel"/>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
|
||||||
<listItems:SettingsDatabaseVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
|
|
||||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||||
<ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
<ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||||
<StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}">
|
<StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
<RadioButton x:Uid="SettingsDatabaseRecycleBinCreate" GroupName="Recycle" IsChecked="{Binding IsNewRecycleBin, Mode=TwoWay}" />
|
<RadioButton x:Uid="SettingsDatabaseRecycleBinCreate" GroupName="Recycle" IsChecked="{Binding IsNewRecycleBin, Mode=TwoWay}" />
|
||||||
|
@@ -8,11 +8,10 @@
|
|||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding FileFormats}" />
|
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding FileFormats}" />
|
||||||
|
<listItems:SettingsNewVm x:Key="ViewModel"/>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
|
||||||
<listItems:SettingsNewVm />
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||||
</Page.DataContext>
|
|
||||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
|
||||||
<TextBlock x:Uid="SettingsNewDatabaseDesc" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
<TextBlock x:Uid="SettingsNewDatabaseDesc" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
||||||
<ToggleSwitch x:Uid="SettingsNewDatabaseSample" IsOn="{Binding IsCreateSample, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
<ToggleSwitch x:Uid="SettingsNewDatabaseSample" IsOn="{Binding IsCreateSample, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||||
<TextBlock x:Uid="SettingsNewDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
<TextBlock x:Uid="SettingsNewDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
||||||
|
@@ -6,11 +6,11 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.DataContext>
|
<Page.Resources>
|
||||||
<listItems:SettingsSaveVm />
|
<listItems:SettingsSaveVm x:Name="ViewModel"/>
|
||||||
</Page.DataContext>
|
</Page.Resources>
|
||||||
|
|
||||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||||
<TextBlock x:Uid="SettingsSaveDatabaseSuspendTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
<TextBlock x:Uid="SettingsSaveDatabaseSuspendTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
||||||
<TextBlock x:Uid="SettingsSaveDatabaseSuspendDesc" TextWrapping="WrapWholeWords" Margin="5,0,0,10"/>
|
<TextBlock x:Uid="SettingsSaveDatabaseSuspendDesc" TextWrapping="WrapWholeWords" Margin="5,0,0,10"/>
|
||||||
<ToggleSwitch x:Uid="SettingsSaveDatabaseSuspend" IsOn="{Binding IsSaveSuspend, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
<ToggleSwitch x:Uid="SettingsSaveDatabaseSuspend" IsOn="{Binding IsSaveSuspend, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||||
|
@@ -49,14 +49,14 @@
|
|||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</SymbolIcon>
|
</SymbolIcon>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding MoveCommand, ElementName=UserControl}" IsEnabled="{Binding IsMoveButtonEnabled, ElementName=UserControl}" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" Click="MoveButton_Click" Style="{StaticResource MenuButtonStyle}">
|
<Button Command="{Binding MoveCommand, ElementName=UserControl}" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" Style="{StaticResource MenuButtonStyle}">
|
||||||
<SymbolIcon Symbol="MoveToFolder">
|
<SymbolIcon Symbol="MoveToFolder">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<ToolTip x:Uid="TopMenuMoveButton" />
|
<ToolTip x:Uid="TopMenuMoveButton" />
|
||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</SymbolIcon>
|
</SymbolIcon>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_Click" Style="{StaticResource MenuButtonStyle}">
|
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Style="{StaticResource MenuButtonStyle}">
|
||||||
<SymbolIcon Symbol="Undo">
|
<SymbolIcon Symbol="Undo">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<ToolTip x:Uid="TopMenuRestoreButton" />
|
<ToolTip x:Uid="TopMenuRestoreButton" />
|
||||||
@@ -96,8 +96,8 @@
|
|||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
||||||
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuMoveFlyout" x:Name="MoveFlyout" Command="{Binding MoveCommand, ElementName=UserControl}" IsEnabled="{Binding IsMoveButtonEnabled, ElementName=UserControl}" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" Click="MoveButton_Click" />
|
<MenuFlyoutItem x:Uid="TopMenuMoveFlyout" x:Name="MoveFlyout" Command="{Binding MoveCommand, ElementName=UserControl}" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_Click" />
|
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
|
||||||
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
|
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Click="DeleteButton_Click" />
|
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Click="DeleteButton_Click" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||||
|
@@ -140,18 +140,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
typeof(TopMenuUserControl),
|
typeof(TopMenuUserControl),
|
||||||
new PropertyMetadata(true, (o, args) => { }));
|
new PropertyMetadata(true, (o, args) => { }));
|
||||||
|
|
||||||
public bool IsMoveButtonEnabled
|
|
||||||
{
|
|
||||||
get { return (bool)GetValue(IsMoveButtonEnabledProperty); }
|
|
||||||
set { SetValue(IsMoveButtonEnabledProperty, value); }
|
|
||||||
}
|
|
||||||
public static readonly DependencyProperty IsMoveButtonEnabledProperty =
|
|
||||||
DependencyProperty.Register(
|
|
||||||
nameof(IsMoveButtonEnabled),
|
|
||||||
typeof(bool),
|
|
||||||
typeof(TopMenuUserControl),
|
|
||||||
new PropertyMetadata(true, (o, args) => { }));
|
|
||||||
|
|
||||||
public bool IsEditButtonChecked
|
public bool IsEditButtonChecked
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsEditButtonCheckedProperty); }
|
get { return (bool)GetValue(IsEditButtonCheckedProperty); }
|
||||||
@@ -166,8 +154,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
|
|
||||||
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
||||||
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
||||||
public event EventHandler<RoutedEventArgs> MoveButtonClick;
|
|
||||||
public event EventHandler<RoutedEventArgs> RestoreButtonClick;
|
|
||||||
|
|
||||||
public TopMenuUserControl()
|
public TopMenuUserControl()
|
||||||
{
|
{
|
||||||
@@ -191,15 +177,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
DeleteButtonClick?.Invoke(sender, e);
|
DeleteButtonClick?.Invoke(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
MoveButtonClick?.Invoke(sender, e);
|
|
||||||
}
|
|
||||||
private void RestoreButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
RestoreButtonClick?.Invoke(sender, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OverflowFlyout_OnOpening(object sender, object e)
|
private void OverflowFlyout_OnOpening(object sender, object e)
|
||||||
{
|
{
|
||||||
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
||||||
|
Reference in New Issue
Block a user