mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Implement add and delete entries and groups
New command bar Some layout changes Some refactoring
This commit is contained in:
@@ -48,15 +48,20 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
|
||||
<Button Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
VerticalAlignment="Top"
|
||||
AutomationProperties.Name="Back"
|
||||
AutomationProperties.AutomationId="BackButton"
|
||||
AutomationProperties.ItemType="Navigation Button"/>
|
||||
<TextBlock x:Name="pageTitle" Text="{Binding Title}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
||||
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
|
||||
<CommandBar Grid.Column="2" Margin="0,40,0,0" Background="Transparent" IsOpen="True">
|
||||
<AppBarButton Icon="Edit" Label="Edit" />
|
||||
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />
|
||||
</CommandBar>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
@@ -83,5 +83,12 @@ namespace ModernKeePass.Pages
|
||||
passwordBox.Visibility = Visibility.Visible;
|
||||
passwordTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void AppBarButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var entry = DataContext as EntryVm;
|
||||
entry?.RemoveEntry();
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,29 +1,27 @@
|
||||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:ModernKeePass.Pages"
|
||||
xmlns:common="using:ModernKeePass.Common"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ViewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:Converters="using:ModernKeePass.Converters"
|
||||
x:Name="pageRoot"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
x:Name="PageRoot"
|
||||
x:Class="ModernKeePass.Pages.GroupDetailPage"
|
||||
mc:Ignorable="d" >
|
||||
<Page.Resources>
|
||||
<Converters:PluralizationConverter x:Key="PluralizationConverter"/>
|
||||
<converters:PluralizationConverter x:Key="PluralizationConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<ViewModels:GroupVm />
|
||||
<viewModels:GroupVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<CollectionViewSource
|
||||
x:Name="groupsViewSource"
|
||||
x:Name="GroupsViewSource"
|
||||
Source="{Binding Groups}"/>
|
||||
<CollectionViewSource
|
||||
x:Name="entriesViewSource"
|
||||
x:Name="EntriesViewSource"
|
||||
Source="{Binding Entries}"/>
|
||||
</Grid.Resources>
|
||||
<Grid.ChildrenTransitions>
|
||||
@@ -36,88 +34,116 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Horizontal scrolling grid -->
|
||||
<GridView
|
||||
x:Name="groupsGridView"
|
||||
AutomationProperties.AutomationId="ItemGridView"
|
||||
AutomationProperties.Name="Groups"
|
||||
<SemanticZoom
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
TabIndex="1"
|
||||
Grid.RowSpan="2"
|
||||
Padding="120,126,120,50"
|
||||
ItemsSource="{Binding Source={StaticResource groupsViewSource}}"
|
||||
IsSwipeEnabled="false"
|
||||
SelectionChanged="groupsGridView_SelectionChanged"
|
||||
IsSynchronizedWithCurrentItem="False" >
|
||||
<GridView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderThickness="2" BorderBrush="DimGray" Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,10,0,0" >
|
||||
<Grid Height="110" Width="480" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" />
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
|
||||
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60"/>
|
||||
<TextBlock Text="{Binding GroupCount, ConverterParameter=group\,groups, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</GridView.ItemTemplate>
|
||||
<GridView.Header>
|
||||
<ListView
|
||||
x:Name="entriesListView"
|
||||
Height="auto"
|
||||
Width="480"
|
||||
ItemsSource="{Binding Source={StaticResource entriesViewSource}}"
|
||||
Margin="10,0,0,0"
|
||||
SelectionChanged="entriesListView_SelectionChanged"
|
||||
Padding="20,126,20,50">
|
||||
<SemanticZoom.ZoomedInView>
|
||||
<GridView
|
||||
AutomationProperties.AutomationId="ItemGridView"
|
||||
AutomationProperties.Name="Groups"
|
||||
TabIndex="1"
|
||||
ItemsSource="{Binding Source={StaticResource GroupsViewSource}}"
|
||||
IsSwipeEnabled="false"
|
||||
SelectionChanged="groups_SelectionChanged"
|
||||
IsSynchronizedWithCurrentItem="False" >
|
||||
<GridView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border
|
||||
BorderThickness="2"
|
||||
BorderBrush="DimGray"
|
||||
Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
||||
Margin="0,10,0,0" >
|
||||
<Grid Height="110" Width="480" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" />
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0" Visibility="{Binding DetailsVisibility}" >
|
||||
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||
<TextBlock Text="{Binding GroupCount, ConverterParameter=group\,groups, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" Visibility="{Binding NewVisibility}" VerticalAlignment="Center" Margin="13,0,0,5"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</GridView.ItemTemplate>
|
||||
<GridView.Header>
|
||||
<ListView
|
||||
Height="auto"
|
||||
Width="480"
|
||||
ItemsSource="{Binding Source={StaticResource EntriesViewSource}}"
|
||||
Margin="10,0,0,0"
|
||||
SelectionChanged="entriesListView_SelectionChanged"
|
||||
IsSwipeEnabled="false"
|
||||
IsSynchronizedWithCurrentItem="False" >
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Background="{Binding BackgroundColor}">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" />
|
||||
<TextBlock Text="{Binding Title}" FontWeight="{Binding FontWeight}" TextWrapping="NoWrap" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Foreground="{Binding ForegroundColor}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" FontSize="20" Margin="0,20,0,20" />
|
||||
</DataTemplate>
|
||||
</ListView.HeaderTemplate>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</GridView.Header>
|
||||
<GridView.ItemContainerStyle>
|
||||
<Style TargetType="FrameworkElement">
|
||||
<Setter Property="Margin" Value="52,0,0,2"/>
|
||||
</Style>
|
||||
</GridView.ItemContainerStyle>
|
||||
</GridView>
|
||||
</SemanticZoom.ZoomedInView>
|
||||
|
||||
<SemanticZoom.ZoomedOutView>
|
||||
<ListView
|
||||
ItemsSource="{Binding Source={StaticResource GroupsViewSource}}"
|
||||
IsSwipeEnabled="false"
|
||||
SelectionChanged="groups_SelectionChanged"
|
||||
IsSynchronizedWithCurrentItem="False" >
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Background="{Binding BackgroundColor}">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,10" Foreground="{Binding ForegroundColor}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="Entries" FontSize="20" Margin="0,20,0,20" />
|
||||
</DataTemplate>
|
||||
</ListView.HeaderTemplate>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</GridView.Header>
|
||||
<GridView.ItemContainerStyle>
|
||||
<Style TargetType="FrameworkElement">
|
||||
<Setter Property="Margin" Value="52,0,0,2"/>
|
||||
</Style>
|
||||
</GridView.ItemContainerStyle>
|
||||
</GridView>
|
||||
</SemanticZoom.ZoomedOutView>
|
||||
</SemanticZoom>
|
||||
|
||||
|
||||
<!-- Back button and page title -->
|
||||
<Grid>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
|
||||
<Button Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
VerticalAlignment="Top"
|
||||
AutomationProperties.Name="Back"
|
||||
AutomationProperties.AutomationId="BackButton"
|
||||
AutomationProperties.ItemType="Navigation Button"/>
|
||||
<TextBlock x:Name="pageTitle" Text="{Binding Name}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
||||
<TextBlock Text="{Binding Name}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
||||
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
|
||||
<CommandBar Grid.Column="2" Margin="0,40,0,0" Background="Transparent" IsOpen="True">
|
||||
<AppBarButton Icon="Edit" Label="Edit" />
|
||||
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="AppBarButton_Click" />
|
||||
</CommandBar>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
@@ -14,20 +14,18 @@ namespace ModernKeePass.Pages
|
||||
/// </summary>
|
||||
public sealed partial class GroupDetailPage : Page
|
||||
{
|
||||
private NavigationHelper navigationHelper;
|
||||
|
||||
/// <summary>
|
||||
/// NavigationHelper is used on each page to aid in navigation and
|
||||
/// process lifetime management
|
||||
/// </summary>
|
||||
public NavigationHelper NavigationHelper => navigationHelper;
|
||||
public NavigationHelper NavigationHelper { get; }
|
||||
|
||||
|
||||
public GroupDetailPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
navigationHelper = new NavigationHelper(this);
|
||||
navigationHelper.LoadState += navigationHelper_LoadState;
|
||||
NavigationHelper = new NavigationHelper(this);
|
||||
NavigationHelper.LoadState += navigationHelper_LoadState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +56,7 @@ namespace ModernKeePass.Pages
|
||||
///
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedTo(e);
|
||||
NavigationHelper.OnNavigatedTo(e);
|
||||
|
||||
if (!(e.Parameter is GroupVm)) return;
|
||||
DataContext = (GroupVm) e.Parameter;
|
||||
@@ -66,22 +64,53 @@ namespace ModernKeePass.Pages
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
navigationHelper.OnNavigatedFrom(e);
|
||||
NavigationHelper.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void groupsGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var gridView = sender as GridView;
|
||||
Frame.Navigate(typeof(GroupDetailPage), gridView?.SelectedItem as GroupVm);
|
||||
GroupVm selectedItem = null;
|
||||
if (sender is GridView)
|
||||
{
|
||||
var gridView = (GridView) sender;
|
||||
if (gridView.SelectedIndex == 0)
|
||||
{
|
||||
var currentGroup = DataContext as GroupVm;
|
||||
currentGroup?.CreateNewGroup();
|
||||
gridView.SelectedIndex = -1;
|
||||
// TODO: Navigate to new group?
|
||||
return;
|
||||
}
|
||||
selectedItem = gridView.SelectedItem as GroupVm;
|
||||
}
|
||||
if (sender is ListView) selectedItem = ((ListView) sender).SelectedItem as GroupVm;
|
||||
if (selectedItem == null) return;
|
||||
Frame.Navigate(typeof(GroupDetailPage), selectedItem);
|
||||
}
|
||||
|
||||
|
||||
private void entriesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var listView = sender as ListView;
|
||||
if (listView != null && listView.SelectedIndex == -1) return;
|
||||
if (listView.SelectedIndex == 0)
|
||||
{
|
||||
var currentGroup = DataContext as GroupVm;
|
||||
currentGroup?.CreateNewEntry();
|
||||
listView.SelectedIndex = -1;
|
||||
// TODO: Navigate to new entry?
|
||||
return;
|
||||
}
|
||||
Frame.Navigate(typeof(EntryDetailPage), listView?.SelectedItem as EntryVm);
|
||||
}
|
||||
|
||||
private void AppBarButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
var group = DataContext as GroupVm;
|
||||
group?.RemoveGroup();
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,13 +54,7 @@ namespace ModernKeePass.Pages
|
||||
private void AddToRecentFiles(StorageFile file)
|
||||
{
|
||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||
var mruToken = mru.Add(file, file.DisplayName);
|
||||
|
||||
/*var localSettings = ApplicationData.Current.LocalSettings;
|
||||
if (!localSettings.Containers.ContainsKey("Recent"))
|
||||
localSettings.CreateContainer("Recent", ApplicationDataCreateDisposition.Always);
|
||||
|
||||
localSettings.Containers["Recent"].Values[file.DisplayName] = mruToken;*/
|
||||
mru.Add(file, file.DisplayName);
|
||||
}
|
||||
|
||||
private void ShowPassword(StorageFile file)
|
||||
|
Reference in New Issue
Block a user