Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.45 KB | None | 0 0
  1. #NoTrayIcon
  2. Opt("TrayMenuMode", 1)
  3. $hWallet = GUICreate("Galaxia Wallet", 800, 470)
  4. GUISetBkColor(0x3b3b3b)
  5.  
  6. Const $Color_White = 0xfafafa, $Color_Grey = 0x424242, $Color_Cyan = 0x1abc9c, $Color_GreyRed = 0x694242
  7. Global $XiNetworkState = 0, $aButtons[0], $walletBalance = 4213.000000
  8.  
  9. GUICtrlCreateElement("", 0, 0, 200, 470, -1, -1, $Color_Grey)
  10.  
  11. $hLabelGalaxia = GUICtrlCreateElement("GALAXIA", 25, 0, 150, 60, 0x0201, -1, $Color_Grey, $Color_Cyan, 24, 600)
  12.  
  13. $hLabelBalance = GUICtrlCreateElement("Balance", 25, 60, -1, -1, -1, -1, $Color_Grey, $Color_Cyan)
  14.  
  15. $hLabelBalanceValue = GUICtrlCreateElement(StringFormat("%.6f", $walletBalance), 25, 75, 175, -1, -1, -1, $Color_Grey, $Color_White, 16)
  16.  
  17. $hLabelBalanceLocked = GUICtrlCreateElement("Locked balance", 25, 105, -1, -1, -1, -1, $Color_Grey, $Color_Cyan)
  18.  
  19. $hLabelBalanceLockedValue = GUICtrlCreateElement("0.000000", 25, 120, 125, -1, -1, -1, $Color_Grey, $Color_White, 14)
  20.  
  21. $hButtonSend = GUICtrlCreateElement(" Send >", 0, 150, 200, 35, 0x0200, -1, $Color_Cyan, $Color_Grey, 10, 600)
  22. _ArrayAdd($aButtons, $hButtonSend)
  23.  
  24. $hButtonReceive = GUICtrlCreateElement(" Receive >", 0, 185, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
  25. _ArrayAdd($aButtons, $hButtonReceive)
  26.  
  27. $hButtonHistory = GUICtrlCreateElement(" Transactions >", 0, 220, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
  28. _ArrayAdd($aButtons, $hButtonHistory)
  29.  
  30. $hButtonSettings = GUICtrlCreateElement(" Settings >", 0, 255, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
  31. _ArrayAdd($aButtons, $hButtonSettings)
  32.  
  33. GUICtrlCreateElement("", 0, 150, 200, 3, -1, -1, 0x3b3b3b)
  34.  
  35. $hLabelNetworkIcon = GUICtrlCreateElement("₪", 15, 420, 35, 35, -1, -1, $Color_Grey, 0xfc7c7c, 24, 600)
  36.  
  37. GUICtrlCreateElement("Network status", 55, 425, 100, 35, -1, -1, $Color_Grey, $Color_White)
  38.  
  39. $hLabelNetworkStatus = GUICtrlCreateElement("Disconnected", 55, 440, 145, 30, -1, -1, $Color_Grey, 0xfc7c7c, 10, 400)
  40.  
  41. GUICtrlCreateElement("", 0, 410, 200, 3, -1, -1, 0x3b3b3b)
  42.  
  43. $hProgressBackground = GUICtrlCreateElement("", 10, 460, 180, 5, -1, -1, 0x3b3b3b)
  44. GUICtrlSetState(-1, 32)
  45.  
  46. $hProgress = GUICtrlCreateElement("", 10, 460, 0, 5, -1, -1, 0xf7ff91)
  47. GUICtrlSetState(-1, 32)
  48.  
  49. #Region ;TAB Send
  50. $hLabelAmount = GUICtrlCreateElement("Amount", 215, 15, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
  51.  
  52. $hInputAmountBackground = GUICtrlCreateElement("", 215, 30, 250, 25, -1, -1, $Color_Grey)
  53. GUICtrlSetState(-1, 128)
  54. $hInputAmount = GUICtrlCreateInput("", 215, 35, 250, 25, -1, 0x00000080)
  55. GUICtrlSetBkColor(-1, $Color_Grey)
  56. GUICtrlSetColor(-1, $Color_Cyan)
  57. GUICtrlSetFont(-1, 12, 600)
  58.  
  59. $hLabelAmountErr = GUICtrlCreateElement("", 365, 60, 100, 35, 0x0002, -1, 0x3b3b3b, 0xb53b3b, 8, 400)
  60.  
  61. $hButtonAmountAll = GUICtrlCreateElement("or All", 475, 30, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
  62. _ArrayAdd($aButtons, $hButtonAmountAll)
  63.  
  64. $hLabelAddress = GUICtrlCreateElement("Address", 215, 65, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
  65.  
  66. $hInputAddressBackground = GUICtrlCreateElement("", 215, 80, 250, 25, -1, -1, $Color_Grey)
  67. GUICtrlSetState(-1, 128)
  68. $hInputAddress = GUICtrlCreateInput("", 215, 85, 250, 25, -1, 0x00000080)
  69. GUICtrlSetBkColor(-1, $Color_Grey)
  70. GUICtrlSetColor(-1, $Color_Cyan)
  71. GUICtrlSetFont(-1, 12, 600)
  72.  
  73. $hButtonAddressPaste = GUICtrlCreateElement("Paste", 475, 80, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
  74. _ArrayAdd($aButtons, $hButtonAddressPaste)
  75.  
  76. $hLabelPaymentID = GUICtrlCreateElement("Payment ID (Optional)", 215, 115, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
  77.  
  78. $hInputPayMentIDBackgorund = GUICtrlCreateElement("", 215, 130, 125, 25, -1, -1, $Color_Grey)
  79. GUICtrlSetState(-1, 128)
  80. $hInputPayMentID = GUICtrlCreateInput("", 215, 135, 125, 25, -1, 0x00000080)
  81. GUICtrlSetBkColor(-1, $Color_Grey)
  82. GUICtrlSetColor(-1, $Color_Cyan)
  83. GUICtrlSetFont(-1, 12, 600)
  84.  
  85. $hButtonSendSend = GUICtrlCreateElement("Send", 215, 170, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
  86. _ArrayAdd($aButtons, $hButtonSendSend)
  87.  
  88. Global $aTabSend[] = [$hLabelPaymentID, $hInputPayMentID, $hInputPayMentIDBackgorund, $hButtonSendSend]
  89. #EndRegion
  90.  
  91. #Region ;TAB Receive
  92. Global $aTabReceive[0]
  93. #EndRegion
  94.  
  95. #Region ;TAB Transactions
  96. Global $aTabTransactions[0]
  97. #EndRegion
  98.  
  99. #Region ;TAB Settings
  100. $hLabelAutoStart = GUICtrlCreateElement("Run at Windows startup", 250, 20, 200, 35, -1, -1, 0x3b3b3b, $Color_Cyan, 10, 600)
  101. $hCheckboxAutoStart = GUICtrlCreateElement("", 215, 15, 25, 25, 0x201, -1, $Color_Grey, $Color_Cyan, 18, 600)
  102.  
  103. $hLabelTray = GUICtrlCreateElement("Minimize to tray instead closing", 250, 60, 250, 35, -1, -1, 0x3b3b3b, $Color_Cyan, 10, 600)
  104. $hCheckboxTray = GUICtrlCreateElement("", 215, 55, 25, 25, 0x201, -1, $Color_Grey, $Color_Cyan, 18, 600)
  105.  
  106. Global $aTabSettings[] = [$hLabelAutoStart, $hCheckboxAutoStart, $hLabelTray, $hCheckboxTray]
  107. #EndRegion
  108.  
  109. GUISwitchTab($hButtonSend, $hButtonHistory)
  110. GUISwitchTab($hButtonSend, $hButtonReceive)
  111. GUISwitchTab($hButtonSend, $hButtonSettings)
  112. GUISetState()
  113.  
  114. $activeTab = $hButtonSend
  115. $lastTab = ""
  116.  
  117. Global $lastAmount[2] = ["", False]
  118.  
  119. ;Tray menu
  120. $hOpen = TrayCreateItem("Open")
  121. $hExit = TrayCreateItem("Exit")
  122. TraySetState(1)
  123. TraySetClick(8)
  124.  
  125. While 1
  126. Switch TrayGetMsg()
  127. Case $hExit
  128. Exit
  129. Case $hOpen, -13 ;Menu item + double click
  130. GUISetState(@SW_SHOW)
  131. EndSwitch
  132. Switch GUIGetMsg()
  133. Case -3
  134. If GUICtrlRead($hCheckboxTray) = "" Then
  135. Exit
  136. Else
  137. GUISetState(@SW_HIDE)
  138. EndIf
  139. Case $hButtonAmountAll
  140. GUICtrlSetData($hInputAmount, StringFormat("%.6f", $walletBalance))
  141. Case $hCheckboxAutoStart
  142. If GUICtrlRead($hCheckboxAutoStart) = "" Then
  143. GUICtrlSetData($hCheckboxAutoStart, "●")
  144. Else
  145. GUICtrlSetData($hCheckboxAutoStart, "")
  146. EndIf
  147. Case $hCheckboxTray
  148. If GUICtrlRead($hCheckboxTray) = "" Then
  149. GUICtrlSetData($hCheckboxTray, "●")
  150. Else
  151. GUICtrlSetData($hCheckboxTray, "")
  152. EndIf
  153. Case $hButtonAddressPaste
  154. GUICtrlSetData($hInputAddress, ClipGet())
  155. EndSwitch
  156. ;Valid Amount watcher
  157. If ControlGetFocus($hWallet) = "Edit1" Then
  158. $iInputAmount = GUICtrlRead($hInputAmount)
  159. ;If input changes
  160. If $iInputAmount <> $lastAmount[0] Then
  161. $lastAmount[0] = $iInputAmount
  162. ;Looking for dot
  163. $iPoint = StringInStr($iInputAmount, ".")
  164. $iLen = StringLen($iInputAmount)
  165. ;If there is more than 6 characters after dot - bad amount
  166. ToolTip($iPoint & ", " & ($iLen > 6 + $iPoint) & ", " & ValidAmount($iInputAmount), 0, 0)
  167. If $iPoint And $iLen > 6 + $iPoint Then
  168. ToolTip("so thats true", 0, 0)
  169. $lastAmount[1] = 1
  170. ;if there is any unallowe character - bad amount
  171. ElseIf Not ValidAmount($iInputAmount) Then
  172. $lastAmount[1] = 1
  173. ElseIf $iInputAmount = "" Then
  174. $lastAmount[1] = 3
  175. ;if your balance is lower than amount - not enaught founds
  176. ElseIf $lastAmount[0] > $walletBalance Then
  177. $lastAmount[1] = 2
  178. ElseIf $lastAmount[0] <= $walletBalance And $iLen <= 6 + $iPoint And ValidAmount($iInputAmount) Then
  179. $lastAmount[1] = False
  180. EndIf
  181. If Not $lastAmount[1] Then
  182. GUICtrlSetBkColor($hInputAmountBackground, $Color_Grey)
  183. GUICtrlSetBkColor($hInputAmount, $Color_Grey)
  184. GuiCtrlSetData($hLabelAmountErr, "")
  185. Else
  186. GUICtrlSetBkColor($hInputAmountBackground, $Color_GreyRed)
  187. GUICtrlSetBkColor($hInputAmount, $Color_GreyRed)
  188. EndIf
  189. Switch $lastAmount[1]
  190. Case 1
  191. GUICtrlSetData($hLabelAmountErr, "Bad amount")
  192. Case 2
  193. GuiCtrlSetData($hLabelAmountErr, "Not enought founds")
  194. Case 3
  195. GuiCtrlSetData($hLabelAmountErr, "Enter amount")
  196. EndSwitch
  197. EndIf
  198. Else
  199. ;Add missed zeros after dot
  200. If GUICtrlRead($hInputAmount) <> 0 And ValidAmount(GUICtrlRead($hInputAmount)) Then
  201. GUICtrlSetData($hInputAmount, StringFormat("%.6f", GUICtrlRead($hInputAmount)))
  202. EndIf
  203. EndIf
  204. $hCursor = GUIGetCursorInfo()
  205. If IsArray($hCursor) Then
  206. If $hCursor[4] <> $activeTab And _ArrayExists($aButtons, $hCursor[4]) Then
  207. GUICtrlSetBkColor($hCursor[4], $Color_Cyan)
  208. GUICtrlSetColor($hCursor[4], $Color_Grey)
  209. While 1
  210. $hCursor2 = GUIGetCursorInfo()
  211. If IsArray($hCursor2) Then
  212. If $hCursor2[4] <> $hCursor[4] Then ExitLoop
  213. If _IsPressed("01") And $hCursor2[4] >= $hButtonSend And $hCursor2[4] <= $hButtonSettings Then
  214. GUICtrlSetBkColor($activeTab, $Color_Grey)
  215. GUICtrlSetColor($activeTab, $Color_Cyan)
  216. $lastTab = $activeTab
  217. $activeTab = $hCursor[4]
  218. GuiSwitchTab($activeTab, $lastTab)
  219. ContinueLoop 2
  220. ElseIf _IsPressed("01") Then
  221. ContinueLoop 2
  222. EndIf
  223. EndIf
  224. WEnd
  225. GUICtrlSetBkColor($hCursor[4], $Color_Grey)
  226. GUICtrlSetColor($hCursor[4], $Color_Cyan)
  227. EndIf
  228. EndIf
  229. WEnd
  230.  
  231. ;Changes netowrk status indicator
  232. ;$iState :
  233. ;0 - Disconnected
  234. ;1 - Synchronizing
  235. ;2 - Synced
  236. ;$iPercent:
  237. ;0-100 percent value of sync
  238. Func XiNetworkSetState($iState, $iPercent = 0)
  239. If $iState <> $XiNetworkState Then
  240. $XiNetworkState = $iState
  241. Switch $iState
  242. Case 0
  243. GUICtrlSetColor($hLabelNetworkIcon, 0xfc7c7c)
  244. GUICtrlSetColor($hLabelNetworkStatus, 0xfc7c7c)
  245. GUICtrlSetData($hLabelNetworkStatus, "Disconnected")
  246. Case 1
  247. GUICtrlSetColor($hLabelNetworkIcon, 0xf7ff91)
  248. GUICtrlSetColor($hLabelNetworkStatus, 0xf7ff91)
  249. GUICtrlSetData($hLabelNetworkStatus, "Synchronizing")
  250. Case 2
  251. GUICtrlSetColor($hLabelNetworkIcon, $Color_Cyan)
  252. GUICtrlSetColor($hLabelNetworkStatus, $Color_Cyan)
  253. GUICtrlSetData($hLabelNetworkStatus, "Synced")
  254. EndSwitch
  255. If $XiNetworkState = 1 Then
  256. GUICtrlShow($hProgressBackground)
  257. GUICtrlShow($hProgress)
  258. Else
  259. GUICtrlHide($hProgressBackground)
  260. GUICtrlHide($hProgress)
  261. EndIf
  262. EndIf
  263. If $XiNetworkState = 1 Then GUICtrlSetPos($hProgress, 10, 460, 180 * ($iPercent / 100), 5)
  264. EndFunc
  265.  
  266. Func GUISwitchTab($tabShow, $tabHide)
  267. Local $aHide, $aShow
  268. Switch $tabHide
  269. Case $hButtonSend
  270. $aHide = $aTabSend
  271. Case $hButtonReceive
  272. $aHide = $aTabReceive
  273. Case $hButtonHistory
  274. $aHide = $aTabTransactions
  275. Case $hButtonSettings
  276. $aHide = $aTabSettings
  277. EndSwitch
  278. For $iControl In $aHide
  279. GUICtrlHide($iControl)
  280. Next
  281. Switch $tabShow
  282. Case $hButtonSend
  283. $aShow = $aTabSend
  284. Case $hButtonReceive
  285. $aShow = $aTabReceive
  286. Case $hButtonHistory
  287. $aShow = $aTabTransactions
  288. Case $hButtonSettings
  289. $aShow = $aTabSettings
  290. EndSwitch
  291. For $iControl In $aShow
  292. GUICtrlShow($iControl)
  293. Next
  294. EndFunc
  295.  
  296. Func ValidAmount($szAmount)
  297. Local $szChrset = "0123456789."
  298. For $iChr = 1 To StringLen($szAmount)
  299. If Not StringInStr($szChrset, StringMid($szAmount, $iChr, 1)) Then Return 0
  300. Next
  301. Return 1
  302. EndFunc
  303.  
  304. ;----------------------------------------------------------------------------
  305. Func GUICtrlShow($ctrlID)
  306. GuiCtrlSetState($ctrlID, 16)
  307. EndFunc
  308.  
  309. Func GUICtrlHide($ctrlID)
  310. GuiCtrlSetState($ctrlID, 32)
  311. EndFunc
  312.  
  313. Func GUICtrlCreateElement($text, $left, $top, $width = -1, $height = -1, $style = -1, $exstyle = -1, $bkcolor = -1, $color = -1, $fontsize = -1, $fontweight = -1)
  314. Local $ctrlID = GUICtrlCreateLabel($text, $left, $top, $width, $height, $style, $exstyle)
  315. If $bkcolor <> -1 Then GUICtrlSetBkColor(-1, $bkcolor)
  316. If $color <> -1 Then GUICtrlSetColor(-1, $color)
  317. If $fontsize <> -1 Then GUICtrlSetFont(-1, $fontsize, $fontweight)
  318. Return $ctrlID
  319. EndFunc
  320.  
  321. Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
  322. Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
  323. If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
  324. Return 0
  325. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement