Swimlane Stacking

I am working with your planogram example.

I would like get some suggestions/help in implementing couple behaviours. Are there other examples in your library that implement behaviour I describe below, that I may have missed?
1) I am interested in having all racks stacked and have the ability for the racks to resize.
2) When I drag one rack over another, the rack that is on top moves up in the stacking order.
3) When I drag the Rack on the panel I would like it be left align.
4) How do I limit that nodes can only be draged onto a rack but not the canvas.
Thank you.
      1. Specify the following Diagram.Layout:

<go:Diagram x:Name="myDiagram" . . .> <go:Diagram.Layout> <go:GridLayout WrappingColumn="1" CellSize="1 1" Spacing="0 0" Conditions="All" Comparer="{StaticResource theYComparer}" /> </go:Diagram.Layout> </go:Diagram>
where theYComparer is declared as:

    <local:YComparer x:Key="theYComparer" />

and that YComparer class is defined as:

public class YComparer : IComparer<Node> { public int Compare(Node a, Node b) { Rect ar = a.Bounds; Rect br = b.Bounds; if (ar.Y < br.Y) return -1; if (ar.Y > br.Y) return 1; return 0; } }
4) Well, I’m not sure about the complete solution, but you can get a partial solution by adding a condition to the CustomDraggingTool.IsValidMember method:

public class CustomDraggingTool : DraggingTool { public override bool IsValidMember(Group group, Node node) { if (group == null) return false; // don't allow container Group to be null if (node != null) { ...
The reason I think it’s incomplete is that a drop is not disallowed away from a Rack. If the user does drop in the background, the node is not re-parented from whatever Rack it had been part of before (good) but it doesn’t snap back either (bad).

4b) Actually, the second part is easy too. Add the following override of DraggingTool.SnapTo:

protected override Point SnapTo(Node moving, Point pt, Node snapper, Dictionary<Part, DraggingTool.Info> draggedparts) { if (snapper == null && moving != null) return moving.Location; return base.SnapTo(moving, pt, snapper, draggedparts); }
Edit: this isn’t correct – see further posts below.

Thank you for your answer. The stacking and moving around the swimlanes worked well.

One issue I did find thought is, if the swimlane contains objects when I move the swimlane the position of the object remains the same.
Any suggestions on what I could try?
Thank you,
Pavel
Example of my StartNodeTemplate
<DataTemplate x:Key="StartNodeTemplate"> <go:NodePanel x:Name="nodePanel" Sizing="Fixed" Height="{Binding Data.Height, Mode=TwoWay}" Width="{Binding Data.Width, Mode=TwoWay}" go:Node.LocationSpot="BottomLeft" go:Node.Location="{Binding Data.Location, Mode=TwoWay}" go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}" go:Part.Resizable="{Binding BoxResizeVisible, Source={StaticResource BusinessProcessOptions}}" go:Part.ResizeCellSize="{Binding CellSize, Source={StaticResource BusinessProcessOptions}}" go:Part.SelectionAdorned="{Binding BoxResizeNotVisible, Source={StaticResource BusinessProcessOptions}}" go:Part.SelectionElementName="nodePanel" go:Part.ResizeAdornmentTemplate="{StaticResource GroupResizeAdornmentTemplate}"> <Ellipse Fill="{StaticResource theGreenBrush}" Height="{Binding Height, ElementName=nodePanel, Mode=OneWay}" Width="{Binding Width, ElementName=nodePanel, Mode=OneWay}" Stroke="Gray" /> <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=Data.Header, Mode=TwoWay}" /> <go:SpotPanel MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave"> <Rectangle Fill="Transparent" Height="{Binding Height, ElementName=nodePanel, Mode=OneWay}" Width="{Binding Width, ElementName=nodePanel, Mode=OneWay}" /> <Ellipse Style="{StaticResource EllipseStyle}" Stroke="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" Fill="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" go:Node.PortId="0" go:Node.LinkableTo="False" go:Node.FromSpot="MiddleBottom" go:SpotPanel.Spot="MiddleBottom" go:SpotPanel.Alignment="MiddleBottom"> <Ellipse.Projection> <PlaneProjection GlobalOffsetY="5" /> </Ellipse.Projection> </Ellipse> <Ellipse Style="{StaticResource EllipseStyle}" Stroke="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" Fill="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" go:Node.PortId="2" go:Node.LinkableTo="False" go:Node.FromSpot="MiddleTop" go:SpotPanel.Spot="MiddleTop" go:SpotPanel.Alignment="MiddleTop"> <Ellipse.Projection> <PlaneProjection GlobalOffsetY="-5" /> </Ellipse.Projection> </Ellipse> <Ellipse Style="{StaticResource EllipseStyle}" Stroke="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" Fill="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}" go:Node.PortId="3" go:Node.LinkableTo="False" go:Node.FromSpot="MiddleRight" go:SpotPanel.Spot="MiddleRight" go:SpotPanel.Alignment="MiddleRight"> <Ellipse.Projection> <PlaneProjection GlobalOffsetX="5" /> </Ellipse.Projection> </Ellipse> </go:SpotPanel> </go:NodePanel> </DataTemplate>

Are you sure that those nodes are members of the swimlane group?

Yes I can confirm the nodes are in the swimlane group. The SubgraphKey matches where I first placed it. I will try to replicate it with your code sample.

Thank again,

Pavel
Below I describe the steps that cause items inside planogram to be incorrectly repositioned.
Thank you.
Pavel
step 1. moved blue rectagle onto planogram
step 2. moved yellow rectangle onto the planogram below
  • the blue one was incorectly moved to the second planogram
step 3. place green object on the first planogram
  • the yellow and blue objects also get moved up to the first planogram
I have found two issues:
  1. moving planograms sometimes doesn't move all objects
  2. placing a new object on planogram incorrectly rearranges other objects that are in other planograms
Posting pictures.
step 1.
step 2.
step 3.

Actually, it was working fine, originally.

The problem was the introduction of the additional constraint that I labelled (4b) above.

Here’s a better definition of the SnapTo method:

protected override Point SnapTo(Node moving, Point pt, Node snapper, Dictionary<Part, DraggingTool.Info> draggedparts) { // don't let a Node move outside a Group to top-level (i.e. to the background) if (snapper == null && !(moving is Group) && this.Active) return moving.Location; return base.SnapTo(moving, pt, snapper, draggedparts); }

Thank you Walter,

I tested only 1) 2) 3) suggestions with Planogram. I am able to consistantly reproduce the two issues states previously.
Would you be able to contact me offline so I could send you a sample video of the behaviour.
Thank you,
Pavel
pavel.hlobil @at blueprintsys dot com

Ah, yes, I see what you mean. We’ll need to investigate.

Thank you, the latest build fixed the issue.

I also noticed that using your suggested solution the elements don't always align along the x-axis. Any suggestions?
Sometimes it looks like I show below.
XXXXXXX
XXXXXXX
XXXXXXX
XXXXXXX
XXXXXXX
XXXXXXX

There was a bug in 1.1.1 beta with nested groups (that will be fixed in the next baselevel), but I suspect that doesn’t apply in your case.

So, I’m not familiar with such a problem. Have you always seen such behavior, or is this new with the latest beta?