namespace CompanyName.ProjectName.TestLanguage.Designer
{
#region Using directives using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Modeling;
using System.Diagnostics;
using Microsoft.VisualStudio.Modeling.Utilities;
using System.Drawing;
using Microsoft.VisualStudio.Modeling.Diagrams;
#endregion
/// <summary>
/// ClassShape in the Class Diagram template.
/// </summary>
public partial class ClassShape
{
/// <summary>
/// Gets called whenever a shape is inserted into the diagram.
/// This is a good time to setup visuals, because all shapes,
/// decorators, compartments, shapefields, etc. have been created.
/// </summary>
public override void OnShapeInserted()
{
base.OnShapeInserted();
// Define the font change to make.
// In this case, make all decorators show bold, italic,
// and bigger sized text.
FontSettings fs = new FontSettings();
fs.Bold = true;
fs.Italic = true;
fs.Size = 0.185f;
foreach (ShapeDecorator decorator in this.Decorators)
{
// Only do this for all of the text decorators in this shape.
TextShapeDecorator shapeDec = decorator as TextShapeDecorator;
if (shapeDec != null)
{
shapeDec.StyleSet.OverrideFont(DiagramFonts.ShapeText, fs);
}
}
// Make the compartment header title bold, and
// the compartment item test italic.
FontSettings fsTitle = new FontSettings();
fsTitle.Bold = true;
FontSettings fsItem = new FontSettings();
fsItem.Italic = true;
foreach (ShapeElement shape in this.NestedChildShapes)
{
// Only do this for all of the compartments in this shape.
Compartment compartment = shape as Compartment;
if (compartment != null)
{
compartment.StyleSet.OverrideFont(DiagramFonts.ShapeTitle, fsTitle);
compartment.StyleSet.OverrideFont(DiagramFonts.ShapeText, fsItem);
}
}
}
}
}