''set the Drwaing Area Starting Xval,Yval and width and Height
drawXval=20
drawYval=140
drawWidth=GraphicsWindow.Width-60
drawHeight=GraphicsWindow.Height-200
'' Draw the Draw Area inside this area we will draw
GraphicsWindow.DrawRectangle(drawXval, drawYval, drawWidth, drawHeight)
'' Check for the button clieked event and perform the action
Sub ButtonEvents
buttonText = Controls.GetButtonCaption(Controls.LastClickedButton)
If buttonText = "ClearALL" Then
' Clear the draw Area for redraw
drawType=1
GraphicsWindow.BrushColor="white"
GraphicsWindow.FillRectangle(drawXval, drawYval, drawWidth, drawHeight)
ElseIf buttonText = "Free PEN Draw" Then
' Draw the Free Pen
drawType=2
ElseIf buttonText = "Image" Then
' Add Image in draw area
drawType=3
ElseIf buttonText = "Rectangle" Then
' Draw Rectangle in draw area
drawType=4
ElseIf buttonText = "FillRectangle" Then
' Fill Rectangle in draw area
drawType=5
ElseIf buttonText = "Circle" Then
' Draw Circle in draw area
drawType=6
ElseIf buttonText = "Fill Circle" Then
' Draw Circle in draw area
drawType=7
EndIf
EndSub
'Mouse Click Events
'here we check for draw type and if the dray type is
GraphicsWindow.MouseDown = MouseClick
Sub MouseClick
OrgX = GraphicsWindow.MouseX
OrgY = GraphicsWindow.MouseY
' If the Drawtype is 3 then its for Image Add
If drawType=3 Then
if OrgX >drawXval And OrgX
if OrgY >drawYval And OrgY
image2 = "C:\ShanuICON.jpg"
EndIf
EndIf
'-- end Draw Image
' to Draw Rectangle
ElseIf drawType=4 Then
if OrgX >drawXval And OrgX
if OrgY >drawYval And OrgY
GraphicsWindow.DrawRectangle(OrgX, OrgY, 60, 60)
EndIf
EndIf
' to Fill Rectangle
ElseIf drawType=5 Then
if OrgX >drawXval And OrgX
if OrgY >drawYval And OrgY
GraphicsWindow.FillRectangle(OrgX, OrgY, 60, 60)
EndIf
EndIf
' to Draw Circle
ElseIf drawType=6 Then
if OrgX >drawXval And OrgX
if OrgY >drawYval And OrgY
GraphicsWindow.DrawEllipse(OrgX, OrgY, 60, 60)
EndIf
EndIf
' to Fill Circle
ElseIf drawType=7 Then
if OrgX >drawXval And OrgX
if OrgY >drawYval And OrgY
GraphicsWindow.FillEllipse(OrgX, OrgY, 60, 60)
EndIf
EndIf
EndIf
EndSub
'Mouse Move event is used to draw the free pen
GraphicsWindow.MouseMove = MouseDrag
Sub MouseDrag
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
'If the drawtype is 2 then for Free Pen draw here we will draw the colors with random
If drawType=2 Then
If (Mouse.IsLeftButtonDown) then
if x >drawXval And x
if y >drawYval And y
GraphicsWindow.FillEllipse(x, y, 6, 6)
EndIf
EndIf
Endif
EndIf
'-- fre pen
EndSub
'' used for free pen for fill random colors
GraphicsWindow.MouseUp = MouseUp
Sub MouseUp
GraphicsWindow.BrushColor=GraphicsWindow.GetRandomColor()