C
cmdolcet69
The code below was written to determine the state of the .Image:
With tmpPic
.Location = New Point(5, 8 + (100 * (groupIndex)))
.Size = defaultPic1Size
.SizeMode = PictureBoxSizeMode.CenterImage
If showBatteryPic Then
If mPort = "-1" Then
.Image = Me.imageListBattery.Images(6)
Else
.Image = Me.imageListBattery.Images(0)
End If
Else
If mPort = "-1" Then
.Image = Me.imageListBattery.Images(6)
Else
.Image = Me.imageListBattery.Images(5)
End If
End If
.Tag = gType & "_" & cPort & "_" & mPort
End With
Me.panelBatteryLevel.Controls.Add(tmpPic)
tmpPic = Nothing
End Sub
I want to check the battery level based off the value return I wanted
to set the .Image with the correct battery level in the sub below. How
can I get the .Image in the above sub to equal the batteryImage ?
Public Sub CheckBatteryLevel(ByVal mux As
LMIObjectLibrary.Multiplexor, ByVal muxPort As Integer, ByRef
picBattery As PictureBox, ByVal batteryImages As ImageList)
Try
If mux.MuxAnalogValues(muxPort) >= 4096 Then
'Mux Not Responding
picBattery.Image = batteryImages.Images(5)
intBatteryLvl = 4096
ElseIf mux.MuxAnalogValues(muxPort) > 3720 Then
'Full battery
picBattery.Image = batteryImages.Images(0)
ElseIf mux.MuxAnalogValues(muxPort) > 3365 And
mux.MuxAnalogValues(muxPort) <= 3720 Then
'OK battery
picBattery.Image = batteryImages.Images(1)
ElseIf mux.MuxAnalogValues(muxPort) > 3240 And
mux.MuxAnalogValues(muxPort) <= 3365 Then
'Low battery
picBattery.Image = batteryImages.Images(2)
ElseIf mux.MuxAnalogValues(muxPort) > 3000 And
mux.MuxAnalogValues(muxPort) <= 3240 Then
'Critical battery
picBattery.Image = batteryImages.Images(3)
ElseIf mux.MuxAnalogValues(muxPort) > 100 And
mux.MuxAnalogValues(muxPort) <= 3000 Then
'Empty battery
picBattery.Image = batteryImages.Images(4)
Else
'AC Adapter in use
picBattery.Image = batteryImages.Images(6)
intBatteryLvl = 4096
End If
Catch ex As Exception
_TListener.AddMethodError(ex)
End Try
End Sub
With tmpPic
.Location = New Point(5, 8 + (100 * (groupIndex)))
.Size = defaultPic1Size
.SizeMode = PictureBoxSizeMode.CenterImage
If showBatteryPic Then
If mPort = "-1" Then
.Image = Me.imageListBattery.Images(6)
Else
.Image = Me.imageListBattery.Images(0)
End If
Else
If mPort = "-1" Then
.Image = Me.imageListBattery.Images(6)
Else
.Image = Me.imageListBattery.Images(5)
End If
End If
.Tag = gType & "_" & cPort & "_" & mPort
End With
Me.panelBatteryLevel.Controls.Add(tmpPic)
tmpPic = Nothing
End Sub
I want to check the battery level based off the value return I wanted
to set the .Image with the correct battery level in the sub below. How
can I get the .Image in the above sub to equal the batteryImage ?
Public Sub CheckBatteryLevel(ByVal mux As
LMIObjectLibrary.Multiplexor, ByVal muxPort As Integer, ByRef
picBattery As PictureBox, ByVal batteryImages As ImageList)
Try
If mux.MuxAnalogValues(muxPort) >= 4096 Then
'Mux Not Responding
picBattery.Image = batteryImages.Images(5)
intBatteryLvl = 4096
ElseIf mux.MuxAnalogValues(muxPort) > 3720 Then
'Full battery
picBattery.Image = batteryImages.Images(0)
ElseIf mux.MuxAnalogValues(muxPort) > 3365 And
mux.MuxAnalogValues(muxPort) <= 3720 Then
'OK battery
picBattery.Image = batteryImages.Images(1)
ElseIf mux.MuxAnalogValues(muxPort) > 3240 And
mux.MuxAnalogValues(muxPort) <= 3365 Then
'Low battery
picBattery.Image = batteryImages.Images(2)
ElseIf mux.MuxAnalogValues(muxPort) > 3000 And
mux.MuxAnalogValues(muxPort) <= 3240 Then
'Critical battery
picBattery.Image = batteryImages.Images(3)
ElseIf mux.MuxAnalogValues(muxPort) > 100 And
mux.MuxAnalogValues(muxPort) <= 3000 Then
'Empty battery
picBattery.Image = batteryImages.Images(4)
Else
'AC Adapter in use
picBattery.Image = batteryImages.Images(6)
intBatteryLvl = 4096
End If
Catch ex As Exception
_TListener.AddMethodError(ex)
End Try
End Sub