mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP Windows 10
Dependencies finally installed Removal of useless code Big cleanup in XAML styles (override colors the correct way)
This commit is contained in:
267
Win10App/Views/EntriesPage.xaml
Normal file
267
Win10App/Views/EntriesPage.xaml
Normal file
@@ -0,0 +1,267 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.EntriesPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Entries}">
|
||||
|
||||
<Page.Resources>
|
||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter" />
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToForegroundBrushComplexityConverter" />
|
||||
</Page.Resources>
|
||||
|
||||
<controls:MasterDetailsView
|
||||
x:Name="MasterDetailList"
|
||||
Style="{StaticResource ReorderMasterDetailsView}"
|
||||
ItemsSource="{x:Bind Model.Entries, Mode=OneWay}"
|
||||
CompactModeThresholdWidth="720"
|
||||
SelectedItem="{x:Bind Model.SelectedEntry, Mode=OneWay}">
|
||||
<controls:MasterDetailsView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style>
|
||||
</controls:MasterDetailsView.ItemContainerStyle>
|
||||
<controls:MasterDetailsView.ItemTemplate>
|
||||
<DataTemplate x:DataType="listItems:EntryItemVm">
|
||||
<Grid x:Name="EntryGrid" Padding="12,0,12,0" Background="{Binding BackgroundColor, ConverterParameter={StaticResource SystemControlPageBackgroundTransparentBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon Grid.Column="0" Symbol="{x:Bind Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=0}" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseMediumBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}" />
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="15">
|
||||
<TextBlock Text="{x:Bind Name, Mode=OneWay}" TextWrapping="NoWrap" FontWeight="SemiBold" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseMediumBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}" />
|
||||
<TextBlock Text="{x:Bind UserName, Mode=OneWay}" MaxHeight="60" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseMediumBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}" />
|
||||
<TextBlock Text="{x:Bind Url, Mode=OneWay}" MaxHeight="60" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseMediumBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem x:Uid="EntryItemCopyLogin" Icon="Page2">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:ClipboardAction Text="{x:Bind UserName, Mode=OneWay}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyLogin" Title="{x:Bind Name, Mode=OneWay}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutItem x:Uid="EntryItemCopyPassword" Icon=" ProtectedDocument">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:ClipboardAction Text="{x:Bind Password, Mode=OneWay}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyPassword" Title="{x:Bind Name, Mode=OneWay}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutItem x:Uid="EntryItemCopyUrl" Icon="OpenFile" IsEnabled="{x:Bind HasUrl, Mode=OneWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:NavigateToUrlAction Url="{x:Bind Url, Mode=OneWay}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyUrl" Title="{x:Bind Name, Mode=OneWay}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutSeparator />
|
||||
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" Icon="Delete" Click="DeleteFlyoutItem_OnClick" />
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</controls:MasterDetailsView.ItemTemplate>
|
||||
<controls:MasterDetailsView.MasterCommandBar>
|
||||
<CommandBar
|
||||
DefaultLabelPosition="Right"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
HorizontalAlignment="Stretch"
|
||||
FontFamily="Segoe UI">
|
||||
<AppBarToggleButton x:Name="AddEntryButton" x:Uid="AppBarAddEntry" Icon="Add">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Checked">
|
||||
<!--<core:ChangePropertyAction TargetObject="{Binding ElementName=AddEntryButton}" PropertyName="IsEnabled" Value="False" />-->
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=NewEntryNameTextBox}" PropertyName="Visibility" Value="Visible" />
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=NewEntryNameTextBox}" />
|
||||
</core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="Unchecked">
|
||||
<!--<core:ChangePropertyAction TargetObject="{Binding ElementName=AddEntryButton}" PropertyName="IsEnabled" Value="False" />-->
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=NewEntryNameTextBox}" PropertyName="Visibility" Value="Collapsed" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarToggleButton>
|
||||
</CommandBar>
|
||||
</controls:MasterDetailsView.MasterCommandBar>
|
||||
<controls:MasterDetailsView.MasterHeader>
|
||||
<TextBox x:Name="NewEntryNameTextBox" Visibility="Collapsed" KeyUp="NewEntryNameTextBox_OnKeyDown" />
|
||||
</controls:MasterDetailsView.MasterHeader>
|
||||
<controls:MasterDetailsView.DetailsTemplate>
|
||||
<DataTemplate x:DataType="listItems:EntryItemVm">
|
||||
<!--<Frame x:Name="ContentFrame" SourcePageType="pages:EntryPage" />-->
|
||||
|
||||
<Pivot>
|
||||
<Pivot.TitleTemplate>
|
||||
<DataTemplate x:DataType="listItems:EntryItemVm">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Pivot.TitleTemplate>
|
||||
<PivotItem x:Uid="EntryPivotItemMain" Margin="0">
|
||||
<Grid Background="White">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="20">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
</Style>
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
</Style>
|
||||
<Style TargetType="TextBox" x:Key="EntryTextBoxWithButtonStyle">
|
||||
<Setter Property="Width" Value="350"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock x:Uid="EntryLogin" />
|
||||
<TextBox Text="{x:Bind UserName, Mode=TwoWay}" Style="{StaticResource EntryTextBoxWithButtonStyle}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{x:Bind UserName}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyLogin" Title="{x:Bind Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock x:Uid="EntryPassword" />
|
||||
<PasswordBox x:Name="Password"
|
||||
HorizontalAlignment="Left"
|
||||
Password="{x:Bind Password, Mode=TwoWay}"
|
||||
Width="350"
|
||||
Height="32"
|
||||
PasswordRevealMode="Hidden">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{x:Bind Password}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyPassword" Title="{x:Bind Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<ProgressBar
|
||||
Maximum="128"
|
||||
Width="350"
|
||||
HorizontalAlignment="Left"
|
||||
Value="{x:Bind PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}"
|
||||
Foreground="{x:Bind PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroundBrushComplexityConverter}}" />
|
||||
<CheckBox x:Uid="EntryShowPassword" HorizontalAlignment="Left" Margin="0">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Checked">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=Password}" PropertyName="PasswordRevealMode" Value="Visible" />
|
||||
</core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="Unchecked">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=Password}" PropertyName="PasswordRevealMode" Value="Hidden" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</CheckBox>
|
||||
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
|
||||
<TextBox Text="{x:Bind Url, Mode=TwoWay}" MaxLength="256" Style="{StaticResource EntryTextBoxWithButtonStyle}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:NavigateToUrlAction Url="{x:Bind Url}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock x:Uid="EntryNotes" />
|
||||
<TextBox
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="Wrap"
|
||||
Text="{x:Bind Notes, Mode=TwoWay}"
|
||||
Width="350"
|
||||
Height="200"
|
||||
AcceptsReturn="True"
|
||||
IsSpellCheckEnabled="True" />
|
||||
<CheckBox
|
||||
x:Uid="EntryExpirationDate"
|
||||
IsChecked="{x:Bind HasExpirationDate, Mode=TwoWay}" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon
|
||||
Grid.Column="0"
|
||||
Symbol="Important"
|
||||
Foreground="DarkRed"
|
||||
Visibility="{x:Bind HasExpired}">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="EntryExpirationTooltip" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<StackPanel Grid.Column="1" x:Name="ExpirationDatePanel" Visibility="{x:Bind HasExpirationDate, Mode=OneWay}">
|
||||
<DatePicker Date="{x:Bind ExpiryDate, Mode=TwoWay}" Style="{StaticResource MainColorDatePicker}" />
|
||||
<TimePicker Margin="0,10,0,0" Time="{x:Bind ExpiryTime, Mode=TwoWay}" Style="{StaticResource MainColorTimePicker}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</PivotItem>
|
||||
<PivotItem x:Uid="EntryPivotItemAdditional">
|
||||
<ItemsControl ItemsSource="{x:Bind AdditionalFields}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="{Binding Key}" />
|
||||
<TextBox Text="{Binding Value, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</PivotItem>
|
||||
<PivotItem x:Uid="EntryPivotItemHistory">
|
||||
<ListView ItemsSource="{x:Bind History}" SelectionChanged="HistoryListView_SelectionChanged" />
|
||||
</PivotItem>
|
||||
<PivotItem x:Uid="EntryPivotItemSettings">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="EntryIcon" />
|
||||
<userControls:SymbolPickerUserControl
|
||||
SelectedSymbol="{Binding IconId, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=0, Mode=TwoWay}" />
|
||||
<TextBlock x:Uid="EntryBackgroundColor" Margin="0,0,10,0" />
|
||||
<ColorPicker
|
||||
HorizontalAlignment="Left"
|
||||
ColorSpectrumShape="Ring"
|
||||
IsColorPreviewVisible="False"
|
||||
IsColorChannelTextInputVisible="False"
|
||||
IsHexInputVisible="False"
|
||||
LostFocus="ColorPickerBackground_LostFocus" />
|
||||
<TextBlock x:Uid="EntryForegroundColor" Margin="0,0,10,0" />
|
||||
<ColorPicker
|
||||
HorizontalAlignment="Left"
|
||||
ColorSpectrumShape="Ring"
|
||||
IsColorPreviewVisible="False"
|
||||
IsColorChannelTextInputVisible="False"
|
||||
IsHexInputVisible="False"
|
||||
LostFocus="ColorPickerForeground_LostFocus" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</PivotItem>
|
||||
</Pivot>
|
||||
</DataTemplate>
|
||||
</controls:MasterDetailsView.DetailsTemplate>
|
||||
</controls:MasterDetailsView>
|
||||
</Page>
|
||||
|
85
Win10App/Views/EntriesPage.xaml.cs
Normal file
85
Win10App/Views/EntriesPage.xaml.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.ViewModels;
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
// TODO: check https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlListView/cs/Samples/MasterDetailSelection
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
public partial class EntriesPage
|
||||
{
|
||||
public EntriesVm Model => (EntriesVm)DataContext;
|
||||
|
||||
public EntriesPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (e.Parameter is string groupId) await Model.Initialize(groupId);
|
||||
}
|
||||
|
||||
private async void DeleteFlyoutItem_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is MenuFlyoutItem flyout)
|
||||
{
|
||||
var item = (EntryItemVm)flyout.DataContext;
|
||||
|
||||
var deleteFileDialog = new ContentDialog
|
||||
{
|
||||
Title = $"{_resourceService.GetResourceValue("EntityDeleteActionButton")} {item.Name} ?",
|
||||
Content = _databaseService.IsRecycleBinEnabled
|
||||
? _resourceService.GetResourceValue("EntryRecyclingConfirmation")
|
||||
: _resourceService.GetResourceValue("EntryDeletingConfirmation"),
|
||||
PrimaryButtonText = _resourceService.GetResourceValue("EntityDeleteActionButton"),
|
||||
CloseButtonText = _resourceService.GetResourceValue("EntityDeleteCancelButton")
|
||||
};
|
||||
|
||||
var result = await deleteFileDialog.ShowAsync();
|
||||
|
||||
// Delete the file if the user clicked the primary button.
|
||||
// Otherwise, do nothing.
|
||||
// TODO: move this logic to the service
|
||||
if (result == ContentDialogResult.Primary)
|
||||
{
|
||||
Model.Entries.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NewEntryNameTextBox_OnKeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Enter)
|
||||
{
|
||||
e.Handled = true;
|
||||
var text = NewEntryNameTextBox.Text;
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
Model.AddNewEntry(text);
|
||||
AddEntryButton.IsChecked = false;
|
||||
}
|
||||
else if (e.Key == VirtualKey.Escape)
|
||||
{
|
||||
AddEntryButton.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorPickerBackground_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is ColorPicker colorPicker) ((EntryItemVm) colorPicker.DataContext).BackgroundColor = colorPicker.Color;
|
||||
}
|
||||
private void ColorPickerForeground_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is ColorPicker colorPicker) ((EntryItemVm) colorPicker.DataContext).ForegroundColor = colorPicker.Color;
|
||||
}
|
||||
|
||||
private void HistoryListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
168
Win10App/Views/EntryPage.xaml
Normal file
168
Win10App/Views/EntryPage.xaml
Normal file
@@ -0,0 +1,168 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.EntryPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Page.Resources>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter" />
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToForegroungBrushComplexityConverter" />
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter" />
|
||||
<converters:IconToSymbolConverter x:Key="IntToSymbolConverter" />
|
||||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
<Pivot>
|
||||
<Pivot.TitleTemplate>
|
||||
<DataTemplate x:DataType="listItems:EntryItemVm">
|
||||
<Grid>
|
||||
<TextBlock Text="{x:Bind Name}" Style="{ThemeResource HeaderTextBlockStyle}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Pivot.TitleTemplate>
|
||||
<PivotItem Header="Main" Margin="0">
|
||||
<Grid Background="White">
|
||||
<RelativePanel>
|
||||
<StackPanel Margin="20">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
</Style>
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
</Style>
|
||||
<Style TargetType="TextBox" x:Key="EntryTextBoxWithButtonStyle">
|
||||
<Setter Property="Width" Value="350"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock x:Uid="EntryLogin" />
|
||||
<TextBox
|
||||
Text="{x:Bind Vm.UserName, Mode=TwoWay}"
|
||||
Style="{StaticResource EntryTextBoxWithButtonStyle}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{x:Bind Vm.UserName}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyLogin" Title="{x:Bind Vm.Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock x:Uid="EntryPassword" />
|
||||
<PasswordBox x:Name="Password"
|
||||
HorizontalAlignment="Left"
|
||||
Password="{x:Bind Vm.Password, Mode=TwoWay}"
|
||||
Width="350"
|
||||
Height="32"
|
||||
PasswordRevealMode="Hidden">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{x:Bind Vm.Password}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyPassword" Title="{x:Bind Vm.Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<ProgressBar
|
||||
Maximum="128"
|
||||
Width="350"
|
||||
HorizontalAlignment="Left"
|
||||
Value="{x:Bind Vm.PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}, Mode=OneWay}"
|
||||
Foreground="{x:Bind Vm.PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}, Mode=OneWay}" />
|
||||
<CheckBox
|
||||
x:Uid="EntryShowPassword"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Checked">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=Password}" PropertyName="PasswordRevealMode" Value="Visible" />
|
||||
</core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="Unchecked">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=Password}" PropertyName="PasswordRevealMode" Value="Hidden" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</CheckBox>
|
||||
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
|
||||
<TextBox
|
||||
Text="{x:Bind Vm.Url, Mode=TwoWay}"
|
||||
MaxLength="256"
|
||||
Style="{StaticResource EntryTextBoxWithButtonStyle}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:NavigateToUrlAction Url="{x:Bind Vm.Url}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<TextBlock x:Uid="EntryNotes" />
|
||||
<TextBox
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="Wrap"
|
||||
Text="{x:Bind Vm.Notes, Mode=TwoWay}"
|
||||
Width="350"
|
||||
Height="200"
|
||||
AcceptsReturn="True"
|
||||
IsSpellCheckEnabled="True" />
|
||||
<CheckBox
|
||||
x:Uid="EntryExpirationDate"
|
||||
IsChecked="{x:Bind Vm.HasExpirationDate, Mode=TwoWay}" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon
|
||||
Grid.Column="0"
|
||||
Symbol="Important"
|
||||
Foreground="DarkRed"
|
||||
Visibility="{x:Bind Vm.HasExpired}">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="EntryExpirationTooltip" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
x:Name="ExpirationDatePanel"
|
||||
Visibility="{x:Bind Vm.HasExpirationDate, Mode=OneWay}">
|
||||
<DatePicker
|
||||
Date="{x:Bind Vm.ExpiryDate, Mode=TwoWay}"
|
||||
Style="{StaticResource MainColorDatePicker}" />
|
||||
<TimePicker
|
||||
Margin="0,10,0,0"
|
||||
Time="{x:Bind Vm.ExpiryTime, Mode=TwoWay}"
|
||||
Style="{StaticResource MainColorTimePicker}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</RelativePanel>
|
||||
</Grid>
|
||||
</PivotItem>
|
||||
<PivotItem Header="Additional">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="EntryIcon" />
|
||||
<userControls:SymbolPickerUserControl
|
||||
SelectedSymbol="{x:Bind Vm.Icon, Converter={StaticResource IntToSymbolConverter}, ConverterParameter=0, Mode=TwoWay}" />
|
||||
<TextBlock x:Uid="EntryBackgroundColor" />
|
||||
<userControls:ColorPickerUserControl
|
||||
HorizontalAlignment="Left"
|
||||
SelectedColor="{x:Bind Vm.BackgroundColor, Converter={StaticResource ColorToBrushConverter}, Mode=TwoWay}" />
|
||||
<TextBlock x:Uid="EntryForegroundColor" />
|
||||
<userControls:ColorPickerUserControl
|
||||
SelectedColor="{x:Bind Vm.ForegroundColor, Converter={StaticResource ColorToBrushConverter}, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</PivotItem>
|
||||
<PivotItem Header="History" />
|
||||
</Pivot>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
21
Win10App/Views/EntryPage.xaml.cs
Normal file
21
Win10App/Views/EntryPage.xaml.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
public partial class EntryPage
|
||||
{
|
||||
public EntryItemVm Vm { get; set; }
|
||||
|
||||
public EntryPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
if (e.Parameter is EntryItemVm entry) Vm = entry;
|
||||
}
|
||||
}
|
||||
}
|
249
Win10App/Views/GroupsPage.xaml
Normal file
249
Win10App/Views/GroupsPage.xaml
Normal file
@@ -0,0 +1,249 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.GroupsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Page.Resources>
|
||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||
</Page.Resources>
|
||||
|
||||
<!-- SplitView -->
|
||||
<SplitView x:Name="SplitView"
|
||||
CompactPaneLength="{StaticResource MenuSize}"
|
||||
OpenPaneLength="320"
|
||||
IsPaneOpen="True"
|
||||
FontFamily="Segoe UI">
|
||||
<SplitView.Pane>
|
||||
<Grid x:Name="SplitViewPane">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid
|
||||
x:Name="TopButtonsBorder"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
BorderThickness="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
IsEnabled="{x:Bind Frame.CanGoBack}"
|
||||
Margin="0"
|
||||
BorderThickness="0"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
Click="BackButton_OnClick" />
|
||||
<TextBox x:Name="NewGroupNameTextBox"
|
||||
Grid.Column="1"
|
||||
Visibility="Visible"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{x:Bind Vm.NewGroupName, Mode=TwoWay}"
|
||||
Height="30"
|
||||
Width="230"
|
||||
KeyUp="NewGroupNameTextBox_KeyDown"
|
||||
LostFocus="NewGroupNameTextBox_LostFocus" />
|
||||
<Button x:Name="AddButton"
|
||||
Grid.Column="2"
|
||||
Margin="0"
|
||||
Width="{StaticResource MenuSize}"
|
||||
Height="{StaticResource MenuSize}"
|
||||
Background="Transparent"
|
||||
VerticalAlignment="Top"
|
||||
BorderThickness="0"
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
Content="">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=NewGroupNameTextBox}" PropertyName="Visibility" Value="Visible"/>
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=AddButton}" PropertyName="IsEnabled" Value="False"/>
|
||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=NewEntryNameTextBox}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
BorderThickness="0">
|
||||
<AutoSuggestBox
|
||||
x:Name="AutoSuggestBox"
|
||||
x:Uid="GroupSearch"
|
||||
Width="250"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
QueryIcon="Find"
|
||||
TextMemberPath="Name"
|
||||
TextChanged="AutoSuggestBox_TextChanged"
|
||||
QuerySubmitted="AutoSuggestBox_QuerySubmitted">
|
||||
<AutoSuggestBox.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style>
|
||||
</AutoSuggestBox.ItemContainerStyle>
|
||||
<AutoSuggestBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="listItems:EntryItemVm">
|
||||
<Grid x:Name="EntryGrid" Padding="12,0,12,0" Background="{Binding BackgroundColor, ConverterParameter={StaticResource SystemControlPageBackgroundTransparentBrush}, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<SymbolIcon Grid.Column="0" Symbol="{x:Bind Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=0}" Foreground="{StaticResource SystemControlPageTextBaseHighBrush}" />
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="15">
|
||||
<TextBlock Text="{Binding Name}" TextWrapping="NoWrap" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseHighBrush}, Converter={StaticResource ColorToBrushConverter}}"/>
|
||||
<TextBlock Text="{x:Bind Parent.Text}" Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource SystemControlPageTextBaseMediumBrush}, Converter={StaticResource ColorToBrushConverter}}" MaxHeight="60" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</AutoSuggestBox.ItemTemplate>
|
||||
</AutoSuggestBox>
|
||||
</Grid>
|
||||
|
||||
<!-- Navigation Tree -->
|
||||
<TreeView x:Name="NavigationTree"
|
||||
Grid.Row="2"
|
||||
ItemsSource="{x:Bind Vm.RootItemVm.Children}"
|
||||
ItemInvoked="NavigationTree_OnItemInvoked">
|
||||
<TreeView.ItemTemplate>
|
||||
<DataTemplate x:DataType="listItems:GroupItemVm">
|
||||
<TreeViewItem ItemsSource="{x:Bind Children}">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Visibility="{x:Bind IsEditMode, Mode=OneWay, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{x:Bind Symbol, Converter={StaticResource IconToSymbolConverter}}" />
|
||||
<TextBlock x:Name="GroupName" Text="{x:Bind Text, Mode=OneWay}" Width="200" Margin="10,0,0,0" />
|
||||
<StackPanel.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" Icon="Delete" Click="DeleteFlyoutItem_OnClick" />
|
||||
<MenuFlyoutItem x:Uid="TopMenuRenameFlyout" Click="RenameFlyoutItem_OnClick" />
|
||||
</MenuFlyout>
|
||||
</StackPanel.ContextFlyout>
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
Text="{x:Bind Text, Mode=TwoWay}"
|
||||
Visibility="{x:Bind IsEditMode, Mode=OneWay}"
|
||||
Width="200"
|
||||
KeyDown="GroupNameTextBox_KeyDown"
|
||||
LostFocus="GroupNameTextBox_OnLostFocus" />
|
||||
</Grid>
|
||||
</TreeViewItem>
|
||||
</DataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
<CommandBar DefaultLabelPosition="Right"
|
||||
Grid.Row="3"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="Segoe UI">
|
||||
<AppBarButton x:Uid="AppBarHome" Icon="Home">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.MainPage10" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton x:Uid="AppBarSettings" Icon="Setting">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.SettingsPage10" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
</CommandBar>
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
<SplitView.Content>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Button Margin="0"
|
||||
Height="{StaticResource MenuSize}"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="HamburgerButton_OnClick">
|
||||
<StackPanel Orientation="Horizontal" Margin="5,0,0,0">
|
||||
<FontIcon x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Glyph="" />
|
||||
<TextBlock Text="{x:Bind Vm.Title, Mode=OneWay}" FontFamily="Segoe UI" FontWeight="Bold" Margin="20,0,0,0" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<!-- Navigation Frame -->
|
||||
<Frame x:Name="SplitViewFrame"
|
||||
Padding="0"
|
||||
FontFamily="Segoe UI">
|
||||
<Frame.ContentTransitions>
|
||||
<TransitionCollection>
|
||||
<NavigationThemeTransition>
|
||||
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
|
||||
<DrillInNavigationTransitionInfo />
|
||||
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
|
||||
</NavigationThemeTransition>
|
||||
</TransitionCollection>
|
||||
</Frame.ContentTransitions>
|
||||
</Frame>
|
||||
</StackPanel>
|
||||
</SplitView.Content>
|
||||
|
||||
<!-- Responsive Visual States -->
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
|
||||
<!-- VisualState to be triggered when window width is >=1007 effective pixels -->
|
||||
<VisualState x:Name="Expanded">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="720" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="HamburgerButton.Visibility" Value="Collapsed" />
|
||||
<Setter Target="SplitView.DisplayMode" Value="Inline" />
|
||||
<Setter Target="SplitViewPane.Background" Value="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" />
|
||||
<Setter Target="TopButtonsBorder.Background" Value="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<!-- VisualState to be triggered when window width is >=640 and <=1007 effective pixels -->
|
||||
<!-- Skipped -->
|
||||
<!--<VisualState x:Name="Compact">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="641" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="SplitView.DisplayMode"
|
||||
Value="CompactOverlay" />
|
||||
<Setter Target="SplitView.IsPaneOpen"
|
||||
Value="False" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>-->
|
||||
|
||||
<!-- VisualState to be triggered when window width is >=0 and <641 effective pixels -->
|
||||
<VisualState x:Name="Minimal">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="0" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="HamburgerButton.Visibility" Value="Visible" />
|
||||
<Setter Target="SplitView.DisplayMode" Value="CompactInline" />
|
||||
<Setter Target="SplitViewPane.Background" Value="{ThemeResource SystemControlChromeHighAcrylicElementMediumBrush}" />
|
||||
<Setter Target="TopButtonsBorder.Background" Value="Transparent" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</SplitView>
|
||||
</Page>
|
194
Win10App/Views/GroupsPage.xaml.cs
Normal file
194
Win10App/Views/GroupsPage.xaml.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Autofac;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
public partial class GroupsPage
|
||||
{
|
||||
private readonly IDatabaseService _databaseService;
|
||||
private readonly IResourceService _resourceService;
|
||||
|
||||
public GroupsVm Vm { get; set; }
|
||||
|
||||
public GroupsPage(): this(App.Container.Resolve<IDatabaseService>(), App.Container.Resolve<IResourceService>())
|
||||
{ }
|
||||
|
||||
public GroupsPage(IDatabaseService databaseService, IResourceService resourceService)
|
||||
{
|
||||
InitializeComponent();
|
||||
SetTitleBar();
|
||||
_databaseService = databaseService;
|
||||
_resourceService = resourceService;
|
||||
}
|
||||
|
||||
private void SetTitleBar()
|
||||
{
|
||||
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
|
||||
//coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
|
||||
//coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged;
|
||||
coreTitleBar.ExtendViewIntoTitleBar = false;
|
||||
//UpdateTitleBarLayout(coreTitleBar);
|
||||
|
||||
// Set XAML element as a draggable region.
|
||||
//Window.Current.SetTitleBar(AppTitleBar);
|
||||
}
|
||||
|
||||
/*private void CoreTitleBar_IsVisibleChanged(CoreApplicationViewTitleBar sender, object args) =>
|
||||
AppTitleBar.Visibility = sender.IsVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar coreTitleBar, object args) => UpdateTitleBarLayout(coreTitleBar);
|
||||
|
||||
private void UpdateTitleBarLayout(CoreApplicationViewTitleBar coreTitleBar)
|
||||
{
|
||||
// Get the size of the caption controls area and back button
|
||||
// (returned in logical pixels), and move your content around as necessary.
|
||||
LeftPaddingColumn.Width = new GridLength(coreTitleBar.SystemOverlayLeftInset);
|
||||
RightPaddingColumn.Width = new GridLength(coreTitleBar.SystemOverlayRightInset);
|
||||
//BackBorder.Margin = new Thickness(0, 0, coreTitleBar.SystemOverlayLeftInset, 0);
|
||||
AutoSuggestBox.Margin = new Thickness(0, 5, coreTitleBar.SystemOverlayRightInset, 5);
|
||||
|
||||
// Update title bar control size as needed to account for system size changes.
|
||||
//AppTitleBar.Height = coreTitleBar.Height;
|
||||
AppTitleBar.Height = 44;
|
||||
}*/
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
if (!(e.Parameter is GroupEntity group)) group = _databaseService.RootGroupEntity;
|
||||
Vm = new GroupsVm(group);
|
||||
}
|
||||
|
||||
private void HamburgerButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//SplitView.IsPaneOpen = !SplitView.IsPaneOpen;
|
||||
switch (SplitView.DisplayMode)
|
||||
{
|
||||
case SplitViewDisplayMode.Inline:
|
||||
SplitView.DisplayMode = SplitViewDisplayMode.CompactInline;
|
||||
break;
|
||||
case SplitViewDisplayMode.CompactInline:
|
||||
SplitView.DisplayMode = SplitViewDisplayMode.Inline;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void BackButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Frame.CanGoBack)
|
||||
{
|
||||
Frame.GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigationTree_OnItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs args)
|
||||
{
|
||||
if (args.InvokedItem is GroupItemVm group)
|
||||
{
|
||||
Vm.Title = group.Text;
|
||||
SplitViewFrame.Navigate(typeof(EntriesPage), group);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenameFlyoutItem_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is MenuFlyoutItem flyout) ((GroupItemVm)flyout.DataContext).IsEditMode = true;
|
||||
}
|
||||
|
||||
private async void DeleteFlyoutItem_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is MenuFlyoutItem flyout)
|
||||
{
|
||||
var item = (GroupItemVm) flyout.DataContext;
|
||||
|
||||
var deleteFileDialog = new ContentDialog
|
||||
{
|
||||
Title = $"{_resourceService.GetResourceValue("EntityDeleteActionButton")} {item.Text} ?",
|
||||
Content = _databaseService.IsRecycleBinEnabled
|
||||
? _resourceService.GetResourceValue("GroupRecyclingConfirmation")
|
||||
: _resourceService.GetResourceValue("GroupDeletingConfirmation"),
|
||||
PrimaryButtonText = _resourceService.GetResourceValue("EntityDeleteActionButton"),
|
||||
CloseButtonText = _resourceService.GetResourceValue("EntityDeleteCancelButton")
|
||||
};
|
||||
|
||||
var result = await deleteFileDialog.ShowAsync();
|
||||
|
||||
// Delete the file if the user clicked the primary button.
|
||||
// Otherwise, do nothing.
|
||||
// TODO: move this logic to the service
|
||||
if (result == ContentDialogResult.Primary)
|
||||
{
|
||||
item.ParentVm.Children.Remove(item);
|
||||
// TODO: refresh treeview
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GroupNameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Enter) GroupNameTextBox_OnLostFocus(sender, null);
|
||||
}
|
||||
|
||||
private void GroupNameTextBox_OnLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is TextBox textBox) ((GroupItemVm)textBox.DataContext).IsEditMode = false;
|
||||
}
|
||||
|
||||
private void NewGroupNameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Enter)
|
||||
{
|
||||
e.Handled = true;
|
||||
var text = ((TextBox)sender).Text;
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
Vm.AddNewGroup(text);
|
||||
AddButton.IsEnabled = true;
|
||||
NewGroupNameTextBox.Visibility = Visibility.Collapsed;
|
||||
NewGroupNameTextBox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||
{
|
||||
// Only get results when it was a user typing,
|
||||
// otherwise assume the value got filled in by TextMemberPath
|
||||
// or the handler for SuggestionChosen.
|
||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||
{
|
||||
//Set the ItemsSource to be your filtered dataset
|
||||
//sender.ItemsSource = dataset;
|
||||
sender.ItemsSource = Vm.RootItemVm.SubEntries.Where(e => e.Name.IndexOf(sender.Text, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||
{
|
||||
if (args.ChosenSuggestion != null)
|
||||
{
|
||||
// User selected an item from the suggestion list, take an action on it here.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use args.QueryText to determine what to do.
|
||||
}
|
||||
}
|
||||
|
||||
private void NewGroupNameTextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NewGroupNameTextBox.Text))
|
||||
{
|
||||
NewGroupNameTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
Win10App/Views/MainPage10.xaml
Normal file
37
Win10App/Views/MainPage10.xaml
Normal file
@@ -0,0 +1,37 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.MainPage10"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Main}">
|
||||
|
||||
<Grid>
|
||||
<Grid x:Name="AppTitleBar" Background="Transparent" />
|
||||
<controls:NavigationView
|
||||
x:Name="NavigationView"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
Header="ModernKeePass"
|
||||
PaneTitle="ModernKeePass"
|
||||
ItemInvoked="NavigationView_OnItemInvoked"
|
||||
Loaded="NavigationView_OnLoaded">
|
||||
<controls:NavigationView.MenuItems>
|
||||
<controls:NavigationViewItem x:Name="Welcome" Tag="welcome" Visibility="Collapsed" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemOpen" x:Name="Open" Icon="Page2" Tag="open" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemNew" x:Name="New" Icon="Add" Tag="new" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemSave" x:Name="Save" Icon="Save" IsEnabled="{x:Bind Model.IsDatabaseOpened, Mode=OneTime}" Tag="save" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemRecent" x:Name="Recent" Icon="Copy" Tag="recent" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemAbout" x:Name="About" Icon="Help" Tag="about" />
|
||||
<controls:NavigationViewItem x:Uid="MainMenuItemDonate" x:Name="Donate" Icon="Shop" Tag="donate" />
|
||||
<controls:NavigationViewItemSeparator/>
|
||||
<controls:NavigationViewItemHeader x:Uid="MainPageOpenedDatabasesHeader" Visibility="{x:Bind Model.IsDatabaseOpened, Mode=OneWay}"/>
|
||||
<controls:NavigationViewItem x:Name="Database" Content="{x:Bind Model.OpenedDatabaseName, Mode=OneWay}" Icon="ProtectedDocument" Visibility="{x:Bind Model.IsDatabaseOpened, Mode=OneWay}" Tag="database"/>
|
||||
</controls:NavigationView.MenuItems>
|
||||
|
||||
<Frame x:Name="ContentFrame" Margin="24"/>
|
||||
</controls:NavigationView>
|
||||
</Grid>
|
||||
</Page>
|
94
Win10App/Views/MainPage10.xaml.cs
Normal file
94
Win10App/Views/MainPage10.xaml.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using MUXC = Microsoft.UI.Xaml.Controls;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
public partial class MainPage10
|
||||
{
|
||||
private MainVm Model => (MainVm)DataContext;
|
||||
|
||||
private readonly IList<(string Tag, Type Page)> _pages = new List<(string Tag, Type Page)>
|
||||
{
|
||||
("welcome", typeof(WelcomePage)),
|
||||
("open", typeof(OpenDatabasePage)),
|
||||
("new", typeof(NewDatabasePage)),
|
||||
("save", typeof(SaveDatabasePage)),
|
||||
("recent", typeof(RecentDatabasesPage)),
|
||||
("about", typeof(AboutPage)),
|
||||
("donate", typeof(DonatePage)),
|
||||
("database", typeof(GroupsPage))
|
||||
};
|
||||
|
||||
public MainPage10()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetTitleBar();
|
||||
}
|
||||
|
||||
private void SetTitleBar()
|
||||
{
|
||||
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
|
||||
coreTitleBar.ExtendViewIntoTitleBar = true;
|
||||
Window.Current.SetTitleBar(AppTitleBar);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
Model.File = e.Parameter as StorageFile;
|
||||
}
|
||||
|
||||
private void NavigationView_OnItemInvoked(MUXC.NavigationView navigationView, MUXC.NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
if (args.IsSettingsInvoked)
|
||||
Frame.Navigate(typeof(SettingsPage10));
|
||||
else
|
||||
{
|
||||
// Getting the Tag from Content (args.InvokedItem is the content of NavigationViewItem)
|
||||
var navItem = NavigationView.MenuItems
|
||||
.OfType<MUXC.NavigationViewItem>()
|
||||
.First(i => args.InvokedItem.Equals(i.Content));
|
||||
|
||||
NavigationView_Navigate(navItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigationView_Navigate(MUXC.NavigationViewItem navItem, object parameter = null)
|
||||
{
|
||||
var (_, page) = _pages.First(p => p.Tag.Equals(navItem.Tag));
|
||||
NavigationView.Header = navItem.Content;
|
||||
ContentFrame.Navigate(page, parameter);
|
||||
}
|
||||
|
||||
private void NavigationView_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
object parameter = null;
|
||||
if (Model.IsDatabaseOpened)
|
||||
{
|
||||
NavigationView.SelectedItem = Save;
|
||||
parameter = Frame;
|
||||
}
|
||||
else if (Model.File != null)
|
||||
{
|
||||
NavigationView.SelectedItem = Open;
|
||||
parameter = Model.File;
|
||||
}
|
||||
else if (Model.HasRecentItems)
|
||||
{
|
||||
NavigationView.SelectedItem = Recent;
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationView.SelectedItem = Welcome;
|
||||
}
|
||||
NavigationView_Navigate((MUXC.NavigationViewItem)NavigationView.SelectedItem, parameter);
|
||||
}
|
||||
}
|
||||
}
|
39
Win10App/Views/MainPageFrames/AboutPage.xaml
Normal file
39
Win10App/Views/MainPageFrames/AboutPage.xaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
x:Class="ModernKeePass.Views.AboutPage"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.DataContext>
|
||||
<viewModels:AboutViewModel/>
|
||||
</Page.DataContext>
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0">
|
||||
<Run Text="{Binding Name}"/>
|
||||
<Run Text="version"/>
|
||||
<Run Text="{Binding Version}" />
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
|
||||
<Run x:Uid="AboutDesc" />
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
|
||||
<Run x:Uid="AboutHomepage" />
|
||||
<Hyperlink NavigateUri="https://wismna.github.io/ModernKeePass/" Foreground="{StaticResource MainColor}">
|
||||
<Run Text="https://wismna.github.io/ModernKeePass/"/>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0">
|
||||
<Run x:Uid="AboutCreditsLabel" />
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
|
||||
<Run x:Uid="AboutCredits1" />
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
|
||||
<Run x:Uid="AboutCredits2" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Page>
|
15
Win10App/Views/MainPageFrames/AboutPage.xaml.cs
Normal file
15
Win10App/Views/MainPageFrames/AboutPage.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class AboutPage
|
||||
{
|
||||
public AboutPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
20
Win10App/Views/MainPageFrames/DonatePage.xaml
Normal file
20
Win10App/Views/MainPageFrames/DonatePage.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.DonatePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<ProgressRing x:Name="LoadingRing" IsActive="True" Width="50" Height="50" Foreground="{StaticResource MainColor}" />
|
||||
<WebView Source="https://PayPal.Me/wismna">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="DOMContentLoaded">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=LoadingRing}" PropertyName="IsActive" Value="False" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</WebView>
|
||||
</Grid>
|
||||
</Page>
|
15
Win10App/Views/MainPageFrames/DonatePage.xaml.cs
Normal file
15
Win10App/Views/MainPageFrames/DonatePage.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class DonatePage
|
||||
{
|
||||
public DonatePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
37
Win10App/Views/MainPageFrames/ImportExportPage.xaml
Normal file
37
Win10App/Views/MainPageFrames/ImportExportPage.xaml
Normal file
@@ -0,0 +1,37 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.ImportExportPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Import" Style="{StaticResource SubheaderTextBlockStyle}" />
|
||||
<HyperlinkButton Grid.Column="0" Grid.Row="1" Content="Select file..." Style="{StaticResource MainColorHyperlinkButton}" Click="ImportFileButton_OnClick" />
|
||||
<StackPanel Grid.Column="1" Grid.Row="1" >
|
||||
<TextBlock Text="Format" Style="{StaticResource BodyTextBlockStyle}" Margin="0,0,0,10" />
|
||||
<ComboBox Style="{StaticResource MainColorComboBox}">
|
||||
<ComboBoxItem>CSV</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Grid.Row="1" >
|
||||
<TextBlock Text="Import into..." Style="{StaticResource BodyTextBlockStyle}" Margin="0,0,0,10" />
|
||||
<RadioButton GroupName="ImportDestination" Content="New database" />
|
||||
<RadioButton GroupName="ImportDestination" Content="Currently opened database" />
|
||||
</StackPanel>
|
||||
<Button Grid.Column="3" Grid.Row="1" Content="Import" Style="{StaticResource MainColorButton}" />
|
||||
</Grid>
|
||||
</Page>
|
35
Win10App/Views/MainPageFrames/ImportExportPage.xaml.cs
Normal file
35
Win10App/Views/MainPageFrames/ImportExportPage.xaml.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// The import/export page.
|
||||
/// </summary>
|
||||
public sealed partial class ImportExportPage
|
||||
{
|
||||
public ImportExportPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void ImportFileButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
picker.FileTypeFilter.Add(".csv");
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
47
Win10App/Views/MainPageFrames/NewDatabasePage.xaml
Normal file
47
Win10App/Views/MainPageFrames/NewDatabasePage.xaml
Normal file
@@ -0,0 +1,47 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.NewDatabasePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<HyperlinkButton x:Uid="NewCreateButton" Click="CreateDatabaseButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" x:Uid="NewCreateDesc" />
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{x:Bind ViewModel.IsFileSelected, Mode=OneWay}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<TextBlock Text="{x:Bind ViewModel.Name}" />
|
||||
<userControls:UpdateCredentialsUserControl x:Uid="CompositeKeyNewButton" DatabaseFilePath="{x:Bind ViewModel.DatabaseFilePath, Mode=OneWay}" CredentialsUpdated="CompositeKeyUserControl_OnValidationChecked" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<CheckBox x:Name="CheckBox" x:Uid="NewImportCheckbox" Margin="15,10,0,0" IsChecked="{x:Bind ViewModel.IsImportChecked, Mode=TwoWay}" Visibility="{x:Bind ViewModel.IsFileSelected}" />
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding IsChecked, ElementName=CheckBox}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock x:Uid="NewImportFormat" Margin="0,15,0,10" Style="{StaticResource BodyTextBlockStyle}" />
|
||||
<ComboBox Style="{StaticResource MainColorComboBox}" Margin="15,15,0,0" SelectionChanged="ImportFormatComboBox_OnSelectionChanged">
|
||||
<ComboBoxItem>CSV</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Button Margin="5,10,0,0" Style="{StaticResource TextBlockButtonStyle}">
|
||||
<SymbolIcon Symbol="Help" RenderTransformOrigin="0.5,0.5" >
|
||||
<SymbolIcon.RenderTransform>
|
||||
<CompositeTransform ScaleX="0.7" ScaleY="0.7"/>
|
||||
</SymbolIcon.RenderTransform>
|
||||
</SymbolIcon>
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<TextBlock Text="{x:Bind ViewModel.ImportFormatHelp}" TextWrapping="WrapWholeWords" MaxWidth="400" />
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<HyperlinkButton x:Name="ImportFileLink" x:Uid="NewImportFile" Margin="-15,0,0,0" Style="{StaticResource MainColorHyperlinkButton}" Click="ImportFileButton_OnClick" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Page>
|
||||
|
||||
|
||||
|
101
Win10App/Views/MainPageFrames/NewDatabasePage.xaml.cs
Normal file
101
Win10App/Views/MainPageFrames/NewDatabasePage.xaml.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Autofac;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Events;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class NewDatabasePage
|
||||
{
|
||||
private Frame _mainFrame;
|
||||
private readonly IResourceService _resourceService;
|
||||
|
||||
public NewViewModel ViewModel { get; }
|
||||
|
||||
public NewDatabasePage(): this(App.Container.Resolve<IResourceService>())
|
||||
{ }
|
||||
|
||||
public NewDatabasePage(IResourceService resourceService)
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new NewViewModel();
|
||||
_resourceService = resourceService;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
_mainFrame = e.Parameter as Frame;
|
||||
}
|
||||
|
||||
private async void CreateDatabaseButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var savePicker = new FileSavePicker
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
|
||||
SuggestedFileName = "New Database"
|
||||
};
|
||||
savePicker.FileTypeChoices.Add("KeePass 2.x database", new List<string> { ".kdbx" });
|
||||
|
||||
var file = await savePicker.PickSaveFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
var fileInfo = new FileInfo
|
||||
{
|
||||
Path = token,
|
||||
Name = file.DisplayName
|
||||
};
|
||||
await ViewModel.OpenFile(fileInfo);
|
||||
}
|
||||
|
||||
private void ImportFormatComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var comboBox = sender as ComboBox;
|
||||
switch (comboBox?.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
ViewModel.ImportFormat = ImportFormat.CSV;
|
||||
ViewModel.ImportFileExtensionFilter = ".csv";
|
||||
ViewModel.ImportFormatHelp = _resourceService.GetResourceValue("NewImportFormatHelpCSV");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async void ImportFileButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
if (!string.IsNullOrEmpty(ViewModel.ImportFileExtensionFilter))
|
||||
picker.FileTypeFilter.Add(ViewModel.ImportFileExtensionFilter);
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
ViewModel.ImportFile = await picker.PickSingleFileAsync();
|
||||
if (ViewModel.ImportFile != null) ImportFileLink.Content = ViewModel.ImportFile.Name;
|
||||
}
|
||||
|
||||
private void CompositeKeyUserControl_OnValidationChecked(object sender, EventArgs e)
|
||||
{
|
||||
ViewModel.PopulateInitialData();
|
||||
_mainFrame.Navigate(typeof(GroupsPage));
|
||||
}
|
||||
}
|
||||
}
|
30
Win10App/Views/MainPageFrames/OpenDatabasePage.xaml
Normal file
30
Win10App/Views/MainPageFrames/OpenDatabasePage.xaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
x:Class="ModernKeePass.Views.OpenDatabasePage"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<HyperlinkButton x:Uid="OpenBrowseButton" Click="ButtonBase_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" x:Uid="OpenBrowseDesc" />
|
||||
<!--<HyperlinkButton x:Uid="OpenUrlButton" IsEnabled="False" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" x:Uid="OpenUrlDesc" />-->
|
||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{x:Bind ViewModel.IsFileSelected, Mode=OneWay}">
|
||||
<StackPanel Margin="25,0,25,0">
|
||||
<TextBlock Text="{x:Bind ViewModel.Name, Mode=OneWay}" />
|
||||
<userControls:CredentialsUserControl x:Uid="CompositeKeyOpenButton" DatabaseFilePath="{x:Bind ViewModel.DatabaseFilePath, Mode=OneWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.GroupsPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</userControls:CredentialsUserControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Page>
|
58
Win10App/Views/MainPageFrames/OpenDatabasePage.xaml.cs
Normal file
58
Win10App/Views/MainPageFrames/OpenDatabasePage.xaml.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.ViewModels;
|
||||
using Windows.Storage.AccessCache;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class OpenDatabasePage
|
||||
{
|
||||
public OpenViewModel ViewModel { get; }
|
||||
|
||||
public OpenDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new OpenViewModel();
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
if (e.Parameter is FileInfo fileInfo)
|
||||
{
|
||||
await ViewModel.OpenFile(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
picker.FileTypeFilter.Add(".kdbx");
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
var fileInfo = new FileInfo
|
||||
{
|
||||
Path = token,
|
||||
Name = file.DisplayName
|
||||
};
|
||||
await ViewModel.OpenFile(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
70
Win10App/Views/MainPageFrames/RecentDatabasesPage.xaml
Normal file
70
Win10App/Views/MainPageFrames/RecentDatabasesPage.xaml
Normal file
@@ -0,0 +1,70 @@
|
||||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
xmlns:listItems="using:ModernKeePass.ViewModels.ListItems"
|
||||
x:Class="ModernKeePass.Views.RecentDatabasesPage"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource x:Name="RecentItemsSource" Source="{x:Bind ViewModel.RecentItems}" />
|
||||
</Page.Resources>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<HyperlinkButton Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{StaticResource MainColorHyperlinkButton}"
|
||||
Foreground="{StaticResource MainColor}"
|
||||
Command="{x:Bind ViewModel.ClearAllCommand}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="Cancel" />
|
||||
<TextBlock x:Uid="RecentClear" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
</StackPanel>
|
||||
</HyperlinkButton>
|
||||
<ListView Grid.Row="1"
|
||||
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedItem, Mode=TwoWay}"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<ListView.DataContext>
|
||||
<listItems:RecentItemViewModel />
|
||||
</ListView.DataContext>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="listItems:RecentItemViewModel">
|
||||
<Grid Margin="10,0,10,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{x:Bind Name}" Padding="5,0,0,0" />
|
||||
<!--<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />-->
|
||||
<userControls:CredentialsUserControl Grid.Row="2"
|
||||
x:Name="DatabaseUserControl"
|
||||
x:Uid="CompositeKeyOpenButton"
|
||||
HorizontalAlignment="Stretch"
|
||||
MinWidth="400"
|
||||
Margin="0,10,0,0"
|
||||
Visibility="{x:Bind IsSelected}"
|
||||
DatabaseFilePath="{x:Bind Token}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<!--<core:CallMethodAction TargetObject="{Binding}" MethodName="UpdateAccessTime" />-->
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.GroupsPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</userControls:CredentialsUserControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Page>
|
20
Win10App/Views/MainPageFrames/RecentDatabasesPage.xaml.cs
Normal file
20
Win10App/Views/MainPageFrames/RecentDatabasesPage.xaml.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
|
||||
/// </summary>
|
||||
public sealed partial class RecentDatabasesPage
|
||||
{
|
||||
private RecentViewModel ViewModel { get; }
|
||||
|
||||
public RecentDatabasesPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new RecentViewModel();
|
||||
}
|
||||
}
|
||||
}
|
15
Win10App/Views/MainPageFrames/SaveDatabasePage.xaml
Normal file
15
Win10App/Views/MainPageFrames/SaveDatabasePage.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Class="ModernKeePass.Views.SaveDatabasePage"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<HyperlinkButton x:Uid="SaveButton" Click="SaveButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<TextBlock x:Uid="SaveDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
|
||||
<HyperlinkButton x:Uid="SaveAsButton" Click="SaveAsButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<TextBlock x:Uid="SaveAsDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
|
||||
</StackPanel>
|
||||
</Page>
|
57
Win10App/Views/MainPageFrames/SaveDatabasePage.xaml.cs
Normal file
57
Win10App/Views/MainPageFrames/SaveDatabasePage.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SaveDatabasePage
|
||||
{
|
||||
private Frame _mainFrame;
|
||||
public SaveViewModel ViewModel { get; }
|
||||
public SaveDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new SaveViewModel();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
_mainFrame = e.Parameter as Frame;
|
||||
}
|
||||
|
||||
private void SaveButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.Save();
|
||||
_mainFrame.Navigate(typeof(MainPage10));
|
||||
}
|
||||
|
||||
private async void SaveAsButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var savePicker = new FileSavePicker
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
|
||||
SuggestedFileName = "New Database"
|
||||
};
|
||||
savePicker.FileTypeChoices.Add("KeePass 2.x database", new List<string> { ".kdbx" });
|
||||
|
||||
var file = await savePicker.PickSaveFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
ViewModel.Save(token);
|
||||
|
||||
_mainFrame.Navigate(typeof(MainPage10));
|
||||
}
|
||||
}
|
||||
}
|
19
Win10App/Views/MainPageFrames/WelcomePage.xaml
Normal file
19
Win10App/Views/MainPageFrames/WelcomePage.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.WelcomePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,10">
|
||||
<SymbolIcon Symbol="Back" Margin="0,7,40,0" />
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" x:Uid="WelcomeOpen" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,6,0,10">
|
||||
<SymbolIcon Symbol="Back" Margin="0,7,40,0" />
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" x:Uid="WelcomeNew" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Page>
|
15
Win10App/Views/MainPageFrames/WelcomePage.xaml.cs
Normal file
15
Win10App/Views/MainPageFrames/WelcomePage.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class WelcomePage
|
||||
{
|
||||
public WelcomePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
34
Win10App/Views/SettingsPage10.xaml
Normal file
34
Win10App/Views/SettingsPage10.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPage10"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Settings}">
|
||||
|
||||
<Grid>
|
||||
<Grid x:Name="AppTitleBar" Background="Transparent" />
|
||||
<NavigationView
|
||||
x:Name="NavigationView"
|
||||
x:Uid="SettingsMenu"
|
||||
IsSettingsVisible="False"
|
||||
ItemInvoked="NavigationView_OnItemInvoked"
|
||||
Loaded="NavigationView_OnLoaded"
|
||||
BackRequested="NavigationView_OnBackRequested">
|
||||
<NavigationView.MenuItems>
|
||||
<NavigationViewItem x:Name="Welcome" Tag="welcome" Visibility="Collapsed" />
|
||||
<NavigationViewItemHeader x:Uid="SettingsMenuGroupApplication" />
|
||||
<NavigationViewItem x:Uid="SettingsMenuItemNew" Icon="Add" Tag="new" />
|
||||
<NavigationViewItem x:Uid="SettingsMenuItemSave" Icon="Save" Tag="save" />
|
||||
<NavigationViewItemSeparator/>
|
||||
<NavigationViewItemHeader x:Uid="SettingsMenuGroupDatabase" />
|
||||
<NavigationViewItem x:Uid="SettingsMenuItemGeneral" Icon="Setting" IsEnabled="{x:Bind Model.IsDatabaseOpened, Mode=OneTime}" Tag="general" />
|
||||
<NavigationViewItem x:Uid="SettingsMenuItemSecurity" Icon="Permissions" IsEnabled="{x:Bind Model.IsDatabaseOpened, Mode=OneTime}" Tag="security" />
|
||||
</NavigationView.MenuItems>
|
||||
|
||||
<Frame x:Name="ContentFrame" Margin="24"/>
|
||||
</NavigationView>
|
||||
</Grid>
|
||||
</Page>
|
66
Win10App/Views/SettingsPage10.xaml.cs
Normal file
66
Win10App/Views/SettingsPage10.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using ModernKeePass.ViewModels;
|
||||
using ModernKeePass.Views.SettingsPageFrames;
|
||||
|
||||
namespace ModernKeePass.Views
|
||||
{
|
||||
public partial class SettingsPage10
|
||||
{
|
||||
private SettingsVm Model => (SettingsVm) DataContext;
|
||||
|
||||
private readonly IList<(string Tag, Type Page)> _pages = new List<(string Tag, Type Page)>
|
||||
{
|
||||
("welcome", typeof(SettingsWelcomePage)),
|
||||
("new", typeof(SettingsNewDatabasePage)),
|
||||
("save", typeof(SettingsSavePage)),
|
||||
("general", typeof(SettingsDatabasePage)),
|
||||
("security", typeof(SettingsSecurityPage))
|
||||
};
|
||||
|
||||
public SettingsPage10()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetTitleBar();
|
||||
}
|
||||
|
||||
private void SetTitleBar()
|
||||
{
|
||||
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
|
||||
coreTitleBar.ExtendViewIntoTitleBar = true;
|
||||
Window.Current.SetTitleBar(AppTitleBar);
|
||||
}
|
||||
|
||||
private void NavigationView_OnItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
// Getting the Tag from Content (args.InvokedItem is the content of NavigationViewItem)
|
||||
var navItem = NavigationView.MenuItems
|
||||
.OfType<NavigationViewItem>()
|
||||
.First(i => args.InvokedItem.Equals(i.Content));
|
||||
|
||||
NavigationView_Navigate(navItem);
|
||||
}
|
||||
|
||||
private void NavigationView_Navigate(NavigationViewItem navItem)
|
||||
{
|
||||
var item = _pages.First(p => p.Tag.Equals(navItem.Tag));
|
||||
NavigationView.Header = navItem.Content;
|
||||
ContentFrame.Navigate(item.Page);
|
||||
}
|
||||
|
||||
private void NavigationView_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NavigationView_Navigate(Welcome);
|
||||
NavigationView.IsBackEnabled = Frame.CanGoBack;
|
||||
}
|
||||
|
||||
private void NavigationView_OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
|
||||
{
|
||||
Frame.GoBack();
|
||||
}
|
||||
}
|
||||
}
|
23
Win10App/Views/SettingsPageFrames/SettingsDatabasePage.xaml
Normal file
23
Win10App/Views/SettingsPageFrames/SettingsDatabasePage.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsDatabasePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{x:Bind ViewModel.HasRecycleBin, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||
<StackPanel Visibility="{x:Bind ViewModel.HasRecycleBin}">
|
||||
<RadioButton x:Uid="SettingsDatabaseRecycleBinCreate" GroupName="Recycle" IsChecked="{x:Bind ViewModel.IsNewRecycleBin, Mode=TwoWay}" />
|
||||
<RadioButton x:Name="RadioButton" x:Uid="SettingsDatabaseRecycleBinExisting" GroupName="Recycle" IsChecked="{x:Bind ViewModel.HasRecycleBin}" />
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.Groups}" SelectedItem="{x:Bind ViewModel.SelectedRecycleBin, Mode=TwoWay}" IsEnabled="{Binding IsChecked, ElementName=RadioButton}" />
|
||||
</StackPanel>
|
||||
<TextBlock x:Uid="SettingsDatabaseEncryption" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.Ciphers}" SelectedItem="{x:Bind ViewModel.SelectedCipher, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" Style="{StaticResource MainColorComboBox}" />
|
||||
<TextBlock x:Uid="SettingsDatabaseCompression" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.Compressions}" SelectedItem="{x:Bind ViewModel.SelectedCompression, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" Style="{StaticResource MainColorComboBox}" />
|
||||
<TextBlock x:Uid="SettingsDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.KeyDerivations}" SelectedItem="{x:Bind ViewModel.SelectedKeyDerivation, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" Style="{StaticResource MainColorComboBox}" />
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,20 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
namespace ModernKeePass.Views.SettingsPageFrames
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsDatabasePage
|
||||
{
|
||||
public SettingsDatabaseViewModel ViewModel { get; }
|
||||
|
||||
public SettingsDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new SettingsDatabaseViewModel();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsNewDatabasePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<TextBlock x:Uid="SettingsNewDatabaseDesc" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
|
||||
<ToggleSwitch x:Uid="SettingsNewDatabaseSample" IsOn="{x:Bind ViewModel.IsCreateSample, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||
<TextBlock x:Uid="SettingsNewDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox Grid.Column="1"
|
||||
ItemsSource="{x:Bind ViewModel.FileFormats}"
|
||||
SelectedItem="{x:Bind ViewModel.FileFormatVersion, Mode=TwoWay}"
|
||||
ItemContainerStyle="{StaticResource MainColorComboBoxItem}"
|
||||
Style="{StaticResource MainColorComboBox}" />
|
||||
<Button Grid.Column="2" Style="{StaticResource TextBlockButtonStyle}">
|
||||
<SymbolIcon Symbol="Help" RenderTransformOrigin="0.5,0.5" >
|
||||
<SymbolIcon.RenderTransform>
|
||||
<CompositeTransform ScaleX="0.7" ScaleY="0.7"/>
|
||||
</SymbolIcon.RenderTransform>
|
||||
</SymbolIcon>
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<TextBlock x:Uid="SettingsNewDatabaseKdfMoreInfo" TextWrapping="WrapWholeWords" MaxWidth="400" />
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,20 @@
|
||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
namespace ModernKeePass.Views.SettingsPageFrames
|
||||
{
|
||||
/// <summary>
|
||||
/// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsNewDatabasePage
|
||||
{
|
||||
private SettingsNewViewModel ViewModel { get; }
|
||||
|
||||
public SettingsNewDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new SettingsNewViewModel();
|
||||
}
|
||||
}
|
||||
}
|
14
Win10App/Views/SettingsPageFrames/SettingsSavePage.xaml
Normal file
14
Win10App/Views/SettingsPageFrames/SettingsSavePage.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsSavePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<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="{x:Bind ViewModel.IsSaveSuspend, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
|
||||
</StackPanel>
|
||||
</Page>
|
19
Win10App/Views/SettingsPageFrames/SettingsSavePage.xaml.cs
Normal file
19
Win10App/Views/SettingsPageFrames/SettingsSavePage.xaml.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
namespace ModernKeePass.Views.SettingsPageFrames
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsSavePage
|
||||
{
|
||||
private SettingsSaveViewModel ViewModel { get; }
|
||||
public SettingsSavePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new SettingsSaveViewModel();
|
||||
}
|
||||
}
|
||||
}
|
28
Win10App/Views/SettingsPageFrames/SettingsSecurityPage.xaml
Normal file
28
Win10App/Views/SettingsPageFrames/SettingsSecurityPage.xaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsSecurityPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<TextBlock x:Uid="SettingsSecurityTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,0" />
|
||||
<TextBlock TextWrapping="WrapWholeWords" Margin="5,0,0,0">
|
||||
<Run x:Uid="SettingsSecurityDesc1" />
|
||||
<Run x:Uid="SettingsSecurityDesc2" FontWeight="SemiBold" />
|
||||
<Run x:Uid="SettingsSecurityDesc3" />
|
||||
</TextBlock>
|
||||
<userControls:UpdateCredentialsUserControl Margin="0,20,0,0" x:Uid="SettingsSecurityUpdateButton">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||
<actions:ToastAction x:Uid="ToastUpdateDatabase" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</userControls:UpdateCredentialsUserControl>
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views.SettingsPageFrames
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsSecurityPage
|
||||
{
|
||||
public SettingsSecurityPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
14
Win10App/Views/SettingsPageFrames/SettingsWelcomePage.xaml
Normal file
14
Win10App/Views/SettingsPageFrames/SettingsWelcomePage.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsWelcomePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<TextBlock FontSize="24" VerticalAlignment="Center" Margin="10,-70,0,0" x:Uid="SettingsWelcomeTitle" />
|
||||
<TextBlock VerticalAlignment="Center" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,0" x:Uid="SettingsWelcomeDesc" />
|
||||
<TextBlock VerticalAlignment="Center" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,0" x:Uid="SettingsWelcomeHowto" />
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -0,0 +1,15 @@
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Views.SettingsPageFrames
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class SettingsWelcomePage
|
||||
{
|
||||
public SettingsWelcomePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
46
Win10App/Views/UserControls/BreadCrumbUserControl.xaml
Normal file
46
Win10App/Views/UserControls/BreadCrumbUserControl.xaml
Normal file
@@ -0,0 +1,46 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Views.UserControls.BreadCrumbUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors"
|
||||
mc:Ignorable="d">
|
||||
<ItemsControl ItemsSource="{Binding ItemsSource, ElementName=UserControl}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.Resources>
|
||||
<DataTemplate x:Name="FirstItemTemplate">
|
||||
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</HyperlinkButton>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Name="OtherItemsTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Viewbox MaxHeight="10" Margin="0,2,0,0">
|
||||
<SymbolIcon Symbol="Forward" />
|
||||
</Viewbox>
|
||||
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</HyperlinkButton>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.Resources>
|
||||
<ItemsControl.ItemTemplateSelector>
|
||||
<templateSelectors:FirstItemDataTemplateSelector FirstItem="{StaticResource FirstItemTemplate}" OtherItem="{StaticResource OtherItemsTemplate}"/>
|
||||
</ItemsControl.ItemTemplateSelector>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
29
Win10App/Views/UserControls/BreadCrumbUserControl.xaml.cs
Normal file
29
Win10App/Views/UserControls/BreadCrumbUserControl.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class BreadCrumbUserControl
|
||||
{
|
||||
public BreadCrumbUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public IEnumerable<Entity> ItemsSource
|
||||
{
|
||||
get => (IEnumerable<Entity>)GetValue(ItemsSourceProperty);
|
||||
set => SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemsSourceProperty =
|
||||
DependencyProperty.Register(
|
||||
"ItemsSource",
|
||||
typeof(IEnumerable<Entity>),
|
||||
typeof(BreadCrumbUserControl),
|
||||
new PropertyMetadata(new Stack<Entity>(), (o, args) => { }));
|
||||
}
|
||||
}
|
24
Win10App/Views/UserControls/ColorPickerUserControl.xaml
Normal file
24
Win10App/Views/UserControls/ColorPickerUserControl.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Views.UserControls.ColorPickerUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<ComboBox x:Name="ComboBox"
|
||||
Width="350"
|
||||
Height="35"
|
||||
ItemsSource="{Binding Colors, ElementName=UserControl}"
|
||||
SelectionChanged="Selector_OnSelectionChanged"
|
||||
Loaded="ComboBox_Loaded" ItemContainerStyle="{StaticResource MainColorComboBoxItem}"
|
||||
Style="{StaticResource MainColorComboBox}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,10,0">
|
||||
<TextBlock Width="100" Text="{Binding ColorName}" Margin="0,0,10,0" />
|
||||
<Rectangle Width="100" Fill="{Binding ColorBrush}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</UserControl>
|
61
Win10App/Views/UserControls/ColorPickerUserControl.xaml.cs
Normal file
61
Win10App/Views/UserControls/ColorPickerUserControl.xaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class ColorPickerUserControl
|
||||
{
|
||||
public struct Color
|
||||
{
|
||||
public string ColorName { get; set; }
|
||||
public SolidColorBrush ColorBrush { get; set; }
|
||||
}
|
||||
|
||||
public List<Color> Colors { get; }
|
||||
|
||||
public SolidColorBrush SelectedColor
|
||||
{
|
||||
get => (SolidColorBrush)GetValue(SelectedColorProperty);
|
||||
set => SetValue(SelectedColorProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SelectedColorProperty =
|
||||
DependencyProperty.Register(
|
||||
"SelectedColor",
|
||||
typeof(SolidColorBrush),
|
||||
typeof(ColorPickerUserControl),
|
||||
new PropertyMetadata(new SolidColorBrush(), (o, args) => { }));
|
||||
|
||||
public ColorPickerUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
Colors = new List<Color>();
|
||||
var type = typeof(Windows.UI.Colors);
|
||||
var properties = type.GetRuntimeProperties().ToArray();
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
Colors.Add(new Color
|
||||
{
|
||||
ColorName = propertyInfo.Name,
|
||||
ColorBrush = new SolidColorBrush((Windows.UI.Color)propertyInfo.GetValue(null, null))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBox_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ComboBox.SelectedItem = Colors.Find(c => c.ColorBrush.Color.Equals(SelectedColor.Color));
|
||||
}
|
||||
|
||||
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var selectedItem = ComboBox.SelectedItem as Color? ?? new Color();
|
||||
SelectedColor = selectedItem.ColorBrush;
|
||||
}
|
||||
}
|
||||
}
|
55
Win10App/Views/UserControls/CredentialsUserControl.xaml
Normal file
55
Win10App/Views/UserControls/CredentialsUserControl.xaml
Normal file
@@ -0,0 +1,55 @@
|
||||
<UserControl
|
||||
x:Class="ModernKeePass.Views.UserControls.CredentialsUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<converters:DiscreteIntToSolidColorBrushConverter x:Key="DiscreteIntToSolidColorBrushConverter"/>
|
||||
<converters:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="Grid">
|
||||
<!-- DataContext is not set at the root of the control because of issues happening when displaying it -->
|
||||
<Grid.DataContext>
|
||||
<viewModels:CredentialsViewModel />
|
||||
</Grid.DataContext>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="45" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{x:Bind ViewModel.HasPassword, Mode=TwoWay}" />
|
||||
<PasswordBox Grid.Row="0" Grid.Column="1" x:Uid="CompositeKeyPassword" Password="{x:Bind ViewModel.Password, Mode=TwoWay}" Height="30" PasswordRevealMode="Peek" KeyDown="PasswordBox_KeyDown" BorderBrush="{x:Bind ViewModel.StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" SelectionHighlightColor="{StaticResource MainColor}" >
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="GotFocus">
|
||||
<core:ChangePropertyAction TargetObject="{Binding}" PropertyName="HasPassword" Value="True" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{x:Bind ViewModel.HasKeyFile, Mode=TwoWay}" />
|
||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0"
|
||||
Content="{x:Bind ViewModel.KeyFileText, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind ViewModel.HasKeyFile, Mode=OneWay}"
|
||||
Click="KeyFileButton_Click"
|
||||
Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<Button Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
|
||||
x:Uid="CredentialsOkButton"
|
||||
Click="OpenButton_OnClick"
|
||||
Style="{StaticResource MainColorButton}"
|
||||
IsEnabled="{x:Bind ViewModel.IsValid, Mode=OneWay}" />
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Height="Auto" FontSize="14" FontWeight="Light"
|
||||
Text="{x:Bind ViewModel.Status, Mode=OneWay}"
|
||||
Foreground="{x:Bind ViewModel.StatusType, Mode=OneWay, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}"
|
||||
Visibility="{x:Bind ViewModel.Status, Mode=OneWay, Converter={StaticResource EmptyStringToVisibilityConverter}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
126
Win10App/Views/UserControls/CredentialsUserControl.xaml.cs
Normal file
126
Win10App/Views/UserControls/CredentialsUserControl.xaml.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Autofac;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Extensions;
|
||||
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
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class CredentialsUserControl
|
||||
{
|
||||
private readonly IDatabaseService _databaseService;
|
||||
private readonly IResourceService _resourceService;
|
||||
|
||||
public CredentialsViewModel ViewModel => Grid.DataContext as CredentialsViewModel;
|
||||
|
||||
public string DatabaseFilePath
|
||||
{
|
||||
get => (string)GetValue(DatabaseFilePathProperty);
|
||||
set => SetValue(DatabaseFilePathProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty DatabaseFilePathProperty =
|
||||
DependencyProperty.Register(
|
||||
"DatabaseFilePath",
|
||||
typeof(string),
|
||||
typeof(CredentialsUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public event EventHandler ValidationChecking;
|
||||
public event EventHandler ValidationChecked;
|
||||
|
||||
public CredentialsUserControl(): this(App.Container.Resolve<IDatabaseService>(), App.Container.Resolve<IResourceService>())
|
||||
{ }
|
||||
|
||||
public CredentialsUserControl(IDatabaseService databaseService, IResourceService resourceService)
|
||||
{
|
||||
InitializeComponent();
|
||||
_databaseService = databaseService;
|
||||
_resourceService = resourceService;
|
||||
}
|
||||
|
||||
private async void OpenButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ValidationChecking?.Invoke(this, new EventArgs());
|
||||
|
||||
if (_databaseService.IsOpen)
|
||||
{
|
||||
await MessageDialogHelper.ShowActionDialog(_resourceService.GetResourceValue("MessageDialogDBOpenTitle"),
|
||||
string.Format(_resourceService.GetResourceValue("MessageDialogDBOpenDesc"), _databaseService.Name),
|
||||
_resourceService.GetResourceValue("MessageDialogDBOpenButtonSave"),
|
||||
_resourceService.GetResourceValue("MessageDialogDBOpenButtonDiscard"),
|
||||
async command =>
|
||||
{
|
||||
await _databaseService.Save();
|
||||
ToastNotificationHelper.ShowGenericToast(
|
||||
_databaseService.Name,
|
||||
_resourceService.GetResourceValue("ToastSavedMessage"));
|
||||
_databaseService.Close();
|
||||
await OpenDatabase();
|
||||
},
|
||||
async command =>
|
||||
{
|
||||
_databaseService.Close();
|
||||
await OpenDatabase();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await OpenDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == VirtualKey.Enter && ViewModel.IsValid)
|
||||
{
|
||||
OpenButton_OnClick(sender, e);
|
||||
// Stop the event from triggering twice
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void KeyFileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
picker.FileTypeFilter.Add(".key");
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
ViewModel.KeyFilePath = token;
|
||||
}
|
||||
|
||||
private async Task OpenDatabase()
|
||||
{
|
||||
if (await Dispatcher.RunTaskAsync(async () =>
|
||||
{
|
||||
var fileInfo = new FileInfo
|
||||
{
|
||||
Path = DatabaseFilePath
|
||||
};
|
||||
return await ViewModel.OpenDatabase(fileInfo);
|
||||
}))
|
||||
{
|
||||
ValidationChecked?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
119
Win10App/Views/UserControls/HamburgerMenuUserControl.xaml
Normal file
119
Win10App/Views/UserControls/HamburgerMenuUserControl.xaml
Normal file
@@ -0,0 +1,119 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Views.UserControls.HamburgerMenuUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<converters:IconToSymbolConverter x:Key="IntToSymbolConverter"/>
|
||||
</UserControl.Resources>
|
||||
<ListView
|
||||
ItemsSource="{Binding ItemsSource, ElementName=UserControl}"
|
||||
SelectionChanged="Selector_OnSelectionChanged"
|
||||
SelectedItem="{Binding SelectedItem, ElementName=UserControl}"
|
||||
IsSwipeEnabled="false"
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
RequestedTheme="Dark"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<ListView.Resources>
|
||||
<x:Double x:Key="HamburgerMenuSize">300</x:Double>
|
||||
<DataTemplate x:Name="IsSpecial">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding IconId, Converter={StaticResource IntToSymbolConverter}, ConverterParameter=48}" Margin="7,15,0,15">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Path={Binding DisplayMemberPath, ElementName=UserControl}}" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<TextBlock Text="{Binding Path={Binding DisplayMemberPath, ElementName=UserControl}}" x:Name="GroupTextBlock" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" FontStyle="Italic" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Name="IsNormal">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding IconId, Converter={StaticResource IntToSymbolConverter}, ConverterParameter=48}" Margin="7,15,0,15">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Path={Binding DisplayMemberPath, ElementName=UserControl}}" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<TextBlock Text="{Binding Path={Binding DisplayMemberPath, ElementName=UserControl}}" x:Name="GroupTextBlock" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemTemplateSelector>
|
||||
<templateSelectors:SelectableDataTemplateSelector FalseItem="{StaticResource IsNormal}" TrueItem="{StaticResource IsSpecial}" />
|
||||
</ListView.ItemTemplateSelector>
|
||||
<ListView.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ToggleButton Style="{StaticResource HamburgerToggleButton}">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding HeaderLabel, ElementName=UserControl}" />
|
||||
</ToolTipService.ToolTip>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Checked">
|
||||
<core:ChangePropertyAction PropertyName="Width" Value="{StaticResource HamburgerMenuSize}" TargetObject="{Binding ResizeTarget, ElementName=UserControl}"/>
|
||||
</core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="Unchecked">
|
||||
<core:ChangePropertyAction PropertyName="Width" Value="{StaticResource MenuSize}" TargetObject="{Binding ResizeTarget, ElementName=UserControl}"/>
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</ToggleButton>
|
||||
<TextBlock Text="{Binding HeaderLabel, ElementName=UserControl}" FontWeight="Bold" FontSize="18" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.HeaderTemplate>
|
||||
<ListView.FooterTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Border BorderBrush="White" BorderThickness="0,0,0,1" />
|
||||
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Visibility="{Binding IsButtonVisible, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left" Click="ButtonBase_OnClick">
|
||||
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
|
||||
<SymbolIcon Symbol="Add">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding ButtonLabel, ElementName=UserControl}" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<TextBlock Text="{Binding ButtonLabel, ElementName=UserControl}" FontWeight="SemiBold" TextWrapping="NoWrap" FontSize="16" VerticalAlignment="Center" Margin="30,0,20,0" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left">
|
||||
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
|
||||
<SymbolIcon Symbol="Home">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="HamburgerMenuHomeTooltip" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<TextBlock x:Uid="HamburgerMenuHomeLabel" FontWeight="SemiBold" TextWrapping="NoWrap" FontSize="16" VerticalAlignment="Center" Margin="30,0,20,0" />
|
||||
</StackPanel>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.MainPage10" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</Button>
|
||||
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left">
|
||||
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
|
||||
<SymbolIcon Symbol="Setting">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="HamburgerMenuSettingsTooltip" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<TextBlock x:Uid="HamburgerMenuSettingsLabel" FontWeight="SemiBold" TextWrapping="NoWrap" FontSize="16" VerticalAlignment="Center" Margin="30,0,20,0" />
|
||||
</StackPanel>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.SettingsPage" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.FooterTemplate>
|
||||
</ListView>
|
||||
</UserControl>
|
115
Win10App/Views/UserControls/HamburgerMenuUserControl.xaml.cs
Normal file
115
Win10App/Views/UserControls/HamburgerMenuUserControl.xaml.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class HamburgerMenuUserControl
|
||||
{
|
||||
public HamburgerMenuUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string HeaderLabel
|
||||
{
|
||||
get => (string)GetValue(HeaderLabelProperty);
|
||||
set => SetValue(HeaderLabelProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty HeaderLabelProperty =
|
||||
DependencyProperty.Register(
|
||||
"HeaderLabel",
|
||||
typeof(string),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata("Header", (o, args) => { }));
|
||||
|
||||
public string ButtonLabel
|
||||
{
|
||||
get => (string)GetValue(ButtonLabelProperty);
|
||||
set => SetValue(ButtonLabelProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty ButtonLabelProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonLabel",
|
||||
typeof(string),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata("Button", (o, args) => { }));
|
||||
|
||||
public string DisplayMemberPath
|
||||
{
|
||||
get => (string)GetValue(DisplayMemberPathProperty);
|
||||
set => SetValue(DisplayMemberPathProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty DisplayMemberPathProperty =
|
||||
DependencyProperty.Register(
|
||||
"DisplayMemberPath",
|
||||
typeof(string),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata("Title", (o, args) => { }));
|
||||
|
||||
public object ResizeTarget
|
||||
{
|
||||
get => GetValue(ResizeTargetProperty);
|
||||
set => SetValue(ResizeTargetProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty ResizeTargetProperty =
|
||||
DependencyProperty.Register(
|
||||
"ResizeTarget",
|
||||
typeof(object),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public Visibility IsButtonVisible
|
||||
{
|
||||
get => (Visibility)GetValue(IsButtonVisibleProperty);
|
||||
set => SetValue(IsButtonVisibleProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty IsButtonVisibleProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsButtonVisible",
|
||||
typeof(Visibility),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public IEnumerable<Entity> ItemsSource
|
||||
{
|
||||
get => (IEnumerable<Entity>)GetValue(ItemsSourceProperty);
|
||||
set => SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemsSourceProperty =
|
||||
DependencyProperty.Register(
|
||||
"ItemsSource",
|
||||
typeof(IEnumerable<Entity>),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata(new List<Entity>(), (o, args) => { }));
|
||||
|
||||
public object SelectedItem
|
||||
{
|
||||
get => GetValue(SelectedItemProperty);
|
||||
set => SetValue(SelectedItemProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SelectedItemProperty =
|
||||
DependencyProperty.Register(
|
||||
"SelectedItem",
|
||||
typeof(object),
|
||||
typeof(HamburgerMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
|
||||
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SelectionChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public event EventHandler<RoutedEventArgs> ButtonClicked;
|
||||
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ButtonClicked?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
24
Win10App/Views/UserControls/SymbolPickerUserControl.xaml
Normal file
24
Win10App/Views/UserControls/SymbolPickerUserControl.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Views.UserControls.SymbolPickerUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<ComboBox x:Name="ComboBox"
|
||||
Height="35"
|
||||
Width="Auto"
|
||||
ItemsSource="{Binding Symbols, ElementName=UserControl}"
|
||||
SelectedItem="{Binding SelectedSymbol, ElementName=UserControl, Mode=TwoWay}"
|
||||
Loaded="ComboBox_OnLoaded"
|
||||
ItemContainerStyle="{StaticResource MainColorComboBoxItem}"
|
||||
Style="{StaticResource MainColorComboBox}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,10,0">
|
||||
<SymbolIcon Symbol="{Binding}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</UserControl>
|
40
Win10App/Views/UserControls/SymbolPickerUserControl.xaml.cs
Normal file
40
Win10App/Views/UserControls/SymbolPickerUserControl.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Converters;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class SymbolPickerUserControl
|
||||
{
|
||||
public IEnumerable<Symbol> Symbols { get; }
|
||||
|
||||
public Symbol SelectedSymbol
|
||||
{
|
||||
get => (Symbol)GetValue(SelectedSymbolProperty);
|
||||
set => SetValue(SelectedSymbolProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SelectedSymbolProperty =
|
||||
DependencyProperty.Register(
|
||||
"SelectedSymbol",
|
||||
typeof(Symbol),
|
||||
typeof(SymbolPickerUserControl),
|
||||
new PropertyMetadata(Symbol.Stop, (o, args) => { }));
|
||||
|
||||
public SymbolPickerUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
var converter = new IconToSymbolConverter();
|
||||
Symbols = Enum.GetValues(typeof(Symbol)).Cast<Symbol>().Where(s => (int)converter.ConvertBack(s, null, null, string.Empty) != -1);
|
||||
}
|
||||
|
||||
private void ComboBox_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ComboBox.SelectedItem = Symbols.FirstOrDefault(s => s == SelectedSymbol);
|
||||
}
|
||||
}
|
||||
}
|
101
Win10App/Views/UserControls/TopMenuUserControl.xaml
Normal file
101
Win10App/Views/UserControls/TopMenuUserControl.xaml
Normal file
@@ -0,0 +1,101 @@
|
||||
<UserControl x:Name="UserControl"
|
||||
x:Class="ModernKeePass.Views.UserControls.TopMenuUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<Style BasedOn="{StaticResource NoBorderButtonStyle}" TargetType="Button" x:Key="MenuButtonStyle" >
|
||||
<Setter Property="Padding" Value="25,0,25,0" />
|
||||
<Setter Property="Background" Value="{ThemeResource ToggleButtonBackgroundThemeBrush}" />
|
||||
<Setter Property="Height" Value="{StaticResource MenuSize}" />
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource NoBorderToggleButtonStyle}" TargetType="ToggleButton" x:Key="MenuToggleButtonStyle" >
|
||||
<Setter Property="Padding" Value="25,0,25,0" />
|
||||
<Setter Property="Height" Value="{StaticResource MenuSize}" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="VisibilityStates">
|
||||
<VisualState x:Name="Overflowed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OverflowButtons" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MoreButton" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Collapsed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OverflowButtons" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MoreButton" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<StackPanel x:Name="OverflowButtons" Orientation="Horizontal">
|
||||
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_Click" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="Undo">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuRestoreButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</Button>
|
||||
<Button Command="{Binding SaveCommand, ElementName=UserControl}" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="Save">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuSaveButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</Button>
|
||||
<Button Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="Sort">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuSortButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Opening="SortFlyout_OnOpening">
|
||||
<MenuFlyoutItem x:Uid="AppBarSortEntries" x:Name="SortEntriesButtonFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="AppBarSortGroups" x:Name="SortGroupsButtonFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
<ToggleButton Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Checked="EditButton_Click" Style="{StaticResource MenuToggleButtonStyle}">
|
||||
<SymbolIcon Symbol="Edit">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuEditButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</ToggleButton>
|
||||
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="Delete">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuDeleteButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<Button x:Name="MoreButton" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="More" />
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
||||
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, 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}" Click="DeleteButton_Click" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="TopMenuSortGroupsFlyout" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
195
Win10App/Views/UserControls/TopMenuUserControl.xaml.cs
Normal file
195
Win10App/Views/UserControls/TopMenuUserControl.xaml.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class TopMenuUserControl
|
||||
{
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => (ICommand)GetValue(SaveCommandProperty);
|
||||
set => SetValue(SaveCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SaveCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"SaveCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand EditCommand
|
||||
{
|
||||
get => (ICommand)GetValue(EditCommandProperty);
|
||||
set => SetValue(EditCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty EditCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"EditCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand DeleteCommand
|
||||
{
|
||||
get => (ICommand)GetValue(DeleteCommandProperty);
|
||||
set => SetValue(DeleteCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty DeleteCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"DeleteCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand RestoreCommand
|
||||
{
|
||||
get => (ICommand)GetValue(RestoreCommandProperty);
|
||||
set => SetValue(RestoreCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty RestoreCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"RestoreCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand SortEntriesCommand
|
||||
{
|
||||
get => (ICommand)GetValue(SortEntriesCommandProperty);
|
||||
set => SetValue(SortEntriesCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SortEntriesCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"SortEntriesCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand SortGroupsCommand
|
||||
{
|
||||
get => (ICommand)GetValue(SortGroupsCommandProperty);
|
||||
set => SetValue(SortGroupsCommandProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SortGroupsCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"SortGroupsCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public Visibility RestoreButtonVisibility
|
||||
{
|
||||
get => (Visibility)GetValue(RestoreButtonVisibilityProperty);
|
||||
set => SetValue(RestoreButtonVisibilityProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty RestoreButtonVisibilityProperty =
|
||||
DependencyProperty.Register(
|
||||
"RestoreButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public Visibility DeleteButtonVisibility
|
||||
{
|
||||
get => (Visibility)GetValue(DeleteButtonVisibilityProperty);
|
||||
set => SetValue(DeleteButtonVisibilityProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty DeleteButtonVisibilityProperty =
|
||||
DependencyProperty.Register(
|
||||
"DeleteButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public Visibility SortButtonVisibility
|
||||
{
|
||||
get => (Visibility)GetValue(SortButtonVisibilityProperty);
|
||||
set => SetValue(SortButtonVisibilityProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty SortButtonVisibilityProperty =
|
||||
DependencyProperty.Register(
|
||||
"SortButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public bool IsDeleteButtonEnabled
|
||||
{
|
||||
get => (bool)GetValue(IsDeleteButtonEnabledProperty);
|
||||
set => SetValue(IsDeleteButtonEnabledProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty IsDeleteButtonEnabledProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsDeleteButtonEnabled",
|
||||
typeof(bool),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(true, (o, args) => { }));
|
||||
|
||||
public bool IsEditButtonChecked
|
||||
{
|
||||
get => (bool)GetValue(IsEditButtonCheckedProperty);
|
||||
set => SetValue(IsEditButtonCheckedProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty IsEditButtonCheckedProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsEditButtonChecked",
|
||||
typeof(bool),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
|
||||
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
||||
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
||||
public event EventHandler<RoutedEventArgs> RestoreButtonClick;
|
||||
|
||||
public TopMenuUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
EditFlyout.Click += EditFlyout_Click;
|
||||
}
|
||||
|
||||
private void EditFlyout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsEditButtonChecked = EditFlyout.IsChecked;
|
||||
EditButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void EditButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EditButtonClick?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DeleteButtonClick?.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;
|
||||
DeleteFlyout.Visibility = DeleteButtonVisibility;
|
||||
|
||||
EditFlyout.IsChecked = IsEditButtonChecked;
|
||||
|
||||
RestoreFlyout.Visibility = RestoreButtonVisibility;
|
||||
|
||||
SortEntriesFlyout.Visibility = SortButtonVisibility;
|
||||
SortGroupsFlyout.Visibility = SortButtonVisibility;
|
||||
SortEntriesFlyout.Command = SortEntriesCommand;
|
||||
SortGroupsFlyout.Command = SortGroupsCommand;
|
||||
}
|
||||
|
||||
private void SortFlyout_OnOpening(object sender, object e)
|
||||
{
|
||||
SortEntriesButtonFlyout.Command = SortEntriesCommand;
|
||||
SortGroupsButtonFlyout.Command = SortGroupsCommand;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
<UserControl
|
||||
x:Class="ModernKeePass.Views.UserControls.UpdateCredentialsUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToSolidColorBrushConverter"/>
|
||||
<converters:DiscreteIntToSolidColorBrushConverter x:Key="DiscreteIntToSolidColorBrushConverter"/>
|
||||
<converters:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="Grid">
|
||||
<!-- DataContext is not set at the root of the control because of issues happening when displaying it -->
|
||||
<Grid.DataContext>
|
||||
<viewModels:UpdateCredentialsViewModel />
|
||||
</Grid.DataContext>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="45" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{x:Bind ViewModel.HasPassword, Mode=TwoWay}" />
|
||||
<PasswordBox Grid.Row="0" Grid.Column="1" x:Uid="CompositeKeyPassword" Password="{x:Bind ViewModel.Password, Mode=TwoWay}" Height="30" PasswordRevealMode="Peek" BorderBrush="{x:Bind ViewModel.StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" SelectionHighlightColor="{StaticResource MainColor}" >
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="GotFocus">
|
||||
<core:ChangePropertyAction TargetObject="{Binding}" PropertyName="HasPassword" Value="True" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</PasswordBox>
|
||||
<PasswordBox Grid.Row="0" Grid.Column="1" x:Uid="CompositeKeyPassword" Password="{x:Bind ViewModel.Password, Mode=TwoWay}" Height="30" PasswordRevealMode="Peek" BorderBrush="{x:Bind ViewModel.StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" SelectionHighlightColor="{StaticResource MainColor}" />
|
||||
<ProgressBar Grid.Row="0" Grid.Column="1"
|
||||
Maximum="128" VerticalAlignment="Bottom"
|
||||
Value="{x:Bind ViewModel.PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}, Mode=OneWay}"
|
||||
Foreground="{x:Bind ViewModel.PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToSolidColorBrushConverter}, Mode=OneWay}"/>
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{x:Bind ViewModel.HasKeyFile, Mode=TwoWay}" />
|
||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0"
|
||||
Content="{x:Bind ViewModel.KeyFileText, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind ViewModel.HasKeyFile, Mode=OneWay}"
|
||||
Click="KeyFileButton_Click"
|
||||
Style="{StaticResource MainColorHyperlinkButton}" />
|
||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right"
|
||||
IsEnabled="{x:Bind ViewModel.HasKeyFile, Mode=OneWay}"
|
||||
Style="{StaticResource MainColorHyperlinkButton}"
|
||||
Click="CreateKeyFileButton_Click">
|
||||
<SymbolIcon Symbol="Add">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="CompositeKeyNewKeyFileTooltip" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</HyperlinkButton>
|
||||
<Button Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
|
||||
x:Uid="UpdateCredentialsOkButton"
|
||||
Click="UpdateButton_OnClick"
|
||||
Style="{StaticResource MainColorButton}"
|
||||
IsEnabled="{x:Bind ViewModel.IsValid, Mode=OneWay}" />
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Height="Auto" FontSize="14" FontWeight="Light"
|
||||
Text="{x:Bind ViewModel.Status, Mode=OneWay}"
|
||||
Foreground="{x:Bind ViewModel.StatusType, Mode=OneWay, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}"
|
||||
Visibility="{x:Bind ViewModel.Status, Mode=OneWay, Converter={StaticResource EmptyStringToVisibilityConverter}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.ViewModels;
|
||||
using ModernKeePass.Extensions;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class UpdateCredentialsUserControl
|
||||
{
|
||||
public UpdateCredentialsViewModel ViewModel => Grid.DataContext as UpdateCredentialsViewModel;
|
||||
public string DatabaseFilePath
|
||||
{
|
||||
get => (string)GetValue(DatabaseFilePathProperty);
|
||||
set => SetValue(DatabaseFilePathProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty DatabaseFilePathProperty =
|
||||
DependencyProperty.Register(
|
||||
"DatabaseFilePath",
|
||||
typeof(string),
|
||||
typeof(CredentialsUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public event EventHandler CredentialsUpdated;
|
||||
|
||||
public UpdateCredentialsUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void KeyFileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker =
|
||||
new FileOpenPicker
|
||||
{
|
||||
ViewMode = PickerViewMode.List,
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
||||
};
|
||||
picker.FileTypeFilter.Add(".key");
|
||||
|
||||
// Application now has read/write access to the picked file
|
||||
var file = await picker.PickSingleFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
ViewModel.KeyFilePath = token;
|
||||
}
|
||||
|
||||
private async void CreateKeyFileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var savePicker = new FileSavePicker
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
|
||||
SuggestedFileName = "Key"
|
||||
};
|
||||
savePicker.FileTypeChoices.Add("Key file", new List<string> { ".key" });
|
||||
|
||||
var file = await savePicker.PickSaveFileAsync();
|
||||
if (file == null) return;
|
||||
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
ViewModel.KeyFilePath = token;
|
||||
}
|
||||
|
||||
private async void UpdateButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
|
||||
if (await Dispatcher.RunTaskAsync(async () =>
|
||||
{
|
||||
var fileInfo = new FileInfo
|
||||
{
|
||||
Path = DatabaseFilePath
|
||||
};
|
||||
return await ViewModel.CreateDatabase(fileInfo);
|
||||
}))
|
||||
{
|
||||
CredentialsUpdated?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user