Files
modernkeepass/ModernKeePass10/Views/EntriesPage.xaml
Geoffroy BONNEVILLE 56d93a5187 Moved application code to the Application layer
Imported Win10 project
Code cleanup
WIP - Use common UWP services for Win8.1 and Win10
2020-04-06 20:20:45 +02:00

267 lines
19 KiB
XML

<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}">
<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 ViewModel.Entries, Mode=OneWay}"
CompactModeThresholdWidth="720"
SelectedItem="{x:Bind ViewModel.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:EntryItemViewModel">
<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:EntryItemViewModel">
<!--<Frame x:Name="ContentFrame" SourcePageType="pages:EntryPage" />-->
<Pivot>
<Pivot.TitleTemplate>
<DataTemplate x:DataType="listItems:EntryItemViewModel">
<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>