66 lines
3.7 KiB
XML
66 lines
3.7 KiB
XML
<UserControl xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:m="clr-namespace:XSDVisualiser.Models;assembly=XSDVisualiser.Core"
|
|
x:Class="XSDVisualiser.Desktop.Views.LeftTreeView"
|
|
x:CompileBindings="False">
|
|
<Border Background="{DynamicResource PanelBackgroundBrush}"
|
|
BorderBrush="{DynamicResource PanelBorderBrush}"
|
|
BorderThickness="1" CornerRadius="6" Margin="0,8,8,0">
|
|
<ScrollViewer>
|
|
<TreeView x:Name="SchemaTree" ItemsSource="{Binding VisibleRootElements}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}">
|
|
<TreeView.DataTemplates>
|
|
<TreeDataTemplate DataType="{x:Type m:SchemaNode}" ItemsSource="{Binding Children}">
|
|
<StackPanel>
|
|
<!-- Connector line from parent to this node (hidden for roots where ContentModel is null) -->
|
|
<Grid Margin="0,8,8,2" IsVisible="{Binding ContentModel, Converter={x:Static ObjectConverters.IsNotNull}}"
|
|
ColumnDefinitions="16,*">
|
|
<!-- leading small elbow -->
|
|
<Rectangle Grid.Column="0" Width="16" Height="2" Fill="{DynamicResource SeparatorBrush}" VerticalAlignment="Center"/>
|
|
<Grid Grid.Column="1">
|
|
<Rectangle Height="2" Fill="{DynamicResource SeparatorBrush}" VerticalAlignment="Center"/>
|
|
<TextBlock Text="{Binding Cardinality, Converter={StaticResource CardinalityToLabel}}"
|
|
Background="{DynamicResource BadgeBackgroundBrush}" Padding="6,0"
|
|
Foreground="{DynamicResource SubtleTextBrush}"
|
|
HorizontalAlignment="Center"/>
|
|
</Grid>
|
|
</Grid>
|
|
|
|
<!-- Node content -->
|
|
<Border CornerRadius="4"
|
|
BorderBrush="{Binding Cardinality, Converter={StaticResource OptionalToBrush}}"
|
|
BorderThickness="{Binding Cardinality, Converter={StaticResource OptionalToThickness}}"
|
|
Padding="8" Margin="0,0,8,6" Background="{DynamicResource PanelBackgroundBrush}">
|
|
<Border.ContextMenu>
|
|
<ContextMenu>
|
|
<MenuItem Header="Copy as TSV" Click="OnCopyAsTsvClick"/>
|
|
</ContextMenu>
|
|
</Border.ContextMenu>
|
|
<StackPanel Orientation="Vertical" Spacing="2">
|
|
<!-- Name on its own line, prominent -->
|
|
<TextBlock Text="{Binding Name}" FontWeight="SemiBold"/>
|
|
|
|
<!-- Path/Namespace on its own line -->
|
|
<TextBlock Text="{Binding Namespace, StringFormat=Namespace: {0}}"
|
|
Foreground="{DynamicResource SubtleTextBrush}"/>
|
|
|
|
<!-- Type info on its own line (TypeName with fallback to BuiltInType) -->
|
|
<StackPanel Orientation="Horizontal" Spacing="6">
|
|
<TextBlock Text="Type:" FontWeight="Medium"/>
|
|
<TextBlock Text="{Binding TypeName}"/>
|
|
<TextBlock Text="{Binding BuiltInType, StringFormat=({0})}"
|
|
Foreground="{DynamicResource MutedTextBrush}"/>
|
|
</StackPanel>
|
|
|
|
<!-- Optional: show content model as a subtle hint -->
|
|
<TextBlock Text="{Binding ContentModel, StringFormat=Model: {0}}"
|
|
Foreground="{DynamicResource SubtleTextBrush}" FontWeight="SemiBold"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</StackPanel>
|
|
</TreeDataTemplate>
|
|
</TreeView.DataTemplates>
|
|
</TreeView>
|
|
</ScrollViewer>
|
|
</Border>
|
|
</UserControl>
|