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
|
Public Class clsCourbeTemperature
Inherits PictureBox
Private m_Temperature, m_EcartEntrePoints, m_NombrePointsMax As Integer
Private m_NombreHautEchelle, m_NombreBasEchelle As String
Private m_CouleurFond, m_CouleurTrait As Color
Private m_col As Collection = New Collection
Private b As Bitmap
Private g As Graphics
Public Sub New(ByVal ParentForm As Form, _
ByVal CouleurTrait As Color, _
ByVal CouleurFond As Color, _
ByVal TempsRafraichissement As Double, _
ByVal EcartEntrePoints As Integer, _
ByVal NombrePointsMax As Integer, _
ByVal NombreBasEchelle As String, _
ByVal NombreHautEchelle As String)
Me.Width = ParentForm.ClientRectangle.Width
Me.Height = ParentForm.ClientRectangle.Height
Me.Parent = ParentForm
m_EcartEntrePoints = EcartEntrePoints
m_NombrePointsMax = NombrePointsMax
m_CouleurFond = CouleurFond
m_CouleurTrait = CouleurTrait
m_NombreHautEchelle = NombreHautEchelle
m_NombreBasEchelle = NombreBasEchelle
b = New Bitmap(Me.Width, Me.Height)
g = Graphics.FromImage(b)
End Sub
Public WriteOnly Property Temperature() As Double
Set(ByVal value As Double)
m_Temperature = value
If m_col.Count >= m_NombrePointsMax Then
m_col.Remove(1)
End If
m_col.Add(((100 - m_Temperature) / 100) * Me.Height)
Dim ft As New Font("Arial", 13, FontStyle.Regular, GraphicsUnit.Pixel)
g.FillRectangle(New SolidBrush(m_CouleurFond), New Rectangle(0, 0, b.Width, b.Height))
g.DrawString(m_NombreBasEchelle, ft, New SolidBrush(Color.White), 5, Me.Height - 20)
g.DrawString(m_NombreHautEchelle, ft, New SolidBrush(Color.White), 5, 5)
For x = 2 To m_col.Count
g.DrawLine(New Pen(m_CouleurTrait, 2), _
New Point(x * m_EcartEntrePoints, m_col.Item(x - 1)), _
New Point((x * m_EcartEntrePoints) + m_EcartEntrePoints, m_col.Item(x)))
If x = m_col.Count Then
g.DrawString(m_Temperature.ToString, _
ft, _
New SolidBrush(Color.Orange), _
(x * m_EcartEntrePoints) + m_EcartEntrePoints, _
m_col.Item(x))
End If
Next
Me.Image = b.Clone
End Set
End Property |
Partager