Divelements Community
Customer discussion of all Divelements products

Custom Rendering

Latest post 04-12-2007 20:45 by RazorDev. 1 replies.
  • 04-11-2007 21:50

    Custom Rendering

    Hi,

    i am having trouble creating a custom renderer for navisight.  i am writting this in vb.net.  This is the template code that was insterted the secont i hit enter on the inherits statement

    Public Class CustomRenderer

        Inherits Divelements.Navisight.Rendering.OfficeRendererBase

        Public Overrides Sub DrawImageCore(ByVal image As System.Drawing.Image, ByVal graphics As System.Drawing.Graphics, ByVal state As System.Windows.Forms.DrawItemState, ByVal bounds As System.Drawing.Rectangle)

        End Sub

        Protected Overrides Sub DrawText(ByVal graphics As System.Drawing.Graphics, ByVal text As String, ByVal font As System.Drawing.Font, ByVal bounds As System.Drawing.Rectangle, ByVal format As System.Drawing.StringFormat, ByVal state As System.Windows.Forms.DrawItemState)

        End Sub

        Public Overrides Sub PaintButtonHighlight(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal state As System.Windows.Forms.DrawItemState)

        End Sub

        Protected Overrides Sub RefreshColors()

        End Sub
    End Class

    in my forms load event i have this code:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           dim r as new CustomRenderer
            buttonbar1.Renderer = r
    End Sub

    this however tells me that "Unable to cast object of type 'WindowsApplication1.CustomRenderer' to type 'Divelements.Navisight.Rendering.INavisightRenderer'."

    any ideas how to fix this, or am i doing something completely wrong?

    thanks
  • 04-12-2007 20:45 In reply to

    Re: Custom Rendering

    Sorry to double post, but i have solved the problem,  and thought someon else might benafit from the solution:

    This is the form's code:

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Dim r As New CustomRenderer
            ButtonBar1.Renderer = DirectCast(r, Divelements.Navisight.Rendering.Office2003Renderer)

        End Sub

    And then this is the new renderer class:

    Public Class
    CustomRenderer
        Inherits Divelements.Navisight.Rendering.Office2003Renderer

        Public Overrides Sub DrawImageCore(ByVal image As System.Drawing.Image, ByVal graphics As System.Drawing.Graphics, ByVal state As System.Windows.Forms.DrawItemState, ByVal bounds As System.Drawing.Rectangle)

        End Sub

        Protected Overrides Sub DrawText(ByVal graphics As System.Drawing.Graphics, ByVal text As String, ByVal font As System.Drawing.Font, ByVal bounds As System.Drawing.Rectangle, ByVal format As System.Drawing.StringFormat, ByVal state As System.Windows.Forms.DrawItemState)
            graphics.DrawString(text, font, Brushes.Red, bounds)
        End Sub

        Public Overrides Sub PaintButtonHighlight(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal state As System.Windows.Forms.DrawItemState)

        End Sub

        Protected Overrides Sub RefreshColors()

        End Sub
    End Class



    hope this helps someone :)
Page 1 of 1 (2 items) | RSS
Copyright © 2008 Divelements Limited
Powered by Community Server (Commercial Edition), by Telligent Systems