Partilhar via


Propriedade ShapeElement.ZOrder

Determina a ordem em que essa forma será exibida em relação a outras formas no diagrama. Normalmente define a ordem de formas filhos.

Namespace:  Microsoft.VisualStudio.Modeling.Diagrams
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (em Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll)

Sintaxe

'Declaração
Public Overridable Property ZOrder As Double
public virtual double ZOrder { get; set; }

Valor de propriedade

Tipo: System.Double

Comentários

Você não é recomendável definir o valor diretamente, pois o diagrama define o ZOrder de todas as formas como parte do processo de pintura. Em vez disso, para alterar a ordem em que as formas são exibidas, requisitam novamente as formas em NestedChildShapesou em RelativeChildShapes, e então chame shape.Diagram.NeedsRenumber = true. Isso garante que o diagrama redefine o ZOrders. Consulte o exemplo a seguir.

Exemplos

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

Para certificar-se que sua forma sempre aparece na parte superior do diagrama, você pode substituir essa propriedade como 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
}

Segurança do .NET Framework

Consulte também

Referência

ShapeElement Classe

Namespace Microsoft.VisualStudio.Modeling.Diagrams