#Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Region Sub Process_Globals Private fx As JFX Private MainForm As Form Private xui As XUI Private btnFileDialog As Button Private fc As FileChooser Private f As String Private ParsedData As Map Private fx As JFX Private xui As XUI Type RectDbl(Left As Double, Top As Double, Width As Double,Height As Double) Private fx As JFX Private MainForm As Form Dim desktop(fx.Screens.Size) As Double End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.RootPane.LoadLayout("Layout1") MainForm.Show MainForm.Title = "Convert .fpl To *.fms" Dim sc As List = fx.Screens Dim cnt As Int = 0 For Each o As JavaObject In sc Dim bounds As JavaObject = o.RunMethodjo("getBounds",Null)' required Dim minX As Double = bounds.RunMethod("getMinX",Null)'required Dim minY As Double = bounds.RunMethod("getMinY",Null)' optional Dim width As Double = bounds.RunMethod("getWidth",Null)' optional Dim height As Double = bounds.RunMethod("getHeight",Null)'optional If cnt == 1 Then Dim width1 As Double = bounds.RunMethod("getWidth",Null)' optional Dim height1 As Double = bounds.RunMethod("getHeight",Null)'optional End If 'Log($"Screen is ${width} x ${height} pixels"$)' optional 'Log($"minimum X: ${minX} minimum Y: ${minY}"$)' optional desktop(cnt) = minX ' required cnt = cnt + 1 ' required Next Log(cnt) showOn(1,MainForm,height1,width1)' form must be shown before this or has no values for left,top etc End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Sub showOn(Screen As Int, what As Form, height1 As Double, width1 As Double) Dim maxScreen As Int = desktop.Length-1 ' maximum number of screens If Screen > maxScreen Then ' if trying to display on non existant screen show on last one Screen = maxScreen End If Dim Stage As JavaObject = what Stage = Stage.GetField("stage") Stage.RunMethod("centerOnScreen",Null) End Sub Sub CenterOnScreen ' Dim R As RectDbl = GetRectDblFromForm(MainForm) Dim R As RectDbl = CreateRectDbl(MainForm.WindowLeft + MainForm.WindowWidth / 2,MainForm.WindowTop + MainForm.WindowHeight / 2,1,1) Dim Scr As Screen = GetCurrentScreen(R) Dim ScrWidth As Double = Scr.MaxX - Scr.MinX Dim ScrHeight As Double = Scr.MaxY - Scr.MinY MainForm.WindowTop = Scr.MinY + (ScrHeight - MainForm.WindowHeight) / 2 MainForm.WindowLeft = Scr.MinX + (ScrWidth - MainForm.WindowWidth) / 2 End Sub Public Sub GetCurrentScreen(R As RectDbl) As Screen Dim Screens As JavaObject Screens.InitializeStatic("javafx.stage.Screen") Dim Rect2d As JavaObject Rect2d.InitializeNewInstance("javafx.geometry.Rectangle2D",Array(R.Left,R.Top,R.Width,R.Height)) Dim L As List = Screens.RunMethod("getScreensForRectangle",Array(Rect2d)) If L.Size = 0 Then Return fx.Screens.Get(0) Return L.Get(0) End Sub Public Sub GetRectDblFromForm(F As Form) As RectDbl Dim R As RectDbl R.Initialize R.Left = F.WindowLeft R.Top = F.WindowTop R.Width = F.WindowWidth R.Height = F.WindowHeight Return R End Sub Public Sub CreateRectDbl (Left As Double, Top As Double, Width As Double, Height As Double) As RectDbl Dim t1 As RectDbl t1.Initialize t1.Left = Left t1.Top = Top t1.Width = Width t1.Height = Height Return t1 End Sub Sub btnFileDialog_Click 'fc.Initialize 'fc.InitialDirectory = "C:\Users\rfresh1011\Documents\3DGarmin430\" 'fc.setExtensionFilter("ForeFlight2", Array As String("*.fpl")) 'f = fc.ShowOpen(MainForm) End Sub