Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. #DEFINE TSNE_SleepLock
    
  2. #INCLUDE Once "TSNE_V3.bi"
    
  3. 
    
  4. 
    
  5. 
    
  6. '##############################################################################################################
    
  7. Dim Shared G_Client As Uinteger
    
  8. Dim Shared G_ClientID As Uinteger
    
  9. Dim Shared G_ClientData As String
    
  10. Dim Shared G_DrawImg As Any Ptr
    
  11. Dim Shared G_Mutex As Any Ptr
    
  12. Dim Shared G_Width As Integer = 1024
    
  13. Dim Shared G_Height As Integer = 768
    
  14. 
    
  15. 
    
  16. 
    
  17. '##############################################################################################################
    
  18. Dim Shared G_ClientX(100) As Integer
    
  19. Dim Shared G_ClientY(100) As Integer
    
  20. 
    
  21. 
    
  22. 
    
  23. '##############################################################################################################
    
  24. Sub TSNE_Disconnected(Byval V_TSNEID As Uinteger)
    
  25. End Sub
    
  26. 
    
  27. 
    
  28. 
    
  29. '##############################################################################################################
    
  30. Sub TSNE_Connected(Byval V_TSNEID As Uinteger)
    
  31. End Sub
    
  32. 
    
  33. 
    
  34. 
    
  35. '##############################################################################################################
    
  36. Sub TSNE_NewData(Byval V_TSNEID As Uinteger, Byref V_Data As String)
    
  37. Mutexlock(G_Mutex)
    
  38. G_ClientData += V_Data
    
  39. Mutexunlock(G_Mutex)
    
  40. End Sub
    
  41. 
    
  42. 
    
  43. 
    
  44. '##############################################################################################################
    
  45. Sub TSNE_Read()
    
  46. Dim TCL As Ubyte
    
  47. Dim TX1 As Integer
    
  48. Dim TY1 As Integer
    
  49. Dim TX2 As Integer
    
  50. Dim TY2 As Integer
    
  51. Dim TW As Ubyte
    
  52. Dim TCol As Uinteger
    
  53. Do
    
  54.     TCL = 1
    
  55.     If Len(G_ClientData) < TCL Then Exit Sub
    
  56.     Select Case G_ClientData[0]
    
  57.         Case 1 'Draw Dot (x, y, w, col)
    
  58.             TCL += 8
    
  59.             If Len(G_ClientData) < TCL Then Exit Sub
    
  60.             TX1 = (G_ClientData[1] Shl 8) Or G_ClientData[2]
    
  61.             TY1 = (G_ClientData[3] Shl 8) Or G_ClientData[4]
    
  62.             TW = G_ClientData[5]
    
  63.             TCol = (G_ClientData[6] Shl 16) Or (G_ClientData[7] Shl 8) Or G_ClientData[8]
    
  64.             Circle G_DrawImg, (TX1, TY1), TW, TCol, , , , F
    
  65.             
    
  66.         Case 2 'Draw Line (x, y, x, y, w, col)
    
  67.             TCL += 12
    
  68.             If Len(G_ClientData) < TCL Then Exit Sub
    
  69.             TX1 = (G_ClientData[1] Shl 8) Or G_ClientData[2]
    
  70.             TY1 = (G_ClientData[3] Shl 8) Or G_ClientData[4]
    
  71.             TX2 = (G_ClientData[5] Shl 8) Or G_ClientData[6]
    
  72.             TY2 = (G_ClientData[7] Shl 8) Or G_ClientData[8]
    
  73.             TW = G_ClientData[9]
    
  74.             TCol = (G_ClientData[10] Shl 16) Or (G_ClientData[11] Shl 8) Or G_ClientData[12]
    
  75.             For X As Double = 0 To 360 Step 0.5
    
  76.                 Line G_DrawImg, (TX1 + TW * Sin(X * 3.14 / 180), TY1 + TW * Cos(X * 3.14 / 180))-(TX2 + TW * Sin(X * 3.14 / 180), TY2 + TW * Cos(X * 3.14 / 180)), TCol
    
  77.             Next
    
  78.             
    
  79.         Case 3 'Draw Rect (x, y, x, y, col)
    
  80.             TCL += 11
    
  81.             If Len(G_ClientData) < TCL Then Exit Sub
    
  82.             TX1 = (G_ClientData[1] Shl 8) Or G_ClientData[2]
    
  83.             TY1 = (G_ClientData[3] Shl 8) Or G_ClientData[4]
    
  84.             TX2 = (G_ClientData[5] Shl 8) Or G_ClientData[6]
    
  85.             TY2 = (G_ClientData[7] Shl 8) Or G_ClientData[8]
    
  86.             TCol = (G_ClientData[9] Shl 16) Or (G_ClientData[10] Shl 8) Or G_ClientData[11]
    
  87.             Line G_DrawImg, (TX1, TY1)-(TX2, TY2), TCol, BF
    
  88.             
    
  89.         Case 230
    
  90.             TCL += 1
    
  91.             If Len(G_ClientData) < TCL Then Exit Sub
    
  92.             G_ClientID = G_ClientData[1]
    
  93.             
    
  94.         Case 240 'Mouse-Pos
    
  95.             TCL += 5
    
  96.             If Len(G_ClientData) < TCL Then Exit Sub
    
  97.             G_ClientX(G_ClientData[1]) = (G_ClientData[2] Shl 8) Or G_ClientData[3]
    
  98.             G_ClientY(G_ClientData[1]) = (G_ClientData[4] Shl 8) Or G_ClientData[5]
    
  99.             
    
  100.         Case 250 'CLS
    
  101.             Line G_DrawImg, (0, 0)-(G_Width, G_Height), &H00444444, BF
    
  102.             
    
  103.         Case Else: G_ClientData = "": Exit Sub 'TSNE_Disconnect(V_TSNEID): 
    
  104.     End Select
    
  105.     G_ClientData = Mid(G_ClientData, TCL + 1)
    
  106. Loop
    
  107. End Sub
    
  108. 
    
  109. 
    
  110. 
    
  111. '##############################################################################################################
    
  112. G_Mutex = Mutexcreate()
    
  113. Screenres G_Width, G_Height, 32
    
  114. Windowtitle "DrawPad Client --- By.: ThePuppetMaster"
    
  115. G_DrawImg = Imagecreate(G_Width, G_Height, 32)
    
  116. Dim RV As Integer
    
  117. Print "[Connecting]"
    
  118. RV = TSNE_Create_Client(G_Client, "deltalabs.de", 5645, @TSNE_Disconnected, @TSNE_Connected, @TSNE_NewData, 60)
    
  119. If RV <> TSNE_Const_NoError Then
    
  120.     Print "[FEHLER] " & TSNE_GetGURUCode(RV)
    
  121.     Sleep
    
  122.     End -1
    
  123. End If
    
  124. Dim TMR As Integer
    
  125. Dim TMX As Integer
    
  126. Dim TMY As Integer
    
  127. Dim TMZ As Integer
    
  128. Dim TMB As Integer
    
  129. Dim TMXL As Integer
    
  130. Dim TMYL As Integer
    
  131. Dim TMZL As Integer
    
  132. Dim TMBL As Integer
    
  133. Dim TTX As String
    
  134. Dim TColor As Uinteger = &H00FFFFFF
    
  135. Dim TMode As Integer
    
  136. Dim TWidth As Double = 5
    
  137. Dim TLineX As Integer
    
  138. Dim TLineY As Integer
    
  139. Dim T As String
    
  140. Dim TC1 As Uinteger
    
  141. Dim TC2 As Uinteger
    
  142. Dim TMSel As Integer
    
  143. Dim TMenu As Ubyte
    
  144. Mutexlock(G_Mutex)
    
  145. Line G_DrawImg, (0, 0)-(G_Width, G_Height), &H00444444, BF
    
  146. Mutexunlock(G_Mutex)
    
  147. TMode = 1
    
  148. TMSel = TMode
    
  149. Do
    
  150.     Mutexlock(G_Mutex)
    
  151.     If Inkey() = Chr(27) Then Mutexunlock(G_Mutex): Exit Do
    
  152.     TMR = Getmouse(TMX, TMY, TMZ, TMB)
    
  153.     If TMR = 0 Then
    
  154.         Setmouse , , 0
    
  155.         If TMB = 0 Then
    
  156.             If TMY <= 30 Then
    
  157.                 If TMenu <> 1 Then TMenu = 1: TMBL = 0
    
  158.             Else: If TMenu <> 0 Then TMenu = 0: TMBL = 0
    
  159.             End If
    
  160.         End If
    
  161.         If (TMX <> TMXL) Or (TMY <> TMYL) Then TTX += Chr(240, G_ClientID, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255)
    
  162.         If TMenu = 0 Then
    
  163.             If TMB = 0 Then
    
  164.                 If TMZ > TMZL Then
    
  165.                     TWidth += TWidth / 4
    
  166.                 Elseif TMZ < TMZL Then
    
  167.                     TWidth -= (TWidth / 8)
    
  168.                 End If
    
  169.             Elseif TMB = 2 Then
    
  170.                 If TMZ > TMZL Then
    
  171.                     TMode -= 1
    
  172.                 Elseif TMZ < TMZL Then
    
  173.                     TMode += 1
    
  174.                 End If
    
  175.             End If
    
  176.             If TWidth < 2 Then TWidth = 2
    
  177.             If TWidth > 400 Then TWidth = 400
    
  178.             If TMode < 1 Then TMode = 4
    
  179.             If TMode > 4 Then TMode = 1
    
  180.             If (TMB = 1) And (TMBL = 0) Then 'down
    
  181.                 TLineX = TMX
    
  182.                 TLineY = TMY
    
  183.                 
    
  184.             Elseif (TMB = 0) And (TMBL = 1) Then 'up
    
  185.                 Select Case TMode
    
  186.                     Case 1
    
  187.                         Circle G_DrawImg, (TMX, TMY), TWidth, TColor, , , , F
    
  188.                         TTX += Chr(1, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, TWidth, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  189.                         
    
  190.                     Case 2
    
  191.                         For X As Double = 0 To 360 Step 0.5
    
  192.                             Line G_DrawImg, (TLineX + TWidth * Sin(X * 3.14 / 180), TLineY + TWidth * Cos(X * 3.14 / 180))-(TMX + TWidth * Sin(X * 3.14 / 180), TMY + TWidth * Cos(X * 3.14 / 180)), TColor
    
  193.                         Next
    
  194.                         TTX += Chr(2, (TLineX Shr 8) And 255, TLineX And 255, (TLineY Shr 8) And 255, TLineY And 255, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, TWidth, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  195.                         
    
  196.                     Case 3
    
  197.                         For X As Double = 0 To 360 Step 0.5
    
  198.                             Line G_DrawImg, (TLineX + TWidth * Sin(X * 3.14 / 180), TLineY + TWidth * Cos(X * 3.14 / 180))-(TMX + TWidth * Sin(X * 3.14 / 180), TMY + TWidth * Cos(X * 3.14 / 180)), TColor
    
  199.                         Next
    
  200.                         TTX += Chr(2, (TLineX Shr 8) And 255, TLineX And 255, (TLineY Shr 8) And 255, TLineY And 255, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, TWidth, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  201.                         
    
  202.                     Case 4
    
  203.                         Line G_DrawImg, (TLineX, TLineY)-(TMX, TMY), TColor, BF
    
  204.                         TTX += Chr(3, (TLineX Shr 8) And 255, TLineX And 255, (TLineY Shr 8) And 255, TLineY And 255, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  205.                         
    
  206.                 End Select
    
  207.                 
    
  208.             Elseif (TMB = 1) And (TMBL = 1) Then 'down + move
    
  209.                 If (TMX <> TMXL) Or (TMY <> TMYL) Then
    
  210.                     Select Case TMode
    
  211.                         Case 1
    
  212.                             Circle G_DrawImg, (TMX, TMY), TWidth, TColor, , , , F
    
  213.                             TTX += Chr(1, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, TWidth, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  214.                             
    
  215.                         Case 3
    
  216.                             For X As Double = 0 To 360 Step 0.5
    
  217.                                 Line G_DrawImg, (TLineX + TWidth * Sin(X * 3.14 / 180), TLineY + TWidth * Cos(X * 3.14 / 180))-(TMX + TWidth * Sin(X * 3.14 / 180), TMY + TWidth * Cos(X * 3.14 / 180)), TColor
    
  218.                             Next
    
  219.                             TTX += Chr(2, (TLineX Shr 8) And 255, TLineX And 255, (TLineY Shr 8) And 255, TLineY And 255, (TMX Shr 8) And 255, TMX And 255, (TMY Shr 8) And 255, TMY And 255, TWidth, (TColor Shr 16) And 255, (TColor Shr 8) And 255, TColor And 255)
    
  220.                             TLineX = TMX
    
  221.                             TLineY = TMY
    
  222.                             
    
  223.                     End Select
    
  224.                 End If
    
  225.             End If
    
  226.             TMSel = 6
    
  227.         Else
    
  228.             TC1 = Int(TMX / 60)
    
  229.             If (TC1 >= 0) And (TC1 <= 4) Then
    
  230.                 TMSel = TC1
    
  231.                 If TC1 = 0 Then
    
  232.                     If TMB = 3 Then
    
  233.                         Line G_DrawImg, (0, 0)-(G_Width, G_Height), &H00444444, BF
    
  234.                         TTX += Chr(250)
    
  235.                     End If
    
  236.                 Else: If TMB = 1 Then TMode = TC1
    
  237.                 End If
    
  238.             Else
    
  239.                 TMSel = 5
    
  240.                 If TMB = 1 Then
    
  241.                     TC1 = Int((TMX - (5 * 60)) / 28)
    
  242.                     If (TC1 >= 0) And (TC1 <= 8) Then
    
  243.                         Select Case TC1
    
  244.                             Case 0: TColor = &H00FFFFFF
    
  245.                             Case 1: TColor = &H00FF0000
    
  246.                             Case 2: TColor = &H0000FF00
    
  247.                             Case 3: TColor = &H000000FF
    
  248.                             Case 4: TColor = &H00FFFF00
    
  249.                             Case 5: TColor = &H0000FFFF
    
  250.                             Case 6: TColor = &H00FF00FF
    
  251.                             Case 7: TColor = &H00888888
    
  252.                             Case 8: TColor = &H00444444
    
  253.                         End Select
    
  254.                     End If
    
  255.                 End If
    
  256.             End If
    
  257.         End If
    
  258.         TMXL = TMX
    
  259.         TMYL = TMY
    
  260.         TMZL = TMZ
    
  261.         TMBL = TMB
    
  262.     Else: Setmouse , , 1
    
  263.     End If
    
  264.     Screenlock()
    
  265.     Cls()
    
  266.     Put (0, 0), G_DrawImg, Pset
    
  267.     If TMenu = 0 Then
    
  268.         If TMR = 0 Then
    
  269.             Select Case TMode
    
  270.                 Case 1
    
  271.                     Circle (TMX, TMY), TWidth + 1, &H00000000
    
  272.                     Circle (TMX, TMY), TWidth - 1, &H00000000
    
  273.                     Circle (TMX, TMY), TWidth, TColor
    
  274.                 Case 2, 3
    
  275.                     If TMB = 0 Then
    
  276.                         Circle (TMX, TMY), TWidth + 1, &H00000000
    
  277.                         Circle (TMX, TMY), TWidth - 1, &H00000000
    
  278.                         Circle (TMX, TMY), TWidth, TColor
    
  279.                     Else
    
  280.                         For X As Double = 0 To 360 Step 0.5
    
  281.                             Line (TLineX + TWidth * Sin(X * 3.14 / 180), TLineY + TWidth * Cos(X * 3.14 / 180))-(TMX + TWidth * Sin(X * 3.14 / 180), TMY + TWidth * Cos(X * 3.14 / 180)), TColor
    
  282.                         Next
    
  283.                     End If
    
  284.                 Case 4
    
  285.                     If TMB = 1 Then Line (TLineX, TLineY)-(TMX, TMY), TColor, BF
    
  286.             End Select
    
  287.         End If
    
  288.     End If
    
  289.     Line (0, 0)-(G_Width, 30), &H00222222, BF
    
  290.     For X As Uinteger = 0 To 4
    
  291.         If X = TMode Then
    
  292.             Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H0055DD66, BF
    
  293.             Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H0066FF99, B
    
  294.         Else
    
  295.             If X > 0 Then
    
  296.                 Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H006699FF, BF
    
  297.                 Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H005577EE, B
    
  298.             Else
    
  299.                 Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H00FF9966, BF
    
  300.                 Line (2 + (X * 60), 2)-(((X + 1) * 60), 28), &H00EE7755, B
    
  301.             End If
    
  302.         End If
    
  303.         Select Case X
    
  304.             Case 0: T = "CLEAR"
    
  305.             Case 1: T = "DOTs"
    
  306.             Case 2: T = "LINE"
    
  307.             Case 3: T = "Paint"
    
  308.             Case 4: T = "Rect"
    
  309.         End Select
    
  310.         Draw String (10 + (X * 60), 12), T, &H00000000
    
  311.     Next
    
  312.     For X As Uinteger = 0 To 8
    
  313.         Select Case X
    
  314.             Case 0: TC1 = &H00FFFFFF: TC2 = &H00888888
    
  315.             Case 1: TC1 = &H00FF0000: TC2 = &H00880000
    
  316.             Case 2: TC1 = &H0000FF00: TC2 = &H00008800
    
  317.             Case 3: TC1 = &H000000FF: TC2 = &H00000088
    
  318.             Case 4: TC1 = &H00FFFF00: TC2 = &H00888800
    
  319.             Case 5: TC1 = &H0000FFFF: TC2 = &H00008888
    
  320.             Case 6: TC1 = &H00FF00FF: TC2 = &H00880088
    
  321.             Case 7: TC1 = &H00888888: TC2 = &H00444444
    
  322.             Case 8: TC1 = &H00444444: TC2 = &H00888888
    
  323.         End Select
    
  324.         Line (2 + (5 * 60) + (X * 28), 2)-((5 * 60) + ((X + 1) * 28), 28), TC1, BF
    
  325.         Line (2 + (5 * 60) + (X * 28), 2)-((5 * 60) + ((X + 1) * 28), 28), TC2, B
    
  326.         If TColor = TC1 Then
    
  327.             Line (2 + (5 * 60) + (X * 28) + 2, 2 + 2)-((5 * 60) + ((X + 1) * 28) - 2, 28 - 2), &H00000000, B
    
  328.             Line (2 + (5 * 60) + (X * 28) + 3, 2 + 3)-((5 * 60) + ((X + 1) * 28) - 3, 28 - 3), &H00000000, B
    
  329.         End If
    
  330.     Next
    
  331.     For X As Uinteger = 1 To 100
    
  332.         If (G_ClientX(X) > 0) And (G_ClientY(X) > 0) Then
    
  333.             Line (G_ClientX(X) - 9, G_ClientY(X) - 2)-(G_ClientX(X) + 9, G_ClientY(X) + 2), &H00004400, BF
    
  334.             Line (G_ClientX(X) - 2, G_ClientY(X) - 9)-(G_ClientX(X) + 2, G_ClientY(X) + 9), &H00004400, BF
    
  335.             Line (G_ClientX(X) - 8, G_ClientY(X))-(G_ClientX(X) + 8, G_ClientY(X)), &H0000FF00
    
  336.             Line (G_ClientX(X), G_ClientY(X) - 8)-(G_ClientX(X), G_ClientY(X) + 8), &H0000FF00
    
  337.         End If
    
  338.     Next
    
  339.     Select Case TMSel
    
  340.         Case 0: T = "Press L + R mouse button to clear screen"
    
  341.         Case 1: T = "Draw single dots while L mouse down moving"
    
  342.         Case 2: T = "Draw a line between L mouse down and mouse up position"
    
  343.         Case 3: T = "Draw continues lines while moving"
    
  344.         Case 4: T = "Draw a filled recent between L mouse down and up position"
    
  345.         Case 5: T = "Select a color for drawing"
    
  346.         Case 6: T = "Draw here! Mouse wheel change draw width"
    
  347.     End Select
    
  348.     Draw String (565, 12), T, &H00FFFF00
    
  349.     Line (0, 0)-(G_Width, 30), &H00888888, B
    
  350.     Line (TMX - 6, TMY - 1)-(TMX + 6, TMY + 1), &H00000000, BF
    
  351.     Line (TMX - 1, TMY - 6)-(TMX + 1, TMY + 6), &H00000000, BF
    
  352.     Line (TMX - 5, TMY)-(TMX + 5, TMY), &H00FFFFFF
    
  353.     Line (TMX, TMY - 5)-(TMX, TMY + 5), &H00FFFFFF
    
  354.     TSNE_Read()
    
  355.     Screenunlock()
    
  356.     Mutexunlock(G_Mutex)
    
  357.     'MutexLock(TSNE_INT_SleepMutex)
    
  358.     'Sleep 1, 1
    
  359.     'MutexUnLock(TSNE_INT_SleepMutex)
    
  360.     If TTX <> "" Then
    
  361.         TSNE_Data_Send(G_Client, TTX)
    
  362.         TTX = ""
    
  363.     End If
    
  364. Loop
    
  365. Mutexdestroy(G_Mutex)
    
  366. End
    
  367. 
    
  368.