Resources for IT Professionals > Forums Home > Microsoft Research Forums > Developer Discussions > How do show Heading Text in Designer surface area in Domain specific language Tool?
Ask a questionAsk a question
 

QuestionHow do show Heading Text in Designer surface area in Domain specific language Tool?

All Replies

  • Thursday, July 09, 2009 8:25 AMPoothapandian Subramanian Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    found the solution of my Question...if Anybody like requirement use it  

    ///
    <summary>

     

    /// Custom Class for the Text field

     

    /// </summary>

     

    // public delegate void DecoratorDBClickHandler(DiagramPointEventArgs e);

     

    public class TitleField:TextField

    {

     

    // public event DecoratorDBClickHandler DBClick;

     

    public TitleField(string name): base(name)

    {

    }

     

    public override void EditValue(ShapeElement parentShape, DiagramClientView view)

    {

     

    base.EditValue(parentShape, view);

    }

     

    public override bool GetSelectable(ShapeElement parentShape)

    {

     

    return false;

    }

     

     

    public override void OnDoubleClick(DiagramPointEventArgs e)

    {

     

    // commentField.EditValue(selectedObject as ShapeEnd, (selectedObject as ShapeEnd).Diagram.ActiveDiagramView.DiagramClientView);

     

    base.OnDoubleClick(e);

     

    // this.DBClick(e);

    }

     

    public override void OnMouseDown(DiagramMouseEventArgs e)

    {

     

    base.OnMouseDown(e);

    }

     

    public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)

    {

     

    //Font font = this.GetFont(parentShape);

     

    //font = new Font(font.FontFamily, 24.0f, FontStyle.Bold | FontStyle.Underline);

     

    //Brush brush = new LinearGradientBrush(e.ClipRectangle, Color.Violet, Color.White, LinearGradientMode.ForwardDiagonal);

     

    //e.Graphics.DrawString(this.GetDisplayText(parentShape), font, brush, e.ClipRectangle.Location);

     

    base.DoPaint(e, parentShape);

    }

     

    public override bool CanEditValue(ShapeElement parentShape, DiagramClientView view)

    {

     

    return true;

    }

    }


     

    /// <summary>

     

    /// Set the style for Text Filed Value

     

    /// </summary>

     

    private void CustomStyle()

    {

     

    StyleSet classStyleSet = this.StyleSet;

     

    FontSettings fs = new FontSettings();

    fs.Name =

    "Vardana";

    fs.Size = 0.15f;

    fs.Bold =

    true;

     

    StyleSetResourceId res = new StyleSetResourceId("NameSpace", "CustomStyle");

    classStyleSet.AddFont(res, res, fs);

     

    BrushSettings Bs = new BrushSettings();

    Bs.Color =

    Color.White;

     

    StyleSetResourceId Bres = new StyleSetResourceId("NameSpace", "CustomStyle");

    classStyleSet.AddBrush(Bres, Bres, Bs);

    }

     

    partial class yourModelDiagram
    {
    protected override void InitializeInstanceResources()
    {

    CustomStyle();

     

    var textField = new TitleField("Name");

    textField.DefaultFontId =

    new StyleSetResourceId("Name", "CustomStyle");

    textField.DefaultBackgroundBrushId =

    new StyleSetResourceId("Name", "CustomStyle");

    textField.AssociateValueWith(

    this.Store, NamedClass.NameDomainPropertyId);

    textField.DefaultFocusable =

    true;

    textField.DefaultSelectable =

    true;

    textField.DefaultVisibility =

    true;

    textField.DefaultAutoSize =

    true;

    textField.DefaultAutoSize =

    true;

    textField.DefaultMultipleLine =

    false;

    textField.DrawBorder =

    false;

    textField.FillBackground =

    true;

    ShapeFields.Add(textField);

    textField.DBClick +=

    new DecoratorDBClickHandler(textField_DBClick);

     

    ShapeDecorator decorator = new ShapeDecorator(textField, ShapeDecoratorPosition.InnerTopCenter);

     

    base.InitializeInstanceResources();

     

     

     

    }

     

    void textField_DBClick(DiagramPointEventArgs e)

    {

     

    TextField commentField =this.ShapeFields[0] as TextField;

    commentField.EditValue(

    this, this.Diagram.ActiveDiagramView.DiagramClientView);

    }

     


    }