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

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

  <FrameworkElement.Resources>
    <go:BooleanBrushConverter x:Key="theBrushConv"
             TrueBrush="Red" FalseBrush="LightSeaGreen" />

    <DataTemplate x:Key="NodeTemplate">
      <StackPanel Orientation="Horizontal"
                  VerticalAlignment="Center" 
                  go:Node.LocationSpot="Center"
                  go:Node.LocationElementName="Icon">
        <!-- links go to the Ellipse, not to the whole node -->
        <Ellipse x:Name="Icon" Width="20" Height="20"
                 Fill="{Binding Path=Node.IsSelected,
                                Converter={StaticResource theBrushConv}}"
                 StrokeThickness="2"
                 go:Node.PortId="" />
        <!-- the text is rotated in code by a customized CircularLayout -->
        <TextBlock x:Name="Text"
                   VerticalAlignment="Center" Margin="5 0 0 0"
                   Text="{Binding Path=Data}" />
      </StackPanel>
    </DataTemplate>
    
    <DataTemplate x:Key="LinkTemplate">
      <go:LinkPanel go:Part.Selectable="False"
                    MouseEnter="Path_MouseEnter"
                    MouseLeave="Path_MouseLeave">
        <go:Link.Route>
          <go:Route Curve="Bezier" />
        </go:Link.Route>
        <!-- this thick transparent link shape helps respond to
             mouse events near the thin link shape -->
        <go:LinkShape
              Stroke="Transparent"
              StrokeThickness="4" />
        <go:LinkShape x:Name="Path"
            Stroke="{Binding Path=Data.Color}"
            StrokeThickness="1" />
      </go:LinkPanel>
    </DataTemplate>
  </FrameworkElement.Resources>

  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                InitialStretch="UniformToFill"
                HorizontalContentAlignment="Center"
                VerticalContentAlignment="Center"
                NodeTemplate="{StaticResource NodeTemplate}"
                LinkTemplate="{StaticResource LinkTemplate}"
                IsReadOnly="True"
                MaximumSelectionCount="1"
                SelectionChanged="myDiagram_SelectionChanged">
      <go:Diagram.Layout>
        <local:CustomLayout Spacing="10"
                            AspectRatio="1.5"
                            Sorting="Optimized" />
      </go:Diagram.Layout>
    </go:Diagram>
  </Grid>
</UserControl>