Microsoft Small Basic

Program Listing: VLB465
' Known Issue 21691 - Rectangle and Ellipse Become Smaller in Remote
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.1 2013-12-07 Minor changed. ()
' 0.1 2013-12-07 Created. (FHV760-6)
'
SB_Workaround()
gw = 700
gh = 400
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.Title = "Known Issue 21691 - Rectangle and Ellipse Become Smaller in Remote"
InitWorkaround()
While "True"
DrawGrid()
DrawRectangle()
DrawEllipse()
WaitStatusChange()
EndWhile
Sub DrawRectangle
GraphicsWindow.PenColor = "Lime"
x = 400
y = 100
width = 200
height = 200
pw = 40
If silverlight Then
Program.Delay(msWait)
EndIf
GraphicsWindow.PenWidth = pw
If silverlight And workaround Then
GraphicsWindow.DrawRectangle(x - pw / 2, y - pw / 2, width + pw, height + pw)
Else
GraphicsWindow.DrawRectangle(x, y, width, height)
EndIf
EndSub
Sub DrawEllipse
GraphicsWindow.PenColor = "Cyan"
x = 100
y = 100
width = 200
height = 200
pw = 40
If silverlight Then
Program.Delay(msWait)
EndIf
GraphicsWindow.PenWidth = pw
If silverlight And workaround Then
GraphicsWindow.DrawEllipse(x - pw / 2, y - pw / 2, width + pw, height + pw)
Else
GraphicsWindow.DrawEllipse(x, y, width, height)
EndIf
EndSub
Sub WaitStatusChange
param["checkBoxName"] = cbox
While lastWorkaround = workaround
IsChecked()
workaround = return
Program.Delay(200)
EndWhile
lastWorkaround = workaround
EndSub
Sub DrawGrid
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(0, 0, gw, gh)
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.PenWidth = 2
For x = 100 To gw Step 100
GraphicsWindow.DrawLine(x, 0, x, gh)
EndFor
For y = 100 To gh Step 100
GraphicsWindow.DrawLine(0, y, gw, y)
EndFor
EndSub
Sub InitWorkaround
workaround = "False"
lastWorkaround = "False"
GraphicsWindow.BrushColor = "Black"
param = "caption=Workaround;left=30;top=40;"
AddCheckBox()
cbox = return
GraphicsWindow.MouseDown = OnMouseDown
EndSub
Sub AddCheckBox
' param["left"] - the x co-ordinate of the check box
' param["top"] - the y co-ordinate of the check box
' returns return - the check box that was just added to the Graphics Window.
cboxColor = GraphicsWindow.BrushColor
cboxSize = GraphicsWindow.FontSize
cboxFont = GraphicsWindow.FontName
cboxPW = GraphicsWindow.PenWidth
cboxPC = GraphicsWindow.PenColor
cboxNum = cboxNum + 1
cboxX0 = param["left"]
cboxX1 = cboxX0 + cboxSize + 1
cboxY0 = param["top"] + 1
cboxY1 = cboxY0 + cboxSize + 1
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.BrushColor = "White"
cboxRect = Shapes.AddRectangle(cboxSize, cboxSize)
GraphicsWindow.PenWidth = cboxPW
GraphicsWindow.PenColor = cboxPC
Shapes.Move(cboxRect, cboxX0, cboxY0)
cboxObj[cboxNum]["x0"] = cboxX0
cboxObj[cboxNum]["x1"] = cboxX1
cboxObj[cboxNum]["y0"] = cboxY0
cboxObj[cboxNum]["y1"] = cboxY1
GraphicsWindow.BrushColor = cboxColor
GraphicsWindow.FontName = "Wingdings 2"
cboxMark = Shapes.AddText("P")
Shapes.Move(cboxMark, param["left"] + 1, param["top"] + 3)
Shapes.HideShape(cboxMark)
cboxObj[cboxNum]["checkmark"] = cboxMark
cboxObj[cboxNum]["checked"] = "False"
GraphicsWindow.FontName = cboxFont
cboxMark = Shapes.AddText(param["caption"])
Shapes.Move(cboxMark, param["left"] + cboxSize * 1.5 , param["top"])
return = "CheckBox" + cboxNum
EndSub
Sub OnMouseDown
mx = GraphicsWindow.MouseX
my = GraphicsWindow.MouseY
For iCheckBox = 1 To cboxNum
x0 = cboxObj[iCheckBox]["x0"]
x1 = cboxObj[iCheckBox]["x1"]
y0 = cboxObj[iCheckBox]["y0"]
y1 = cboxObj[iCheckBox]["y1"]
If x0 <= mx And mx <= x1 And y0 <= my And my <= y1 Then
If cboxObj[iCheckBox]["checked"] Then
Shapes.HideShape(cboxObj[iCheckBox]["checkmark"])
cboxObj[iCheckBox]["checked"] = "false"
Else
Shapes.ShowShape(cboxObj[iCheckBox]["checkmark"])
cboxObj[iCheckBox]["checked"] = "true"
EndIf
EndIf
EndFor
EndSub
Sub IsChecked
' param["checkBoxName"] - check box name
' return - "True" if checked
iCheckBox = Text.GetSubTextToEnd(param["checkBoxName"], 9)
return = cboxObj[iCheckBox]["checked"]
EndSub
Sub SB_Workaround
' Small Basic | Workaround for Silverlight
' returns silverlight - "True" if in remote
color = GraphicsWindow.GetPixel(0, 0)
If Text.GetLength(color) > 7 Then
silverlight = "True"
msWait = 300
Else
silverlight = "False"
EndIf
EndSub