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 命名空间