Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- Opt("TrayMenuMode", 1)
- $hWallet = GUICreate("Galaxia Wallet", 800, 470)
- GUISetBkColor(0x3b3b3b)
- Const $Color_White = 0xfafafa, $Color_Grey = 0x424242, $Color_Cyan = 0x1abc9c, $Color_GreyRed = 0x694242
- Global $XiNetworkState = 0, $aButtons[0], $walletBalance = 4213.000000
- GUICtrlCreateElement("", 0, 0, 200, 470, -1, -1, $Color_Grey)
- $hLabelGalaxia = GUICtrlCreateElement("GALAXIA", 25, 0, 150, 60, 0x0201, -1, $Color_Grey, $Color_Cyan, 24, 600)
- $hLabelBalance = GUICtrlCreateElement("Balance", 25, 60, -1, -1, -1, -1, $Color_Grey, $Color_Cyan)
- $hLabelBalanceValue = GUICtrlCreateElement(StringFormat("%.6f", $walletBalance), 25, 75, 175, -1, -1, -1, $Color_Grey, $Color_White, 16)
- $hLabelBalanceLocked = GUICtrlCreateElement("Locked balance", 25, 105, -1, -1, -1, -1, $Color_Grey, $Color_Cyan)
- $hLabelBalanceLockedValue = GUICtrlCreateElement("0.000000", 25, 120, 125, -1, -1, -1, $Color_Grey, $Color_White, 14)
- $hButtonSend = GUICtrlCreateElement(" Send >", 0, 150, 200, 35, 0x0200, -1, $Color_Cyan, $Color_Grey, 10, 600)
- _ArrayAdd($aButtons, $hButtonSend)
- $hButtonReceive = GUICtrlCreateElement(" Receive >", 0, 185, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonReceive)
- $hButtonHistory = GUICtrlCreateElement(" Transactions >", 0, 220, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonHistory)
- $hButtonSettings = GUICtrlCreateElement(" Settings >", 0, 255, 200, 35, 0x0200, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonSettings)
- GUICtrlCreateElement("", 0, 150, 200, 3, -1, -1, 0x3b3b3b)
- $hLabelNetworkIcon = GUICtrlCreateElement("₪", 15, 420, 35, 35, -1, -1, $Color_Grey, 0xfc7c7c, 24, 600)
- GUICtrlCreateElement("Network status", 55, 425, 100, 35, -1, -1, $Color_Grey, $Color_White)
- $hLabelNetworkStatus = GUICtrlCreateElement("Disconnected", 55, 440, 145, 30, -1, -1, $Color_Grey, 0xfc7c7c, 10, 400)
- GUICtrlCreateElement("", 0, 410, 200, 3, -1, -1, 0x3b3b3b)
- $hProgressBackground = GUICtrlCreateElement("", 10, 460, 180, 5, -1, -1, 0x3b3b3b)
- GUICtrlSetState(-1, 32)
- $hProgress = GUICtrlCreateElement("", 10, 460, 0, 5, -1, -1, 0xf7ff91)
- GUICtrlSetState(-1, 32)
- #Region ;TAB Send
- $hLabelAmount = GUICtrlCreateElement("Amount", 215, 15, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
- $hInputAmountBackground = GUICtrlCreateElement("", 215, 30, 250, 25, -1, -1, $Color_Grey)
- GUICtrlSetState(-1, 128)
- $hInputAmount = GUICtrlCreateInput("", 215, 35, 250, 25, -1, 0x00000080)
- GUICtrlSetBkColor(-1, $Color_Grey)
- GUICtrlSetColor(-1, $Color_Cyan)
- GUICtrlSetFont(-1, 12, 600)
- $hLabelAmountErr = GUICtrlCreateElement("", 365, 60, 100, 35, 0x0002, -1, 0x3b3b3b, 0xb53b3b, 8, 400)
- $hButtonAmountAll = GUICtrlCreateElement("or All", 475, 30, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonAmountAll)
- $hLabelAddress = GUICtrlCreateElement("Address", 215, 65, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
- $hInputAddressBackground = GUICtrlCreateElement("", 215, 80, 250, 25, -1, -1, $Color_Grey)
- GUICtrlSetState(-1, 128)
- $hInputAddress = GUICtrlCreateInput("", 215, 85, 250, 25, -1, 0x00000080)
- GUICtrlSetBkColor(-1, $Color_Grey)
- GUICtrlSetColor(-1, $Color_Cyan)
- GUICtrlSetFont(-1, 12, 600)
- $hButtonAddressPaste = GUICtrlCreateElement("Paste", 475, 80, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonAddressPaste)
- $hLabelPaymentID = GUICtrlCreateElement("Payment ID (Optional)", 215, 115, -1, -1, -1, -1, 0x3b3b3b, $Color_White, 8, 400)
- $hInputPayMentIDBackgorund = GUICtrlCreateElement("", 215, 130, 125, 25, -1, -1, $Color_Grey)
- GUICtrlSetState(-1, 128)
- $hInputPayMentID = GUICtrlCreateInput("", 215, 135, 125, 25, -1, 0x00000080)
- GUICtrlSetBkColor(-1, $Color_Grey)
- GUICtrlSetColor(-1, $Color_Cyan)
- GUICtrlSetFont(-1, 12, 600)
- $hButtonSendSend = GUICtrlCreateElement("Send", 215, 170, 50, 30, 0x0201, -1, $Color_Grey, $Color_Cyan, 10, 600)
- _ArrayAdd($aButtons, $hButtonSendSend)
- Global $aTabSend[] = [$hLabelPaymentID, $hInputPayMentID, $hInputPayMentIDBackgorund, $hButtonSendSend]
- #EndRegion
- #Region ;TAB Receive
- Global $aTabReceive[0]
- #EndRegion
- #Region ;TAB Transactions
- Global $aTabTransactions[0]
- #EndRegion
- #Region ;TAB Settings
- $hLabelAutoStart = GUICtrlCreateElement("Run at Windows startup", 250, 20, 200, 35, -1, -1, 0x3b3b3b, $Color_Cyan, 10, 600)
- $hCheckboxAutoStart = GUICtrlCreateElement("", 215, 15, 25, 25, 0x201, -1, $Color_Grey, $Color_Cyan, 18, 600)
- $hLabelTray = GUICtrlCreateElement("Minimize to tray instead closing", 250, 60, 250, 35, -1, -1, 0x3b3b3b, $Color_Cyan, 10, 600)
- $hCheckboxTray = GUICtrlCreateElement("", 215, 55, 25, 25, 0x201, -1, $Color_Grey, $Color_Cyan, 18, 600)
- Global $aTabSettings[] = [$hLabelAutoStart, $hCheckboxAutoStart, $hLabelTray, $hCheckboxTray]
- #EndRegion
- GUISwitchTab($hButtonSend, $hButtonHistory)
- GUISwitchTab($hButtonSend, $hButtonReceive)
- GUISwitchTab($hButtonSend, $hButtonSettings)
- GUISetState()
- $activeTab = $hButtonSend
- $lastTab = ""
- Global $lastAmount[2] = ["", False]
- ;Tray menu
- $hOpen = TrayCreateItem("Open")
- $hExit = TrayCreateItem("Exit")
- TraySetState(1)
- TraySetClick(8)
- While 1
- Switch TrayGetMsg()
- Case $hExit
- Exit
- Case $hOpen, -13 ;Menu item + double click
- GUISetState(@SW_SHOW)
- EndSwitch
- Switch GUIGetMsg()
- Case -3
- If GUICtrlRead($hCheckboxTray) = "" Then
- Exit
- Else
- GUISetState(@SW_HIDE)
- EndIf
- Case $hButtonAmountAll
- GUICtrlSetData($hInputAmount, StringFormat("%.6f", $walletBalance))
- Case $hCheckboxAutoStart
- If GUICtrlRead($hCheckboxAutoStart) = "" Then
- GUICtrlSetData($hCheckboxAutoStart, "●")
- Else
- GUICtrlSetData($hCheckboxAutoStart, "")
- EndIf
- Case $hCheckboxTray
- If GUICtrlRead($hCheckboxTray) = "" Then
- GUICtrlSetData($hCheckboxTray, "●")
- Else
- GUICtrlSetData($hCheckboxTray, "")
- EndIf
- Case $hButtonAddressPaste
- GUICtrlSetData($hInputAddress, ClipGet())
- EndSwitch
- ;Valid Amount watcher
- If ControlGetFocus($hWallet) = "Edit1" Then
- $iInputAmount = GUICtrlRead($hInputAmount)
- ;If input changes
- If $iInputAmount <> $lastAmount[0] Then
- $lastAmount[0] = $iInputAmount
- ;Looking for dot
- $iPoint = StringInStr($iInputAmount, ".")
- $iLen = StringLen($iInputAmount)
- ;If there is more than 6 characters after dot - bad amount
- ToolTip($iPoint & ", " & ($iLen > 6 + $iPoint) & ", " & ValidAmount($iInputAmount), 0, 0)
- If $iPoint And $iLen > 6 + $iPoint Then
- ToolTip("so thats true", 0, 0)
- $lastAmount[1] = 1
- ;if there is any unallowe character - bad amount
- ElseIf Not ValidAmount($iInputAmount) Then
- $lastAmount[1] = 1
- ElseIf $iInputAmount = "" Then
- $lastAmount[1] = 3
- ;if your balance is lower than amount - not enaught founds
- ElseIf $lastAmount[0] > $walletBalance Then
- $lastAmount[1] = 2
- ElseIf $lastAmount[0] <= $walletBalance And $iLen <= 6 + $iPoint And ValidAmount($iInputAmount) Then
- $lastAmount[1] = False
- EndIf
- If Not $lastAmount[1] Then
- GUICtrlSetBkColor($hInputAmountBackground, $Color_Grey)
- GUICtrlSetBkColor($hInputAmount, $Color_Grey)
- GuiCtrlSetData($hLabelAmountErr, "")
- Else
- GUICtrlSetBkColor($hInputAmountBackground, $Color_GreyRed)
- GUICtrlSetBkColor($hInputAmount, $Color_GreyRed)
- EndIf
- Switch $lastAmount[1]
- Case 1
- GUICtrlSetData($hLabelAmountErr, "Bad amount")
- Case 2
- GuiCtrlSetData($hLabelAmountErr, "Not enought founds")
- Case 3
- GuiCtrlSetData($hLabelAmountErr, "Enter amount")
- EndSwitch
- EndIf
- Else
- ;Add missed zeros after dot
- If GUICtrlRead($hInputAmount) <> 0 And ValidAmount(GUICtrlRead($hInputAmount)) Then
- GUICtrlSetData($hInputAmount, StringFormat("%.6f", GUICtrlRead($hInputAmount)))
- EndIf
- EndIf
- $hCursor = GUIGetCursorInfo()
- If IsArray($hCursor) Then
- If $hCursor[4] <> $activeTab And _ArrayExists($aButtons, $hCursor[4]) Then
- GUICtrlSetBkColor($hCursor[4], $Color_Cyan)
- GUICtrlSetColor($hCursor[4], $Color_Grey)
- While 1
- $hCursor2 = GUIGetCursorInfo()
- If IsArray($hCursor2) Then
- If $hCursor2[4] <> $hCursor[4] Then ExitLoop
- If _IsPressed("01") And $hCursor2[4] >= $hButtonSend And $hCursor2[4] <= $hButtonSettings Then
- GUICtrlSetBkColor($activeTab, $Color_Grey)
- GUICtrlSetColor($activeTab, $Color_Cyan)
- $lastTab = $activeTab
- $activeTab = $hCursor[4]
- GuiSwitchTab($activeTab, $lastTab)
- ContinueLoop 2
- ElseIf _IsPressed("01") Then
- ContinueLoop 2
- EndIf
- EndIf
- WEnd
- GUICtrlSetBkColor($hCursor[4], $Color_Grey)
- GUICtrlSetColor($hCursor[4], $Color_Cyan)
- EndIf
- EndIf
- WEnd
- ;Changes netowrk status indicator
- ;$iState :
- ;0 - Disconnected
- ;1 - Synchronizing
- ;2 - Synced
- ;$iPercent:
- ;0-100 percent value of sync
- Func XiNetworkSetState($iState, $iPercent = 0)
- If $iState <> $XiNetworkState Then
- $XiNetworkState = $iState
- Switch $iState
- Case 0
- GUICtrlSetColor($hLabelNetworkIcon, 0xfc7c7c)
- GUICtrlSetColor($hLabelNetworkStatus, 0xfc7c7c)
- GUICtrlSetData($hLabelNetworkStatus, "Disconnected")
- Case 1
- GUICtrlSetColor($hLabelNetworkIcon, 0xf7ff91)
- GUICtrlSetColor($hLabelNetworkStatus, 0xf7ff91)
- GUICtrlSetData($hLabelNetworkStatus, "Synchronizing")
- Case 2
- GUICtrlSetColor($hLabelNetworkIcon, $Color_Cyan)
- GUICtrlSetColor($hLabelNetworkStatus, $Color_Cyan)
- GUICtrlSetData($hLabelNetworkStatus, "Synced")
- EndSwitch
- If $XiNetworkState = 1 Then
- GUICtrlShow($hProgressBackground)
- GUICtrlShow($hProgress)
- Else
- GUICtrlHide($hProgressBackground)
- GUICtrlHide($hProgress)
- EndIf
- EndIf
- If $XiNetworkState = 1 Then GUICtrlSetPos($hProgress, 10, 460, 180 * ($iPercent / 100), 5)
- EndFunc
- Func GUISwitchTab($tabShow, $tabHide)
- Local $aHide, $aShow
- Switch $tabHide
- Case $hButtonSend
- $aHide = $aTabSend
- Case $hButtonReceive
- $aHide = $aTabReceive
- Case $hButtonHistory
- $aHide = $aTabTransactions
- Case $hButtonSettings
- $aHide = $aTabSettings
- EndSwitch
- For $iControl In $aHide
- GUICtrlHide($iControl)
- Next
- Switch $tabShow
- Case $hButtonSend
- $aShow = $aTabSend
- Case $hButtonReceive
- $aShow = $aTabReceive
- Case $hButtonHistory
- $aShow = $aTabTransactions
- Case $hButtonSettings
- $aShow = $aTabSettings
- EndSwitch
- For $iControl In $aShow
- GUICtrlShow($iControl)
- Next
- EndFunc
- Func ValidAmount($szAmount)
- Local $szChrset = "0123456789."
- For $iChr = 1 To StringLen($szAmount)
- If Not StringInStr($szChrset, StringMid($szAmount, $iChr, 1)) Then Return 0
- Next
- Return 1
- EndFunc
- ;----------------------------------------------------------------------------
- Func GUICtrlShow($ctrlID)
- GuiCtrlSetState($ctrlID, 16)
- EndFunc
- Func GUICtrlHide($ctrlID)
- GuiCtrlSetState($ctrlID, 32)
- EndFunc
- Func GUICtrlCreateElement($text, $left, $top, $width = -1, $height = -1, $style = -1, $exstyle = -1, $bkcolor = -1, $color = -1, $fontsize = -1, $fontweight = -1)
- Local $ctrlID = GUICtrlCreateLabel($text, $left, $top, $width, $height, $style, $exstyle)
- If $bkcolor <> -1 Then GUICtrlSetBkColor(-1, $bkcolor)
- If $color <> -1 Then GUICtrlSetColor(-1, $color)
- If $fontsize <> -1 Then GUICtrlSetFont(-1, $fontsize, $fontweight)
- Return $ctrlID
- EndFunc
- Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
- Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
- If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
- Return 0
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement