VERSION 5.00
Begin VB.UserControl LED 
   BackStyle       =   0  'Transparent
   ClientHeight    =   3270
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4005
   ScaleHeight     =   218
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   267
   Begin VB.Shape shpSpot 
      BorderColor     =   &H0080FF80&
      FillColor       =   &H00FFFFFF&
      FillStyle       =   0  'Solid
      Height          =   90
      Left            =   45
      Shape           =   3  'Circle
      Top             =   45
      Width           =   90
   End
   Begin VB.Shape shpBulb 
      FillColor       =   &H0000FF00&
      FillStyle       =   0  'Solid
      Height          =   285
      Left            =   0
      Shape           =   3  'Circle
      Top             =   0
      Width           =   285
   End
   Begin VB.Shape shpShadow 
      BorderColor     =   &H00303030&
      FillColor       =   &H00202020&
      FillStyle       =   0  'Solid
      Height          =   285
      Left            =   45
      Shape           =   3  'Circle
      Top             =   45
      Width           =   285
   End
End
Attribute VB_Name = "LED"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Public Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
BackColor = shpShadow.BackColor
End Property
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
shpShadow.BackColor() = New_BackColor
PropertyChanged "BackColor"
CalcIntermediaryColors
End Property
Public Property Get FillColor() As OLE_COLOR
Attribute FillColor.VB_Description = "Returns/sets the color used to fill in shapes, circles, and boxes."
FillColor = shpBulb.FillColor
End Property
Public Property Let FillColor(ByVal New_FillColor As OLE_COLOR)
shpBulb.FillColor() = New_FillColor
PropertyChanged "FillColor"
CalcIntermediaryColors
End Property
Public Property Get ForeColor() As OLE_COLOR
Attribute ForeColor.VB_Description = "Returns/sets the color used to fill in shapes, circles, and boxes."
ForeColor = shpSpot.FillColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
shpSpot.FillColor() = New_ForeColor
PropertyChanged "ForeColor"
CalcIntermediaryColors
End Property
Public Property Get BackColorLight() As OLE_COLOR
Attribute BackColorLight.VB_Description = "Returns/sets the color of an object's border."
BackColorLight = shpShadow.BorderColor
End Property
Public Property Let BackColorLight(ByVal New_BackColorLight As OLE_COLOR)
shpShadow.BorderColor() = New_BackColorLight
PropertyChanged "BackColorLight"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
shpShadow.BackColor = PropBag.ReadProperty("BackColor", &H80000005)
shpBulb.FillColor = PropBag.ReadProperty("FillColor", &HFF00&)
shpSpot.FillColor = PropBag.ReadProperty("ForeColor", &HFFFFFF)
shpShadow.BorderColor = PropBag.ReadProperty("BackColorLight", 3158064)
CalcIntermediaryColors
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackColor", shpShadow.BackColor, &H80000005)
Call PropBag.WriteProperty("BorderColor", shpBulb.BorderColor, -2147483640)
Call PropBag.WriteProperty("FillColor", shpBulb.FillColor, &HFF00&)
Call PropBag.WriteProperty("ForeColor", shpSpot.FillColor, &HFFFFFF)
Call PropBag.WriteProperty("BackColorLight", shpShadow.BorderColor, 3158064)
End Sub
Sub CalcIntermediaryColors()
Dim R1 As Byte, G1 As Byte, B1 As Byte
Dim R2 As Byte, G2 As Byte, B2 As Byte
Dim RA As Byte, GA As Byte, BA As Byte

ParseColor UserControl.shpBulb.FillColor, R1, G1, B1
ParseColor UserControl.shpSpot.FillColor, R2, G2, B2

RA = (CLng(R1) + CLng(R2)) / 2: GA = (CLng(G1) + CLng(G2)) / 2: BA = (CLng(B1) + CLng(B2)) / 2
UserControl.shpSpot.BorderColor = ComposeColor(RA, GA, BA)

ParseColor UserControl.shpShadow.FillColor, R2, G2, B2

RA = (CLng(R1) + CLng(R2)) / 2: GA = (CLng(G1) + CLng(G2)) / 2: BA = (CLng(B1) + CLng(B2)) / 2
UserControl.shpBulb.BorderColor = ComposeColor(RA, GA, BA)

End Sub
