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

<UserControl x:Class="Arrowheads.Arrowheads"
    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:go="http://schemas.nwoods.com/GoXam"
    xmlns:local="clr-namespace:Arrowheads">

  <UserControl.Resources>
    <!-- A simple Node template which disallows user interaction with Nodes.
         It supports data binding for the Node.Location and the Width and Height properties. -->
    <DataTemplate x:Key="NodeTemplate">
      <go:NodePanel go:Part.Selectable="False"
                    go:Node.LocationSpot="Center"
                    go:Node.Location="{Binding Path=Data.Location, Mode=OneTime}"
                    MouseEnter="NodePanel_MouseEnter">
        <go:NodeShape go:NodePanel.Figure="Ellipse"
                      Width="{Binding Data.Diameter, Mode=OneTime}"
                      Height="{Binding Data.Diameter, Mode=OneTime}">
          <Shape.Fill>
            <RadialGradientBrush>
              <GradientStop Offset="0" Color="Black" />
              <GradientStop Offset="1" Color="Gray" />
            </RadialGradientBrush>
          </Shape.Fill>
        </go:NodeShape>
        <TextBlock Text="{Binding Path=Data.Text}"
                   FontSize="12" Foreground="White"
                   HorizontalAlignment="Center" VerticalAlignment="Center" />
      </go:NodePanel>
    </DataTemplate>

    <!-- Convert an Arrowhead to a Brush or null, depending on whether it should be filled. -->
    <local:ArrowheadFillConverter x:Key="theArrowheadFillConverter" Fill="Red" />

    <!-- A simple Link Template that data binds the LinkPanel.[To/From]Arrow properties. -->
    <DataTemplate x:Key="LinkTemplate">
      <go:LinkPanel go:Part.Selectable="False">
        <go:LinkShape Stroke="Gray" StrokeThickness="1" />
        <Path Stroke="Black" StrokeThickness="1"
              Fill="{Binding Path=Data.ToArrow, Converter={StaticResource theArrowheadFillConverter}}"
              go:LinkPanel.ToArrow="{Binding Path=Data.ToArrow, Mode=OneTime}"
              go:LinkPanel.ToArrowScale="2" />
        <Path Stroke="Black" StrokeThickness="1"
              Fill="{Binding Path=Data.FromArrow, Converter={StaticResource theArrowheadFillConverter}}"
              go:LinkPanel.FromArrow="{Binding Path=Data.FromArrow, Mode=OneTime}"
              go:LinkPanel.FromArrowScale="2" /> 
      </go:LinkPanel>
    </DataTemplate>
  </UserControl.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0">
      <TextBlock Text="Move the mouse over a Node to get the Arrowhead names on the Link into it." />
      <StackPanel Orientation="Vertical">
        <TextBlock x:Name="ToArrowheadName" Text="ToArrow = " FontSize="16" Margin="5" />
        <TextBlock x:Name="FromArrowheadName" Text="FromArrow = " FontSize="16" Margin="5" />
      </StackPanel>
    </StackPanel>
    <go:Diagram Grid.Row="1" x:Name="myDiagram"
                NodeTemplate="{StaticResource NodeTemplate}"
                LinkTemplate="{StaticResource LinkTemplate}" 
                VerticalContentAlignment="Center"
                HorizontalContentAlignment="Center"
                InitialStretch="Uniform"
                Loaded="myDiagram_Loaded" />
  </Grid>
</UserControl>