Share via


TextField.DefaultFontId Property

Gets or sets the default font id.

Namespace:  Microsoft.VisualStudio.Modeling.Diagrams
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0.dll)

Syntax

'Declaration
Public Property DefaultFontId As StyleSetResourceId
public StyleSetResourceId DefaultFontId { get; set; }
public:
property StyleSetResourceId^ DefaultFontId {
    StyleSetResourceId^ get ();
    void set (StyleSetResourceId^ value);
}
member DefaultFontId : StyleSetResourceId with get, set
function get DefaultFontId () : StyleSetResourceId
function set DefaultFontId (value : StyleSetResourceId)

Property Value

Type: Microsoft.VisualStudio.Modeling.Diagrams.StyleSetResourceId

Remarks

To set the font id for a particular field in every instance of a particular shape class, override InitializeShapeFields() in the shape class, find the text field, and assign the new value. The ID value must be a member of DiagramFonts.

For example, to use the standard comment font for a field called "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;
    }
}

To alter the font dynamically, derive your own subclass of TextField and override GetFondId(). To change to a font outside the standard style set, override GetFont(). See the examples in those methods.

.NET Framework Security

See Also

Reference

TextField Class

Microsoft.VisualStudio.Modeling.Diagrams Namespace