User Interface for .NET / User's Guide / Renderers / UIRenderer Static Methods

In This Topic
    UIRenderer Static Methods
    In This Topic

    The following table describes some of the public static methods exposed by the NUIRenderer class, which are meant to help you with your custom drawing:

     

    Method Description and sample

     DrawArrow

    Draws an arrow glyph into the specified bounds using the specified direction and color.

     

    The following code demonstrates how to draw arrows:


     

     DrawBorder3D

    Draws a rectangular border within specified bounds and using the specified border style and base color.

     

    The following example demonstrates how to draw 3D-borders:

    C#
    Copy Code
    Rectangle drawBounds;
    
    drawBounds = new Rectangle(10, 10, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Bump, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(35, 10, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Etched, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(60, 10, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Flat, SystemColors.Control, Color.Red);
    
    drawBounds = new Rectangle(85, 10, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Raised, Color.Beige, SystemColors.Control);
    
    drawBounds = new Rectangle(110, 10, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedFrame, Color.BlanchedAlmond, SystemColors.Control);
    
    drawBounds = new Rectangle(10, 35, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedInner, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(35, 35, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedOuter, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(60, 35, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Sunken, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(85, 35, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.SunkenInner, SystemColors.Control, SystemColors.Control);
    
    drawBounds = new Rectangle(110, 35, 20, 20);
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.SunkenOuter, SystemColors.Control, SystemColors.Control);
    
    Visual Basic
    Copy Code
    Dim drawBounds As Rectangle 
    
    drawBounds = New Rectangle(10, 10, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Bump, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(35, 10, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Etched, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(60, 10, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Flat, SystemColors.Control, Color.Red)
    
    drawBounds = New Rectangle(85, 10, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Raised, Color.Beige, SystemColors.Control);
    
    drawBounds = New Rectangle(110, 10, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedFrame, Color.BlanchedAlmond, SystemColors.Control)
    
    drawBounds = New Rectangle(10, 35, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedInner, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(35, 35, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.RaisedOuter, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(60, 35, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.Sunken, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(85, 35, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.SunkenInner, SystemColors.Control, SystemColors.Control)
    
    drawBounds = New Rectangle(110, 35, 20, 20)
    NUIRenderer.DrawBorder3D(g, drawBounds, BorderStyle3D.SunkenOuter, SystemColors.Control, SystemColors.Control)
    

     

     DrawCheckBox

    Draws a checkbox within the specified bounds using the specified palette and button state.

     

    The following example demonstrates how to render checkboxes:

    C#
    Copy Code
    Rectangle drawBounds;
    
    //create a new palette to use for drawing checkboxes
    //you may however use any existing palette -
    //for example the global one exposed by the NUIManager
    NPalette palette = new NUIPalette();
    palette.Scheme = ColorScheme.WindowsDefault;
    
    drawBounds = new Rectangle(10, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Normal, false);
    
    drawBounds = new Rectangle(30, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Checked, false);
    
    drawBounds = new Rectangle(50, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Pushed, false);
    
    drawBounds = new Rectangle(70, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Normal, true);
    
    drawBounds = new Rectangle(90, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Checked, true);
    
    drawBounds = new Rectangle(110, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Pushed | ButtonState.Checked, true);
    
    drawBounds = new Rectangle(130, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Inactive, false);
    
    drawBounds = new Rectangle(150, 10, 15, 15);
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Inactive | ButtonState.Checked, false);
    
    Visual Basic
    Copy Code
    Dim drawBounds As Rectangle 
    
    'create a new palette to use for drawing checkboxes
    'you may however use any existing palette -
    'for example the global one exposed by the NUIManager
    Dim palette As NPalette = New NUIPalette()
    palette.Scheme = ColorScheme.WindowsDefault
    
    drawBounds = New Rectangle(10, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Normal, False)
    
    drawBounds = New Rectangle(30, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Checked, False)
    
    drawBounds = New Rectangle(50, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Pushed, False)
    
    drawBounds = New Rectangle(70, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Normal, True)
    
    drawBounds = New Rectangle(90, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Checked, True)
    
    drawBounds = New Rectangle(110, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Pushed Or ButtonState.Checked, True)
    
    drawBounds = New Rectangle(130, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Inactive, False)
    
    drawBounds = New Rectangle(150, 10, 15, 15)
    NUIRenderer.DrawCheckBox(g, palette, drawBounds, ButtonState.Inactive Or ButtonState.Checked, False)
    

     

     DrawRadioButton

    Draws a radio button within the specified bounds using the specified palette and button state.

     

    See the example code for DrawCheckBox method - instead of DrawCheckBox use DrawRadioButton

     

     

     DrawCheckGlyph

    Draws a checkmark glyph within the specified bounds using the specified color.

     

    The following example demonstrates how to draw check glyphs:

    C#
    Copy Code
    Rectangle drawBounds;
    
    drawBounds = new Rectangle(10, 10, 12, 12);
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Red);
    
    //make a bold glyph
    drawBounds = new Rectangle(26, 10, 12, 12);
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black);
    drawBounds = new Rectangle(25, 10, 12, 12);
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black);
    
    //make a glyph with shadow
    drawBounds = new Rectangle(41, 10, 12, 12);
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black);
    drawBounds = new Rectangle(40, 10, 12, 12);
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Pink);
    
    Visual Basic
    Copy Code
    Dim drawBounds Rectangle 
    
    drawBounds = New Rectangle(10, 10, 12, 12)
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Red)
    
    'make a bold glyph
    drawBounds = New Rectangle(26, 10, 12, 12)
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black)
    drawBounds = New Rectangle(25, 10, 12, 12)
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black)
    
    'make a glyph with shadow
    drawBounds = New Rectangle(41, 10, 12, 12)
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Black)
    drawBounds = New Rectangle(40, 10, 12, 12)
    NUIRenderer.DrawCheckGlyph(g, drawBounds, Color.Pink)
    

     

     DrawReversibleFrame

    Draws a reversible frame on the screen.

     

    The following example demonstrates how to draw reversible frames:

    C#
    Copy Code
    Rectangle screenPreview = RectangleToScreen(m_Preview.Bounds);
    Rectangle drawBounds;
    
    drawBounds = new Rectangle(screenPreview.Left + 10, screenPreview.Top + 10, 50, 50);
    NUIRenderer.DrawReversibleFrame(drawBounds);
    
    drawBounds = new Rectangle(screenPreview.Left + 70, screenPreview.Top + 10, 70, 70);
    NUIRenderer.DrawReversibleFrame(drawBounds, 10);
    
    Visual Basic
    Copy Code
    Dim screenPreview As Rectangle = RectangleToScreen(m_Preview.Bounds)
    Dim drawBounds As Rectangle 
    
    drawBounds = New Rectangle(screenPreview.Left + 10, screenPreview.Top + 10, 50, 50)
    NUIRenderer.DrawReversibleFrame(drawBounds)
    
    drawBounds = New Rectangle(screenPreview.Left + 70, screenPreview.Top + 10, 70, 70)
    NUIRenderer.DrawReversibleFrame(drawBounds, 10)
    

     

     DrawSizeGrip

    Draws a sizing grip within the specified bounds using the specified backcolor and GripperStyle.

     

    The following example demonstrates how to draw size grips:

    C#
    Copy Code
    m_Preview.BackColor = Color.Orange;
    Rectangle drawBounds;
    
    drawBounds = new Rectangle(10, 10, 20, 20);
    NUIRenderer.DrawSizeGrip(g, drawBounds, Color.Orange, GripperStyle.DotsSunken);
    
    drawBounds = new Rectangle(35, 10, 20, 20);
    NUIRenderer.DrawSizeGrip(g, drawBounds, Color.Orange, GripperStyle.LinesRaised);
    
    Visual Basic
    Copy Code
    m_Preview.BackColor = Color.Orange
    Dim drawBounds As Rectangle 
    
    drawBounds = New Rectangle(10, 10, 20, 20)
    NUIRenderer.DrawSizeGrip(g, drawBounds, Color.Orange, GripperStyle.DotsSunken)
    
    drawBounds = New Rectangle(35, 10, 20, 20)
    NUIRenderer.DrawSizeGrip(g, drawBounds, Color.Orange, GripperStyle.LinesRaised)
    

     

    See Also