Copying Pedro's e-mail reply to the same question here so it's publicly available:
These things are not settable in the DD file, but you can write custom code to change the font boldness and color. Add the following code to the shape class that you want to customize (I used the ClassDiagram template for my example):
public
partial class ClassShape { public override void OnShapeInserted() { base.OnShapeInserted(); if (this.Decorators != null && this.Decorators.Count > 0) { foreach (ShapeDecorator dec in this.Decorators) { if (dec.Name == "Name") // this corresponds to name you set in the DD file (in this case the name was Name) { TextShapeDecorator textDec = dec as TextShapeDecorator; if (textDec != null) { // changes the font for the text in the decorator. FontSettings fs = new FontSettings(); fs.Bold = true; textDec.StyleSet.OverrideFont(DiagramFonts.ShapeText, fs);
// changes the brush color for the text in the decorator. BrushSettings bs = new BrushSettings(); bs.Color = System.Drawing.Color.Orange; textDec.StyleSet.OverrideBrush(DiagramBrushes.ShapeText, bs); } } } } } }
This code changes the font and color for the Name decorator on the ClassShape class. All other decorators remain the way they were. In our next milestone, we changing the way decorators work, so that they’re not subshapes but only ShapeFields instead. This will make code customization of this type easier. And, we’re also talking about exposing text color and font properties for shapes on the DD file, so in lots of cases you wouldn’t need custom code. However, those would affect all decorators on a particular shape, so if you want different decorators within the same shape to look different, you would need to do a little custom coding.
Controlling Font
Chris Nurse
Copying Pedro's e-mail reply to the same question here so it's publicly available:
These things are not settable in the DD file, but you can write custom code to change the font boldness and color. Add the following code to the shape class that you want to customize (I used the ClassDiagram template for my example):
public
partial class ClassShape{
public override void OnShapeInserted()
{
base.OnShapeInserted();
if (this.Decorators != null && this.Decorators.Count > 0)
{
foreach (ShapeDecorator dec in this.Decorators)
{
if (dec.Name == "Name") // this corresponds to name you set in the DD file (in this case the name was Name)
{
TextShapeDecorator textDec = dec as TextShapeDecorator;
if (textDec != null)
{
// changes the font for the text in the decorator.
FontSettings fs = new FontSettings();
fs.Bold = true;
textDec.StyleSet.OverrideFont(DiagramFonts.ShapeText, fs);
// changes the brush color for the text in the decorator.
BrushSettings bs = new BrushSettings();
bs.Color = System.Drawing.Color.Orange;
textDec.StyleSet.OverrideBrush(DiagramBrushes.ShapeText, bs);
}
}
}
}
}
}
This code changes the font and color for the Name decorator on the ClassShape class. All other decorators remain the way they were. In our next milestone, we changing the way decorators work, so that they’re not subshapes but only ShapeFields instead. This will make code customization of this type easier. And, we’re also talking about exposing text color and font properties for shapes on the DD file, so in lots of cases you wouldn’t need custom code. However, those would affect all decorators on a particular shape, so if you want different decorators within the same shape to look different, you would need to do a little custom coding.
Regards,