ShapeElement.ZOrder 屬性
決定相對於圖表上其他圖案顯示這個圖案所依照的順序。 通常根據子圖案的順序來設定。
命名空間: Microsoft.VisualStudio.Modeling.Diagrams
組件: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (在 Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll 中)
語法
'宣告
Public Overridable Property ZOrder As Double
public virtual double ZOrder { get; set; }
屬性值
備註
做為繪製製程的一部分,,,因為嘗試將其所有圖案 ZOrder 建議您無法直接設定值。 相反地,變更圖案顯示,重新排列在 NestedChildShapes或 RelativeChildShapes的圖案的命令,然後呼叫 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。