TextField.DefaultFontId 属性

获取或设置默认字体 ID.

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

备注

若要设置特定字段的字体 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 安全性

请参见

参考

TextField 类

Microsoft.VisualStudio.Modeling.Diagrams 命名空间