Condividi tramite


Proprietà ShapeElement.ZOrder

Determina l'ordine in cui questa forma verrà visualizzata rispetto alle altre forme del diagramma. Generalmente impostato dall'ordine delle forme figlio.

Spazio dei nomi:  Microsoft.VisualStudio.Modeling.Diagrams
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll)

Sintassi

'Dichiarazione
Public Overridable Property ZOrder As Double
public virtual double ZOrder { get; set; }

Valore proprietà

Tipo: System.Double

Note

Si consiglia di non impostare direttamente il valore, poiché il diagramma imposta lo ZOrder di tutte le forme come parte del processo di generazione. Al contrario, per modificare l'ordine delle forme visualizzate, riordinano le forme in NestedChildShapeso RelativeChildShapesquindi shape.Diagram.NeedsRenumber = true. Ciò garantisce che il diagramma reimpostare lo ZOrders. Vedere l'esempio che segue.

Esempi

    /// <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();
          }
        }

Per assicurarsi che la forma viene visualizzato sempre all'inizio del diagramma, è possibile eseguire l'override di questa proprietà come segue.

/// <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
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ShapeElement Classe

Spazio dei nomi Microsoft.VisualStudio.Modeling.Diagrams