TextField.DefaultFontId 屬性
取得或設定預設字型 ID。
命名空間: Microsoft.VisualStudio.Modeling.Diagrams
組件: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (在 Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll 中)
語法
'宣告
Public Property DefaultFontId As StyleSetResourceId
public StyleSetResourceId DefaultFontId { get; set; }
屬性值
類型:Microsoft.VisualStudio.Modeling.Diagrams.StyleSetResourceId
備註
若要設定特定欄位的字型 ID 特定圖案類別的每個執行個體,請覆寫圖案類別的 InitializeShapeFields() ,尋找文字欄位,並指派新的值。 ID 值必須是 DiagramFonts的成員。
例如,為欄位使用標準註解字型稱為 CommentDecorator」:
// Set Generates Double Derived in DSL Definition
// to allow InitializeShapeFields to be overridden.
partial class ExampleShape
{
/// <summary>
/// Compose a list of the fields in this shape.
/// Called once for each shape class.
/// </summary>
protected override void InitializeShapeFields(IList<ShapeField> shapeFields)
{
// Set up fields according to DSL Definition:
base.InitializeShapeFields(shapeFields);
// Update the text field for CommentDecorator:
TextField commentField = ShapeElement.FindShapeField(shapeFields, "CommentDecorator") as TextField;
commentField.DefaultFontId = DiagramsFonts.CommentText;
}
}
若要動態修改字型,請取得 TextField 您的子類別並覆寫 GetFondId()。 若要變更為在標準樣式集合中的字型,請覆寫 GetFont()。 如需這些方法的範例。
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。