-
Notifications
You must be signed in to change notification settings - Fork 0
/
Supportcenter.pb
149 lines (123 loc) · 4.15 KB
/
Supportcenter.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
;------------------------------------------------------------------------------------
;- Notes
;------------------------------------------------------------------------------------
;-- See TODO.txt
;------------------------------------------------------------------------------------
;- Compiler Settings
;------------------------------------------------------------------------------------
EnableExplicit
UsePNGImageDecoder()
;------------------------------------------------------------------------------------
;- Structures
;------------------------------------------------------------------------------------
Structure Menu
OpenIn.s
Url.s
Title.s
EndStructure
Structure Configuration
List Menus.Menu()
EndStructure
;------------------------------------------------------------------------------------
;- Variables, Enumerations, Lists and Maps
;------------------------------------------------------------------------------------
Global Event = #Null, Quit = #False
Global Customization.Configuration
#JSON_Parser = 0
; Files
Global IndexFile.s = "file://" + GetCurrentDirectory() + "Web/src/index.html"
Global ConfigurationFile.s = GetCurrentDirectory() + "Configuration.json"
;------------------------------------------------------------------------------------
;- Forms
;------------------------------------------------------------------------------------
XIncludeFile "Forms/MainWindow.pbf"
;------------------------------------------------------------------------------------
;- Functions
;------------------------------------------------------------------------------------
Procedure ShowMainWindow()
OpenMainWindow()
WindowBounds(MainWindow, WindowWidth(MainWindow)-200, WindowHeight(MainWindow), #PB_Ignore, #PB_Ignore)
BindEvent(#PB_Event_SizeWindow, @ResizeGadgetsMainWindow(), MainWindow)
EndProcedure
Procedure LoadConfiguration()
If LoadJSON(#JSON_Parser, ConfigurationFile)
;Debug "JSON object data from file:"
;Debug ComposeJSON(#JSON_Parser, #PB_JSON_PrettyPrint)
ExtractJSONStructure(JSONValue(#JSON_Parser), Customization, Configuration)
FreeJSON(#JSON_Parser)
Else
Debug "Can't read the configuration or the file is empty: " + ConfigurationFile
EndIf
EndProcedure
Procedure WebView_Home()
Debug "WebView: Show Local File: " + IndexFile
If IsGadget(WebView_Index) : SetGadgetText(WebView_Index, IndexFile) : EndIf
EndProcedure
Procedure Menu_Quit()
End
EndProcedure
Procedure Menu_EventHandler()
Protected Entry = EventGadget(), i = 1
Protected OpenIn.s, Url.s
ForEach Customization\Menus()
If Entry = i
OpenIn = Customization\Menus()\OpenIn
Url = Customization\Menus()\Url
EndIf
; Counter
i+1
Next
Debug "Open-in ("+OpenIn+") with url: " + Url
Select OpenIn
Case "process":
RunProgram(Url)
Case "browser":
If IsGadget(WebView_Index) : SetGadgetText(WebView_Index, Url) : EndIf
EndSelect
EndProcedure
Procedure BuildMenu()
Protected i = 1
If CreateMenu(0, WindowID(MainWindow))
MenuTitle("File")
ForEach Customization\Menus()
MenuItem(i, Customization\Menus()\Title)
BindMenuEvent(0, i, @Menu_EventHandler())
; Counter
i+1
Next
MenuBar()
MenuItem(98, "&Quit")
BindMenuEvent(0, 98, @Menu_Quit())
MenuTitle("Browse")
MenuItem(99, "Home")
BindMenuEvent(0, 99, @WebView_Home())
EndIf
EndProcedure
;------------------------------------------------------------------------------------
;- Main Loop
;------------------------------------------------------------------------------------
ShowMainWindow()
LoadConfiguration()
BuildMenu()
WebView_Home()
;------------------------------------------------------------------------------------
;- Event Loop
;------------------------------------------------------------------------------------
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
If Event = #PB_Event_CloseWindow
End
Else
MainWindow_Events(Event)
EndIf
EndSelect
Until Quit = #True
; IDE Options = PureBasic 6.10 LTS (Windows - x64)
; CursorPosition = 89
; FirstLine = 44
; Folding = 1-
; EnableXP
; DPIAware