共用方式為


TextField.DefaultFontId 屬性

取得或設定的預設字型識別碼。

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

語法

'宣告
Public Property DefaultFontId As StyleSetResourceId
public StyleSetResourceId DefaultFontId { get; set; }

屬性值

型別:Microsoft.VisualStudio.Modeling.Diagrams.StyleSetResourceId

備註

在某個特定欄位的字型識別碼中設定特定的圖形類別的每個執行個體,在 shape 類別會覆寫 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 安全性

請參閱

參考

TextField 類別

Microsoft.VisualStudio.Modeling.Diagrams 命名空間