Click here to Skip to main content
15,892,927 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.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports BV.Core
'Imports IMidRang
Imports MidRange
Imports IMidRange


Public Class GraphOfVisorSerial
    Inherits GraphOfVisorSimple
    'Implements IBlockInputSerial

    'para la interfaz serie
    Protected intClearOnComplete As Boolean
    Protected intRefreshAt As Integer
    Protected intRefreshCounter As Integer
    Protected intWindowWidth As Long

#Region "Constructor"

    Public Sub New(ByVal ParentVisor As IVisorBase, ByVal Pen1 As Pen, ByVal TypeOfComplexValue As SubGraphType)
        MyBase.New(ParentVisor, Pen1, TypeOfComplexValue)

    End Sub

    Protected Overrides Sub Initialize(ByVal UsedPen As Pen, ByVal ParentVisor As IVisorBase)
        Me.intBriefDesc = "Graph Of Visor"
        'Me.intDescription = "Graph Of Visor"
        Me.intName = "GraphOfVisor"
        Me.intIcon = New Icon([GetType], "GoV.ico")

        intVisible = True
        intAutoShow = True
        intLineType = TypeOfVisorLine.Solid
        intAutoScale = AutoScaleTypes.Y

        intClearOnComplete = True
        intWindowWidth = 100
        intRefreshAt = 10

        MyBase.Initialize(UsedPen, ParentVisor)
        'intArrayLinesR.Capacity = 10
    End Sub

#End Region

#Region "Serial properties"

    <Browsable(False)> _
    Public Property ClearOnComplete() As Boolean 'Implements IBlockInputSerial.ClearOnComplete
        Get
            Return intClearOnComplete
        End Get
        Set(ByVal Value As Boolean)
            intClearOnComplete = Value
        End Set
    End Property

    <Browsable(False)> _
    Public Property WindowWidth() As Long 'Implements IBlockInputSerial.WindowWidth
        Get
            Return intWindowWidth
        End Get
        Set(ByVal Value As Long)
            If Value > 0 Then
                intWindowWidth = Value
            Else
                OnSendMessage(Me, New MessageEventArgs("Windows must be greater as 0", MessageEventArgs.EMessageType.[Error]))
            End If
        End Set
    End Property

    <Browsable(False)> _
    Public Property RefreshAt() As Integer 'Implements IBlockInputSerial.RefreshAt
        Get
            Return intRefreshAt
        End Get
        Set(ByVal Value As Integer)
            If Value >= 0 Then
                If Value <= Me.intWindowWidth Then
                    intRefreshAt = Value
                Else
                    intRefreshAt = intWindowWidth
                End If
            Else
                OnSendMessage(Me, New MessageEventArgs("Refresh Number must be greater as 0", MessageEventArgs.EMessageType.Warning))
            End If
        End Set
    End Property

#End Region

#Region "Mannaged Events"

    Private Sub MannageSerialData()
        Dim data() As Object

        If ArrayData.Count > 0 Then
            'para 2 datos o mas
            data = ArrayData.Item(ArrayData.Count - 1)
            ReDim Preserve data(data.GetUpperBound(0) + 1)
            data(data.GetUpperBound(0)) = CType(ptrObject, IOutput).Data

            If intArrayLinesR.Count > 0 Then
                intArrayLinesR.RemoveAt(intArrayLinesR.Count - 1)  'borro el ultimo
            End If
            ArrayData.Add(data)
        Else
            'primer dato
            ReDim data(0)
            data(0) = CType(ptrObject, IOutput).Data
            ArrayData.Add(data)
        End If
        UpdatePoints(data)          'actualizo el array de lineas

        If Me.intRefreshAt <= intRefreshCounter Then
            RaiseDataChanged(Me, New EventArgs)
            intRefreshCounter = 0
        End If
        intRefreshCounter = intRefreshCounter + 1
    End Sub

    Protected Overrides Sub MannageDataChanged(ByVal sender As Object, ByVal e As EventArgs)
        If TypeOf ptrObject Is IOutput Then
            MyBase.MannageDataChanged(sender, e)

        ElseIf TypeOf ptrObject Is IOutput Then
            MannageSerialData()
        Else
            Stop    'error
            OnSendMessage(Me, New MessageEventArgs("Unsupported data Type", MessageEventArgs.EMessageType.[Error]))
        End If
        'UpdatePoints()
    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