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

<UserControl x:Class="SequenceDiagram.SequenceDiagram"
    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:SequenceDiagram">
  <UserControl.Resources>
    <DataTemplate x:Key="Activity">
      <Rectangle go:Node.LocationSpot="MiddleTop"
                 go:Node.Location="{Binding Path=Data.Location}"
                 Width="15" Height="{Binding Path=Data.Length}"
                 Fill="White" Stroke="Black"
                 go:Part.Selectable="False" />
    </DataTemplate>
    
    <DataTemplate x:Key="Lifeline">
      <StackPanel go:Node.LocationSpot="Center" go:Node.LocationElementName="Header"
                  go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
                  go:Node.MinLocation="0 0" go:Node.MaxLocation="9999 0"
                  go:Part.SelectionAdorned="True" go:Part.SelectionElementName="LINE">
        <Border x:Name="Header" BorderBrush="Black" BorderThickness="1" Background="LightGreen">
          <TextBlock Margin="5" Text="{Binding Path=Data.Text}" />
        </Border>
        <Line x:Name="LINE" Stroke="Gray" StrokeDashArray="3 3" 
              X1="0" Y1="0" X2="0" Y2="{Binding Path=Data.Length}"
              HorizontalAlignment="Center" />
      </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="Message">
      <go:LinkPanel go:Part.SelectionAdorned="True" go:Part.SelectionElementName="Path">
        <go:Link.Route>
          <local:BarRoute Curviness="0" />
        </go:Link.Route>
        <go:LinkShape x:Name="Path" Stroke="Black" StrokeThickness="1" />
        <Path go:LinkPanel.ToArrow="OpenTriangle" Stroke="Black" />
        <TextBlock Text="{Binding Path=Data.Text}" go:LinkPanel.Index="0" go:LinkPanel.Offset="NaN NaN" />
      </go:LinkPanel>
    </DataTemplate>
  </UserControl.Resources>

  <Grid>
    <go:Diagram x:Name="myDiagram"
                HorizontalContentAlignment="Stretch"
                VerticalContentAlignment="Stretch"
                Padding="10"
                NodeTemplate="{StaticResource Activity}"
                GroupTemplate="{StaticResource Lifeline}"
                LinkTemplate="{StaticResource Message}"
                AllowDelete="False" AllowCopy="False">
    </go:Diagram>
    <StackPanel Orientation="Horizontal"
                HorizontalAlignment="Right" VerticalAlignment="Top">
      <Button Content="Save" Click="Save_Click" />
      <Button Content="Load" Click="Load_Click" x:Name="LoadButton" IsEnabled="False" />
    </StackPanel>
  </Grid>
</UserControl>
