'Custom View class
'#Event: ExampleEvent (Value As Int)
'#DesignerProperty: Key: BooleanExample, DisplayName: Boolean Example, FieldType: Boolean, DefaultValue: True, Description: Example of a boolean property.
'#DesignerProperty: Key: StringWithListExample, DisplayName: String With List, FieldType: String, DefaultValue: Sunday, List: Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday
#DesignerProperty: Key: Name, DisplayName: Name, FieldType: String, DefaultValue: Name ...
#DesignerProperty: Key: Watt, DisplayName: Watt, FieldType: Int, DefaultValue: 1, MinRange: 0, MaxRange: 9999, Description:
'#DesignerProperty: Key: ColorExample, DisplayName: Color Example, FieldType: Color, DefaultValue: 0xFFCFDCDC, Description: You can use the built-in color picker to find the color values.
'#DesignerProperty: Key: DefaultColorExample, DisplayName: Default Color Example, FieldType: Color, DefaultValue: Null, Description: Setting the default value to Null means that a nullable field will be displayed.
Sub Class_Globals
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Private mBase As Panel
Private Const DefaultColorConstant As Int = -984833 'ignore
Private LabelName As Label
Private LabelDateStartStop As Label
Private LabelWatt As Label
Private LabelDurationHours As Label
Private LabelSumPrice As Label
Private LabelOnOff As Label
Private ToggleButtonOnOff As ToggleButton
End Sub
Public Sub Initialize (Callback As Object, EventName As String)
mEventName = EventName
mCallBack = Callback
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
mBase = Base
Sleep(0)
Base.LoadLayout("Consumer")
End Sub
Public Sub GetBase As Panel
Return mBase
End Sub
public Sub Set(Consumer1 As Consumer)
LabelName.Text = Consumer1.Data.Name
LabelDateStartStop.Text = DateTime.Date(Consumer1.Data.DateOn) & " - " & DateTime.Date(Consumer1.Data.DateOff)
LabelWatt.Text = Consumer1.Data.Watt
LabelDurationHours.Text = Consumer1.Data.SumDurationHours & "(+ " & Consumer1.Data.DurationHours & ")"
LabelSumPrice.Text = Consumer1.Data.SumPrice
If Consumer1.Data.On = True Then
LabelOnOff.Text = "On"
Else
LabelOnOff.Text = "Off"
End If
End Sub
Sub ToggleButtonOnOff_CheckedChange(Checked As Boolean)
Dim Consumer1 As Consumer
Consumer1 = mBase.Tag
If Checked Then
Consumer1.Start
Else
Consumer1.Stop
End If
Set(Consumer1)
End Sub