共用方式為


ShapeElement.ZOrder 屬性

決定在此圖形將會相對於其他圖案在圖表上的順序。 通常會設定從子類型圖形的順序。

命名空間:  Microsoft.VisualStudio.Modeling.Diagrams
組件:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0 (在 Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0.dll 中)

語法

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

屬性值

型別:System.Double

備註

建議您將值設定為直接,因為圖表會將所有圖形的 ZOrder 設繪製過程的一部分。 相反地,若要變更圖形所顯示的順序,重新排列的圖案NestedChildShapesRelativeChildShapes,然後呼叫shape.Diagram.NeedsRenumber = true。 如此可確保該圖表將 ZOrders 重設。 請參閱下列範例。

範例

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

若要確定您的圖案永遠出現在圖表的頂端,您可以以下列方式覆寫這個屬性。

/// <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 安全性

請參閱

參考

ShapeElement 類別

Microsoft.VisualStudio.Modeling.Diagrams 命名空間