diff --git a/Base/Base.vbproj b/Base/Base.vbproj
index 66cdaafa..f876f98b 100644
--- a/Base/Base.vbproj
+++ b/Base/Base.vbproj
@@ -57,6 +57,7 @@
+
@@ -99,6 +100,7 @@
True
+
diff --git a/Base/ScreenEx.vb b/Base/ScreenEx.vb
new file mode 100644
index 00000000..6921e20c
--- /dev/null
+++ b/Base/ScreenEx.vb
@@ -0,0 +1,48 @@
+Imports System
+Imports System.Drawing
+Imports System.Windows.Forms
+
+Public Class ScreenEx
+ Public Shared Function GetLocationWithinScreen(pLocation As Point) As Point?
+ For Each screen As Screen In Screen.AllScreens
+ If screen.Bounds.Contains(pLocation) Then
+ Return New Point(pLocation.X - screen.Bounds.Left, pLocation.Y - screen.Bounds.Top)
+ End If
+ Next
+
+ Return Nothing
+ End Function
+
+ Public Shared Sub RestoreFormPosition(pForm As Form, pPosition As Point)
+ Dim oLocationWithinScreen As Point? = GetLocationWithinScreen(pPosition)
+
+ If oLocationWithinScreen Is Nothing Then
+ Dim oPrimaryScreen = Screen.PrimaryScreen
+ pForm.StartPosition = FormStartPosition.CenterScreen
+ Else
+ pForm.StartPosition = FormStartPosition.Manual
+ pForm.Location = pPosition
+ End If
+ End Sub
+
+ Public Shared Sub RestoreFormState(pForm As Form, pFormState As FormWindowState)
+ If pFormState = FormWindowState.Maximized Then
+ pForm.WindowState = FormWindowState.Normal
+ pForm.WindowState = FormWindowState.Maximized
+ ElseIf pFormState = FormWindowState.Minimized Then
+ pForm.WindowState = FormWindowState.Normal
+ pForm.WindowState = FormWindowState.Minimized
+ Else
+ pForm.WindowState = FormWindowState.Normal
+ End If
+ End Sub
+
+ Public Shared Sub RestoreFormState(pForm As Form, pFormState As String)
+ Dim oFormState As FormWindowState
+ If Not [Enum].TryParse(pFormState, oFormState) Then
+ oFormState = FormWindowState.Normal
+ End If
+
+ RestoreFormState(pForm, oFormState)
+ End Sub
+End Class