Właściwość ShapeElement.ZOrder —
Określa kolejność wyświetlania tego kształtu względem innych kształtów na diagramie.Zwykle ustawić kolejność kształtów podrzędnych.
Przestrzeń nazw: Microsoft.VisualStudio.Modeling.Diagrams
Zestaw: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0 (w Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0.dll)
Składnia
'Deklaracja
Public Overridable Property ZOrder As Double
public virtual double ZOrder { get; set; }
Wartość właściwości
Typ: System.Double
Uwagi
Nie, aby ustawić wartość bezpośrednio, są zalecane, ponieważ diagramu ustawia ZOrder z jego kształtami jako część procesu malowania.Zamiast tego, aby zmienić kolejność wyświetlania kształtów, uporządkować kształty w NestedChildShapeslub RelativeChildShapes, a następnie wywołać shape.Diagram.NeedsRenumber = true.To sprawia, że Diagram resetuje ZOrders.Zobacz przykład poniżej.
Przykłady
/// <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();
}
}
Aby upewnić się, że kształt zawsze pojawia się w górnej części diagramu, można zastąpić tę właściwość w następujący sposób.
/// <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
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..