mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Creating groups and entries now navigates to the related detail page, in edit mode
Code cleanup
This commit is contained in:
@@ -63,13 +63,15 @@
|
|||||||
AutomationProperties.ItemType="Navigation Button"/>
|
AutomationProperties.ItemType="Navigation Button"/>
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
|
x:Name="TitleTextBox"
|
||||||
Text="{Binding Title, Mode=TwoWay}"
|
Text="{Binding Title, Mode=TwoWay}"
|
||||||
Style="{StaticResource HeaderTextBoxStyle}"
|
Style="{StaticResource HeaderTextBoxStyle}"
|
||||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||||
IsHitTestVisible="{Binding IsEditMode}"
|
IsHitTestVisible="{Binding IsEditMode}"
|
||||||
TextWrapping="NoWrap"
|
TextWrapping="NoWrap"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="0,0,30,0"/>
|
Margin="0,0,30,0"
|
||||||
|
PlaceholderText="New entry name..."/>
|
||||||
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
|
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
|
||||||
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}" />
|
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}" />
|
||||||
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />
|
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Windows.UI.Core;
|
||||||
using Windows.UI.Popups;
|
using Windows.UI.Popups;
|
||||||
using ModernKeePass.Common;
|
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
// Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232
|
// Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232
|
||||||
@@ -18,6 +20,8 @@ namespace ModernKeePass.Pages
|
|||||||
{
|
{
|
||||||
private NavigationHelper navigationHelper;
|
private NavigationHelper navigationHelper;
|
||||||
|
|
||||||
|
public EntryVm Model => (EntryVm) DataContext;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
|
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
|
||||||
/// gestion de la durée de vie des processus
|
/// gestion de la durée de vie des processus
|
||||||
@@ -58,10 +62,12 @@ namespace ModernKeePass.Pages
|
|||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
navigationHelper.OnNavigatedTo(e);
|
navigationHelper.OnNavigatedTo(e);
|
||||||
if (e.Parameter is EntryVm)
|
if (!(e.Parameter is EntryVm)) return;
|
||||||
{
|
DataContext = (EntryVm)e.Parameter;
|
||||||
DataContext = e.Parameter as EntryVm;
|
if (Model.IsEditMode)
|
||||||
}
|
Task.Factory.StartNew(
|
||||||
|
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
|
||||||
|
() => TitleTextBox.Focus(FocusState.Programmatic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
@@ -220,13 +220,15 @@
|
|||||||
AutomationProperties.ItemType="Navigation Button"/>
|
AutomationProperties.ItemType="Navigation Button"/>
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
|
x:Name="TitleTextBox"
|
||||||
Text="{Binding Name, Mode=TwoWay}"
|
Text="{Binding Name, Mode=TwoWay}"
|
||||||
Style="{StaticResource HeaderTextBoxStyle}"
|
Style="{StaticResource HeaderTextBoxStyle}"
|
||||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||||
IsHitTestVisible="{Binding IsEditMode}"
|
IsHitTestVisible="{Binding IsEditMode}"
|
||||||
TextWrapping="NoWrap"
|
TextWrapping="NoWrap"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="0,0,30,0"/>
|
Margin="0,0,30,0"
|
||||||
|
PlaceholderText="New group name..."/>
|
||||||
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
|
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
|
||||||
<AppBarButton Icon="Find" Label="Search">
|
<AppBarButton Icon="Find" Label="Search">
|
||||||
<AppBarButton.Flyout>
|
<AppBarButton.Flyout>
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Windows.Storage.Streams;
|
using Windows.Storage.Streams;
|
||||||
|
using Windows.UI.Core;
|
||||||
using Windows.UI.Popups;
|
using Windows.UI.Popups;
|
||||||
using ModernKeePass.Common;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229
|
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229
|
||||||
@@ -61,6 +64,10 @@ namespace ModernKeePass.Pages
|
|||||||
|
|
||||||
if (!(e.Parameter is GroupVm)) return;
|
if (!(e.Parameter is GroupVm)) return;
|
||||||
DataContext = (GroupVm) e.Parameter;
|
DataContext = (GroupVm) e.Parameter;
|
||||||
|
if (Model.IsEditMode)
|
||||||
|
Task.Factory.StartNew(
|
||||||
|
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
|
||||||
|
() => TitleTextBox.Focus(FocusState.Programmatic)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
@@ -75,32 +82,36 @@ namespace ModernKeePass.Pages
|
|||||||
|
|
||||||
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (LeftListView.SelectedIndex == 0)
|
GroupVm group;
|
||||||
|
switch (LeftListView.SelectedIndex)
|
||||||
{
|
{
|
||||||
var currentGroup = DataContext as GroupVm;
|
case -1:
|
||||||
currentGroup?.CreateNewGroup();
|
|
||||||
LeftListView.SelectedIndex = -1;
|
|
||||||
// TODO: Navigate to new group?
|
|
||||||
return;
|
return;
|
||||||
|
case 0:
|
||||||
|
group = Model.CreateNewGroup();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
group = LeftListView.SelectedItem as GroupVm;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
var selectedItem = LeftListView.SelectedItem as GroupVm;
|
Frame.Navigate(typeof(GroupDetailPage), group);
|
||||||
if (selectedItem == null) return;
|
|
||||||
Frame.Navigate(typeof(GroupDetailPage), selectedItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
EntryVm entry;
|
||||||
switch (GridView.SelectedIndex)
|
switch (GridView.SelectedIndex)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
return;
|
return;
|
||||||
case 0:
|
case 0:
|
||||||
Model.CreateNewEntry();
|
entry = Model.CreateNewEntry();
|
||||||
GridView.SelectedIndex = -1;
|
break;
|
||||||
// TODO: Navigate to new entry?
|
default:
|
||||||
return;
|
entry = GridView.SelectedItem as EntryVm;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Frame.Navigate(typeof(EntryDetailPage), GridView.SelectedItem as EntryVm);
|
Frame.Navigate(typeof(EntryDetailPage), entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void DeleteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
private async void DeleteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||||
@@ -128,6 +139,7 @@ namespace ModernKeePass.Pages
|
|||||||
|
|
||||||
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
|
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// We need to synchronize the two lists (zoomed-in and zoomed-out) because the source is different
|
||||||
if (e.IsSourceZoomedInView == false)
|
if (e.IsSourceZoomedInView == false)
|
||||||
{
|
{
|
||||||
e.DestinationItem.Item = e.SourceItem.Item;
|
e.DestinationItem.Item = e.SourceItem.Item;
|
||||||
|
@@ -76,18 +76,22 @@ namespace ModernKeePass.ViewModels
|
|||||||
Groups.Insert(0, new GroupVm ());
|
Groups.Insert(0, new GroupVm ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateNewGroup()
|
public GroupVm CreateNewGroup()
|
||||||
{
|
{
|
||||||
var pwGroup = new PwGroup(true, true, "New group", PwIcon.Folder);
|
var pwGroup = new PwGroup(true, true, string.Empty, PwIcon.Folder);
|
||||||
_pwGroup.AddGroup(pwGroup, true);
|
_pwGroup.AddGroup(pwGroup, true);
|
||||||
Groups.Add(new GroupVm(pwGroup, this));
|
var newGroup = new GroupVm(pwGroup, this) {IsEditMode = true};
|
||||||
|
Groups.Add(newGroup);
|
||||||
|
return newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateNewEntry()
|
public EntryVm CreateNewEntry()
|
||||||
{
|
{
|
||||||
var pwEntry = new PwEntry(true, true);
|
var pwEntry = new PwEntry(true, true);
|
||||||
_pwGroup.AddEntry(pwEntry, true);
|
_pwGroup.AddEntry(pwEntry, true);
|
||||||
Entries.Add(new EntryVm(pwEntry, this));
|
var newEntry = new EntryVm(pwEntry, this) {IsEditMode = true};
|
||||||
|
Entries.Add(newEntry);
|
||||||
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveGroup()
|
public void RemoveGroup()
|
||||||
|
Reference in New Issue
Block a user