Click here to Skip to main content
15,894,180 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.4K   6.2K   171  
.NET Mathematical Framework
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports BV.Core
Imports MidRange
Imports IMidRange
Imports GraphicsObjects


Public Enum EButtonStyle
    Push
    Toggle
End Enum


Public Class BVButton
    Inherits VisorLabel
    'Implements IMouseEvents

    Protected intButtonStyle As EButtonStyle
    Protected intStyle As ScrollButton
    Protected intIcon As Image
    Protected intPushedIcon As Image
    Protected intToolTipTex As String
    Protected intPushed As Boolean

    'Public Event MouseClick(ByVal sender As Object, ByVal m As MouseEventArgs) Implements IMouseEvents.MouseClick
    'Public Event MouseDoubleClick(ByVal sender As Object, ByVal m As MouseEventArgs) Implements IMouseEvents.MouseDoubleClick
    'Public Event MouseDown(ByVal sender As Object, ByVal m As MouseEventArgs) Implements IMouseEvents.MouseDown
    'Public Event MouseMove(ByVal sender As Object, ByVal m As MouseEventArgs) Implements IMouseEvents.MouseMove
    'Public Event MouseUp(ByVal sender As Object, ByVal m As MouseEventArgs) Implements IMouseEvents.MouseUp
    Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

    Public Sub New(ByVal ParentCtl As Control, ByVal Size As Size)
        MyBase.New(ParentCtl)
        intSize = Size 'New Rectangle(0, 0, intIcon.Width, intIcon.Height)

        Initialize()
    End Sub

    Public Sub New(ByVal ParentCtl As Control, ByVal Size As Size, ByVal Style As ScrollButton)
        MyBase.New(ParentCtl)
        intSize = Size ' New Rectangle(0, 0, intIcon.Width, intIcon.Height)
        Me.intStyle = Style
    End Sub

    Public Sub New(ByVal ParentCtl As Control, ByVal Location As Point, ByVal bmp As Image, ByVal PushedBmp As Image)
        MyBase.New(ParentCtl)
        intIcon = bmp
        intPushedIcon = PushedBmp
        intSize = intIcon.Size
    End Sub

    Public Sub New(ByVal ParentCtl As Control, ByVal Location As Point, ByVal IconName As String, ByVal PuchedIconName As String)
        MyBase.New(ParentCtl)
        If Dir(System.Environment.CurrentDirectory & "\" & IconName, FileAttribute.Archive) = IconName Then
            intIcon = New Bitmap(IconName)
            Me.intSize = intIcon.Size
            If Dir(System.Environment.CurrentDirectory & "\" & PuchedIconName, FileAttribute.Archive) = PuchedIconName Then
                intPushedIcon = New Bitmap(PuchedIconName)
            Else
                intPushedIcon = New Bitmap([GetType], "Minus.bmp")
            End If
        Else
            'iconos por defecto si no encuentra el pasado en la ruta
            intIcon = New Bitmap([GetType], "Plus.bmp")
            intPushedIcon = New Bitmap([GetType], "Minus.bmp")
            Me.intSize = intIcon.Size
        End If
    End Sub

    Protected Overrides Sub Initialize()
        intButtonStyle = EButtonStyle.Push
        Me.intBrshBack = New SolidBrush(Color.Yellow)
        intFont = New System.Drawing.Font("Arial", 12)
        intLocation = New Point(0, 0)
        intBrush = New SolidBrush(Color.Black)
        intVisible = True
        Me.intIco = New Icon([GetType], "Button.ico")
        AddHandler intControl.MouseDown, AddressOf On_MouseDown
        AddHandler intControl.MouseUp, AddressOf On_MouseUp
    End Sub

#Region "Properties"

    Public Property ToolTipTex() As String
        Get
            Return intToolTipTex
        End Get
        Set(ByVal Value As String)
            intToolTipTex = Value
        End Set
    End Property

    Public Property Pushed() As Boolean
        Get
            Return Me.intPushed
        End Get
        Set(ByVal Value As Boolean)
            intPushed = Value
        End Set
    End Property

    Public Property ButtonStyle() As EButtonStyle
        Get
            Return intButtonStyle
        End Get
        Set(ByVal Value As EButtonStyle)
            intButtonStyle = Value
        End Set
    End Property

#End Region

    Public Overrides Sub Redraw(ByVal sender As Object, ByVal p As PaintEventArgs) 'Implements IGraphicsBase.Redraw
        If Me.intVisible = False Then
            Exit Sub
        End If
        If Not intIcon Is Nothing Then
            If Me.intPushed Then
                p.Graphics.DrawImage(Me.intPushedIcon, New System.Drawing.Rectangle(Me.intLocation, Me.intSize))
            Else
                p.Graphics.DrawImage(intIcon, New System.Drawing.Rectangle(Me.intLocation, Me.intSize))
            End If
        Else
            'If intPushed Then
            '    ControlPaint.DrawBorder3D(p.Graphics, 1, 1, intSize.Width - 2, intSize.Height - 2, Border3DStyle.Sunken)
            'Else
            '    ControlPaint.DrawBorder3D(p.Graphics, 1, 1, intSize.Width - 2, intSize.Height - 2, Border3DStyle.Raised)
            'End If
            ControlPaint.DrawScrollButton(p.Graphics, New System.Drawing.Rectangle(Me.intLocation, Me.intSize), intStyle, ButtonState.Normal)
        End If
    End Sub

    'Public Overrides Sub Refresh() 'Implements IGraphicsBase.Refresh
    '    Me.inintParentCtl.Refresh()
    'End Sub

#Region "Events Management"

    Protected Sub On_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles MyClass.MouseDown
        If New System.Drawing.Rectangle(Me.intLocation, Me.intSize).Contains(e.X, e.Y) Then
            If intButtonStyle = EButtonStyle.Toggle Then
                intPushed = Not intPushed
            Else
                intPushed = True
            End If
            RaiseEvent Click(Me, New EventArgs)
            Me.Refresh()
        End If
        'RaiseEvent MouseDown(Me, e)
    End Sub

    Protected Sub On_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles intParentCtl.MouseUp
        If intButtonStyle = EButtonStyle.Push Then
            If Me.intPushed Then
                intPushed = False
                Me.Refresh()
            End If
        End If
        'If New Rectangle(Me.intLocation, Me.intSize).Contains(e.X, e.Y) Then
        '    RaiseEvent MouseUp(Me, e)
        'End If
    End Sub

    'Public Sub On_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    '    If New Rectangle(Me.intLocation, Me.intSize).Contains(e.X, e.Y) Then
    '        RaiseEvent MouseMove(Me, e)
    '    End If
    'End Sub

    'Public Sub On_Resize(ByVal sender As Object, ByVal e As EventArgs)


    'End Sub


#End Region


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