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;
|
||||
});
|
||||
services.AddSingleton(provider => Messenger.Default);
|
||||
services.AddTransient(typeof(IDialogService), typeof(DialogService));
|
||||
|
||||
services.AddSingleton(provider =>
|
||||
{
|
||||
|
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
@@ -219,10 +220,13 @@ namespace ModernKeePass.ViewModels
|
||||
public RelayCommand GeneratePasswordCommand { get; }
|
||||
public RelayCommand MoveCommand { get; }
|
||||
public RelayCommand RestoreCommand { get; }
|
||||
public RelayCommand DeleteCommand { get; }
|
||||
public RelayCommand GoBackCommand { get; }
|
||||
|
||||
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
|
||||
private readonly IMediator _mediator;
|
||||
private readonly INavigationService _navigation;
|
||||
private readonly GroupVm _parent;
|
||||
private EntryVm _selectedItem;
|
||||
private int _selectedIndex;
|
||||
@@ -233,11 +237,12 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
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;
|
||||
_navigation = navigation;
|
||||
SelectedItem = _mediator.Send(new GetEntryQuery { Id = entryId }).GetAwaiter().GetResult();
|
||||
_parent = _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId }).GetAwaiter().GetResult();
|
||||
History = new ObservableCollection<EntryVm> { SelectedItem };
|
||||
@@ -251,6 +256,13 @@ namespace ModernKeePass.ViewModels
|
||||
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
||||
MoveCommand = new RelayCommand(async () => await Move(_parent), () => _parent != null);
|
||||
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()
|
||||
|
@@ -8,6 +8,7 @@ using Windows.UI.Xaml.Controls;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
@@ -92,11 +93,15 @@ namespace ModernKeePass.ViewModels
|
||||
public RelayCommand MoveCommand { get; }
|
||||
public RelayCommand CreateEntryCommand { 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 readonly IMediator _mediator;
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INavigationService _navigation;
|
||||
private readonly IDialogService _dialog;
|
||||
private readonly GroupVm _group;
|
||||
private readonly GroupVm _parent;
|
||||
private bool _isEditMode;
|
||||
@@ -104,13 +109,19 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
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;
|
||||
_resource = resource;
|
||||
_navigation = navigation;
|
||||
_dialog = dialog;
|
||||
_group = _mediator.Send(new GetGroupQuery { Id = groupId }).GetAwaiter().GetResult();
|
||||
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
||||
{
|
||||
@@ -124,12 +135,33 @@ namespace ModernKeePass.ViewModels
|
||||
MoveCommand = new RelayCommand(async () => await Move(_parent), () => IsNotRoot);
|
||||
CreateEntryCommand = new RelayCommand(async () => await AddNewEntry(), () => !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.CollectionChanged += Entries_CollectionChanged;
|
||||
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 = "")
|
||||
{
|
||||
var group = await _mediator.Send(new CreateGroupCommand {Name = name, ParentGroup = _group});
|
||||
|
@@ -481,7 +481,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Command="{Binding GoBackCommand}"
|
||||
Height="{StaticResource MenuSize}"
|
||||
Width="{StaticResource MenuSize}"
|
||||
AutomationProperties.Name="Back"
|
||||
@@ -543,10 +543,6 @@
|
||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</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>
|
||||
</userControls:TopMenuUserControl>
|
||||
</Grid>
|
||||
|
@@ -18,19 +18,12 @@ namespace ModernKeePass.Views
|
||||
{
|
||||
private readonly IResourceProxy _resource;
|
||||
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(IResourceProxy resource)
|
||||
{
|
||||
InitializeComponent();
|
||||
_resource = resource;
|
||||
NavigationHelper = new NavigationHelper(this);
|
||||
}
|
||||
|
||||
#region Inscription de NavigationHelper
|
||||
@@ -46,7 +39,6 @@ namespace ModernKeePass.Views
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
NavigationHelper.OnNavigatedTo(e);
|
||||
var args = e.Parameter as NavigationItem;
|
||||
if (args != null)
|
||||
{
|
||||
@@ -58,7 +50,6 @@ namespace ModernKeePass.Views
|
||||
protected override async void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
await Model.AddHistory();
|
||||
NavigationHelper.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -85,7 +76,7 @@ namespace ModernKeePass.Views
|
||||
var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted");
|
||||
//ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text);
|
||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||
NavigationHelper.GoBack();
|
||||
//NavigationHelper.GoBack();
|
||||
}, null);
|
||||
}
|
||||
else
|
||||
|
@@ -193,7 +193,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Command="{Binding GoBackCommand}"
|
||||
Height="{StaticResource MenuSize}"
|
||||
Width="{StaticResource MenuSize}"
|
||||
AutomationProperties.Name="Back"
|
||||
@@ -255,10 +255,6 @@
|
||||
<core:EventTriggerBehavior EventName="EditButtonClick">
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=TitleTextBox}" />
|
||||
</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>
|
||||
</userControls:TopMenuUserControl>
|
||||
<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.Entry.Models;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Events;
|
||||
using ModernKeePass.Models;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
@@ -26,12 +25,7 @@ namespace ModernKeePass.Views
|
||||
{
|
||||
private readonly IResourceProxy _resource;
|
||||
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 GroupDetailPage(): this (App.Services.GetRequiredService<IResourceProxy>(), App.Services.GetRequiredService<INavigationService>()) { }
|
||||
@@ -40,7 +34,6 @@ namespace ModernKeePass.Views
|
||||
InitializeComponent();
|
||||
_resource = resource;
|
||||
_navigation = navigation;
|
||||
NavigationHelper = new NavigationHelper(this);
|
||||
}
|
||||
|
||||
#region NavigationHelper registration
|
||||
@@ -56,18 +49,11 @@ namespace ModernKeePass.Views
|
||||
///
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
NavigationHelper.OnNavigatedTo(e);
|
||||
|
||||
var navigationItem = e.Parameter as NavigationItem;
|
||||
if (navigationItem != null)
|
||||
DataContext = new GroupDetailVm(navigationItem.Id) { IsEditMode = navigationItem.IsNew };
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
NavigationHelper.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -149,7 +135,7 @@ namespace ModernKeePass.Views
|
||||
{
|
||||
//ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
||||
await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle"));
|
||||
NavigationHelper.GoBack();
|
||||
//NavigationHelper.GoBack();
|
||||
}, null);
|
||||
}
|
||||
|
||||
|
@@ -10,20 +10,17 @@
|
||||
x:Name="PageRoot"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource
|
||||
x:Name="MenuItemsSource"
|
||||
Source="{Binding MainMenuItems}"
|
||||
IsSourceGrouped="True" />
|
||||
<viewModels:MainVm x:Key="ViewModel"/>
|
||||
</Page.Resources>
|
||||
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</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>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition/>
|
||||
|
@@ -13,8 +13,8 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class MainPage
|
||||
{
|
||||
public new MainVm Model => (MainVm)DataContext;
|
||||
|
||||
private new MainVm Model => (MainVm)Resources["ViewModel"];
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@@ -10,16 +10,16 @@
|
||||
x:Class="ModernKeePass.Views.SettingsPage"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource x:Name="MenuItemsSource" Source="{Binding MenuItems}" IsSourceGrouped="True" />
|
||||
<viewModels:SettingsVm x:Key="ViewModel"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:SettingsVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</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>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition/>
|
||||
|
@@ -12,7 +12,7 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class SettingsPage
|
||||
{
|
||||
public new SettingsVm Model => (SettingsVm)DataContext;
|
||||
private new SettingsVm Model => (SettingsVm)Resources["ViewModel"];
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
|
@@ -14,12 +14,10 @@
|
||||
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||
<listItems:SettingsDatabaseVm x:Key="ViewModel"/>
|
||||
</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}" />
|
||||
<StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<RadioButton x:Uid="SettingsDatabaseRecycleBinCreate" GroupName="Recycle" IsChecked="{Binding IsNewRecycleBin, Mode=TwoWay}" />
|
||||
|
@@ -8,11 +8,10 @@
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding FileFormats}" />
|
||||
<listItems:SettingsNewVm x:Key="ViewModel"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<listItems:SettingsNewVm />
|
||||
</Page.DataContext>
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
||||
<TextBlock x:Uid="SettingsNewDatabaseDesc" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
||||
<ToggleSwitch x:Uid="SettingsNewDatabaseSample" IsOn="{Binding IsCreateSample, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||
<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:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||
mc:Ignorable="d">
|
||||
<Page.DataContext>
|
||||
<listItems:SettingsSaveVm />
|
||||
</Page.DataContext>
|
||||
<Page.Resources>
|
||||
<listItems:SettingsSaveVm x:Name="ViewModel"/>
|
||||
</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="SettingsSaveDatabaseSuspendDesc" TextWrapping="WrapWholeWords" Margin="5,0,0,10"/>
|
||||
<ToggleSwitch x:Uid="SettingsSaveDatabaseSuspend" IsOn="{Binding IsSaveSuspend, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||
|
@@ -49,14 +49,14 @@
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</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">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuMoveButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</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">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuRestoreButton" />
|
||||
@@ -96,8 +96,8 @@
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
||||
<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="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_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}" />
|
||||
<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="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||
|
@@ -139,19 +139,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
typeof(bool),
|
||||
typeof(TopMenuUserControl),
|
||||
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
|
||||
{
|
||||
get { return (bool)GetValue(IsEditButtonCheckedProperty); }
|
||||
@@ -166,8 +154,6 @@ namespace ModernKeePass.Views.UserControls
|
||||
|
||||
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
||||
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
||||
public event EventHandler<RoutedEventArgs> MoveButtonClick;
|
||||
public event EventHandler<RoutedEventArgs> RestoreButtonClick;
|
||||
|
||||
public TopMenuUserControl()
|
||||
{
|
||||
@@ -191,15 +177,6 @@ namespace ModernKeePass.Views.UserControls
|
||||
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)
|
||||
{
|
||||
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
||||
|
Reference in New Issue
Block a user