B4J=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=8.9
@EndOfDesignText@
Sub Class_Globals
Private TiledMenuPageVw As B4XView
Private xui As XUI
Private ox, oy As Double
Private DateTimeLbl As B4XView
Private DateTimeTimer As Timer
Private DateTimePnl As B4XView
Private PlantOverviewBtnPnl As B4XView
Private OpnProceduresBtnPnl As B4XView
Private MntProceduresBtnPnl As B4XView
Private KKSFinderBtnPnl As B4XView
Private SEC12DatabookBtnPnl As B4XView
Private UserSettingBtnPnl As B4XView
Private MainPane As B4XView
Private TitlePnl As B4XView
Private ConfigBtnPnl As B4XView
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (PageView As B4XView)
Log("TiledMenuPage Create")
TiledMenuPageVw = PageView
TiledMenuPageVw.LoadLayout("TiledMenuPage")
SetPageSize
#if b4j
Log("OpenWindows :" & Main.OpenWindows)
#End If
B4XPages.SetTitle(Me, B4XPages.MainPage.ProjectTitle)
SetConctrolsLocation
UpdateBtns
End Sub
Private Sub SetPageSize
CodeLibrary.SetMoveListener(B4XPages.GetNativeParent(Me))
#if b4j
CodeLibrary.SetMinMaxWindowSize(B4XPages.GetNativeParent(Me))
CodeLibrary.SetPageSizeAndLocation(B4XPages.GetNativeParent(Me))
CodeLibrary.CheckIfPageWindowIsMaximized(B4XPages.GetNativeParent(Me))
#End If
End Sub
Private Sub SetConctrolsLocation
OpnProceduresBtnPnl.RemoveViewFromParent
PlantOverviewBtnPnl.RemoveViewFromParent
MntProceduresBtnPnl.RemoveViewFromParent
KKSFinderBtnPnl.RemoveViewFromParent
SEC12DatabookBtnPnl.RemoveViewFromParent
UserSettingBtnPnl.RemoveViewFromParent
OpnProceduresBtnPnl.Width = MainPane.Width / 4
OpnProceduresBtnPnl.Height = MainPane.Height / 4
OpnProceduresBtnPnl.Top = (TitlePnl.Height) + (OpnProceduresBtnPnl.Height / 3)
OpnProceduresBtnPnl.Left = (MainPane.Width / 2) - (OpnProceduresBtnPnl.Width / 2)
MainPane.AddView( _
OpnProceduresBtnPnl, _
OpnProceduresBtnPnl.Left, _
OpnProceduresBtnPnl.Top, _
OpnProceduresBtnPnl.Width, _
OpnProceduresBtnPnl.Height)
PlantOverviewBtnPnl.Width = OpnProceduresBtnPnl.Width
PlantOverviewBtnPnl.Height = OpnProceduresBtnPnl.Height
PlantOverviewBtnPnl.Top = OpnProceduresBtnPnl.Top
PlantOverviewBtnPnl.Left = OpnProceduresBtnPnl.Left - PlantOverviewBtnPnl.Width - (OpnProceduresBtnPnl.Width /8)
MainPane.AddView( _
PlantOverviewBtnPnl, _
PlantOverviewBtnPnl.Left, _
PlantOverviewBtnPnl.Top, _
PlantOverviewBtnPnl.Width, _
PlantOverviewBtnPnl.Height)
MntProceduresBtnPnl.Width = OpnProceduresBtnPnl.Width
MntProceduresBtnPnl.Height = OpnProceduresBtnPnl.Height
MntProceduresBtnPnl.Top = OpnProceduresBtnPnl.Top
MntProceduresBtnPnl.Left = OpnProceduresBtnPnl.Left + OpnProceduresBtnPnl.Width + (OpnProceduresBtnPnl.Width /8)
MainPane.AddView( _
MntProceduresBtnPnl, _
MntProceduresBtnPnl.Left, _
MntProceduresBtnPnl.Top, _
MntProceduresBtnPnl.Width, _
MntProceduresBtnPnl.Height)
KKSFinderBtnPnl.Height = OpnProceduresBtnPnl.Height
KKSFinderBtnPnl.Width = OpnProceduresBtnPnl.Width
KKSFinderBtnPnl.Top = PlantOverviewBtnPnl.Top + PlantOverviewBtnPnl.Height + (PlantOverviewBtnPnl.Height / 8)
KKSFinderBtnPnl.Left = PlantOverviewBtnPnl.Left
MainPane.AddView( _
KKSFinderBtnPnl, _
KKSFinderBtnPnl.Left, _
KKSFinderBtnPnl.Top, _
KKSFinderBtnPnl.Width, _
KKSFinderBtnPnl.Height)
SEC12DatabookBtnPnl.Height = OpnProceduresBtnPnl.Height
SEC12DatabookBtnPnl.Width = OpnProceduresBtnPnl.Width
SEC12DatabookBtnPnl.Top = KKSFinderBtnPnl.Top
SEC12DatabookBtnPnl.Left = OpnProceduresBtnPnl.Left
MainPane.AddView( _
SEC12DatabookBtnPnl, _
SEC12DatabookBtnPnl.Left, _
SEC12DatabookBtnPnl.Top, _
SEC12DatabookBtnPnl.Width, _
SEC12DatabookBtnPnl.Height)
UserSettingBtnPnl.Height = OpnProceduresBtnPnl.Height
UserSettingBtnPnl.Width = OpnProceduresBtnPnl.Width
UserSettingBtnPnl.Top = KKSFinderBtnPnl.Top
UserSettingBtnPnl.Left = MntProceduresBtnPnl.Left
MainPane.AddView( _
UserSettingBtnPnl, _
UserSettingBtnPnl.Left, _
UserSettingBtnPnl.Top, _
UserSettingBtnPnl.Width, _
UserSettingBtnPnl.Height)
End Sub
Private Sub AppPage_Tick
DateTime.DateFormat = "yyyy MMM d, EEE HH:mm:ss"
DateTimeLbl.Text = DateTime.Date(DateTime.Now)
DateTimePnl.Width = DateTimeLbl.Width + 15
End Sub
Private Sub CheckIfTimerIsInitialized
If Not(DateTimeTimer.IsInitialized) Then
DateTimeTimer.Initialize("AppPage", 200)
DateTimeTimer.Enabled = True
End If
End Sub
Private Sub B4XPage_Appear
Log("TiledMenuPage Appear")
#if b4j
Main.OpenWindows = Main.OpenWindows + 1
#End If
CheckIfTimerIsInitialized
SetPageSize
HideSplashForm
End Sub
Private Sub B4XPage_Disappear
Log("TiledMenuPage Disappear")
#if b4j
Main.OpenWindows = Main.OpenWindows - 1
#End If
HideSplashForm
End Sub
Private Sub B4XPage_Foreground
Log("TiledMenuPage Foreground")
HideSplashForm
End Sub
Private Sub B4XPage_Background
Log("TiledMenuPage Background")
#if b4j
Main.OpenWindows = Main.OpenWindows - 1
#End If
HideSplashForm
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
HideSplashForm
Log("TiledMenuPage Resize " & Width & " / " & Height)
#if b4j
CodeLibrary.GetPageSizeAndLocation(B4XPages.GetNativeParent(Me))
CodeLibrary.CheckIfPageWindowIsMaximized(B4XPages.GetNativeParent(Me))
#End If
SetConctrolsLocation
UpdateBtns
End Sub
Private Sub UpdateBtns
For i = 1 To 6
MouseMouseExitedBtn(i)
Next
End Sub
Private Sub AppClosingMsgBx As Object
HideSplashForm
Dim icon As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "SEC logo w-bg.png", 60dip, 60dip, True)
Dim myMsgBx As Object = xui.Msgbox2Async("Are you sure on closing this App?", "App Alert", "Yes", "No", "", icon)
Return myMsgBx
End Sub
Private Sub CheckAppClosing
Wait For (AppClosingMsgBx) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log("Closing the application through menu exit button")
CodeLibrary.CloseAllSQLiteConnections
ExitApplication
Else
B4XPages.ShowPageAndRemovePreviousPages("TiledMenu Page")
End If
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
Dim closerequestresult As Boolean = False
#if b4j
If Main.OpenWindows <= 1 Then
Wait For (AppClosingMsgBx) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log("Exiting the application through close button")
CodeLibrary.CloseAllSQLiteConnections
ExitApplication
closerequestresult = True
Else
B4XPages.ShowPageAndRemovePreviousPages("TiledMenu Page")
Main.OpenWindows = Main.OpenWindows - 1
closerequestresult = False
End If
Else
Main.OpenWindows = Main.OpenWindows - 1
closerequestresult = True
End If
#End If
Return closerequestresult
End Sub
Private Sub HideSplashForm
#if b4j
If Not(Main.SplashHidden) Then
Main.SplashHidden = True
Main.SplashForm.Close
End If
#End If
End Sub
Private Sub ProgLbl_Click
CodeLibrary.AboutProgrammer
HideSplashForm
End Sub
Private Sub ShowAnnivGreeting (days As Int, yrs As Int)
Try
#if b4j
Main.ShowAnnivScreen(True, B4XPages.GetNativeParent(Me).WindowLeft, _
B4XPages.GetNativeParent(Me).WindowTop, _
B4XPages.GetNativeParent(Me).WindowWidth, _
B4XPages.GetNativeParent(Me).WindowHeight, days, yrs)
#End If
Catch
Log(LastException)
End Try
End Sub
Private Sub CheckDateForAnniv
Dim days, yrs As Int
DateTime.DateFormat = "yyyy-MM-dd"
Dim DateNgHandog As Long = DateTime.DateParse("2016-04-27")
Dim AnnivThisYr As Long = DateTime.DateParse(DateTime.GetYear(DateTime.Now) & "-04-27")
If AnnivThisYr > DateTime.Now Then
days = - DateTime.GetDayOfYear(AnnivThisYr - DateTime.Now)
Else
days = DateTime.GetDayOfYear(DateTime.Now - AnnivThisYr) - 1
End If
yrs = DateTime.GetYear(DateTime.Now) - DateTime.GetYear(DateNgHandog)
ShowAnnivGreeting(days, yrs)
End Sub
Private Sub MouseEnteredBtn (BtnNumber As Byte)
Select BtnNumber
Case 1
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "PlantOverview-mouse-enter.png", PlantOverviewBtnPnl.Width, PlantOverviewBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgPlantOverviewBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
PlantOverviewBtnPnl.RemoveAllViews
PlantOverviewBtnPnl.AddView(BtnImgVw, 0, 0, PlantOverviewBtnPnl.Width, PlantOverviewBtnPnl.Height)
Case 2
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "OpnProcedures-mouse-enter.png", OpnProceduresBtnPnl.Width, OpnProceduresBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgOpnProcBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
OpnProceduresBtnPnl.RemoveAllViews
OpnProceduresBtnPnl.AddView(BtnImgVw, 0, 0, OpnProceduresBtnPnl.Width, OpnProceduresBtnPnl.Height)
Case 3
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "MntProcedures-mouse-enter.png", MntProceduresBtnPnl.Width, MntProceduresBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgMntProcBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
MntProceduresBtnPnl.RemoveAllViews
MntProceduresBtnPnl.AddView(BtnImgVw, 0, 0, MntProceduresBtnPnl.Width, MntProceduresBtnPnl.Height)
Case 4
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "KKSFinder-mouse-enter.png", KKSFinderBtnPnl.Width, KKSFinderBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgKKSBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
KKSFinderBtnPnl.RemoveAllViews
KKSFinderBtnPnl.AddView(BtnImgVw, 0, 0, KKSFinderBtnPnl.Width, KKSFinderBtnPnl.Height)
Case 5
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "Databook-mouse-enter.png", SEC12DatabookBtnPnl.Width, SEC12DatabookBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgSECDatabookBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
SEC12DatabookBtnPnl.RemoveAllViews
SEC12DatabookBtnPnl.AddView(BtnImgVw, 0, 0, SEC12DatabookBtnPnl.Width, SEC12DatabookBtnPnl.Height)
Case 6
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "UserSettings-mouse-enter.png", UserSettingBtnPnl.Width, UserSettingBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgUserBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
UserSettingBtnPnl.RemoveAllViews
UserSettingBtnPnl.AddView(BtnImgVw, 0, 0, UserSettingBtnPnl.Width, UserSettingBtnPnl.Height)
Case 7
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "config-mouse-enter.png", ConfigBtnPnl.Width, ConfigBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgConfigBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
ConfigBtnPnl.RemoveAllViews
ConfigBtnPnl.AddView(BtnImgVw, 0, 0, ConfigBtnPnl.Width, ConfigBtnPnl.Height)
End Select
End Sub
Private Sub MouseMouseExitedBtn (BtnNumber As Byte)
Select BtnNumber
Case 1
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "PlantOverview.png", PlantOverviewBtnPnl.Width, PlantOverviewBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgPlantOverviewBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
PlantOverviewBtnPnl.RemoveAllViews
PlantOverviewBtnPnl.AddView(BtnImgVw, 0, 0, PlantOverviewBtnPnl.Width, PlantOverviewBtnPnl.Height)
Case 2
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "OpnProcedures.png", OpnProceduresBtnPnl.Width, OpnProceduresBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgOpnProcBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
OpnProceduresBtnPnl.RemoveAllViews
OpnProceduresBtnPnl.AddView(BtnImgVw, 0, 0, OpnProceduresBtnPnl.Width, OpnProceduresBtnPnl.Height)
Case 3
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "MntProcedures.png", MntProceduresBtnPnl.Width, MntProceduresBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgMntProcBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
MntProceduresBtnPnl.RemoveAllViews
MntProceduresBtnPnl.AddView(BtnImgVw, 0, 0, MntProceduresBtnPnl.Width, MntProceduresBtnPnl.Height)
Case 4
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "KKSFinder.png", KKSFinderBtnPnl.Width, KKSFinderBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgKKSBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
KKSFinderBtnPnl.RemoveAllViews
KKSFinderBtnPnl.AddView(BtnImgVw, 0, 0, KKSFinderBtnPnl.Width, KKSFinderBtnPnl.Height)
Case 5
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "Databook.png", SEC12DatabookBtnPnl.Width, SEC12DatabookBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgSECDatabookBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
SEC12DatabookBtnPnl.RemoveAllViews
SEC12DatabookBtnPnl.AddView(BtnImgVw, 0, 0, SEC12DatabookBtnPnl.Width, SEC12DatabookBtnPnl.Height)
Case 6
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "UserSettings.png", UserSettingBtnPnl.Width, UserSettingBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgUserBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
UserSettingBtnPnl.RemoveAllViews
UserSettingBtnPnl.AddView(BtnImgVw, 0, 0, UserSettingBtnPnl.Width, UserSettingBtnPnl.Height)
Case 7
Dim BtnImg As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "config.png", ConfigBtnPnl.Width, ConfigBtnPnl.Height, False)
Dim BtnImgVw As ImageView
BtnImgVw.Initialize("imgConfigBtn")
#if b4j
BtnImgVw.SetImage(BtnImg)
BtnImgVw.PickOnBounds = True
#End If
ConfigBtnPnl.RemoveAllViews
ConfigBtnPnl.AddView(BtnImgVw, 0, 0, ConfigBtnPnl.Width, ConfigBtnPnl.Height)
End Select
End Sub
#if b4j
Private Sub ExitAppLbl_MouseClicked (EventData As MouseEvent)
CheckAppClosing
End Sub
Private Sub DateTimeLbl_MouseClicked (EventData As MouseEvent)
CheckDateForAnniv
End Sub
Private Sub DateTimePnl_MouseClicked (EventData As MouseEvent)
CheckDateForAnniv
End Sub
Private Sub TitlePnl_MousePressed (EventData As MouseEvent)
ox = EventData.X
oy = EventData.Y
End Sub
Private Sub MovePageOnMouseDrag (eventdata As MouseEvent)
Dim jo As JavaObject = eventdata
B4XPages.GetNativeParent(Me).WindowLeft = jo.RunMethod("getScreenX", Null) - ox
B4XPages.GetNativeParent(Me).WindowTop = jo.RunMethod("getScreenY", Null) - oy
End Sub
Private Sub TitlePnl_MouseDragged (EventData As MouseEvent)
MovePageOnMouseDrag (EventData)
End Sub
Private Sub PlantOverviewBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("MainPage")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub PlantOverviewBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(1)
End Sub
Private Sub PlantOverviewBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(1)
End Sub
Private Sub OpnProceduresBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("OpnProcedures Page")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub OpnProceduresBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(2)
End Sub
Private Sub OpnProceduresBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(2)
End Sub
Private Sub MntProceduresBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("MntProcedures Page")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub MntProceduresBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(3)
End Sub
Private Sub MntProceduresBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(3)
End Sub
Private Sub KKSFinderBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("KKSFinder Page")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub KKSFinderBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(4)
End Sub
Private Sub KKSFinderBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(4)
End Sub
Private Sub SEC12DatabookBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("SEC12Databook Page")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub SEC12DatabookBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(5)
End Sub
Private Sub SEC12DatabookBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(5)
End Sub
Private Sub UserSettingBtnPnl_MouseClicked (EventData As MouseEvent)
B4XPages.ShowPageAndRemovePreviousPages("UserSettings Page")
Main.OpenWindows = Main.OpenWindows - 1
End Sub
Private Sub UserSettingBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(6)
End Sub
Private Sub UserSettingBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(6)
End Sub
Private Sub ConfigBtnPnl_MouseEntered (EventData As MouseEvent)
MouseEnteredBtn(7)
End Sub
Private Sub ConfigBtnPnl_MouseExited (EventData As MouseEvent)
MouseMouseExitedBtn(7)
End Sub
Private Sub ConfigBtnPnl_MouseClicked (EventData As MouseEvent)
Dim MsgBx As Object = xui.Msgbox2Async( _
$"Continue with App configuration/setup?"$, _
"App Alert", "Yes", "No", "", Null)
Wait For (MsgBx) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log("Show Config Page")
B4XPages.ShowPageAndRemovePreviousPages("Config Page")
Main.OpenWindows = Main.OpenWindows - 1
End If
End Sub
#End If