SHARE
TWEET

me_test.lua

a guest Jul 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local me = component.me_controller
  3. local GUI = require("GUI")
  4.  
  5.  
  6. --------------------------------------------------------------------------------
  7. function getNI()
  8.   NI = me.getItemsInNetwork()
  9. end
  10.  
  11.  
  12. local sort_func_a_z = function( a,b ) return a.label < b.label end
  13. local sort_func_z_a = function( a,b ) return a.label > b.label end
  14. local sort_func_1_9 = function( a,b ) return a.size < b.size end
  15. local sort_func_9_1 = function( a,b ) return a.size > b.size end
  16.  
  17. local application = GUI.application()
  18.  
  19. application:addChild(GUI.panel(1, 1, application.width, application.height, 0x2D2D2D))
  20. application:addChild(GUI.panel(1, 44, application.width, 7, 0x880000))
  21.  
  22. textBox = application:addChild(GUI.textBox(1, 1, 53, 43, 0x2D6FD1, 0x2D2D2D, {}, 1, 1, 0))
  23. textBox.scrollBarEnabled = true
  24.  
  25. local resizer = application:addChild(GUI.resizer(textBox.localX + textBox.width - 2, textBox.localY + math.floor(textBox.height / 2 - 2), 3, 4, 0xAAAAAA, 0x0))
  26.  
  27. -- This function will be called during the "drag" event, when the user moves over the resizer
  28. resizer.onResize = function(dragWidth, dragHeight)
  29.   textBox.width = textBox.width + dragWidth
  30.   resizer.localX = resizer.localX + dragWidth
  31.    
  32.   application:draw()
  33. end
  34.  
  35.  
  36. function buildNIinGUI()
  37.   getNI()
  38.   table.sort(NI, sort_func_9_1)
  39.   for i,j in ipairs(NI) do
  40.     table.insert(textBox.lines, j.label .. " " .. j.size)
  41.   end
  42. end
  43.  
  44. function refresh()
  45.   getNI()
  46.   table.sort(NI, sort_func_9_1)
  47.   xa = 1
  48.   for ia,ja in ipairs(NI) do
  49.     textBox.lines[xa] = ja.label .. " " .. ja.size
  50.     xa = xa + 1
  51.   end
  52. end
  53.  
  54. buildNIinGUI()
  55.  
  56. local exitButton = application:addChild(GUI.button(4, 48, 20, 3, 0xFFFFFF, 0x555555, 0x775555, 0xFFFFFF, "Close"))
  57. exitButton.onTouch = function()
  58.   application:stop()
  59. end
  60.  
  61. local refreshButton = application:addChild(GUI.button(29, 48, 20, 3, 0xFFFFFF, 0x555555, 0x775555, 0xFFFFFF, "Refresh"))
  62. refreshButton.onTouch = function()
  63.   refresh()
  64.   application:draw(true)
  65. end  
  66.  
  67. local comboBox = application:addChild(GUI.comboBox(54, 48, 20, 3, 0xEEEEEE, 0x2D2D2D, 0xCCCCCC, 0x888888))
  68. comboBox:addItem("A to Z")
  69. comboBox:addItem("Z to A").onTouch = function()
  70.   -- Do something when .JPG was selected
  71. end
  72. comboBox:addItem("1 to 9")
  73. comboBox:addItem("9 to 1")
  74.  
  75.  
  76. ----- Zum debugen application:draw(true) auskommertieren
  77.  
  78.  
  79.  
  80. -- Start processing events for application
  81. application:draw(true)
  82. application:start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top