Moin,
in Anlehnung an:
Button blinken lassen
(sorry, irgendwie krieg ich den nicht als Hyperlink eingefügt)
habe ich mir eine eigene Klasse für nen StatusStrip erstellt, damt ich dieses einfach blinken lassen kann:
Spoiler anzeigen
Ist ja vom Prinzip her erstmal simpel - ich kann mir jetzt diesen angepassten StatusStrip einfach auf die Form ziehen. Wie sieht es aber aus, wenn ich auch an die Elemente des StatusStrip ran will (Progressbar und StatusLabel)? Z.B. wenn ich die StatusLabels auch zum Blinken bringen möchte (nur als Beispiel).
MfG
Refra
in Anlehnung an:
Button blinken lassen
(sorry, irgendwie krieg ich den nicht als Hyperlink eingefügt)
habe ich mir eine eigene Klasse für nen StatusStrip erstellt, damt ich dieses einfach blinken lassen kann:
VB.NET-Quellcode
- Option Strict On
- Imports System.Timers
- Public Class CFlashingStatusStrip
- Inherits StatusStrip
- #Region "Variablen"
- Private _colOk As Color
- Private _colFlash1 As Color
- Private _colFlash2 As Color
- Private _EnableFlashing As Boolean
- Private _timFlash As New Timer(1000)
- Private _timInterval As Integer
- #End Region
- #Region "Properties"
- Public Property EnableFlashing As Boolean
- Get
- Return _EnableFlashing
- End Get
- Set(value As Boolean)
- _EnableFlashing = value
- If _EnableFlashing = False Then
- _timFlash.Enabled = False
- BackColor = _colOk
- Else
- _timFlash.Enabled = True
- Tick(Nothing, Nothing)
- End If
- End Set
- End Property
- Public Property ColOk As Color
- Get
- Return _colOk
- End Get
- Set(value As Color)
- _colOk = value
- End Set
- End Property
- Public Property ColFlash1 As Color
- Get
- Return _colFlash1
- End Get
- Set(value As Color)
- _colFlash1 = value
- End Set
- End Property
- Public Property ColFlash2 As Color
- Get
- Return _colFlash2
- End Get
- Set(value As Color)
- _colFlash2 = value
- End Set
- End Property
- Public Property TimInterval As Integer
- Get
- Return _timInterval
- End Get
- Set(value As Integer)
- _timInterval = value
- _timFlash.Interval = _timInterval
- End Set
- End Property
- #End Region
- #Region "Konstruktoren"
- Public Sub New()
- AddHandler _timFlash.Elapsed, AddressOf Tick
- _colOk = Color.LimeGreen
- _colFlash1 = Color.Yellow
- _colFlash2 = Color.Red
- End Sub
- Public Sub New(ByVal ColOk As Color, ByVal ColFlash1 As Color, ByVal ColFlash2 As Color)
- AddHandler _timFlash.Elapsed, AddressOf Tick
- _colOk = ColOk
- _colFlash1 = ColFlash1
- _colFlash2 = ColFlash2
- End Sub
- #End Region
- #Region "Events"
- Private Sub Tick(sender As Object, e As EventArgs)
- If EnableFlashing Then
- If BackColor = _colFlash1 Then
- BackColor = _colFlash2
- Else
- BackColor = _colFlash1
- End If
- End If
- End Sub
- #End Region
- End Class
Ist ja vom Prinzip her erstmal simpel - ich kann mir jetzt diesen angepassten StatusStrip einfach auf die Form ziehen. Wie sieht es aber aus, wenn ich auch an die Elemente des StatusStrip ran will (Progressbar und StatusLabel)? Z.B. wenn ich die StatusLabels auch zum Blinken bringen möchte (nur als Beispiel).
MfG
Refra