Microsoft Small Basic

Program Listing: WBK046
' KinectWindow Viewer
' Copyright © 2015 Nonki Takahashi. The MIT License.
'
lastSensor = ""
sensor = ""
GraphicsWindow.BackgroundColor = "Gray"
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.BrushColor = "Black"
btnColor = Controls.AddButton("Color", 10, 10)
btnInfrared = Controls.AddButton("Infrared", 10, 40)
btnDepth = Controls.AddButton("Depth", 10, 70)
btnBodyIndex = Controls.AddButton("BodyIndex", 10, 100)
btnBody = Controls.AddButton("Body", 10, 130)
txtSize = Shapes.AddText("")
Shapes.Move(txtSize, 10, 160)
txtBody = Shapes.AddText("")
Shapes.Move(txtBody, 10, 190)
Controls.ButtonClicked = OnButtonClicked
While "True"
If sensor <> lastSensor Then
KinectWindow.Show(sensor)
size = KinectWindow.SensorSize
Shapes.SetText(txtSize, size)
KinectWindow.Title = "Small Basic Kinect Window - " + sensor
lastSensor = sensor
Else
Program.Delay(200)
EndIf
EndWhile
Sub OnButtonClicked
lastSensor = sensor
If Controls.LastClickedButton = btnColor Then
sensor = "Color"
ElseIf Controls.LastClickedButton = btnInfrared Then
sensor = "Infrared"
ElseIf Controls.LastClickedButton = btnDepth Then
sensor = "Depth"
ElseIf Controls.LastClickedButton = btnBodyIndex Then
sensor = "BodyIndex"
ElseIf Controls.LastClickedButton = btnBody Then
sensor = "Body"
EndIf
EndSub