version but can find the source..hehe...disk craches etc.. ;-)
Code: Select all
;------------------------------------------------------------------------------------------------
;; version 1.0 PB linux Beta 4
;; UDP wall, displays all info from UDP port 8080 on an Image-Wall
;; to create more output then forward all your udp ports to 8080 ;-)
;;------------------------------------------------------------------------------------------------
;;------------------------------------------------------------------------------------------------
;;globals
;;------------------------------------------------------------------------------------------------
Global port = 8080
Global T.s
Global C.s
Global true = 1
Global false = 0
;;------------------------------------------------------------------------------------------------
;; console init
;;------------------------------------------------------------------------------------------------
OpenConsole()
;;------------------------------------------------------------------------------------------------
;; check desktop
;;------------------------------------------------------------------------------------------------
If ExamineDesktops()
Global dw = DesktopWidth(0)
Global dh = DesktopHeight(0)
Global dd = DesktopDepth(0)
Global df = DesktopFrequency(0)
Global dn.s = DesktopName(0)
EndIf
;;------------------------------------------------------------------------------------------------
;; create image of dw - 10 x400
;;------------------------------------------------------------------------------------------------
;;------------------------------------------------------------------------------------------------
;;check network
;;------------------------------------------------------------------------------------------------
PrintN("udpGUI: Running")
If InitNetwork() = 0 : PrintN("No network available!") : End : EndIf
If CreateNetworkServer(0,port,#PB_Network_UDP) = 0 : PrintN("Cant bind to "+Str(port)+" !") : End : EndIf
;;------------------------------------------------------------------------------------------------
;;create update image
;;------------------------------------------------------------------------------------------------
Procedure _pixel(x.w, y.w)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(Random(255),Random(255),Random(255)))
FrontColor(RGB(Random(255),Random(255),Random(255)))
Plot(x,y)
StopDrawing()
SetGadgetState(0, ImageID(0))
EndProcedure
Procedure _square(x.w, y.w, w.w, h.w)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(Random(255),Random(255),Random(255)))
FrontColor(RGB(Random(255),Random(255),Random(255)))
Box(x,y,w,h)
StopDrawing()
SetGadgetState(0, ImageID(0))
EndProcedure
Procedure _circle(x.w, y.w, r.w)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(Random(255),Random(255),Random(255)))
FrontColor(RGB(Random(255),Random(255),Random(255)))
Circle(x,y,r)
StopDrawing()
SetGadgetState(0, ImageID(0))
EndProcedure
Procedure _text(x.w, y.w, t.s)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(Random(255),Random(255),Random(255)))
FrontColor(RGB(Random(255),Random(255),Random(255)))
DrawText(x,y,t)
StopDrawing()
SetGadgetState(0, ImageID(0))
EndProcedure
;;------------------------------------------------------------------------------------------------
;;network UDP thread
;;------------------------------------------------------------------------------------------------
Procedure listener()
Repeat
Delay(1)
server_event = NetworkServerEvent()
If server_event
client = EventClient()
Select server_event
Case #PB_NetworkEvent_Data
*buffer = AllocateMemory(65)
If ReceiveNetworkData(client, *buffer, 64)
T = PeekS(*buffer)
T = LTrim(T)
T = RTrim(T)
T = LCase(T)
EndIf
FreeMemory(*buffer)
C= IPString(GetClientIP(client)) + ":" + Str(GetClientPort(client))
CloseNetworkConnection(client)
EndSelect
EndIf
Until quit = 1
EndProcedure
udpT = CreateThread(@listener(), 1)
If udpT = 0 : PrintN("Error creating thread!") : End : EndIf
;;------------------------------------------------------------------------------------------------
;; main window
;;------------------------------------------------------------------------------------------------
If OpenWindow(0, 0, 0, 0, 0, "udpGUIl", #PB_Window_Invisible |#PB_Window_MinimizeGadget| #PB_Window_MaximizeGadget|#PB_Window_Maximize )
CreateGadgetList(WindowID(0))
Repeat
;Delay(1)
EventID = WaitWindowEvent(100)
;; init a new window hide it create an image on it
If StringField(T, 1, " ") = "init" And init = false
ResizeWindow(0,Val(StringField(T, 2, " ")), Val(StringField(T, 3, " ")),Val(StringField(T, 4, " ")),Val(StringField(T, 5, " ")))
HideWindow(0, 0)
SetWindowTitle(0,StringField(T, 6, " "))
ImageGadget(0, 0, 0, Val(StringField(T, 4, " ")),Val(StringField(T, 5, " ")) , ImageID(0))
CreateImage(0, Val(StringField(T, 4, " ")),Val(StringField(T, 5, " ")) , #PB_Image_DisplayFormat )
init = true;
ElseIf init = true
;; pixel x y
If StringField(T, 1, " ") = "pixel"
_pixel(Val(StringField(T, 2, " ")), Val(StringField(T, 3, " ")))
;; box x y w h
ElseIf StringField(T, 1, " ") = "square"
_square(Val(StringField(T, 2, " ")), Val(StringField(T, 3, " ")),Val(StringField(T, 4, " ")),Val(StringField(T, 5, " ")))
;; circle x y r
ElseIf StringField(T, 1, " ") = "circle"
_circle(Val(StringField(T, 2, " ")), Val(StringField(T, 3, " ")),Val(StringField(T, 4, " ")))
;; text x y text
ElseIf StringField(T, 1, " ") = "text"
_text(Val(StringField(T, 2, " ")), Val(StringField(T, 3, " ")), LTrim(RemoveString(T,Left(T,FindString(T,StringField(T, 4, " "),1) - 1 ))))
;; hides the window
ElseIf StringField(T, 1, " ") = "hide"
HideWindow(0, 1)
;; shows the window
ElseIf StringField(T, 1, " ") = "show"
HideWindow(0, 0)
;; make window sticky on top of all
ElseIf StringField(T, 1, " ") = "wett"
StickyWindow(0, 1)
;; make window dray, normal behavior
ElseIf StringField(T, 1, " ") = "dry"
StickyWindow(0, 0)
ElseIf StringField(T, 1, " ") = "clean"
w = ImageWidth(0)
h = ImageHeight(0)
FreeImage(0)
CreateImage(0, w, h , #PB_Image_DisplayFormat )
;; close all
ElseIf StringField(T, 1, " ") = "close"
quit = true
EndIf
EndIf
T = ""
Until EventID = #PB_Event_CloseWindow Or quit = true
EndIf
KillThread(udpT)
CloseNetworkServer(0)
CloseConsole()
End