UI/HandshakeDialog.xaml
author Thomas
Tue, 03 Apr 2018 10:17:13 +0200
branchOUT-369
changeset 2100 91f72cbed562
parent 1996 4a8c0f84a4fa
child 2102 3939ad287c0c
permissions -rw-r--r--
Close branch OUT-369
     1 <Window x:Class="pEp.UI.HandshakeDialog"
     2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     5         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     6         xmlns:core="clr-namespace:System;assembly=mscorlib"
     7         xmlns:p="clr-namespace:pEp.Properties"
     8         xmlns:local="clr-namespace:pEp.UI"
     9         x:ClassModifier="internal"
    10         mc:Ignorable="d"
    11         MinHeight="5"
    12         Height="Auto"
    13         Width="Auto"
    14         ResizeMode="NoResize"
    15         SizeToContent="WidthAndHeight"
    16         Background="{x:Static SystemColors.MenuBarBrush}"
    17         Icon="pack://application:,,,/pEp;component/Resources/ImageLogoIcon.png"
    18         WindowStartupLocation="CenterScreen">
    19     <Window.Resources>
    20         <ResourceDictionary>
    21             <!-- Converters -->
    22             <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
    23             <local:IsEnabledToColorConverter x:Key="IsEnabledToColor" />
    24             <local:IsActiveTabToBoolConverter x:Key="IsActiveTabToBool" />
    25             <local:ValueConverterGroup x:Key="IsActiveTabToVisibility">
    26                 <local:IsActiveTabToBoolConverter />
    27                 <BooleanToVisibilityConverter />
    28             </local:ValueConverterGroup>
    29             <local:ValueConverterGroup x:Key="IsActiveTabToBackground">
    30                 <local:IsActiveTabToBoolConverter />
    31                 <local:BooleanToBackgroundConverter />
    32             </local:ValueConverterGroup>
    33             <local:InvertBoolConverter x:Key="InvertBool" />
    34             <local:MultiBooleanToVisibilityConverter x:Key="MultiBooleanToVisibility" />
    35             <local:ValueConverterGroup x:Key="InvertBoolToVisibility">
    36                 <local:InvertBoolConverter />
    37                 <BooleanToVisibilityConverter />
    38             </local:ValueConverterGroup>
    39             <local:ValueConverterGroup x:Key="IsStandardModeToVisibility">
    40                 <local:IsStandardModeToBoolConverter />
    41                 <BooleanToVisibilityConverter />
    42             </local:ValueConverterGroup>
    43             <local:ValueConverterGroup x:Key="IsNotStandardModeToVisibility">
    44                 <local:IsStandardModeToBoolConverter />
    45                 <local:InvertBoolConverter />
    46                 <BooleanToVisibilityConverter />
    47             </local:ValueConverterGroup>
    48             <local:ValueConverterGroup x:Key="IsStringEmptyToVisibility">
    49                 <local:IsStringEmptyConverter />
    50                 <local:InvertBoolConverter />
    51                 <BooleanToVisibilityConverter />
    52             </local:ValueConverterGroup>
    53             <local:ValueConverterGroup x:Key="IsNotSyncModeToVisibility">
    54                 <local:IsSyncModeToBoolConverter />
    55                 <local:InvertBoolConverter />
    56                 <BooleanToVisibilityConverter />
    57             </local:ValueConverterGroup>
    58 
    59             <!--Template for identities-->
    60             <DataTemplate x:Key="HandshakeItemsTemplate">
    61                 <StackPanel>
    62                     <StackPanel.Style>
    63                         <Style TargetType="StackPanel">
    64                             <Setter Property="Background"
    65                                     Value="Transparent" />
    66                             <Style.Triggers>
    67                                 <MultiDataTrigger>
    68                                     <MultiDataTrigger.Conditions>
    69                                         <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
    70                                                    Value="True" />
    71                                         <Condition Binding="{Binding Path=IsExpanded}"
    72                                                    Value="False" />
    73                                         <Condition Binding="{Binding Path=IsButtonVisible}"
    74                                                    Value="False" />
    75                                         <Condition Binding="{Binding Path=IsClickable}"
    76                                                    Value="True" />
    77                                     </MultiDataTrigger.Conditions>
    78                                     <Setter Property="Background"
    79                                             Value="{x:Static SystemColors.ControlLightBrush}" />
    80                                 </MultiDataTrigger>
    81                             </Style.Triggers>
    82                         </Style>
    83                     </StackPanel.Style>
    84 
    85                     <!--Separator between items-->
    86                     <Separator Margin="5,5,5,0"
    87                                Background="LightGray"
    88                                Visibility="{Binding Path=IsSeparatorVisible, Converter={StaticResource BoolToVisibility}}" />
    89 
    90                     <!--The list entry-->
    91                     <Grid Name="IdentityGrid"
    92                           Background="Transparent"
    93                           Margin="5"
    94                           MinHeight="38"
    95                           MouseLeftButtonUp="IdentityGrid_MouseLeftButtonUp"
    96                           Visibility="{Binding Path=Mode, Converter={StaticResource IsNotSyncModeToVisibility}}">
    97                         <Grid.ColumnDefinitions>
    98                             <ColumnDefinition Width="Auto" />
    99                             <ColumnDefinition Width="*" />
   100                             <ColumnDefinition Width="Auto" />
   101                         </Grid.ColumnDefinitions>
   102 
   103                         <!--The identity rating-->
   104                         <Image Grid.Column="0"
   105                                Height="15"
   106                                Stretch="Uniform"
   107                                VerticalAlignment="Stretch"
   108                                HorizontalAlignment="Center"
   109                                Margin="0,0,5,0"
   110                                Source="{Binding Path=ItemImage, Mode=OneWay}">
   111                         </Image>
   112 
   113                         <!--The identity name-->
   114                         <TextBlock Grid.Column="1"
   115                                    HorizontalAlignment="Left"
   116                                    VerticalAlignment="Center"
   117                                    Margin="5,0"
   118                                    Text="{Binding Path=ItemName, Mode=OneWay}" />
   119 
   120                         <!--Trust button-->
   121                         <Button Grid.Column="2"
   122                                 Style="{StaticResource StyleTrustButton}"
   123                                 Visibility="{Binding Path=IsButtonVisible, Converter={StaticResource BoolToVisibility}}"
   124                                 Margin="5"
   125                                 HorizontalAlignment="Right"
   126                                 Content="{Binding Path=ButtonText, Mode=OneWay}"
   127                                 Click="ButtonTrust_Click" />
   128                     </Grid>
   129 
   130                     <!--Advanced section-->
   131                     <StackPanel Visibility="{Binding Path=IsExpanded, Converter={StaticResource BoolToVisibility}}">
   132 
   133                         <!--Tabs-->
   134                         <StackPanel Orientation="Horizontal"
   135                                     HorizontalAlignment="Right">
   136                             <Label Name="TrustwordsTabControl"
   137                                    MouseLeftButtonUp="TabControl_MouseLeftButtonUp"
   138                                    Content="{x:Static p:Resources.Handshake_TrustwordsText}"
   139                                    Visibility="{Binding Path=AreTabControlsVisible, Converter={StaticResource BoolToVisibility}}">
   140                                 <Label.Style>
   141                                     <Style TargetType="Label">
   142                                         <Setter Property="BorderBrush"
   143                                                 Value="LightGray" />
   144                                         <Setter Property="Background"
   145                                                 Value="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBackground}, ConverterParameter=Trustwords}" />
   146                                         <Setter Property="BorderThickness"
   147                                                 Value="1" />
   148                                         <Setter Property="Padding"
   149                                                 Value="10,5" />
   150                                         <Style.Triggers>
   151                                             <MultiDataTrigger>
   152                                                 <MultiDataTrigger.Conditions>
   153                                                     <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
   154                                                                Value="True" />
   155                                                     <Condition Binding="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Trustwords}"
   156                                                                Value="False" />
   157                                                 </MultiDataTrigger.Conditions>
   158                                                 <Setter Property="Background"
   159                                                         Value="AliceBlue" />
   160                                                 <Setter Property="BorderBrush"
   161                                                         Value="LightSkyBlue" />
   162                                             </MultiDataTrigger>
   163                                         </Style.Triggers>
   164                                     </Style>
   165                                 </Label.Style>
   166                             </Label>
   167                             <Label Name="FingerprintTabControl"
   168                                    MouseLeftButtonUp="TabControl_MouseLeftButtonUp"
   169                                    Content="{x:Static p:Resources.Handshake_FingerprintText}"
   170                                    Visibility="{Binding Path=AreTabControlsVisible, Converter={StaticResource BoolToVisibility}}">
   171                                 <Label.Style>
   172                                     <Style TargetType="Label">
   173                                         <Setter Property="BorderBrush"
   174                                                 Value="LightGray" />
   175                                         <Setter Property="Background"
   176                                                 Value="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBackground}, ConverterParameter=Fingerprint}" />
   177                                         <Setter Property="BorderThickness"
   178                                                 Value="1" />
   179                                         <Setter Property="Padding"
   180                                                 Value="10,5" />
   181                                         <Style.Triggers>
   182                                             <MultiDataTrigger>
   183                                                 <MultiDataTrigger.Conditions>
   184                                                     <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
   185                                                                Value="True" />
   186                                                     <Condition Binding="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Fingerprint}"
   187                                                                Value="False" />
   188                                                 </MultiDataTrigger.Conditions>
   189                                                 <Setter Property="Background"
   190                                                         Value="AliceBlue" />
   191                                                 <Setter Property="BorderBrush"
   192                                                         Value="LightSkyBlue" />
   193                                             </MultiDataTrigger>
   194                                         </Style.Triggers>
   195                                     </Style>
   196                                 </Label.Style>
   197                             </Label>
   198 
   199                             <!--Language selector-->
   200                             <ComboBox Padding="10,2"
   201                                       VerticalContentAlignment="Center"
   202                                       ItemsSource="{Binding Path=TrustwordsCultureList, Mode=OneWay}"
   203                                       DisplayMemberPath="Value"
   204                                       SelectedValuePath="Key"
   205                                       SelectedValue="{Binding Path=TrustwordsCulture, Mode=TwoWay}"
   206                                       IsEnabled="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Trustwords}"
   207                                       Foreground="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource IsEnabledToColor}}" />
   208                         </StackPanel>
   209 
   210                         <!-- Trustwords -->
   211                         <StackPanel Background="White"
   212                                     Visibility="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToVisibility}, ConverterParameter=Trustwords}">
   213                             <TextBlock Text="{Binding Path=TrustwordsShort}"
   214                                        Visibility="{Binding Path=AreTrustwordsExpanded, Converter={StaticResource InvertBoolToVisibility}}"
   215                                        TextWrapping="Wrap"
   216                                        Padding="10" />
   217                             <TextBlock Text="{Binding Path=TrustwordsFull}"
   218                                        Visibility="{Binding Path=AreTrustwordsExpanded, Converter={StaticResource BoolToVisibility}}"
   219                                        TextWrapping="Wrap"
   220                                        Padding="10" />
   221                             <Expander ExpandDirection="Down"
   222                                       Margin="10,10,5,5"
   223                                       ToolTip="{Binding Path=ExpanderToolTip, Mode=OneWay}"
   224                                       Collapsed="TrustwordsExpander_Toggled"
   225                                       Expanded="TrustwordsExpander_Toggled" />
   226                         </StackPanel>
   227 
   228                         <!--Fingerprints-->
   229                         <StackPanel Background="White"
   230                                     Visibility="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToVisibility}, ConverterParameter=Fingerprint}">
   231                             <TextBlock Text="{Binding Path=UIDPartner}"
   232                                        Margin="10,10,10,2" />
   233                             <TextBlock Text="{Binding Path=FingerprintPartner}"
   234                                        Margin="10,2,10,22" />
   235                             <TextBlock Text="{Binding Path=UIDMyself}"
   236                                        Margin="10,10,10,2" />
   237                             <TextBlock Text="{Binding Path=FingerprintMyself}"
   238                                        Margin="10,2,10,10" />
   239                         </StackPanel>
   240 
   241                         <!-- Buttons -->
   242                         <StackPanel Grid.Row="5"
   243                                     Orientation="Horizontal"
   244                                     HorizontalAlignment="Right"
   245                                     Margin="0,5,0,0">
   246                             <Button Style="{StaticResource StyleWrongButton}"
   247                                     HorizontalAlignment="Center"
   248                                     Margin="0,5,5,5"
   249                                     Content="{Binding Path=ExpandedButton2Text, FallbackValue=Wrong}"
   250                                     Click="ButtonWrong_Click" />
   251                             <Button Style="{StaticResource StyleConfirmButton}"
   252                                     HorizontalAlignment="Center"
   253                                     Margin="5,5,0,5"
   254                                     Content="{Binding Path=ExpandedButton1Text, FallbackValue=Confirm}"
   255                                     Click="ButtonConfirm_Click"
   256                                     IsDefault="True"
   257                                     Loaded="ConfirmButton_Loaded" />
   258                         </StackPanel>
   259                     </StackPanel>
   260                 </StackPanel>
   261             </DataTemplate>
   262 
   263             <!-- Dictionary -->
   264             <ResourceDictionary.MergedDictionaries>
   265                 <ResourceDictionary Source="pack://application:,,,/pEp;component/Resources/Dictionary.xaml" />
   266             </ResourceDictionary.MergedDictionaries>
   267         </ResourceDictionary>
   268     </Window.Resources>
   269 
   270     <!--The window content-->
   271     <StackPanel Margin="10"
   272                 Width="470">
   273 
   274         <!--Information section-->
   275         <TextBlock Text="{Binding Path=ExplanationText, Mode=OneWay}"
   276                    TextWrapping="Wrap"
   277                    Margin="5,5,5,15" />
   278 
   279         <!--Identities section-->
   280         <ItemsControl ItemsSource="{Binding Path=Items}"
   281                       ItemTemplate="{StaticResource HandshakeItemsTemplate}" />
   282 
   283         <!--Expander for identities without color-->
   284         <StackPanel Visibility="{Binding Path=IsExpanderVisible, Converter={StaticResource BoolToVisibility}}">
   285             <StackPanel Orientation="Horizontal"
   286                         HorizontalAlignment="Center"
   287                         VerticalAlignment="Center">
   288                 <Expander ExpandDirection="Down"
   289                           Margin="10"
   290                           Collapsed="NonColorRecipientsExpander_Toggled"
   291                           Expanded="NonColorRecipientsExpander_Toggled" />
   292                 <TextBlock Text="{x:Static p:Resources.Handshake_ShowAllRecipientsText}"
   293                            TextWrapping="Wrap"
   294                            VerticalAlignment="Center"
   295                            Margin="10" />
   296             </StackPanel>
   297 
   298             <!--Identities section-->
   299             <ItemsControl ItemsSource="{Binding Path=NonColorItems}"
   300                           ItemTemplate="{StaticResource HandshakeItemsTemplate}"
   301                           Visibility="{Binding Path=IsExpanderExpanded, Converter={StaticResource BoolToVisibility}}"/>
   302 
   303         </StackPanel>
   304     </StackPanel>
   305 </Window>