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

<UserControl x:Class="BeatPaths.BeatPaths"
    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:BeatPaths">

  <UserControl.Resources>
    <!-- this converts a team name to an ImageSource referring to an image on www.goxam.com -->
    <local:TextImageSourceConverter x:Key="theTextImageSourceConverter" />

    <DataTemplate x:Key="NodeTemplate">
      <!-- the "Icon" gets the selection handle when the node is selected -->
      <StackPanel go:Part.SelectionElementName="Icon" go:Part.SelectionAdorned="True">
        <!-- the node data is just the team name string -->
        <TextBlock Text="{Binding Path=Data}" HorizontalAlignment="Center" />
        <!-- this creates the ImageSource by converting it from the team name -->
        <Image x:Name="Icon"
               Source="{Binding Path=Data,
                        Converter={StaticResource theTextImageSourceConverter}}"
               Width="50" Height="50" HorizontalAlignment="Center" />
      </StackPanel>
    </DataTemplate>
    
    <DataTemplate x:Key="LinkTemplate">
      <go:LinkPanel go:Part.SelectionElementName="Path" go:Part.SelectionAdorned="True">
        <!-- the link's Route is drawn as a Bezier curve -->
        <go:Link.Route>
          <go:Route Curve="Bezier" />
        </go:Link.Route>
        <!-- a simple thin black line -->
        <go:LinkShape x:Name="Path" Stroke="Black" StrokeThickness="1" />
        <!-- a standard arrowhead -->
        <Path Fill="Black" go:LinkPanel.ToArrow="Standard" />
      </go:LinkPanel>
    </DataTemplate>
  </UserControl.Resources>
  
  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                InitialStretch="Uniform"
                HorizontalContentAlignment="Center"
                VerticalContentAlignment="Center"
                NodeTemplate="{StaticResource NodeTemplate}"
                LinkTemplate="{StaticResource LinkTemplate}">
      <go:Diagram.Layout>
        <!-- automatically lay out the nodes in layers -->
        <go:LayeredDigraphLayout Direction="90" SetsPortSpots="False"
                                 ColumnSpacing="15" LayerSpacing="10" />
      </go:Diagram.Layout>
    </go:Diagram>
  </Grid>
</UserControl>
