UI/HandshakeDialog.xaml
author Thomas
Wed, 25 Oct 2017 14:21:44 +0200
branchOUT-308
changeset 1885 a284dbe6cf79
parent 1878 8883864e2b0e
child 1995 fbdb1ab657f4
permissions -rw-r--r--
Adjust design, reorder, add deletion of internal messages
     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             <!-- Dictionary -->
    60             <ResourceDictionary.MergedDictionaries>
    61                 <ResourceDictionary Source="pack://application:,,,/pEp;component/Resources/Dictionary.xaml" />
    62             </ResourceDictionary.MergedDictionaries>
    63         </ResourceDictionary>
    64     </Window.Resources>
    65 
    66     <!--The window content-->
    67     <StackPanel Margin="10"
    68                 Width="470">
    69 
    70         <!--Information section-->
    71         <TextBlock Text="{Binding Path=ExplanationText, Mode=OneWay}"
    72                    TextWrapping="Wrap"
    73                    Margin="5,5,5,15" />
    74 
    75         <!--Identities section-->
    76         <ItemsControl ItemsSource="{Binding Path=Items}">
    77             <ItemsControl.ItemTemplate>
    78                 <DataTemplate>
    79 
    80                     <!--Template for identities-->
    81                     <StackPanel>
    82                         <StackPanel.Style>
    83                             <Style TargetType="StackPanel">
    84                                 <Setter Property="Background"
    85                                         Value="Transparent" />
    86                                 <Style.Triggers>
    87                                     <MultiDataTrigger>
    88                                         <MultiDataTrigger.Conditions>
    89                                             <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
    90                                                        Value="True" />
    91                                             <Condition Binding="{Binding Path=IsExpanded}"
    92                                                        Value="False" />
    93                                             <Condition Binding="{Binding Path=IsButtonVisible}"
    94                                                        Value="False" />
    95                                             <Condition Binding="{Binding Path=IsClickable}"
    96                                                        Value="True" />
    97                                         </MultiDataTrigger.Conditions>
    98                                         <Setter Property="Background"
    99                                                 Value="{x:Static SystemColors.ControlLightBrush}" />
   100                                     </MultiDataTrigger>
   101                                 </Style.Triggers>
   102                             </Style>
   103                         </StackPanel.Style>
   104 
   105                         <!--Separator between items-->
   106                         <Separator Margin="5,5,5,0"
   107                                    Background="LightGray"
   108                                    Visibility="{Binding Path=IsSeparatorVisible, Converter={StaticResource BoolToVisibility}}" />
   109 
   110                         <!--The list entry-->
   111                         <Grid Name="IdentityGrid"
   112                               Background="Transparent"
   113                               Margin="5"
   114                               MinHeight="38"
   115                               MouseLeftButtonUp="IdentityGrid_MouseLeftButtonUp"
   116                               Visibility="{Binding Path=Mode, Converter={StaticResource IsNotSyncModeToVisibility}}">
   117                             <Grid.ColumnDefinitions>
   118                                 <ColumnDefinition Width="Auto" />
   119                                 <ColumnDefinition Width="*" />
   120                                 <ColumnDefinition Width="Auto" />
   121                             </Grid.ColumnDefinitions>
   122 
   123                             <!--The identity rating-->
   124                             <Image Grid.Column="0"
   125                                    Height="15"
   126                                    Stretch="Uniform"
   127                                    VerticalAlignment="Stretch"
   128                                    HorizontalAlignment="Center"
   129                                    Margin="0,0,5,0"
   130                                    Source="{Binding Path=ItemImage, Mode=OneWay}">
   131                             </Image>
   132 
   133                             <!--The identity name-->
   134                             <TextBlock Grid.Column="1"
   135                                        HorizontalAlignment="Left"
   136                                        VerticalAlignment="Center"
   137                                        Margin="5,0"
   138                                        Text="{Binding Path=ItemName, Mode=OneWay}" />
   139 
   140                             <!--Trust button-->
   141                             <Button Grid.Column="2"
   142                                     Style="{StaticResource StyleTrustButton}"
   143                                     Visibility="{Binding Path=IsButtonVisible, Converter={StaticResource BoolToVisibility}}"
   144                                     Margin="5"
   145                                     HorizontalAlignment="Right"
   146                                     Content="{Binding Path=ButtonText, Mode=OneWay}"
   147                                     Click="ButtonTrust_Click" />
   148                         </Grid>
   149 
   150                         <!--Advanced section-->
   151                         <StackPanel Visibility="{Binding Path=IsExpanded, Converter={StaticResource BoolToVisibility}}">
   152 
   153                             <!--Tabs-->
   154                             <StackPanel Orientation="Horizontal"
   155                                         HorizontalAlignment="Right">
   156                                 <Label Name="TrustwordsTabControl"
   157                                        MouseLeftButtonUp="TabControl_MouseLeftButtonUp"
   158                                        Content="{x:Static p:Resources.Handshake_TrustwordsText}"
   159                                        Visibility="{Binding Path=AreTabControlsVisible, Converter={StaticResource BoolToVisibility}}">
   160                                     <Label.Style>
   161                                         <Style TargetType="Label">
   162                                             <Setter Property="BorderBrush"
   163                                                     Value="LightGray" />
   164                                             <Setter Property="Background"
   165                                                     Value="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBackground}, ConverterParameter=Trustwords}" />
   166                                             <Setter Property="BorderThickness"
   167                                                     Value="1" />
   168                                             <Setter Property="Padding"
   169                                                     Value="10,5" />
   170                                             <Style.Triggers>
   171                                                 <MultiDataTrigger>
   172                                                     <MultiDataTrigger.Conditions>
   173                                                         <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
   174                                                                    Value="True" />
   175                                                         <Condition Binding="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Trustwords}"
   176                                                                    Value="False" />
   177                                                     </MultiDataTrigger.Conditions>
   178                                                     <Setter Property="Background"
   179                                                             Value="AliceBlue" />
   180                                                     <Setter Property="BorderBrush"
   181                                                             Value="LightSkyBlue" />
   182                                                 </MultiDataTrigger>
   183                                             </Style.Triggers>
   184                                         </Style>
   185                                     </Label.Style>
   186                                 </Label>
   187                                 <Label Name="FingerprintTabControl"
   188                                        MouseLeftButtonUp="TabControl_MouseLeftButtonUp"
   189                                        Content="{x:Static p:Resources.Handshake_FingerprintText}"
   190                                        Visibility="{Binding Path=AreTabControlsVisible, Converter={StaticResource BoolToVisibility}}">
   191                                     <Label.Style>
   192                                         <Style TargetType="Label">
   193                                             <Setter Property="BorderBrush"
   194                                                     Value="LightGray" />
   195                                             <Setter Property="Background"
   196                                                     Value="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBackground}, ConverterParameter=Fingerprint}" />
   197                                             <Setter Property="BorderThickness"
   198                                                     Value="1" />
   199                                             <Setter Property="Padding"
   200                                                     Value="10,5" />
   201                                             <Style.Triggers>
   202                                                 <MultiDataTrigger>
   203                                                     <MultiDataTrigger.Conditions>
   204                                                         <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
   205                                                                    Value="True" />
   206                                                         <Condition Binding="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Fingerprint}"
   207                                                                    Value="False" />
   208                                                     </MultiDataTrigger.Conditions>
   209                                                     <Setter Property="Background"
   210                                                             Value="AliceBlue" />
   211                                                     <Setter Property="BorderBrush"
   212                                                             Value="LightSkyBlue" />
   213                                                 </MultiDataTrigger>
   214                                             </Style.Triggers>
   215                                         </Style>
   216                                     </Label.Style>
   217                                 </Label>
   218 
   219                                 <!--Language selector-->
   220                                 <ComboBox Padding="10,2"
   221                                           VerticalContentAlignment="Center"
   222                                           ItemsSource="{Binding Path=TrustwordsCultureList, Mode=OneWay}"
   223                                           DisplayMemberPath="Value"
   224                                           SelectedValuePath="Key"
   225                                           SelectedValue="{Binding Path=TrustwordsCulture, Mode=TwoWay}"
   226                                           IsEnabled="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToBool}, ConverterParameter=Trustwords}"
   227                                           Foreground="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource IsEnabledToColor}}" />
   228                             </StackPanel>
   229 
   230                             <!-- Trustwords -->
   231                             <StackPanel Background="White"
   232                                         Visibility="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToVisibility}, ConverterParameter=Trustwords}">
   233                                 <TextBlock Text="{Binding Path=TrustwordsShort}"
   234                                            Visibility="{Binding Path=AreTrustwordsExpanded, Converter={StaticResource InvertBoolToVisibility}}"
   235                                            TextWrapping="Wrap"
   236                                            Padding="10" />
   237                                 <TextBlock Text="{Binding Path=TrustwordsFull}"
   238                                            Visibility="{Binding Path=AreTrustwordsExpanded, Converter={StaticResource BoolToVisibility}}"
   239                                            TextWrapping="Wrap"
   240                                            Padding="10" />
   241                                 <Expander ExpandDirection="Down"
   242                                           Margin="10,10,5,5"
   243                                           ToolTip="{Binding Path=ExpanderToolTip, Mode=OneWay}"
   244                                           Collapsed="Expander_Collapsed"
   245                                           Expanded="Expander_Expanded" />
   246                             </StackPanel>
   247 
   248                             <!--Fingerprints-->
   249                             <StackPanel Background="White"
   250                                         Visibility="{Binding Path=ActiveTab, Converter={StaticResource IsActiveTabToVisibility}, ConverterParameter=Fingerprint}">
   251                                 <TextBlock Text="{Binding Path=UIDPartner}"
   252                                            Margin="10,10,10,2" />
   253                                 <TextBlock Text="{Binding Path=FingerprintPartner}"
   254                                            Margin="10,2,10,22" />
   255                                 <TextBlock Text="{Binding Path=UIDMyself}"
   256                                            Margin="10,10,10,2" />
   257                                 <TextBlock Text="{Binding Path=FingerprintMyself}"
   258                                            Margin="10,2,10,10" />
   259                             </StackPanel>
   260 
   261                             <!-- Buttons -->
   262                             <StackPanel Grid.Row="5"
   263                                         Orientation="Horizontal"
   264                                         HorizontalAlignment="Right"
   265                                         Margin="0,5,0,0">
   266                                 <Button Style="{StaticResource StyleWrongButton}"
   267                                         HorizontalAlignment="Center"
   268                                         Margin="0,5,5,5"
   269                                         Content="{Binding Path=ExpandedButton2Text, FallbackValue=Wrong}"
   270                                         Click="ButtonWrong_Click" />
   271                                 <Button Style="{StaticResource StyleConfirmButton}"
   272                                         HorizontalAlignment="Center"
   273                                         Margin="5,5,0,5"
   274                                         Content="{Binding Path=ExpandedButton1Text, FallbackValue=Confirm}"
   275                                         Click="ButtonConfirm_Click"
   276                                         IsDefault="True"
   277                                         Loaded="ConfirmButton_Loaded"/>
   278                             </StackPanel>
   279                         </StackPanel>
   280                     </StackPanel>
   281                 </DataTemplate>
   282             </ItemsControl.ItemTemplate>
   283         </ItemsControl>
   284     </StackPanel>
   285 </Window>