ZOrder
I am having problems setting the ZORder manually.
...
using (Transaction t = this.Store.TransactionManager.BeginTransaction("Setting ZOrder"))
{
try
{
shape.ZOrder = shapeParent.ZOrder + 1;
t.Commit();
}
catch (Exception xException)
{
t.Rollback();
System.Diagnostics.Debug.WriteLine(xException);
}
}
The code works, but the shape doesn't change the visual arrangement in the diagram.
Is it working?
Setting the Z-Order by itself doesn't fix things. You have to re-order the NestedChildShapes of the diagram.
Take a look at Example.Components that you'll find by opening the VS SDK Samples Browser and look in CustomCode\NestedShapes.cs. Search on FixZOrder.
Note lines like
LinkedElementCollection<ShapeElement> allShapes = movedShape.ParentShape.NestedChildShapes;...
allShapes.Move(i, allShapes.Count - 1);
Changing the ZOrder doesn't change the Z-Order! You need to rearrange the content of the diagram's NestedChildShapes, using the Move operation.
See the Example.Components sample that you'll find by opening the VS SDK Samples browser - it will be in somewhere like Program Files\VisualStudio 2005 SDK\2006.09\VisualStudioIntegration\Samples\DSLTools\Example.DesignerCustomizations\Example.Components
Open Dsl\CustomCode\NestedShapes.cs and search in FixZOrder.
Look particularly at lines like
LinkedElementCollection
<ShapeElement> allShapes = movedShape.ParentShape.NestedChildShapes; allShapes.Move(i, allShapes.Count - 1);
Changing the ZOrder doesn't change the Z-Order! You need to rearrange the content of the diagram's NestedChildShapes, using the Move operation.
See the Example.Components sample that you'll find by opening the VS SDK Samples browser - it will be in somewhere like Program Files\VisualStudio 2005 SDK\2006.09\VisualStudioIntegration\Samples\DSLTools\Example.DesignerCustomizations\Example.Components
Open Dsl\CustomCode\NestedShapes.cs and search in FixZOrder.
Look particularly at lines like
LinkedElementCollection
<ShapeElement> allShapes = movedShape.ParentShape.NestedChildShapes; allShapes.Move(i, allShapes.Count - 1);
So another way to put Alan's answer is that at the current time, ZOrder is calculated rather than really stored. You cna play tricks by overriding the ZOrder proeprty and supplying your own implementation, but you cna get some other weird effects happenign if you do, so beware.