Skybound VisualTips

VisualTipLayout Class

Describes the layout of text and graphics on a VisualTip.

For a list of all members of this type, see VisualTipLayout Members.

System.Object
   Skybound.VisualTips.Rendering.VisualTipLayout

[Visual Basic]
Public Class VisualTipLayout
[C#]
public class VisualTipLayout

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The properties and methods in this type can be used to determine where a VisualTipRenderer draws each element of a VisualTip. This enables you to change the location of these elements without writing the actual drawing code.

Before a VisualTipRenderer draws a tip, it calls CreateLayout to determine where each element is positioned. By overridding the OnCreateLayout method, you can return a custom VisualTipLayout instead. It is also possible to call the base OnCreateLayout method, and then set the location of only the elements you require.

For example, let's assume you would like to swap the location of the image and text so that the image appears on the right, and the text appears on the left. Implement the following code:

[C#]

private class CustomRenderer : VisualTipRenderer
{
    protected override VisualTipLayout OnCreateLayout(VisualTip tip)
    {
        VisualTipLayout layout = base.OnCreateLayout(tip);
        
        // obtain the original bounds
        Rectangle text = layout.GetElementBounds(VisualTipRenderElement.Text);
        Rectangle disabled = layout.GetElementBounds(VisualTipRenderElement.DisabledMessage);
        Rectangle image = layout.GetElementBounds(VisualTipRenderElement.Image);
        
        // swap the coordinates
        int imageX = image.X;
        image.X = text.Right - image.Width;
        text.X = imageX;
        disabled.X = imageX;
        
        // re-assign the new bounds
        layout.SetElementBounds(VisualTipRenderElement.Text, text);
        layout.SetElementBounds(VisualTipRenderElement.DisabledMessage, disabled);
        layout.SetElementBounds(VisualTipRenderElement.Image, image);
        
        return layout;
    }
}

[VB.NET]

Private Class CustomRenderer 
    Inherits VisualTipRenderer 

    Protected Overloads Overrides Function OnCreateLayout(ByVal tip As VisualTip) As VisualTipLayout 
        
        Dim layout As VisualTipLayout = MyBase.OnCreateLayout(tip)
        
        ' obtain the original bounds
        Dim text As Rectangle = layout.GetElementBounds(VisualTipRenderElement.Text) 
        Dim disabled As Rectangle = layout.GetElementBounds(VisualTipRenderElement.DisabledMessage) 
        Dim image As Rectangle = layout.GetElementBounds(VisualTipRenderElement.Image) 
        
        ' swap the coordinates
        Dim imageX As Integer = image.X 
        image.X = text.Right - image.Width 
        text.X = imageX 
        disabled.X = imageX
        
        ' re-assign the new bounds
        layout.SetElementBounds(VisualTipRenderElement.Text, text) 
        layout.SetElementBounds(VisualTipRenderElement.DisabledMessage, disabled) 
        layout.SetElementBounds(VisualTipRenderElement.Image, image) 
        
        Return layout
    End Function 
End Class

Requirements

Namespace: Skybound.VisualTips.Rendering

Assembly: Skybound.VisualTips (in Skybound.VisualTips.dll)

See Also

VisualTipLayout Members | Skybound.VisualTips.Rendering Namespace