UI/PrivacyView.xaml
author Thomas
Tue, 03 Apr 2018 10:17:13 +0200
branchOUT-369
changeset 2100 91f72cbed562
parent 1548 f45d44448548
permissions -rw-r--r--
Close branch OUT-369
     1 <UserControl x:Class="pEp.UI.PrivacyView"
     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:local="clr-namespace:pEp.UI"
     7              mc:Ignorable="d"
     8              MinHeight="28"
     9              MinWidth="140"
    10              d:DesignHeight="28"
    11              d:DesignWidth="140">
    12     <UserControl.Resources>
    13         <ResourceDictionary>
    14             <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
    15             <ResourceDictionary.MergedDictionaries>
    16                 <ResourceDictionary Source="pack://application:,,,/pEp;component/Resources/Dictionary.xaml" />
    17             </ResourceDictionary.MergedDictionaries>
    18         </ResourceDictionary>
    19     </UserControl.Resources>
    20     <Grid>
    21         <Border Name="BorderLayoutRoot"
    22                 Background="{Binding Path=DisplayState.Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    23                 HorizontalAlignment="Stretch"
    24                 VerticalAlignment="Stretch"
    25                 BorderBrush="Black"
    26                 BorderThickness="1"
    27                 Padding="{StaticResource ButtonPaddingStandard}">
    28             <Grid>
    29                 <Grid.ColumnDefinitions>
    30                     <ColumnDefinition Width="auto" />
    31                     <ColumnDefinition Width="*" />
    32                 </Grid.ColumnDefinitions>
    33                 <Image Grid.Column="0"
    34                        Stretch="Uniform"
    35                        VerticalAlignment="Stretch"
    36                        Margin="0,0,5,0"
    37                        Visibility="{Binding Path=DisplayState.IsInIndicatorMode, Converter={StaticResource BoolToVisibility}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}, FallbackValue=Collapsed}">
    38                     <Image.Style>
    39                         <Style TargetType="Image">
    40                             <Style.Triggers>
    41                                 <DataTrigger Binding="{Binding Path='DisplayState.Color', RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    42                                              Value="pEpColorGreen">
    43                                     <Setter Property="Source"
    44                                             Value="pack://application:,,,/pEp;component/Resources/ImagePrivacyStatusGreenInvert.png" />
    45                                 </DataTrigger>
    46                                 <DataTrigger Binding="{Binding Path='DisplayState.Color', RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    47                                              Value="pEpColorNoColor">
    48                                     <Setter Property="Source"
    49                                             Value="pack://application:,,,/pEp;component/Resources/ImagePrivacyStatusNoColorInvert.png" />
    50                                 </DataTrigger>
    51                                 <DataTrigger Binding="{Binding Path='DisplayState.Color', RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    52                                              Value="pEpColorRed">
    53                                     <Setter Property="Source"
    54                                             Value="pack://application:,,,/pEp;component/Resources/ImagePrivacyStatusRedInvert.png" />
    55                                 </DataTrigger>
    56                                 <DataTrigger Binding="{Binding Path='DisplayState.Color', RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    57                                              Value="pEpColorYellow">
    58                                     <Setter Property="Source"
    59                                             Value="pack://application:,,,/pEp;component/Resources/ImagePrivacyStatusYellowInvert.png" />
    60                                 </DataTrigger>
    61                             </Style.Triggers>
    62                         </Style>
    63                     </Image.Style>
    64                 </Image>
    65                 <TextBlock Grid.Column="1"
    66                            Foreground="{Binding Path=DisplayState.Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    67                            Text="{Binding Path=DisplayState.Text, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}"
    68                            TextAlignment="Center"
    69                            HorizontalAlignment="Center"
    70                            VerticalAlignment="Center"
    71                            FontFamily="Arial"
    72                            FontSize="13" />
    73             </Grid>
    74         </Border>
    75         <Grid Name="GridHitTarget"
    76               Tag="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PrivacyView}}}">
    77             <!--
    78                 Note: A tooltip is not part of the visual tree we are using here.
    79                 This means any RelativeSource in binding will not work correctly.
    80                 As a work around, the Tag in the 'PlacementTarget' is used to store the reference to the PrivacyView.
    81                 This is then relayed to the ToolTip itself where the tooltip can then use bindings to the PrivacyView state.
    82                 A downside is this is setting the DataContext. But that shouldn't be an issue as this never needs to be used 
    83                 outside this control.
    84             -->
    85             <Grid.ToolTip>
    86                 <ToolTip DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}"
    87                          Visibility="{Binding Path=DisplayState.ToolTipIsVisible, Converter={StaticResource BoolToVisibility}, FallbackValue=Collapsed}">
    88                     <TextBlock Text="{Binding Path=DisplayState.ToolTip}" />
    89                 </ToolTip>
    90             </Grid.ToolTip>
    91             <Grid.Background>
    92                 <SolidColorBrush>
    93                     <SolidColorBrush.Color>
    94                         <!-- Not fully transparent to catch mouse events -->
    95                         <Color A="1"
    96                                R="255"
    97                                G="255"
    98                                B="255" />
    99                     </SolidColorBrush.Color>
   100                 </SolidColorBrush>
   101             </Grid.Background>
   102         </Grid>
   103     </Grid>
   104 </UserControl>