Microsoft Small Basic

Program Listing:
Embed this in your website
' Known Issue 21694 - Font Size or Pen Width Changes Earlier in Remote
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.3 2013-12-08 Bug fixed. (HRK303-1)
' 0.2 2013-12-07 Minor changed. (HRK303-0)
' 0.1 2013-12-07 Created. (HRK303)
'
SB_Workaround()
gw = 700
gh = 400
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.Title = "Known Issue 21694 - Font Size or Pen Width Changes Earlier in Remote"
InitWorkaround()
While "True"
  Clear()
  DrawTexts()
  DrawEllipses()
  DrawGrid()
  WaitStatusChange()
EndWhile
Sub DrawTexts
  GraphicsWindow.BrushColor = "Green"
  x = "1=100;2=300;3=500;"
  y = 100
  fs = "1=40;2=30;3=20;"
  For i = 1 To 3
    If silverlight And workaround Then
      Program.Delay(msWait)
    EndIf
    GraphicsWindow.FontSize = fs[i]
    GraphicsWindow.DrawText(x[i], y, "Hello!")
  EndFor
EndSub
Sub DrawEllipses
  GraphicsWindow.PenColor = "Cyan"
  x = "1=100;2=300;3=500;"
  y = 200
  width = 100
  height = 100
  pw = "1=40;2=30;3=20;"
  For i = 1 To 3
    If silverlight And workaround Then
      Program.Delay(msWait)
    EndIf
    GraphicsWindow.PenWidth = pw[i]
    If silverlight Then
      GraphicsWindow.DrawEllipse(x[i] - pw[i] / 2, y - pw[i] / 2, width + pw[i], height + pw[i])
    Else
      GraphicsWindow.DrawEllipse(x[i], y, width, height)
    EndIf
  EndFor
EndSub
Sub WaitStatusChange
  param["checkBoxName"] = cbox
  While lastWorkaround = workaround
    IsChecked()
    workaround = return
    Program.Delay(200)
  EndWhile
  lastWorkaround = workaround
EndSub
Sub Clear
  GraphicsWindow.BrushColor = "White"
  GraphicsWindow.FillRectangle(0, 0, gw, gh)
EndSub
Sub DrawGrid
  GraphicsWindow.PenColor = "Gray"
  If silverlight Then
    Program.Delay(msWait)
  EndIf
  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
Copyright (c) Microsoft Corporation. All rights reserved.