<!-- Copyright © Northwoods Software Corporation, 2008-2026. All Rights Reserved. -->

<UserControl x:Class="Genogram.Genogram"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:go="http://schemas.nwoods.com/GoXam"
    xmlns:local="clr-namespace:Genogram">

  <UserControl.Resources>
    <local:AttributeFillConverter x:Key="AttributeFillConv" />
    <local:MaleGeometryConverter x:Key="MaleGeometryConv" />
    <local:FemaleGeometryConverter x:Key="FemaleGeometryConv" />

    <go:DataTemplateDictionary x:Key="NodeTemplates">
      <DataTemplate x:Key="M">
        <StackPanel go:Part.SelectionAdorned="True">
          <Grid HorizontalAlignment="Center">
            <!-- this holds all of the shapes corresponding to attributes/markers -->
            <ItemsControl ItemsSource="{Binding Path=Data.Attributes}">
              <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                  <Canvas />
                </ItemsPanelTemplate>
              </ItemsControl.ItemsPanel>
              <ItemsControl.ItemTemplate>
                <DataTemplate>
                  <Path Canvas.Left="0" Canvas.Top="0"
                        Stroke="{x:Null}" StrokeThickness="0"
                        Fill="{Binding Converter={StaticResource AttributeFillConv}}"
                        Data="{Binding Converter={StaticResource MaleGeometryConv}}" />
                </DataTemplate>
              </ItemsControl.ItemTemplate>
            </ItemsControl>
            <Rectangle Width="40" Height="40"
                       Stroke="Black" StrokeThickness="2" Fill="Transparent"
                       go:Node.PortId="" />
          </Grid>
          <TextBlock HorizontalAlignment="Center"
                     Text="{Binding Path=Data.Text}" />
        </StackPanel>
      </DataTemplate>
      
      <DataTemplate x:Key="F">
        <StackPanel go:Part.SelectionAdorned="True">
          <Grid HorizontalAlignment="Center">
            <!-- this holds all of the shapes corresponding to attributes/markers -->
            <ItemsControl ItemsSource="{Binding Path=Data.Attributes}">
              <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                  <Canvas />
                </ItemsPanelTemplate>
              </ItemsControl.ItemsPanel>
              <ItemsControl.ItemTemplate>
                <DataTemplate>
                  <Path Canvas.Left="0" Canvas.Top="0"
                        Stroke="{x:Null}" StrokeThickness="0"
                        Fill="{Binding Converter={StaticResource AttributeFillConv}}"
                        Data="{Binding Converter={StaticResource FemaleGeometryConv}}" />
                </DataTemplate>
              </ItemsControl.ItemTemplate>
            </ItemsControl>
            <Ellipse Width="40" Height="40"
                     Stroke="Black" StrokeThickness="2" Fill="Transparent"
                     go:Node.PortId="" />
          </Grid>
          <TextBlock HorizontalAlignment="Center"
                     Text="{Binding Path=Data.Text}" />
        </StackPanel>
      </DataTemplate>
      
      <DataTemplate x:Key="LinkLabel">
        <Rectangle Width="1" Height="1" go:Part.Selectable="False" />
      </DataTemplate>
    </go:DataTemplateDictionary>

    <go:DataTemplateDictionary x:Key="LinkTemplates">
      <DataTemplate x:Key="ParentChild">
        <go:LinkPanel go:Part.Selectable="False">
          <go:Link.Route>
            <go:Route Routing="Orthogonal" Curviness="10" FromSpot="MiddleBottom" ToSpot="MiddleTop" />
          </go:Link.Route>
          <go:LinkShape Stroke="Black" StrokeThickness="2" />
        </go:LinkPanel>
      </DataTemplate>
      
      <DataTemplate x:Key="Marriage">
        <go:LinkPanel go:Part.Selectable="False">
          <go:LinkShape Stroke="DarkGreen" StrokeThickness="2" />
        </go:LinkPanel>
      </DataTemplate>
    </go:DataTemplateDictionary>
  </UserControl.Resources>
  
  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                InitialStretch="Uniform"
                HorizontalContentAlignment="Center"
                VerticalContentAlignment="Center"
                NodeTemplateDictionary="{StaticResource NodeTemplates}"
                LinkTemplateDictionary="{StaticResource LinkTemplates}">
      <go:Diagram.Layout>
        <local:GenogramLayout Angle="90" LayerSpacing="60" />
      </go:Diagram.Layout>
    </go:Diagram>
  </Grid>
</UserControl>
