User Interface for .NET / User's Guide / Custom Forms / Frame Appearance Template

In This Topic
    Frame Appearance Template
    In This Topic
     Overview
    The entire appearance of a NForm component is controlled by a NFrameAppearance instance. Being either locally specified or globally by the NUIManager this object specifies both metrics and appearance of the non-client area of a NForm. A form may specify whether to use the global template or not if the locally set one is null (its default value). And you may always tell the form that the system look-and-feel is preferred.
     Metric Settings

    There are many cases when an application needs either have larger borders or higher caption. This is completely achievable with our forms as they override each non-client aspect.

     

    The following code demonstrates how to specify custom settings for a template and assign it to a NForm: 

    C#
    Copy Code
    //create a new NFrameAppearance object
    //by default if no segmented images are specified the Simple rendering is applied.
    NFrameAppearance appearance = new NFrameAppearance();
    //customize metrics
    appearance.LeftBorder = 8;
    appearance.RightBorder = 8;
    appearance.BottomBorder = 8;
    appearance.CaptionHeight = 32;
    
    //offset the caption buttons
    appearance.ButtonsOffset = new Size(4, 8);
    
    //create new NForm object and assign it this template
    NForm form = new NForm();
    form.FrameAppearance = appearance;
    form.ShowDialog();
    
    Visual Basic
    Copy Code
    'create a new NFrameAppearance object
    'by default if no segmented images are specified the Simple rendering is applied.
    Dim appearance As NFrameAppearance = New NFrameAppearance()
    'customize metrics
    appearance.LeftBorder = 8
    appearance.RightBorder = 8
    appearance.BottomBorder = 8
    appearance.CaptionHeight = 32
    
    'offset the caption buttons
    appearance.ButtonsOffset = New Size(4, 8)
    
    'create new NForm object and assign it this template
    Dim form As NForm = New NForm()
    form.FrameAppearance = appearance
    form.ShowDialog()
    

    The result of the above code:

     

     Caption Settings

    The template allows for a complete customization of the caption including both image and text. Settings like TextAlign, ImageAlign, ImageTextRelation, etc. are provided so that you can define the caption appearance that suits your forms most.

     

    The following example demonstrates how to manipulate the image and text of a NForm's caption via the NFrameAppearance template: 

    C#
    Copy Code
    NFrameAppearance appearance = new NFrameAppearance();
    //customize settings related with image and text positioning
    appearance.ImageTextRelation = ImageTextRelation.TextBeforeImage;
    appearance.ImageAlign = ContentAlignment.MiddleRight;
    appearance.TextAlign = ContentAlignment.MiddleRight;
    
    NForm form = new NForm();
    form.FrameAppearance = appearance;
    form.ShowDialog();
    
    Visual Basic
    Copy Code
    Dim appearance As NFrameAppearance = New NFrameAppearance()
    'customize settings related with image and text positioning
    appearance.ImageTextRelation = ImageTextRelation.TextBeforeImage
    appearance.ImageAlign = ContentAlignment.MiddleRight
    appearance.TextAlign = ContentAlignment.MiddleRight
    
    Dim form AsNForm = New NForm()
    form.FrameAppearance = appearance
    form.ShowDialog()
    

    The result of the above code:

     

     Appearance Settings
    The NFrameAppearance template object allows you to completely customize how a form will look via a set of segmented images defining how the caption, borders and system buttons like "Close", "Maximize/Restore", "Minimize" and "Help" are rendered. For more information about the segmented image semantic see Segmented Image.
    See Also