Click here to Skip to main content
15,884,986 members
Articles / Programming Languages / Visual Basic

Mathemathics Framework

Rate me:
Please Sign up or sign in to vote.
4.76/5 (56 votes)
16 Sep 2008CPOL6 min read 75.3K   6.2K   171  
.NET Mathematical Framework
Imports System
Imports System.Reflection
Imports System.Reflection.Module
Imports System.Drawing
Imports System.Windows.Forms
Imports ggCoreLib
Imports MidRange
Imports IMidRange
Imports GraphicsObjects
'Imports BVCtl



<CLSCompliant(True)> _
Public Class ListItemBase
    Inherits ItemBase
    Implements IComparable

    Protected intName As String
    Protected intImg As Image
    Protected intParentGroup As ItemGroup
    Protected intDefaultIcoSize As Size
    Protected intMouseIsOver As Boolean

    Public Sub New(ByVal ParentControl As BVItmListBase, ByVal Description As String, ByVal Img As Image)
        MyBase.New(ParentControl)

        Me.intImg = Img
        Initialize(ParentControl, Description)
    End Sub

    Public Sub New(ByVal ParentControl As BVItmListBase, ByVal Description As String)
        MyBase.New(ParentControl)

        Initialize(ParentControl, Description)
    End Sub

    Protected Overridable Sub Initialize(ByVal ParentControl As BVItmListBase, _
                                        ByVal Description As String)

        intRect = New System.Drawing.Rectangle(CType(intParentControl, BVItmListBase).DefaultItemSize.Height, _
                                0, _
                                intParentControl.Width - CType(intParentControl, BVItmListBase).DefaultItemSize.Height, _
                                CType(intParentControl, BVItmListBase).DefaultItemSize.Height)

        intName = Description
        intSelectObj.IsSelected = False
        intDefaultIcoSize = New Size(12, 12)

        intPen = New Pen(Color.LightGray)
        intBrushSelected = New System.Drawing.SolidBrush(Color.LightGray)
        intPen.Width = 1
        intBackColor = Color.White
        intForeColor = Color.Black
        intBrush = New System.Drawing.SolidBrush(intBackColor)
        intBrushText = New System.Drawing.SolidBrush(intForeColor)
        intFont = ParentControl.Font ' New System.Drawing.Font("Arial", 10)

    End Sub


#Region "Properties"

    Public Property ParentGroup() As ItemGroup
        Get
            Return intParentGroup
        End Get
        Set(ByVal Value As ItemGroup)
            intParentGroup = Value
        End Set
    End Property

    Public Overrides ReadOnly Property Height() As Integer
        Get
            Return Me.intRect.Height
        End Get
    End Property

    'Public ReadOnly Property HaveSubItems() As Boolean
    '    Get
    '        Return intHaveSubItems
    '    End Get
    'End Property

    Public Property Description() As String
        Get
            Return Me.intName
        End Get
        Set(ByVal Value As String)
            If Not Value Is Nothing AndAlso Not Value = String.Empty Then
                Me.intName = Value
            End If
        End Set
    End Property

    'Public Property IsKnowObject() As Boolean
    '    Get
    '        Return intIsKnowObject
    '    End Get
    '    Set(ByVal Value As Boolean)
    '        If intIsKnowObject <> Value Then
    '            intIsKnowObject = Value
    '        End If
    '    End Set
    'End Property

#End Region

    Protected Overridable Sub DrawText(ByVal text As String, ByVal p As PaintEventArgs, ByVal left As Integer)
        Dim r As System.Drawing.Rectangle
        Dim s As SizeF

        r = Me.intRect
        'r.Width = ColsDivision - CType(intParentControl, BVItmListBase).DefaultRowHeight
        s = p.Graphics.MeasureString(text, intFont)
        p.Graphics.DrawString(text, intFont, intBrushText, intRect.Left + 1, intRect.Y + 0.5 * intRect.Height - 0.5 * s.Height)
        p.Graphics.DrawRectangle(Me.intPen, r)
    End Sub

    Protected Overridable Sub DrawImage(ByVal img As Image, ByVal p As PaintEventArgs, ByVal Loc As Point)
        p.Graphics.DrawImage(intImg, New System.Drawing.Rectangle(Loc.X, Loc.Y, Me.intDefaultIcoSize.Width, Me.intDefaultIcoSize.Height))
    End Sub

    Public Overrides Sub Redraw(ByVal sender As Object, ByVal p As PaintEventArgs)
        If Me.intMouseIsOver Then
            p.Graphics.FillRectangle(Me.intBrushSelected, Me.intRect)
        End If
        If intImg Is Nothing Then
            DrawText(intName, p, 2)
        Else
            DrawImage(intImg, p, New Point(2, Me.intRect.Y))
            DrawText(intName, p, intDefaultIcoSize.Width + 2)
        End If
    End Sub

    Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
        If TypeOf obj Is ListItemBase Then
            If CType(obj, ListItemBase).intName < Me.intName Then
                Return +1
            ElseIf CType(obj, ListItemBase).intName = Me.intName Then
                Return 0
            Else
                Return -1
            End If
        Else
            Return -1
        End If
        'me.i
    End Function


    Protected Sub On_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles intParentControl.MouseMove
        If intRect.Contains(e.X, e.Y) Then
            If Not Me.intMouseIsOver Then
                Me.intMouseIsOver = True
                Me.intParentControl.Refresh()
            End If
        Else
            If Me.intMouseIsOver Then
                Me.intMouseIsOver = False
                Me.intParentControl.Refresh()
            End If
        End If
    End Sub

    'Protected Overrides Sub On_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles intParentControl.MouseDown
    '    If intRect.Contains(e.X, e.Y) Then
    '        If Not intSelectObj.IsSelected Then
    '            Me.intSelectObj.IsSelected = True
    '            RaiseSelected(Me, New EventArgs)
    '            Me.intParentControl.Refresh()
    '        End If
    '    Else
    '        If intSelectObj.IsSelected Then
    '            intSelectObj.IsSelected = False
    '            Me.intParentControl.Refresh()
    '        End If
    '    End If
    'End Sub



End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Universidad Tecnológica Nacional
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions