ShapeElement.ZOrder Property
Determines the order in which this shape will be displayed relative to other shapes on the diagram. Normally set from the order of child shapes.
Namespace: Microsoft.VisualStudio.Modeling.Diagrams
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0.dll)
Syntax
'Déclaration
Public Overridable Property ZOrder As Double
Get
Set
public virtual double ZOrder { get; set; }
public:
virtual property double ZOrder {
double get ();
void set (double value);
}
abstract ZOrder : float with get, set
override ZOrder : float with get, set
function get ZOrder () : double
function set ZOrder (value : double)
Property Value
Type: System.Double
Remarks
You are recommended not to set the value directly, because the Diagram sets the ZOrder of all its shapes as part of the painting process. Instead, to change the order in which shapes are displayed, re-order the shapes in the NestedChildShapesor RelativeChildShapes, and then call shape.Diagram.NeedsRenumber = true. This makes sure that the Diagram resets the ZOrders. See the following example.
Examples
/// <summary>
/// Command to send current shapes to the back.
/// </summary>
private void OnMenuSendShapesToBackCommand(object sender, EventArgs e)
{
MenuCommand command = sender as MenuCommand;
Store store = this.CurrentDocData.Store;
foreach (object selectedItem in this.CurrentSelection)
{
ShapeElement shape = selectedItem as ShapeElement;
if (shape == null || shape.ParentShape == null) continue;
if (shape.IsNestedChild)
{
using (Transaction t = store.TransactionManager.BeginTransaction("sendToBack"))
{
// Make the current shape the first in the list.
shape.ParentShape.NestedChildShapes.Move(shape, 0);
// Update the ZOrder of the shapes to reflect the change.
shape.Diagram.NeedsRenumber = true;
// Make sure the shape is redrawn:
shape.Invalidate();
t.Commit();
}
}
To make sure that your shape always appears at the top of the diagram, you can override this property as follows.
/// <summary>
/// Gets the relative Z-Order for this ShapeElement.
/// Make sure that my shape stays above all other diagram elements.
/// Add a million to the Z-Order that we are given.
/// </summary>
public override double ZOrder
{
get
{
return base.ZOrder + 1e6;
}
// leave set{ } as inherited
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.