Dim intValue As Integer = CInt(_Value / _Maximum * Height)
Dim intValue As Integer = CInt((Maximum - _Value) / _Maximum * Height)
(1, 1, Width - 2, intValue - 2))ça commence de 1,1 je sais pas si ça fonctionne mais pourquoi tu me fais pas ça 1,Height
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Public Class Form1
Dim alea As New Random
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ProgressBarV1.Value = 10
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ProgressBarV1.Value = alea.Next(0, 100)
Label1.Text = ProgressBarV1.Value.ToString
End Sub
End Class
G.FillRectangle(hatch, New Rectangle(1, Height - intValue, Width - 2, intValue - 2)) ' ligne modifiée
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Collections.Generic
Public Class ProgressBarV : Inherits Control
#Region " Control Help - Properties & Flicker Control "
Private OFS As Integer = Width
Private Speed As Integer = 50
Private _Maximum As Integer = 100
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal v As Integer)
Select Case v
Case Is < _Value
_Value = v
End Select
_Maximum = v
Invalidate()
End Set
End Property
Private _Value As Integer = 0
Public Property Value() As Integer
Get
Select Case _Value
Case 0
Return 1
Case Else
Return _Value
End Select
End Get
Set(ByVal v As Integer)
Select Case v
Case Is > _Maximum
v = _Maximum
End Select
_Value = v
Invalidate()
End Set
End Property
Private _BorderStyle As Boolean = False
Private _BorderColor As Color = Color.Black 'Color.FromArgb(45, 45, 45)
Public Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(ByVal Value As Color)
If Value <> _BorderColor Then
_BorderColor = Value
Me.Refresh()
If _BorderStyle Then
Me.Invalidate()
End If
End If
End Set
End Property
Private _RibbonStyle1 As Boolean = False
Private _RibbonColor1 As Color = Color.Blue 'Color.FromArgb(255, 35, 4)
Public Property RibbonColor1() As Color
Get
Return _RibbonColor1
End Get
Set(ByVal Value As Color)
If Value <> _RibbonColor1 Then
_RibbonColor1 = Value
Me.Refresh()
If _RibbonStyle1 Then
Me.Invalidate()
End If
End If
End Set
End Property
Private _RibbonStyle2 As Boolean = False
Private _RibbonColor2 As Color = Color.Green ' Color.FromArgb(255, 0, 0)
Public Property RibbonColor2() As Color
Get
Return _RibbonColor2
End Get
Set(ByVal Value As Color)
If Value <> _RibbonColor2 Then
_RibbonColor2 = Value
Me.Refresh()
If _RibbonStyle2 Then
Me.Invalidate()
End If
End If
End Set
End Property
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
Dim T As New Threading.Thread(AddressOf Animate)
T.IsBackground = True
T.Start()
End Sub
Sub Animate()
While True
If OFS <= Width Then : OFS -= 1
Else : OFS = 0
End If
Invalidate()
Threading.Thread.Sleep(Speed)
End While
End Sub
#End Region
Sub New()
MyBase.New()
Me.BackColor = Color.FromArgb(38, 38, 38)
DoubleBuffered = True
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim G As Graphics = e.Graphics
MyBase.OnPaint(e)
Dim intValue As Integer = CInt(_Value / _Maximum * Height)
G.Clear(Me.BackColor)
Dim hatch As New HatchBrush(HatchStyle.WideUpwardDiagonal, _RibbonColor1, _RibbonColor2)
G.RenderingOrigin = New Point(0, OFS)
G.FillRectangle(hatch, New Rectangle(1, Height - intValue, Width - 2, intValue - 2)) ' ligne modifiée
G.DrawRectangle(New Pen(Color.Red, 2), 1, 1, Me.Width - 2, Me.Height - 2) 'Ajoute un cadre sur le dessin du Panel
End Sub
End Class
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Collections.Generic
Public Class ProgressBarCirculaire : Inherits Control
#Region " Control Help - Properties & Flicker Control "
Private _Texte As String = " %"
Private OFS As Integer = 0
Private Angle As Integer = 0
Private Speed As Integer = 50
Private _Maximum As Integer = 100
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal v As Integer)
Select Case v
Case Is < _Value
_Value = v
End Select
_Maximum = v
Invalidate()
End Set
End Property
Private _Value As Integer = 0
Public Property Value() As Integer
Get
Select Case _Value
Case 0
Return 0
Case Else
Return _Value
End Select
End Get
Set(ByVal v As Integer)
Select Case v
Case Is > _Maximum
v = _Maximum
End Select
_Value = v
Invalidate()
End Set
End Property
Private _BorderStyle As Boolean = False
Private _BorderColor As Color = Color.Black
Public Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(ByVal Value As Color)
If Value <> _BorderColor Then
_BorderColor = Value
Me.Refresh()
If _BorderStyle Then
Me.Invalidate()
End If
End If
End Set
End Property
Private _RibbonStyle1 As Boolean = False
Private _RibbonColor1 As Color = Color.FromArgb(225, 28, 55)
Public Property RibbonColor1() As Color
Get
Return _RibbonColor1
End Get
Set(ByVal Value As Color)
If Value <> _RibbonColor1 Then
_RibbonColor1 = Value
Me.Refresh()
If _RibbonStyle1 Then
Me.Invalidate()
End If
End If
End Set
End Property
Private _RibbonStyle2 As Boolean = False
Private _RibbonColor2 As Color = Color.Gray
Public Property RibbonColor2() As Color
Get
Return _RibbonColor2
End Get
Set(ByVal Value As Color)
If Value <> _RibbonColor2 Then
_RibbonColor2 = Value
Me.Refresh()
If _RibbonStyle2 Then
Me.Invalidate()
End If
End If
End Set
End Property
Private _TextVisibel As Boolean = True
Public Property TextVisibel() As Boolean
Get
Return _TextVisibel
End Get
Set(ByVal Value As Boolean)
If Value <> _TextVisibel Then
_TextVisibel = Value
Me.Refresh()
If _TextVisibel Then
Me.Invalidate()
End If
End If
End Set
End Property
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
Dim T As New Threading.Thread(AddressOf Animate)
T.IsBackground = True
T.Start()
End Sub
Sub Animate()
While True
If Angle < 360 Then : Angle = CInt(_Value * 360 / _Maximum)
'Else : Angle = 0
End If
Invalidate()
Threading.Thread.Sleep(Speed)
End While
End Sub
#End Region
Sub New()
MyBase.New()
Me.Text = _Texte
Me.BackColor = Color.FromArgb(38, 38, 38)
Me.Font = New Font("Century Gothic", 14)
Me.MinimumSize = New Size(100, 100)
Me.BackColor = SystemColors.Control
Me.Value = 0
DoubleBuffered = True
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim G As Graphics = e.Graphics
MyBase.OnPaint(e)
Dim intValue As Integer = CInt(_Value / _Maximum * Width)
G.Clear(Me.BackColor)
e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(37, 46, 59)), 12, 12, Width - 24, Height - 24)
e.Graphics.DrawArc(New Pen(New SolidBrush(Color.Gray), 5), 10, 10, Width - 20, Height - 20, -90, 360)
e.Graphics.DrawArc(New Pen(New SolidBrush(_BorderColor), 3), 7, 7, Width - 14, Height - 14, 0, 360) ' la progressBar Circulaire vide
e.Graphics.DrawString(CInt((Angle * 100) / 360) & Me.Text, New Font("Century Gothic", 20), New SolidBrush(Color.FromArgb(225, 28, 55)), New RectangleF(3, 3, Width - 5, Height - 5), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
e.Graphics.DrawArc(New Pen(New SolidBrush(_RibbonColor1), 5), 10, 10, Width - 20, Height - 20, -90, Angle)
End Sub
End Class
Dim G As Graphics = e.Graphics
MyBase.OnPaint(e)
Dim intValue As Integer = CInt(_Value / _Maximum * Width)
With G
.Clear(Me.BackColor)
.FillEllipse(New SolidBrush(Color.White), 12, 12, Width - 24, Height - 24)
.DrawArc(New Pen(New SolidBrush(Color.Gray), 18), 10, 10, Width - 20, Height - 20, -90, 360)
.DrawString(CInt((Angle * 100) / 360).ToString, New Font("Century Gothic", 20), New SolidBrush(Color.FromArgb(225, 28, 55)), New RectangleF(3, 3, Width - 5, Height - 5), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
.DrawArc(New Pen(New SolidBrush(_RibbonColor1), 12), 10, 10, Width - 20, Height - 20, -90, Angle)
End With
End Sub
Sub Animate()
While True
Angle = CInt(_Value * 360 / _Maximum)
Invalidate()
Threading.Thread.Sleep(Speed)
End While
End Sub