1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| Imports System.ComponentModel
Public Class controlegraph
Private tableau(3600) As Integer
Private hauteur_controle As Integer
Private largeur_controle As Integer
Private _Zoom As Integer
Private _Offset As Integer
Private _Pas As Integer
Private _Max As Integer
Private _Min As Integer
Private Y As Integer
Private X As Integer
Private graphics As Graphics
Private image As Bitmap
Private police As Object
Public Property Offset() As Integer
Get
Return _Offset
End Get
Set(ByVal Value As Integer)
_Offset = Value
End Set
End Property
Public Property Pas() As Integer
Get
Return _Pas
End Get
Set(ByVal Value As Integer)
_Pas = Value
End Set
End Property
Public Property Zoom() As Integer
Get
Return _Zoom
End Get
Set(ByVal Value As Integer)
_Zoom = Value
End Set
End Property
Public Sub Updt(ByVal V As Integer)
Dim H As Integer = hauteur_controle
Y = hauteur_controle + Zoom * Offset - V * Zoom
graphics.Clear(Color.White)
tableau(X) = Y
Do Until H < 0
H = H - Pas * Zoom
graphics.DrawLine(Pens.Gray, largeur_controle, H, 0, H) 'trace la ligne
graphics.DrawString((hauteur_controle + Zoom * Offset - H) / Zoom, police, Brushes.Blue, 0, H - 12)
Loop
For P As Integer = 0 To largeur_controle - 1 'on trace les lignes formant la courbe
If tableau(largeur_controle - P - 1) <> 0 Then 'on ne trace pas si il n'y a pas de valeur
graphics.DrawLine(Pens.Blue, P, tableau(largeur_controle - P), P + 1, tableau(largeur_controle - P - 1))
End If
Next P
If X = 0 Then 'la courbe arrive au bout du graph, alors decalage du tableau vers la gauche,
Array.Copy(tableau, 0, tableau, 1, 3599) 'on remonte les données, on decalle vers la gauche le graphe
Else 'on ne decalle pas le tableau
X = X - 1
End If
'enregistrement des images
PictureBox.Image = image 'on mets l'image temp dans la picturebox
End Sub
Public Sub Init()
largeur_controle = Me.Width
hauteur_controle = Me.Height
'Array.Resize(tableau, largeur)
image = New Bitmap(PictureBox.Width, PictureBox.Height) 'on créer l'image a mettre dans la picturebox
graphics = graphics.FromImage(image)
police = New Font("arial", 10, FontStyle.Regular, GraphicsUnit.Pixel)
X = largeur_controle
End Sub
Public Sub New()
InitializeComponent()
End Sub
End Class |
Partager