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