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
| Private Sub pb_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles pb.Paint
Try
Dim x, h, i, headerColHeight As Integer
x = 0
'traçage de l'entête
h = Math.Floor(StartHour)
headerColHeight = dgv.ColumnHeadersHeight
e.Graphics.DrawLine(Drawing.Pens.Black, 0, headerColHeight, pb.Width, headerColHeight)
While Not h > Math.Floor(EndHour)
e.Graphics.DrawLine(Drawing.Pens.Black, HorizontalIncrement * (h - Math.Floor(StartHour)), 0, HorizontalIncrement * (h - Math.Floor(StartHour)), pb.Height)
e.Graphics.DrawString(h.ToString, New Drawing.Font("arial", 10), Drawing.Brushes.Black, HorizontalIncrement * (h - Math.Floor(StartHour)), 0)
h += 1
End While
'traçagge des ranges horaires + écriture du texte
h = 22 'hauteur d'une ligne DGV non resizée
i = 0
If Not IsNothing(DataSource) Then
For Each elem As Source In DataSource
e.Graphics.DrawLine(Drawing.Pens.Black, 0, headerColHeight + h * i, pb.Width, headerColHeight + h * i)
For Each rng As Range In elem.Ranges
e.Graphics.FillRectangle(New Drawing.SolidBrush(rng.Type.Color), CInt((HorizontalIncrement / 4) * ((rng.BeginTime - Math.Floor(StartHour)) / 0.25)), (headerColHeight + h * i) + 1, CInt((rng.EndTime - rng.BeginTime) / 0.25 * (HorizontalIncrement / 4)), h - 1)
e.Graphics.DrawString(rng.Text, New Drawing.Font("arial", 11), Drawing.Brushes.Black, CInt((HorizontalIncrement / 4) * ((rng.BeginTime - Math.Floor(StartHour)) / 0.25)) + 3, (headerColHeight + h * i) + 2)
If SelectedRange Is rng Then
e.Graphics.DrawRectangle(New Drawing.Pen(Drawing.Brushes.Blue, 3), CInt((HorizontalIncrement / 4) * ((SelectedRange.BeginTime - Math.Floor(StartHour)) / 0.25) + 1), (headerColHeight + h * i) + 2, CInt(((SelectedRange.EndTime - SelectedRange.BeginTime) / 0.25 * (HorizontalIncrement / 4)) - 3), 18)
End If
Next
i += 1
Next
End If
Catch ex As Exception
Throw ex
End Try
End Sub |
Partager