home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / arrang1g / led.ctl next >
Encoding:
Text File  |  1998-11-19  |  15.1 KB  |  429 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
  3. Begin VB.UserControl LED 
  4.    ClientHeight    =   300
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   300
  8.    ScaleHeight     =   20
  9.    ScaleMode       =   3  'Pixel
  10.    ScaleWidth      =   20
  11.    ToolboxBitmap   =   "LED.ctx":0000
  12.    Begin VB.Timer Timer1 
  13.       Enabled         =   0   'False
  14.       Interval        =   1000
  15.       Left            =   1020
  16.       Top             =   1500
  17.    End
  18.    Begin VB.Image Image1 
  19.       Height          =   300
  20.       Left            =   0
  21.       Stretch         =   -1  'True
  22.       Top             =   0
  23.       Width           =   300
  24.    End
  25.    Begin ComctlLib.ImageList ImageList1 
  26.       Left            =   2100
  27.       Top             =   1500
  28.       _ExtentX        =   1005
  29.       _ExtentY        =   1005
  30.       BackColor       =   -2147483643
  31.       ImageWidth      =   20
  32.       ImageHeight     =   20
  33.       MaskColor       =   12632256
  34.       _Version        =   327682
  35.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  36.          NumListImages   =   18
  37.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  38.             Picture         =   "LED.ctx":0312
  39.             Key             =   "RedCirLo"
  40.          EndProperty
  41.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  42.             Picture         =   "LED.ctx":0814
  43.             Key             =   "RedCirHi"
  44.          EndProperty
  45.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  46.             Picture         =   "LED.ctx":0D16
  47.             Key             =   "GreCirLo"
  48.          EndProperty
  49.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  50.             Picture         =   "LED.ctx":1218
  51.             Key             =   "GreCirHi"
  52.          EndProperty
  53.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  54.             Picture         =   "LED.ctx":171A
  55.             Key             =   "RedSqeLo"
  56.          EndProperty
  57.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  58.             Picture         =   "LED.ctx":1C1C
  59.             Key             =   "RedSqeHi"
  60.          EndProperty
  61.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  62.             Picture         =   "LED.ctx":211E
  63.             Key             =   "GreSqeLo"
  64.          EndProperty
  65.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  66.             Picture         =   "LED.ctx":2620
  67.             Key             =   "GreSqeHi"
  68.          EndProperty
  69.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  70.             Picture         =   "LED.ctx":2B22
  71.             Key             =   "YelCirLo"
  72.          EndProperty
  73.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  74.             Picture         =   "LED.ctx":3024
  75.             Key             =   "YelCirHi"
  76.          EndProperty
  77.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  78.             Picture         =   "LED.ctx":3526
  79.             Key             =   "YelSqeLo"
  80.          EndProperty
  81.          BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  82.             Picture         =   "LED.ctx":3A28
  83.             Key             =   "YelSqeHi"
  84.          EndProperty
  85.          BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  86.             Picture         =   "LED.ctx":3F2A
  87.             Key             =   "ButtonUp"
  88.          EndProperty
  89.          BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  90.             Picture         =   "LED.ctx":55A8
  91.             Key             =   "ButtonDown"
  92.          EndProperty
  93.          BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  94.             Picture         =   "LED.ctx":6C26
  95.             Key             =   "KeyOff"
  96.          EndProperty
  97.          BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  98.             Picture         =   "LED.ctx":A2D8
  99.             Key             =   "KeyOn"
  100.          EndProperty
  101.          BeginProperty ListImage17 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  102.             Picture         =   "LED.ctx":D98A
  103.             Key             =   "KeyOffwo"
  104.          EndProperty
  105.          BeginProperty ListImage18 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  106.             Picture         =   "LED.ctx":F2F4
  107.             Key             =   "KeyOnwo"
  108.          EndProperty
  109.       EndProperty
  110.    End
  111. End
  112. Attribute VB_Name = "LED"
  113. Attribute VB_GlobalNameSpace = False
  114. Attribute VB_Creatable = True
  115. Attribute VB_PredeclaredId = False
  116. Attribute VB_Exposed = False
  117.  
  118. 'Default Property Values:
  119. Const m_def_ButtonMode = 0
  120. Const m_def_LEDColor = 0
  121. Const m_def_Shape = 0
  122. Const m_def_Value = False
  123. 'Property Variables:
  124. Dim m_ButtonMode As enButtMode
  125. Dim m_LEDColor As enLedColor
  126. Dim m_Shape As LedShape
  127. Dim m_Value As Boolean
  128. 'Event Declarations:
  129. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Image1,Image1,-1,MouseDown
  130. Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
  131. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Image1,Image1,-1,MouseUp
  132. Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
  133. Event Click() 'MappingInfo=Image1,Image1,-1,Click
  134.  
  135. Enum LedShape
  136.     ledCircle = 0
  137.     ledSquare = 1
  138.     ledButton = 2
  139. End Enum
  140.  
  141. Enum enLedColor
  142.     ledRed = 0
  143.     ledGreen = 1
  144.     ledYellow = 2
  145. End Enum
  146.  
  147. Enum enButtMode
  148.     ledPushButton = 0
  149.     ledSwitch = 1
  150. End Enum
  151.  
  152.  
  153. Public Property Get LEDColor() As enLedColor
  154. Attribute LEDColor.VB_Description = "Color of LED"
  155. Attribute LEDColor.VB_ProcData.VB_Invoke_Property = ";Appearance"
  156. Attribute LEDColor.VB_MemberFlags = "200"
  157.     LEDColor = m_LEDColor
  158. End Property
  159.  
  160. Public Property Let LEDColor(ByVal New_LEDColor As enLedColor)
  161.     m_LEDColor = New_LEDColor
  162.     PropertyChanged "LEDColor"
  163.     Call Nastavi
  164. End Property
  165.  
  166. Public Property Get Shape() As LedShape
  167. Attribute Shape.VB_Description = "Shape of LED"
  168. Attribute Shape.VB_ProcData.VB_Invoke_Property = ";Appearance"
  169.     Shape = m_Shape
  170. End Property
  171.  
  172. Public Property Let Shape(ByVal New_Shape As LedShape)
  173.     
  174.     m_Shape = New_Shape
  175.     PropertyChanged "Shape"
  176.     Call Nastavi
  177. End Property
  178.  
  179. Public Property Get Value() As Boolean
  180. Attribute Value.VB_ProcData.VB_Invoke_Property = ";Data"
  181.     Value = m_Value
  182. End Property
  183.  
  184. Public Property Let Value(ByVal New_Value As Boolean)
  185.     m_Value = New_Value
  186.     PropertyChanged "Value"
  187.     Call Nastavi
  188. End Property
  189.  
  190. Private Sub Timer1_Timer()
  191. Static test As Boolean
  192.     If m_Shape = 0 Then
  193.         If m_LEDColor = 0 Then
  194.             If test = False Then
  195.                 Image1.Picture = ImageList1.ListImages("RedCirLo").Picture
  196.                 test = True
  197.             Else
  198.                 Image1.Picture = ImageList1.ListImages("RedCirHi").Picture
  199.                 test = False
  200.             End If
  201.         ElseIf m_LEDColor = 1 Then
  202.             If test = False Then
  203.                 Image1.Picture = ImageList1.ListImages("GreCirLo").Picture
  204.                 test = True
  205.             Else
  206.                 Image1.Picture = ImageList1.ListImages("GreCirHi").Picture
  207.                 test = False
  208.             End If
  209.         Else
  210.             If test = False Then
  211.                 Image1.Picture = ImageList1.ListImages("YelCirLo").Picture
  212.                 test = True
  213.             Else
  214.                 Image1.Picture = ImageList1.ListImages("YelCirHi").Picture
  215.                 test = False
  216.             End If
  217.         End If
  218.     ElseIf m_Shape = 1 Then
  219.         If m_LEDColor = 0 Then
  220.             If test = False Then
  221.                 Image1.Picture = ImageList1.ListImages("RedSqeLo").Picture
  222.                 test = True
  223.             Else
  224.                 Image1.Picture = ImageList1.ListImages("RedSqeHi").Picture
  225.                 test = False
  226.             End If
  227.         ElseIf m_LEDColor = 1 Then
  228.             If test = False Then
  229.                 Image1.Picture = ImageList1.ListImages("GreSqeLo").Picture
  230.                 test = True
  231.             Else
  232.                 Image1.Picture = ImageList1.ListImages("GreSqeHi").Picture
  233.                 test = False
  234.             End If
  235.         Else
  236.             If test = False Then
  237.                 Image1.Picture = ImageList1.ListImages("YelSqeLo").Picture
  238.                 test = True
  239.             Else
  240.                 Image1.Picture = ImageList1.ListImages("YelSqeHi").Picture
  241.                 test = False
  242.             End If
  243.         End If
  244.     End If
  245.  
  246. End Sub
  247.  
  248. 'Initialize Properties for User Control
  249. Private Sub UserControl_InitProperties()
  250.     m_LEDColor = m_def_LEDColor
  251.     m_Shape = m_def_Shape
  252.     m_Value = m_def_Value
  253.     m_ButtonMode = m_def_ButtonMode
  254.     Call Nastavi
  255. End Sub
  256.  
  257. 'Load property values from storage
  258. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  259.  
  260.     m_LEDColor = PropBag.ReadProperty("LEDColor", m_def_LEDColor)
  261.     m_Shape = PropBag.ReadProperty("Shape", m_def_Shape)
  262.     m_Value = PropBag.ReadProperty("Value", m_def_Value)
  263.     Timer1.Enabled = PropBag.ReadProperty("Blink", False)
  264.     Timer1.Interval = PropBag.ReadProperty("BlinkInterval", 1000)
  265.     m_ButtonMode = PropBag.ReadProperty("ButtonMode", m_def_ButtonMode)
  266.     UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
  267. End Sub
  268.  
  269. Private Sub UserControl_Resize()
  270. Image1.Width = UserControl.ScaleWidth
  271. Image1.Height = UserControl.ScaleHeight
  272. End Sub
  273.  
  274. Private Sub UserControl_Show()
  275.     Call Nastavi
  276. End Sub
  277.  
  278. 'Write property values to storage
  279. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  280.  
  281.     Call PropBag.WriteProperty("LEDColor", m_LEDColor, m_def_LEDColor)
  282.     Call PropBag.WriteProperty("Shape", m_Shape, m_def_Shape)
  283.     Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
  284.     Call PropBag.WriteProperty("Blink", Timer1.Enabled, False)
  285.     Call PropBag.WriteProperty("BlinkInterval", Timer1.Interval, 1000)
  286.     Call PropBag.WriteProperty("ButtonMode", m_ButtonMode, m_def_ButtonMode)
  287.     Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
  288. End Sub
  289.  
  290.  
  291. Public Sub Nastavi()
  292.     If m_Shape = 0 Then
  293.         If m_LEDColor = 0 Then
  294.             If m_Value = False Then
  295.                 Image1.Picture = ImageList1.ListImages("RedCirLo").Picture
  296.             Else
  297.                 Image1.Picture = ImageList1.ListImages("RedCirHi").Picture
  298.             End If
  299.         ElseIf m_LEDColor = 1 Then
  300.             If m_Value = False Then
  301.                 Image1.Picture = ImageList1.ListImages("GreCirLo").Picture
  302.             Else
  303.                 Image1.Picture = ImageList1.ListImages("GreCirHi").Picture
  304.             End If
  305.         Else
  306.             If m_Value = False Then
  307.                 Image1.Picture = ImageList1.ListImages("YelCirLo").Picture
  308.             Else
  309.                 Image1.Picture = ImageList1.ListImages("YelCirHi").Picture
  310.             End If
  311.         End If
  312.     ElseIf m_Shape = 1 Then
  313.         If m_LEDColor = 0 Then
  314.             If m_Value = False Then
  315.                 Image1.Picture = ImageList1.ListImages("RedSqeLo").Picture
  316.             Else
  317.                 Image1.Picture = ImageList1.ListImages("RedSqeHi").Picture
  318.             End If
  319.         ElseIf m_LEDColor = 1 Then
  320.             If m_Value = False Then
  321.                 Image1.Picture = ImageList1.ListImages("GreSqeLo").Picture
  322.             Else
  323.                 Image1.Picture = ImageList1.ListImages("GreSqeHi").Picture
  324.             End If
  325.         Else
  326.             If m_Value = False Then
  327.                 Image1.Picture = ImageList1.ListImages("YelSqeLo").Picture
  328.             Else
  329.                 Image1.Picture = ImageList1.ListImages("YelSqeHi").Picture
  330.             End If
  331.         End If
  332.     ElseIf m_Shape = 2 Then
  333.         If m_Value = False Then
  334.             Image1.Picture = ImageList1.ListImages("KeyOffwo").Picture
  335.         Else
  336.             Image1.Picture = ImageList1.ListImages("KeyOnwo").Picture
  337.         End If
  338.     End If
  339. End Sub
  340.             
  341.             
  342. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  343. 'MappingInfo=Timer1,Timer1,-1,Enabled
  344. Public Property Get Blink() As Boolean
  345. Attribute Blink.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
  346. Attribute Blink.VB_ProcData.VB_Invoke_Property = ";Behavior"
  347.     Blink = Timer1.Enabled
  348. End Property
  349.  
  350. Public Property Let Blink(ByVal New_Blink As Boolean)
  351.     Timer1.Enabled() = New_Blink
  352.     PropertyChanged "Blink"
  353. End Property
  354.  
  355. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  356. 'MappingInfo=Timer1,Timer1,-1,Interval
  357. Public Property Get BlinkInterval() As Long
  358. Attribute BlinkInterval.VB_Description = "Returns/sets the number of milliseconds between calls to a Timer control's Timer event."
  359. Attribute BlinkInterval.VB_ProcData.VB_Invoke_Property = ";Behavior"
  360.     BlinkInterval = Timer1.Interval
  361. End Property
  362.  
  363. Public Property Let BlinkInterval(ByVal New_BlinkInterval As Long)
  364.     Timer1.Interval() = New_BlinkInterval
  365.     PropertyChanged "BlinkInterval"
  366. End Property
  367. Private Sub Image1_Click()
  368. If m_ButtonMode = ledSwitch Then
  369.     If m_Shape = ledButton Then
  370.         If m_Value = True Then
  371.             Image1.Picture = ImageList1.ListImages("KeyOffwo").Picture
  372.             m_Value = False
  373.             PropertyChanged "Value"
  374.          Else
  375.             Image1.Picture = ImageList1.ListImages("KeyOnwo").Picture
  376.             m_Value = True
  377.             PropertyChanged "Value"
  378.          End If
  379.     End If
  380. End If
  381. RaiseEvent Click
  382. End Sub
  383.  
  384. Public Property Get ButtonMode() As enButtMode
  385. Attribute ButtonMode.VB_ProcData.VB_Invoke_Property = ";Misc"
  386.     ButtonMode = m_ButtonMode
  387. End Property
  388.  
  389. Public Property Let ButtonMode(ByVal New_ButtonMode As enButtMode)
  390.     m_ButtonMode = New_ButtonMode
  391.     PropertyChanged "ButtonMode"
  392. End Property
  393.  
  394. Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  395. If m_ButtonMode = ledPushButton Then
  396.     If m_Shape = ledButton Then
  397.         Image1.Picture = ImageList1.ListImages("KeyOnwo").Picture
  398.         m_Value = True
  399.         PropertyChanged "Value"
  400.     End If
  401. End If
  402.     RaiseEvent MouseDown(Button, Shift, X, Y)
  403. End Sub
  404.  
  405. Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  406. If m_ButtonMode = ledPushButton Then
  407.     If m_Shape = ledButton Then
  408.         Image1.Picture = ImageList1.ListImages("KeyOffwo").Picture
  409.         m_Value = False
  410.         PropertyChanged "Value"
  411.     End If
  412. End If
  413. RaiseEvent MouseUp(Button, Shift, X, Y)
  414. End Sub
  415.  
  416. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  417. 'MappingInfo=UserControl,UserControl,-1,Enabled
  418. Public Property Get Enabled() As Boolean
  419. Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
  420. Attribute Enabled.VB_UserMemId = -514
  421.     Enabled = UserControl.Enabled
  422. End Property
  423.  
  424. Public Property Let Enabled(ByVal New_Enabled As Boolean)
  425.     UserControl.Enabled() = New_Enabled
  426.     PropertyChanged "Enabled"
  427. End Property
  428.  
  429.