Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #Region Header
  2. ; #INDEX# =======================================================================================================================
  3. ; Title .........: SLG
  4. ; AutoIt Version : 3.3.4.0
  5. ; Language ......: English
  6. ; Description ...: Functions to assist in creating and updating Scrolling Line Graphs
  7. ; Author(s) .....: Beege
  8. ; ===============================================================================================================================
  9.  
  10. ; #CURRENT# =====================================================================================================================
  11. ;_SLG_CreateGraph
  12. ;_SLG_UpdateGraph
  13. ;_SLG_ClearGraph
  14. ;_SLG_SetLineColor
  15. ;_SLG_SetYRange
  16. ;_SLG_SetBackGroundColor
  17. ;_SLG_AddLine
  18. ;_SLG_SetLineValue
  19. ;_SLG_SetLineWidth
  20. ;_SLG_EnableGridLines
  21. ;_SLG_SetGridLineColor
  22. ; ===============================================================================================================================
  23.  
  24. #Region User KeyWords and CallTips
  25. #cs
  26.  
  27. Keywords:
  28. au3.keywords.user.udfs= _slg_creategraph _slg_updategraph _slg_cleargraph \
  29. _slg_setlinecolor _slg_setyrange _slg_setbackgroundcolor _slg_addline \
  30. _slg_setlinevalue _slg_setlinewidth _slg_enablegridlines _slg_setgridlinecolor
  31.  
  32. CallTips:
  33. _SLG_CreateGraph($hGUI, $iLeft, $iTop, $iWidth, $iHeight, $iY_Min, $iY_Max, $iIncrements, $Line_Color = 0xFF00FF00, $Line_Width = 2, $iBackGround = 0xFF000000, $bGridlines = True)
  34. _SLG_UpdateGraph($iIndex)
  35. _SLG_AddLine($iIndex, $Line_Color = 0xFF00FF00, $Line_Width = 2)
  36. _SLG_ClearGraph($iIndex)
  37. _SLG_SetLineValue($iIndex, $iValue, $iLine = 1)
  38. _SLG_SetLineColor($iIndex, $iARGB, $iLine = 1)
  39. _SLG_SetLineWidth($iIndex, $iWidth, $iLine = 1)
  40. _SLG_SetYRange($iIndex, $iY_Min, $iY_Max)
  41. _SLG_SetBackGroundColor($iIndex, $iARGB = 0xFF000000)
  42. _SLG_SetGridLineColor($iIndex, $iARGB = Default)
  43. _SLG_EnableGridLines($iIndex, $bGridlines = True)
  44. #ce
  45. #EndRegion
  46.  
  47. #include-once
  48. #include <GDIPlus.au3>
  49. #include <WindowsConstants.au3>
  50. _GDIPlus_Startup()
  51. OnAutoItExitRegister('_SLG_Exit')
  52. #EndRegion Header
  53.  
  54. #Region Global Variables and Constants
  55. Global Enum $g_hGraphic, $g_hBitmap, $g_hBuffer, $g_aPens, $g_iLeft, $g_iTop, $g_iWidth, $g_iHeight, $g_iIncrements, _
  56.         $g_iIncrement_Size, $g_iShift_Distance, $g_iY, $g_iY_Last, $g_iY_Min, $g_iY_Max, $g_iY_Range, $g_hDC, $g_hGUI, $g_iBackColor, _
  57.         $g_iX_counter, $g_iY_counter, $g_iX_counter_mem, $g_bGridlines, $g_iGridColor, $MAX
  58. Global $aGraphs[1][$MAX]
  59. $aGraphs[0][0] = 0
  60. #cs
  61.  
  62.     $aGraphs[0][0]          = List Count
  63.     [0][1-17]               = Nothing
  64.  
  65.     $aGraphs[$i][0]         = $Graphic Object Handle
  66.     [$i][$g_hBitmap]        = Bitmap Object Handle
  67.     [$i][$g_hBuffer]        = Buffer Handle
  68.     [$i][$g_iLeft]          = Left
  69.     [$i][$g_iTop]           = Top
  70.     [$i][$g_iWidth]         = Width
  71.     [$i][$g_iHeight]        = Height
  72.     [$i][$g_iIncrements]    = Step Count
  73.     [$i][$g_iIncrement_Size]= Step Size
  74.     [$i][$g_iShift_Distance]= Shift Distance
  75.     [$i][$g_iY_Min]         = Y Min
  76.     [$i][$g_iY_Max]         = Y Max
  77.     [$i][$g_iY_Range]       = Y Range
  78.     [$i][$g_hDC]            = Display device context Handle
  79.     [$i][$g_hGUI]           = GUI Handle
  80.     [$i][$g_iBackColor]     = BackGround Color value
  81.     [$i][$g_iY_Last]        = Array containing Last Y Cordnate for each Line
  82.     [$i][$g_iY]             = Array containing Y Cordnate for each Line
  83.     [$i][$g_aPens]          = Array containing Pen Handles for each Line
  84.     [$i][$g_bGridlines]     = Draw GridLines flag
  85.     [$i][$g_iGridColor]     = GridLines Color Value
  86.     [$i][$g_iX_counter]     = Counter for X GridLines
  87.     [$i][$g_iY_counter]     = Counter for Y GridLines
  88.     [$i][$g_iX_counter_mem] = Original Counter Value
  89.  
  90. #ce
  91. #EndRegion Global Variables and Constants
  92.  
  93. #Region Public Functions
  94. ; #FUNCTION# ====================================================================================================================
  95. ; Name...........: _SLG_CreateGraph
  96. ; Description ...: Creates a Scrolling Line Graph
  97. ; Syntax.........: _SLG_CreateGraph($hGUI, $iLeft, $iTop, $iWidth, $iHeight, $iY_Min, $iY_Max, $iIncrement_Total, $Line_Color = 0xFF00FF00, $iBackGround = 0xFF000000)
  98. ; Parameters ....: $hGUI        - Handle to parent or owner window
  99. ;                  $iLeft       - Left side of the graph
  100. ;                  $iTop        - Top side of the graph
  101. ;                  $iWidth      - Width of the graph
  102. ;                  $iHeight     - Height of the graph
  103. ;                  $iY_Min      - Minimum Y Value
  104. ;                  $iY_Max      - Maximum Y Value
  105. ;                  $iIncrements - How many parts the Graph is divided up into. More Parts means more history..
  106. ;                  $Line_Color  - Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB). Default = Green
  107. ;                  $iLine_Width - Line Width. Default = 1
  108. ;                  $iBackGround - BackGround Color. Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB). Default = Black
  109. ;                  $bGridlines  - Enable Gridlines. Default = True
  110. ; Return values .: Success      - Graph Index
  111. ; Author ........: Beege
  112. ; Remarks .......: Line index of line created is 1.
  113. ; ===============================================================================================================================
  114. Func _SLG_CreateGraph($hGUI, $iLeft, $iTop, $iWidth, $iHeight, $iY_Min, $iY_Max, $iIncrements, $Line_Color = 0xFF00FF00, $iLine_Width = 2, $iBackGround = 0xFF000000, $bGridlines = True)
  115.  
  116.     ReDim $aGraphs[UBound($aGraphs) + 1][UBound($aGraphs, 2)]
  117.     $aGraphs[0][0] += 1
  118.  
  119.     If $Line_Color = -1 Or $Line_Color = Default Then $Line_Color = 0xFF00FF00
  120.     If $iBackGround = -1 Or $iBackGround = Default Then $iBackGround = 0xFF000000
  121.     If $iLine_Width = -1 Or $iLine_Width = Default Then $iLine_Width = 2
  122.     If $bGridlines = -1 Or $bGridlines = Default Then $bGridlines = True
  123.  
  124.     $aGraphs[$aGraphs[0][0]][$g_hGraphic] = _GDIPlus_GraphicsCreateFromHWND($hGUI)
  125.     $aGraphs[$aGraphs[0][0]][$g_hBitmap] = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $aGraphs[$aGraphs[0][0]][$g_hGraphic])
  126.     $aGraphs[$aGraphs[0][0]][$g_hBuffer] = _GDIPlus_ImageGetGraphicsContext($aGraphs[$aGraphs[0][0]][$g_hBitmap])
  127.     $aGraphs[$aGraphs[0][0]][$g_iLeft] = $iLeft
  128.     $aGraphs[$aGraphs[0][0]][$g_iTop] = $iTop
  129.     $aGraphs[$aGraphs[0][0]][$g_iWidth] = $iWidth
  130.     $aGraphs[$aGraphs[0][0]][$g_iHeight] = $iHeight
  131.     $aGraphs[$aGraphs[0][0]][$g_iIncrements] = $iIncrements
  132.     $aGraphs[$aGraphs[0][0]][$g_iIncrement_Size] = Int($iWidth / $iIncrements)
  133.     $aGraphs[$aGraphs[0][0]][$g_iShift_Distance] = $iWidth - $aGraphs[$aGraphs[0][0]][$g_iIncrement_Size]
  134.     _SLG_AddLine($aGraphs[0][0], $Line_Color, $iLine_Width)
  135.     $aGraphs[$aGraphs[0][0]][$g_iY_Min] = $iY_Min
  136.     $aGraphs[$aGraphs[0][0]][$g_iY_Max] = $iY_Max
  137.     _SLG_SetYRange($aGraphs[0][0], $iY_Min, $iY_Max)
  138.     $aGraphs[$aGraphs[0][0]][$g_hDC] = _WinAPI_GetDC($hGUI)
  139.     $aGraphs[$aGraphs[0][0]][$g_hGUI] = $hGUI
  140.     _SLG_SetBackGroundColor($aGraphs[0][0], BitOR($iBackGround, 0xFF000000))
  141.     $aGraphs[$aGraphs[0][0]][$g_bGridlines] = $bGridlines
  142.     $aGraphs[$aGraphs[0][0]][$g_iX_counter] = 20;$iX_c
  143.     $aGraphs[$aGraphs[0][0]][$g_iX_counter_mem] = 20;$iX_c
  144.     $aGraphs[$aGraphs[0][0]][$g_iY_counter] = 20;$iY_c
  145.     $aGraphs[$aGraphs[0][0]][$g_iGridColor] = Default
  146.     _GDIPlus_GraphicsSetSmoothingMode($aGraphs[$aGraphs[0][0]][$g_hBuffer], 2)
  147.  
  148.     _GDIPlus_GraphicsClear($aGraphs[$aGraphs[0][0]][$g_hBuffer], $aGraphs[$aGraphs[0][0]][$g_iBackColor]);
  149.     If $bGridlines Then _FullGridLines($aGraphs[0][0])
  150.     Return $aGraphs[0][0]
  151.  
  152. EndFunc   ;==>_SLG_CreateGraph
  153.  
  154. ; #FUNCTION# ====================================================================================================================
  155. ; Name...........: _SLG_UpdateGraph
  156. ; Description ...: Updates Line Graph with new values
  157. ; Syntax.........: _SLG_UpdateGraph($iIndex, $iValue)
  158. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  159. ; Return values .: Success      - 1
  160. ;                  Failure      - 0  and sets @ERROR:
  161. ;                               - 1 Invalid iIndex
  162. ; Author ........: Beege
  163. ; Remarks .......: All Lines of the graph must be updated before calling this function.
  164. ; ===============================================================================================================================
  165. Func _SLG_UpdateGraph($iIndex)
  166.  
  167.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  168.  
  169.     Local $aLineY = $aGraphs[$iIndex][$g_iY]
  170.  
  171.     For $i = 1 To $aLineY[0]
  172.         If Not $aLineY[$i] Then Return
  173.     Next
  174.  
  175.     Local $hShift_Section = _GDIPlus_BitmapCloneArea($aGraphs[$iIndex][$g_hBitmap], $aGraphs[$iIndex][$g_iIncrement_Size], 0, $aGraphs[$iIndex][$g_iShift_Distance], $aGraphs[$iIndex][$g_iHeight]);
  176.     _GDIPlus_GraphicsClear($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iBackColor]);
  177.     _GDIPlus_GraphicsDrawImageRect($aGraphs[$iIndex][$g_hBuffer], $hShift_Section, 0, 0, $aGraphs[$iIndex][$g_iShift_Distance], $aGraphs[$iIndex][$g_iHeight])
  178.  
  179.     If $aGraphs[$iIndex][$g_bGridlines] Then _AddGridLines($iIndex)
  180.  
  181.     Local $aLineYLast = $aGraphs[$iIndex][$g_iY_Last]
  182.     Local $aPens = $aGraphs[$iIndex][$g_aPens]
  183.  
  184.     For $i = 1 To $aLineYLast[0]
  185.         _GDIPlus_GraphicsDrawLine($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iShift_Distance] - 1, $aLineYLast[$i], $aGraphs[$iIndex][$g_iWidth] - 1, $aLineY[$i], $aPens[$i])
  186.     Next
  187.     _WriteBuffer($iIndex)
  188.  
  189.     _GDIPlus_BitmapDispose($hShift_Section)
  190.     For $i = 1 To $aLineY[0]
  191.         $aLineYLast[$i] = $aLineY[$i]
  192.     Next
  193.     $aGraphs[$iIndex][$g_iY_Last] = $aLineYLast
  194.  
  195.     Return 1
  196.  
  197. EndFunc   ;==>_SLG_UpdateGraph
  198.  
  199. ; #FUNCTION# ====================================================================================================================
  200. ; Name...........: _SLG_SetLineValue
  201. ; Description ...: Sets Line value
  202. ; Syntax.........: _SLG_SetLineValue($iIndex, $iValue, $iLine = 1)
  203. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  204. ;                  $iValue      - Value to add to graph
  205. ;                  $iLine       - Line index returned from _SLG_AddLine()
  206. ; Return values .: Success      - 1
  207. ;                  Failure      - 0  and sets @ERROR:
  208. ;                               - 1 Invalid iIndex
  209. ; Author ........: Beege
  210. ; Remarks .......: If your graph only has 1 line then the line index is 1
  211. ; ===============================================================================================================================
  212. Func _SLG_SetLineValue($iIndex, $iValue, $iLine = 1)
  213.  
  214.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  215.  
  216.     If $iValue > $aGraphs[$iIndex][$g_iY_Max] Then
  217.         $iValue = $aGraphs[$iIndex][$g_iY_Max]
  218.     ElseIf $iValue < $aGraphs[$iIndex][$g_iY_Min] Then
  219.         $iValue = $aGraphs[$iIndex][$g_iY_Min]
  220.     EndIf
  221.  
  222.     Local $Percent = Abs($iValue - $aGraphs[$iIndex][$g_iY_Min]) / $aGraphs[$iIndex][$g_iY_Range]
  223.     If $Percent > .992 Then $Percent = .992
  224.  
  225.     Local $iY = Int($aGraphs[$iIndex][$g_iHeight] - ($Percent * $aGraphs[$iIndex][$g_iHeight]))
  226.  
  227.     Local $aLineYLast = $aGraphs[$iIndex][$g_iY_Last]
  228.  
  229.     If Not $aLineYLast[$iLine] Then
  230.         $aLineYLast[$iLine] = $iY
  231.         $aGraphs[$iIndex][$g_iY_Last] = $aLineYLast
  232.         Return 0
  233.     Else
  234.         Local $aLineY = $aGraphs[$iIndex][$g_iY]
  235.         $aLineY[$iLine] = $iY
  236.         $aGraphs[$iIndex][$g_iY] = $aLineY
  237.         Return 1
  238.     EndIf
  239.  
  240. EndFunc   ;==>_SLG_SetLineValue
  241.  
  242. ; #FUNCTION# ====================================================================================================================
  243. ; Name...........: _SLG_AddLine
  244. ; Description ...: Adds additional lines to the graph
  245. ; Syntax.........: _SLG_AddLine($iIndex, $Line_Color = 0xFF00FF00, $Line_Width = 1)
  246. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  247. ;                  $iLine_Color - Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB)
  248. ;                  $Line_Width  - Line Width
  249. ; Return values .: Success      - Line Index
  250. ;                  Failure      - 0  and sets @ERROR:
  251. ;                               - 1 Invalid iIndex
  252. ; Author ........: Beege
  253. ; Remarks .......: Every line must have its value set before you can call _SLG_UpdateGraph()
  254. ; ===============================================================================================================================
  255. Func _SLG_AddLine($iIndex, $Line_Color = 0xFF00FF00, $Line_Width = 2)
  256.  
  257.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  258.  
  259.     If $Line_Color = -1 Or $Line_Color = Default Then $Line_Color = 0xFF00FF00
  260.     If $Line_Width = -1 Or $Line_Width = Default Then $Line_Width = 1
  261.  
  262.     Local $aLinesY = $aGraphs[$iIndex][$g_iY]
  263.     Local $aLinesYLast = $aGraphs[$iIndex][$g_iY_Last]
  264.     Local $aPens = $aGraphs[$iIndex][$g_aPens]
  265.  
  266.     If Not IsArray($aLinesYLast) Then
  267.         Local $aLinesY[1] = [0]
  268.         Local $aLinesYLast[1] = [0]
  269.         Local $aPens[1] = [0]
  270.     EndIf
  271.  
  272.     ReDim $aLinesYLast[UBound($aLinesYLast) + 1]
  273.     ReDim $aLinesY[UBound($aLinesY) + 1]
  274.     ReDim $aPens[UBound($aPens) + 1]
  275.  
  276.     $aLinesYLast[0] += 1
  277.     $aLinesY[0] += 1
  278.     $aPens[0] += 1
  279.  
  280.     $aLinesYLast[$aLinesYLast[0]] = False
  281.     $aLinesY[$aLinesY[0]] = False
  282.     $aPens[$aPens[0]] = _GDIPlus_PenCreate($Line_Color, $Line_Width)
  283.  
  284.     $aGraphs[$iIndex][$g_iY_Last] = $aLinesYLast
  285.     $aGraphs[$iIndex][$g_iY] = $aLinesY
  286.     $aGraphs[$iIndex][$g_aPens] = $aPens
  287.  
  288.     Return $aLinesY[0]
  289.  
  290. EndFunc   ;==>_SLG_AddLine
  291.  
  292. ; #FUNCTION# ====================================================================================================================
  293. ; Name...........: _SLG_SetLineColor
  294. ; Description ...: Sets Line Color of Graph
  295. ; Syntax.........: _SLG_SetLineColor($iIndex, $iARGB)
  296. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  297. ;                  $iValue      - Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB)
  298. ;                  $iLine       - Line index returned from _SLG_AddLine()
  299. ; Return values .: Success      - 1
  300. ;                  Failure      - 0  and sets @ERROR:
  301. ;                               - 1 Invalid iIndex
  302. ;                               - 2 Invalid iLine
  303. ;                               - 3 Error setting pen color
  304. ; Author ........: Beege
  305. ; Remarks .......: If your graph only has 1 line then the line index is 1
  306. ; ===============================================================================================================================
  307. Func _SLG_SetLineColor($iIndex, $iARGB, $iLine = 1)
  308.  
  309.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  310.  
  311.     Local $aPens = $aGraphs[$iIndex][$g_aPens]
  312.     If $iLine > $aPens[0] Then Return SetError(2, @extended, 0)
  313.  
  314.     _GDIPlus_PenSetColor($aPens[$iLine], $iARGB)
  315.     If @error Then Return SetError(3, @extended, 0)
  316.  
  317.     Return 1
  318.  
  319. EndFunc   ;==>_SLG_SetLineColor
  320.  
  321. ; #FUNCTION# ====================================================================================================================
  322. ; Name...........: _SLG_SetLineWidth
  323. ; Description ...: Sets Line Width
  324. ; Syntax.........: _SLG_SetLineWidth($iIndex, $iWidth, $iLine = 1)
  325. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  326. ;                  $iValue      - Width of Line
  327. ;                  $iLine       - Line index returned from _SLG_AddLine()
  328. ; Return values .: Success      - 1
  329. ;                  Failure      - 0  and sets @ERROR:
  330. ;                               - 1 Invalid iIndex
  331. ;                               - 2 Invalid iLine index
  332. ;                               - 3 Error setting pen width
  333. ; Author ........: Beege
  334. ; Remarks .......: If your graph only has 1 line then the line index is 1
  335. ; ===============================================================================================================================
  336. Func _SLG_SetLineWidth($iIndex, $iWidth, $iLine = 1)
  337.  
  338.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  339.  
  340.     Local $aPens = $aGraphs[$iIndex][$g_aPens]
  341.     If $iLine > $aPens[0] Then Return SetError(2, @extended, 0)
  342.  
  343.     Local $aPens = $aGraphs[$iIndex][$g_aPens]
  344.     _GDIPlus_PenSetWidth($aPens[$iLine], $iWidth)
  345.     If @error Then Return SetError(3, @extended, 0)
  346.  
  347.     Return 1
  348.  
  349. EndFunc   ;==>_SLG_SetLineWidth
  350.  
  351. ; #FUNCTION# ====================================================================================================================
  352. ; Name...........: _SLG_ClearGraph
  353. ; Description ...: Clears all data from Graph
  354. ; Syntax.........: _SLG_ClearGraph($iIndex)
  355. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  356. ; Return values .: Success      - 1
  357. ;                  Failure      - 0  and sets @ERROR:
  358. ;                               - 1 Invalid iIndex
  359. ; Author ........: Beege
  360. ; Remarks .......: none
  361. ; ===============================================================================================================================
  362. Func _SLG_ClearGraph($iIndex)
  363.  
  364.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  365.  
  366.     _GDIPlus_GraphicsClear($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iBackColor]);
  367.     If $aGraphs[$iIndex][$g_bGridlines] Then _FullGridLines($iIndex)
  368.     _WriteBuffer($iIndex)
  369.  
  370.     Return 1
  371.  
  372. EndFunc   ;==>_SLG_ClearGraph
  373.  
  374. ; #FUNCTION# ====================================================================================================================
  375. ; Name...........: _SLG_SetYRange
  376. ; Description ...: Sets the Minimum and Maximum Y Values
  377. ; Syntax.........: _SLG_SetYRange($iIndex, $iY_Min, $iY_Max)
  378. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  379. ;                  $iY_Min      - Minimum Y Value
  380. ;                  $iY_Max      - Maximum Y Value
  381. ; Return values .: Success      - 1
  382. ;                  Failure      - 0  and sets @ERROR:
  383. ;                               - 1 Invalid iIndex
  384. ; Author ........: Beege
  385. ; Remarks .......: User should most likly want to ClearGraph after changing Y Range
  386. ; ===============================================================================================================================
  387. Func _SLG_SetYRange($iIndex, $iY_Min, $iY_Max)
  388.  
  389.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  390.  
  391.     $aGraphs[$iIndex][$g_iY_Min] = $iY_Min
  392.     $aGraphs[$iIndex][$g_iY_Max] = $iY_Max
  393.     $aGraphs[$iIndex][$g_iY_Range] = Abs($iY_Max - $iY_Min)
  394.  
  395.     Return 1
  396.  
  397. EndFunc   ;==>_SLG_SetYRange
  398.  
  399. ; #FUNCTION# ====================================================================================================================
  400. ; Name...........: _SLG_SetBackGroundColor
  401. ; Description ...: Sets Graph BackGround Color
  402. ; Syntax.........: _SLG_SetBackGroundColor($iIndex, $iARGB = 0xFF000000)
  403. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  404. ;                  $iARGB       - Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB). Default = Black
  405. ; Return values .: Success      - 1
  406. ;                  Failure      - 0  and sets @ERROR:
  407. ;                               - 1 Invalid iIndex
  408. ; Author ........: Beege
  409. ; Remarks .......: All previous data will be cleared
  410. ; ===============================================================================================================================
  411. Func _SLG_SetBackGroundColor($iIndex, $iARGB = 0xFF000000)
  412.  
  413.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  414.  
  415.     $aGraphs[$iIndex][$g_iBackColor] = $iARGB
  416.     _SLG_ClearGraph($iIndex)
  417.  
  418.     Return 1
  419.  
  420. EndFunc   ;==>_SLG_SetBackGroundColor
  421.  
  422. ; #FUNCTION# ====================================================================================================================
  423. ; Name...........: _SLG_SetGridLineColor($iIndex)
  424. ; Description ...: Sets Graph GridLines Color Value
  425. ; Syntax.........: _SLG_SetGridLineColor($iIndex, $iARGB = Default)
  426. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  427. ;                  $iARGB       - Alpha, Red, Green and Blue Hex Value. (0xAARRGGBB). Default = Invert of Background Color.
  428. ; Return values .: Success      - 1
  429. ;                  Failure      - 0  and sets @ERROR:
  430. ;                               - 1 Invalid iIndex
  431. ; Author ........: Beege
  432. ; Remarks .......: All previous data will be cleared
  433. ; ===============================================================================================================================
  434. Func _SLG_SetGridLineColor($iIndex, $iARGB = Default)
  435.  
  436.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  437.  
  438.     $aGraphs[$iIndex][$g_iGridColor] = $iARGB
  439.     _SLG_ClearGraph($iIndex)
  440.  
  441.     Return 1
  442.  
  443. EndFunc   ;==>_SLG_SetGridLineColor
  444.  
  445. ; #FUNCTION# ====================================================================================================================
  446. ; Name...........: _SLG_EnableGridLines
  447. ; Description ...: Enables or Disables Drawing of Gridlines for Graph
  448. ; Syntax.........: _SLG_EnableGridLines($iIndex, $bGridlines = True)
  449. ; Parameters ....: $iIndex      - Index returned from _SLG_CreateGraph()
  450. ;                  $bGridlines  - GridLines flag:
  451. ;                  |True  - GridLines will be drawn
  452. ;                  |False - GridLines will not be drawn
  453. ; Return values .: Success      - 1
  454. ;                  Failure      - 0  and sets @ERROR:
  455. ;                               - 1 Invalid iIndex
  456. ;                               - 2 Invalid $bGridlines Value
  457. ; Author ........: Beege
  458. ; Remarks .......: none
  459. ; ===============================================================================================================================
  460. Func _SLG_EnableGridLines($iIndex, $bGridlines = True)
  461.  
  462.     If $iIndex > $aGraphs[0][0] Then Return SetError(1, @extended, 0)
  463.     If $bGridlines <> True And $bGridlines <> False Then SetError(2, @extended, 0)
  464.  
  465.     $aGraphs[$iIndex][$g_bGridlines] = $bGridlines
  466.  
  467.     Return 1
  468.  
  469. EndFunc   ;==>_SLG_EnableGridLines
  470.  
  471. #EndRegion Public Functions
  472. #Region Internel Functions
  473. ; #FUNCTION# ====================================================================================================================
  474. ; Author ........: UEZ
  475. ; Modified ......: Beege
  476. ; ===============================================================================================================================
  477. Func _AddGridLines($iIndex)
  478.     Local $iGridlineColor = $aGraphs[$iIndex][$g_iGridColor]
  479.     If $iGridlineColor = Default Or $iGridlineColor = -1 Then $iGridlineColor = BitOR(0xFF000000, (0xFFFFFFFF - $aGraphs[$iIndex][$g_iBackColor]));Invert Background RGB
  480.  
  481.     Local $iY1, $hPen = _GDIPlus_PenCreate($iGridlineColor)
  482.  
  483.     For $iY1 = 0 To $aGraphs[$iIndex][$g_iHeight] Step $aGraphs[$iIndex][$g_iY_counter]
  484.         _GDIPlus_GraphicsDrawLine($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iShift_Distance] - 1, $iY1, $aGraphs[$iIndex][$g_iWidth], $iY1, $hPen)
  485.     Next
  486.     If $aGraphs[$iIndex][$g_iX_counter] <= 0 Then
  487.         _GDIPlus_GraphicsDrawLine($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iWidth] - 1, 0, $aGraphs[$iIndex][$g_iWidth] - 1, $aGraphs[$iIndex][$g_iHeight], $hPen)
  488.         $aGraphs[$iIndex][$g_iX_counter] = $aGraphs[$iIndex][$g_iX_counter_mem]
  489.     EndIf
  490.     $aGraphs[$iIndex][$g_iX_counter] -= $aGraphs[$iIndex][$g_iIncrement_Size]
  491.  
  492.     _GDIPlus_PenDispose($hPen)
  493.  
  494. EndFunc   ;==>_AddGridLines
  495.  
  496. Func _FullGridLines($iIndex)
  497.     Local $iGridlineColor = $aGraphs[$iIndex][$g_iGridColor]
  498.     If $iGridlineColor = Default Or $iGridlineColor = -1 Then $iGridlineColor = BitOR(0xFF000000, (0xFFFFFFFF - $aGraphs[$iIndex][$g_iBackColor]));Invert Background RGB
  499.  
  500.     Local $iY1, $hPen = _GDIPlus_PenCreate($iGridlineColor)
  501.     Local $hShift_Section = _GDIPlus_BitmapCloneArea($aGraphs[$iIndex][$g_hBitmap], 0, 0, $aGraphs[$iIndex][$g_iWidth], $aGraphs[$iIndex][$g_iHeight]);
  502.     _GDIPlus_GraphicsClear($aGraphs[$iIndex][$g_hBuffer], $aGraphs[$iIndex][$g_iBackColor]);
  503.     _GDIPlus_GraphicsDrawImageRect($aGraphs[$iIndex][$g_hBuffer], $hShift_Section, 0, 0, $aGraphs[$iIndex][$g_iWidth], $aGraphs[$iIndex][$g_iHeight])
  504.     For $iY1 = 0 To $aGraphs[$iIndex][$g_iHeight] Step $aGraphs[$iIndex][$g_iY_counter]
  505.         _GDIPlus_GraphicsDrawLine($aGraphs[$iIndex][$g_hBuffer], 0, $iY1, $aGraphs[$iIndex][$g_iWidth], $iY1, $hPen)
  506.     Next
  507.  
  508.     For $iX = 0 To $aGraphs[$iIndex][$g_iWidth] Step $aGraphs[$iIndex][$g_iIncrement_Size]
  509.         If $aGraphs[$iIndex][$g_iX_counter] <= 0 Then
  510.             _GDIPlus_GraphicsDrawLine($aGraphs[$iIndex][$g_hBuffer], $iX, 0, $iX, $aGraphs[$iIndex][$g_iHeight], $hPen)
  511.             $aGraphs[$iIndex][$g_iX_counter] = $aGraphs[$iIndex][$g_iX_counter_mem]
  512.         EndIf
  513.         $aGraphs[$iIndex][$g_iX_counter] -= $aGraphs[$iIndex][$g_iIncrement_Size]
  514.     Next
  515.     _WriteBuffer($iIndex)
  516.     _GDIPlus_BitmapDispose($hShift_Section)
  517.     _GDIPlus_PenDispose($hPen)
  518.  
  519. EndFunc   ;==>_FullGridLines
  520.  
  521. Func _WriteBuffer($iIndex)
  522.  
  523.     Local $hGDI_HBitmap, $hDC
  524.  
  525.     $hGDI_HBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($aGraphs[$iIndex][$g_hBitmap])
  526.     $hDC = _WinAPI_CreateCompatibleDC($aGraphs[$iIndex][$g_hDC])
  527.     _WinAPI_SelectObject($hDC, $hGDI_HBitmap)
  528.     _WinAPI_BitBlt($aGraphs[$iIndex][$g_hDC], $aGraphs[$iIndex][$g_iLeft], $aGraphs[$iIndex][$g_iTop], $aGraphs[$iIndex][$g_iWidth], $aGraphs[$iIndex][$g_iHeight], $hDC, 0, 0, $SRCCOPY)
  529.     _WinAPI_DeleteObject($hGDI_HBitmap)
  530.     _WinAPI_DeleteDC($hDC)
  531.  
  532. EndFunc   ;==>_WriteBuffer
  533.  
  534. Func _SLG_Exit()
  535.  
  536.     Local $i, $j, $aPens
  537.  
  538.     If $aGraphs[0][0] Then
  539.         For $i = 1 To $aGraphs[0][0]
  540.             _GDIPlus_GraphicsDispose($aGraphs[$i][$g_hBuffer])
  541.             _GDIPlus_BitmapDispose($aGraphs[$i][$g_hBitmap])
  542.             _GDIPlus_GraphicsDispose($aGraphs[$i][$g_hGraphic])
  543.             $aPens = $aGraphs[$i][$g_aPens]
  544.             For $j = 1 To $aPens[0]
  545.                 _GDIPlus_PenDispose($aPens[$j])
  546.             Next
  547.             _WinAPI_ReleaseDC($aGraphs[$i][$g_hGUI], $aGraphs[$i][$g_hDC])
  548.         Next
  549.     EndIf
  550.  
  551.     _GDIPlus_Shutdown()
  552.  
  553. EndFunc   ;==>_SLG_Exit
  554. #EndRegion Internel Functions