Fix issue MR-398 - Full Screen mode doesn't correctly make use of available space

This commit is contained in:
Riley McArdle
2013-03-19 23:20:49 -05:00
parent 317175bb03
commit 965f43a4c3
5 changed files with 44 additions and 60 deletions

View File

@@ -1,3 +1,4 @@
Fixed issue MR-398 - Full Screen mode doesn't correctly make use of available space
Fixed issue MR-406 - Items disappear from External Tools toolbar when accessing External Tools panel
Fixed issue MR-410 - Unhandled exception when clicking New button under Theme
Fixed new connections having a globe icon.

View File

@@ -80,7 +80,8 @@ Namespace Config
.Location = newBounds.Location
If My.Settings.MainFormKiosk = True Then
Tools.Misc.Fullscreen.EnterFullscreen()
.Fullscreen.Value = True
.mMenViewFullscreen.Checked = True
End If
If My.Settings.UseCustomPuttyPath Then

View File

@@ -25,7 +25,7 @@ Namespace Config
My.Settings.MainFormState = .WindowState
My.Settings.MainFormKiosk = Tools.Misc.Fullscreen.FullscreenActive
My.Settings.MainFormKiosk = .Fullscreen.Value
My.Settings.FirstStart = False
My.Settings.ResetPanels = False

View File

@@ -589,14 +589,10 @@ Public Class frmMain
End If
End Sub
Public Fullscreen As New Tools.Misc.Fullscreen(Me)
Private Sub mMenViewFullscreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mMenViewFullscreen.Click
If Tools.Misc.Fullscreen.FullscreenActive Then
Tools.Misc.Fullscreen.ExitFullscreen()
Me.mMenViewFullscreen.Checked = False
Else
Tools.Misc.Fullscreen.EnterFullscreen()
Me.mMenViewFullscreen.Checked = True
End If
Fullscreen.Value = Not Fullscreen.Value
mMenViewFullscreen.Checked = Fullscreen.Value
End Sub
#End Region

View File

@@ -297,62 +297,48 @@ Namespace Tools
End Class
Public Class Fullscreen
Private Shared winState As FormWindowState
Private Shared brdStyle As FormBorderStyle
Private Shared topMost As Boolean
Private Shared bounds As Rectangle
Public Sub New(ByVal handledForm As Form)
_handledForm = handledForm
End Sub
Public Shared targetForm As Form = frmMain
Public Shared FullscreenActive As Boolean = False
Private ReadOnly _handledForm As Form
Private _savedWindowState As FormWindowState
Private _savedBorderStyle As FormBorderStyle
Private _savedBounds As Rectangle
Public Shared Sub EnterFullscreen()
Try
If Not FullscreenActive Then
FullscreenActive = True
Save()
targetForm.WindowState = FormWindowState.Maximized
targetForm.FormBorderStyle = FormBorderStyle.None
SetWinFullScreen(targetForm.Handle)
Private _value As Boolean = False
Public Property Value() As Boolean
Get
Return _value
End Get
Set(value As Boolean)
If _value = value Then Return
If Not _value Then
EnterFullscreen()
Else
ExitFullscreen()
End If
Catch ex As Exception
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Entering Fullscreen failed" & vbNewLine & ex.Message, True)
End Try
_value = value
End Set
End Property
Private Sub EnterFullscreen()
_savedBorderStyle = _handledForm.FormBorderStyle
_savedWindowState = _handledForm.WindowState
_savedBounds = _handledForm.Bounds
_handledForm.TopMost = True
_handledForm.FormBorderStyle = FormBorderStyle.None
If _handledForm.WindowState = FormWindowState.Maximized Then
_handledForm.WindowState = FormWindowState.Normal
End If
_handledForm.WindowState = FormWindowState.Maximized
End Sub
Public Shared Sub Save()
winState = targetForm.WindowState
brdStyle = targetForm.FormBorderStyle
bounds = targetForm.Bounds
End Sub
Public Shared Sub ExitFullscreen()
Try
targetForm.WindowState = winState
targetForm.FormBorderStyle = brdStyle
targetForm.Bounds = bounds
FullscreenActive = False
Catch ex As Exception
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Exiting Fullscreen failed" & vbNewLine & ex.Message, True)
End Try
End Sub
<DllImport("user32.dll", EntryPoint:="GetSystemMetrics")> Public Shared Function GetSystemMetrics(ByVal which As Integer) As Integer
End Function
<DllImport("user32.dll")> Public Shared Sub SetWindowPos(ByVal hwnd As IntPtr, ByVal hwndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal flags As UInteger)
End Sub
Private Shared HWND_TOP As IntPtr = IntPtr.Zero
Private Const SWP_SHOWWINDOW As Integer = 64
' 0<>0040
Public Shared Sub SetWinFullScreen(ByVal hwnd As IntPtr)
Try
Dim curScreen As Screen = Screen.FromHandle(targetForm.Handle)
SetWindowPos(hwnd, HWND_TOP, curScreen.Bounds.Left, curScreen.Bounds.Top, curScreen.Bounds.Right, curScreen.Bounds.Bottom, SWP_SHOWWINDOW)
Catch ex As Exception
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SetWindowPos failed" & vbNewLine & ex.Message, True)
End Try
Private Sub ExitFullscreen()
_handledForm.FormBorderStyle = _savedBorderStyle
_handledForm.WindowState = _savedWindowState
_handledForm.Bounds = _savedBounds
End Sub
End Class