refactored class out of frmmain

This commit is contained in:
David Sparer
2017-02-06 15:30:59 -07:00
parent 2b2e01f3d1
commit afbc580ae6
3 changed files with 59 additions and 61 deletions

View File

@@ -0,0 +1,56 @@
using System.Drawing;
using System.Windows.Forms;
namespace mRemoteNG.UI.Forms
{
public class FullscreenHandler
{
private readonly Form _handledForm;
private FormWindowState _savedWindowState;
private FormBorderStyle _savedBorderStyle;
private Rectangle _savedBounds;
private bool _value;
public bool Value
{
get
{
return _value;
}
set
{
if (_value == value) return;
if (!_value)
EnterFullscreen();
else
ExitFullscreen();
_value = value;
}
}
public FullscreenHandler(Form handledForm)
{
_handledForm = handledForm;
}
private void EnterFullscreen()
{
_savedBorderStyle = _handledForm.FormBorderStyle;
_savedWindowState = _handledForm.WindowState;
_savedBounds = _handledForm.Bounds;
_handledForm.FormBorderStyle = FormBorderStyle.None;
if (_handledForm.WindowState == FormWindowState.Maximized)
{
_handledForm.WindowState = FormWindowState.Normal;
}
_handledForm.WindowState = FormWindowState.Maximized;
}
private void ExitFullscreen()
{
_handledForm.FormBorderStyle = _savedBorderStyle;
_handledForm.WindowState = _savedWindowState;
_handledForm.Bounds = _savedBounds;
}
}
}

View File

@@ -45,7 +45,7 @@ namespace mRemoteNG.UI.Forms
private bool _showFullPathInTitle;
private ConnectionInfo _selectedConnection;
private SystemMenu _systemMenu;
internal Fullscreen _fullscreen { get; set; }
internal FullscreenHandler _fullscreen { get; set; }
private ConnectionTreeWindow ConnectionTreeWindow { get; set; }
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
private readonly string _credentialFilePath = Path.Combine(CredentialsFileInfo.CredentialsPath, CredentialsFileInfo.CredentialsFile);
@@ -57,7 +57,7 @@ namespace mRemoteNG.UI.Forms
{
_showFullPathInTitle = Settings.Default.ShowCompleteConsPathInTitle;
InitializeComponent();
_fullscreen = new Fullscreen(this);
_fullscreen = new FullscreenHandler(this);
pnlDock.Theme = new VS2012LightTheme();
}
@@ -125,65 +125,6 @@ namespace mRemoteNG.UI.Forms
UpdateWindowTitle();
}
}
internal class Fullscreen
{
public Fullscreen(Form handledForm)
{
_handledForm = handledForm;
}
private readonly Form _handledForm;
private FormWindowState _savedWindowState;
private FormBorderStyle _savedBorderStyle;
private Rectangle _savedBounds;
private bool _value;
public bool Value
{
get
{
return _value;
}
set
{
if (_value == value)
{
return;
}
if (!_value)
{
EnterFullscreen();
}
else
{
ExitFullscreen();
}
_value = value;
}
}
private void EnterFullscreen()
{
_savedBorderStyle = _handledForm.FormBorderStyle;
_savedWindowState = _handledForm.WindowState;
_savedBounds = _handledForm.Bounds;
_handledForm.FormBorderStyle = FormBorderStyle.None;
if (_handledForm.WindowState == FormWindowState.Maximized)
{
_handledForm.WindowState = FormWindowState.Normal;
}
_handledForm.WindowState = FormWindowState.Maximized;
}
private void ExitFullscreen()
{
_handledForm.FormBorderStyle = _savedBorderStyle;
_handledForm.WindowState = _savedWindowState;
_handledForm.Bounds = _savedBounds;
}
}
#endregion
#region Startup & Shutdown

View File

@@ -346,6 +346,7 @@
<Compile Include="UI\Forms\frmOptions.Designer.cs">
<DependentUpon>frmOptions.cs</DependentUpon>
</Compile>
<Compile Include="UI\Forms\FullscreenHandler.cs" />
<Compile Include="UI\Forms\Input\input.cs" />
<Compile Include="UI\Forms\OptionsPages\AdvancedPage.Designer.cs">
<DependentUpon>AdvancedPage.cs</DependentUpon>