Files
C4IT-F4SD-Client/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml
2025-11-11 19:43:15 +01:00

161 lines
9.2 KiB
XML

<UserControl x:Class="FasdDesktopUi.Basics.UserControls.HierarchicalSelectionControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
xmlns:models="clr-namespace:FasdDesktopUi.Basics.Models"
mc:Ignorable="d"
x:Name="HierarchySelector"
Focusable="True"
d:DesignHeight="60"
d:DesignWidth="350">
<UserControl.Resources>
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
</UserControl.Resources>
<Grid>
<Border x:Name="DisplayBorder"
Height="28"
Background="{Binding ElementName=HierarchySelector, Path=ComboBoxBackground}"
BorderBrush="{Binding ElementName=HierarchySelector, Path=BorderBrush}"
BorderThickness="1"
CornerRadius="7.5"
Padding="6 0"
MouseLeftButtonUp="DisplayBorder_MouseLeftButtonUp">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Opacity" Value="1" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsOpen, ElementName=DropDownPopup}"
Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource BackgroundColor.Menu.SubCategory.Hover}" />
<Setter Property="Background" Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}" />
</DataTrigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource BackgroundColor.Menu.SubCategory.Hover}" />
</Trigger>
<DataTrigger Binding="{Binding ElementName=HierarchySelector, Path=IsEnabled}"
Value="False">
<Setter Property="Opacity" Value="0.5" />
<Setter Property="Cursor" Value="Arrow" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0"
Margin="0 0 10 0"
VerticalAlignment="Center">
<TextBlock Text="{Binding ElementName=HierarchySelector, Path=SelectedItem.FullPath}"
Foreground="{DynamicResource FontColor.Menu.Categories}"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding ElementName=HierarchySelector, Path=SelectedItem.FullPath}" />
</Grid>
<Path Grid.Column="1"
Margin="0 0 6 0"
Data="F1 M 2.89067,4.99467C 2.89067,4.22933 3.724,3.74533 4.39067,4.13067L 10.8227,7.844L 17.26,4.13067C 18.412,3.48 19.4013,5.19333 18.26,5.86533L 11.3227,9.86533C 11.016,10.0413 10.636,10.0413 10.3227,9.86533L 3.39067,5.86533C 3.07867,5.688 2.89067,5.35467 2.89067,4.99467 Z"
Fill="{DynamicResource Color.Menu.Icon}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Width="10"
Height="6"
Stretch="Uniform"
IsHitTestVisible="False" />
</Grid>
</Border>
<Popup x:Name="DropDownPopup"
PlacementTarget="{Binding ElementName=DisplayBorder}"
Placement="Bottom"
StaysOpen="False"
AllowsTransparency="True"
Width="{Binding ElementName=DisplayBorder, Path=ActualWidth}"
Opened="DropDownPopup_Opened"
Closed="DropDownPopup_Closed">
<Border Background="{DynamicResource BackgroundColor.Menu.SubCategory}"
CornerRadius="7.5"
Padding="10">
<Border.Effect>
<DropShadowEffect BlurRadius="10"
Color="{DynamicResource DropShadowColor.Menu}"
Direction="55"
ShadowDepth="10"
Opacity="0.35" />
</Border.Effect>
<StackPanel>
<Grid Margin="0 0 10 0">
<TextBox x:Name="SearchTextBox"
Style="{DynamicResource Customizable.Editable.TextBox.EditOnly}"
Background="{Binding ElementName=HierarchySelector, Path=ComboBoxBackground}"
Padding="27 5 5 5"
VerticalContentAlignment="Center"
TextChanged="SearchTextBox_TextChanged" />
<ico:AdaptableIcon SelectedInternIcon="menuBar_search"
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Base}"
BorderPadding="5 5 5 7"
Margin="0"
IconBackgroundColor="Transparent"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
<TextBlock Margin="30 0 0 0"
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Date}"
IsHitTestVisible="False"
VerticalAlignment="Center">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding Text, ElementName=SearchTextBox}"
Value="">
<Setter Property="Text"
Value="{Binding ElementName=HierarchySelector, Path=SearchPlaceholderText}" />
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<Border Margin="0 10 0 0"
Background="{DynamicResource BackgroundColor.Menu.SubCategory}"
BorderThickness="0"
CornerRadius="5">
<ScrollViewer MaxHeight="300"
VerticalScrollBarVisibility="Auto">
<TreeView x:Name="TreeViewControl"
Background="{Binding ElementName=HierarchySelector, Path=ComboBoxBackground}"
ItemsSource="{Binding VisibleItems, ElementName=HierarchySelector}"
SelectedItemChanged="TreeViewControl_SelectedItemChanged">
<TreeView.Resources>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded"
Value="{Binding IsExpanded, Mode=TwoWay}" />
</Style>
<HierarchicalDataTemplate DataType="{x:Type models:HierarchicalSelectionItem}"
ItemsSource="{Binding Children}">
<TextBlock Text="{Binding DisplayName}"
Foreground="{DynamicResource FontColor.Menu.Categories}"
Margin="0 2 0 2" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
</ScrollViewer>
</Border>
</StackPanel>
</Border>
</Popup>
</Grid>
</UserControl>