From 94a6e9a886d05c968182c108f6a67debd181ff5c Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Thu, 22 Dec 2016 10:01:20 -0500 Subject: [PATCH] code clean up around startup / frmMain Slightly related to #298 --- mRemoteV1/App/Startup.cs | 43 ++++++------------- .../Config/Settings/LayoutSettingsLoader.cs | 2 +- mRemoteV1/UI/Forms/frmMain.cs | 23 +++++++++- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/mRemoteV1/App/Startup.cs b/mRemoteV1/App/Startup.cs index 163669376..e78376c9e 100644 --- a/mRemoteV1/App/Startup.cs +++ b/mRemoteV1/App/Startup.cs @@ -1,11 +1,4 @@ -using mRemoteNG.App.Info; -using mRemoteNG.App.Update; -using mRemoteNG.Config.Connections; -using mRemoteNG.Connection; -using mRemoteNG.Messages; -using mRemoteNG.Tools; -using mRemoteNG.UI.Forms; -using System; +using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; @@ -14,9 +7,15 @@ using System.IO; using System.Management; using System.Threading; using System.Windows.Forms; +using mRemoteNG.App.Info; +using mRemoteNG.App.Update; +using mRemoteNG.Config.Connections; using mRemoteNG.Config.Connections.Multiuser; +using mRemoteNG.Connection; +using mRemoteNG.Messages; +using mRemoteNG.Tools; using mRemoteNG.UI; -using WeifenLuo.WinFormsUI.Docking; +using mRemoteNG.UI.Forms; namespace mRemoteNG.App { @@ -47,24 +46,6 @@ namespace mRemoteNG.App DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a=>"InhDefault"+a); } - public void SetDefaultLayout() - { - frmMain.Default.pnlDock.Visible = false; - - frmMain.Default.pnlDock.DockLeftPortion = frmMain.Default.pnlDock.Width * 0.2; - frmMain.Default.pnlDock.DockRightPortion = frmMain.Default.pnlDock.Width * 0.2; - frmMain.Default.pnlDock.DockTopPortion = frmMain.Default.pnlDock.Height * 0.25; - frmMain.Default.pnlDock.DockBottomPortion = frmMain.Default.pnlDock.Height * 0.25; - - Windows.TreePanel.Show(frmMain.Default.pnlDock, DockState.DockLeft); - Windows.ConfigPanel.Show(frmMain.Default.pnlDock); - Windows.ConfigPanel.DockTo(Windows.TreePanel.Pane, DockStyle.Bottom, -1); - - Windows.ScreenshotForm.Hide(); - - frmMain.Default.pnlDock.Visible = true; - } - private static void GetConnectionIcons() { var iPath = GeneralAppInfo.HomePath + "\\Icons\\"; @@ -116,7 +97,7 @@ namespace mRemoteNG.App { Logger.Instance.WarnFormat($"Error retrieving operating system information from WMI. {ex.Message}"); } - var osData = string.Join(" ", new string[] { osVersion, servicePack }); + var osData = string.Join(" ", osVersion, servicePack); return osData; } @@ -209,7 +190,7 @@ namespace mRemoteNG.App { if (frmMain.Default.InvokeRequired) { - frmMain.Default.Invoke(new AsyncCompletedEventHandler(GetUpdateInfoCompleted), new object[] { sender, e }); + frmMain.Default.Invoke(new AsyncCompletedEventHandler(GetUpdateInfoCompleted), sender, e); return; } @@ -223,7 +204,7 @@ namespace mRemoteNG.App } if (e.Error != null) { - throw (e.Error); + throw e.Error; } if (_appUpdate.IsUpdateAvailable()) @@ -311,7 +292,7 @@ namespace mRemoteNG.App Settings.Default.CustomConsPath = GeneralAppInfo.HomePath + "\\" + cmd[ConsParam]; return; } - else if (File.Exists(ConnectionsFileInfo.DefaultConnectionsPath + "\\" + cmd[ConsParam])) + if (File.Exists(ConnectionsFileInfo.DefaultConnectionsPath + "\\" + cmd[ConsParam])) { Settings.Default.LoadConsFromCustomLocation = true; Settings.Default.CustomConsPath = ConnectionsFileInfo.DefaultConnectionsPath + "\\" + cmd[ConsParam]; diff --git a/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs b/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs index 027cfb896..1728e8b97 100644 --- a/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs +++ b/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs @@ -48,7 +48,7 @@ namespace mRemoteNG.Config.Settings } else { - Startup.Instance.SetDefaultLayout(); + frmMain.Default.SetDefaultLayout(); } } catch (Exception ex) diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index 5d632e74f..2be6e1fac 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -164,7 +164,7 @@ namespace mRemoteNG.UI.Forms ConnectionTreeWindow = Windows.TreeForm; } - private void ApplyLanguage() + private void ApplyLanguage() { mMenFile.Text = Language.strMenuFile; mMenFileNew.Text = Language.strMenuNewConnectionFile; @@ -426,6 +426,7 @@ namespace mRemoteNG.UI.Forms private void mMenFile_DropDownOpening(object sender, EventArgs e) { var selectedNodeType = ConnectionTreeWindow.SelectedNode?.GetTreeNodeType(); + // ReSharper disable once SwitchStatementMissingSomeCases switch (selectedNodeType) { case TreeNodeType.Root: @@ -733,7 +734,7 @@ namespace mRemoteNG.UI.Forms MessageBoxIcon.Question); if (msgBoxResult == DialogResult.Yes) { - Startup.Instance.SetDefaultLayout(); + Default.SetDefaultLayout(); } } @@ -1201,6 +1202,24 @@ namespace mRemoteNG.UI.Forms _systemMenu.InsertMenuItem(_systemMenu.SystemMenuHandle, 0, SystemMenu.Flags.MF_POPUP | SystemMenu.Flags.MF_BYPOSITION, popMen, Language.strSendTo); _systemMenu.InsertMenuItem(_systemMenu.SystemMenuHandle, 1, SystemMenu.Flags.MF_BYPOSITION | SystemMenu.Flags.MF_SEPARATOR, IntPtr.Zero, null); } + + public void SetDefaultLayout() + { + Default.pnlDock.Visible = false; + + Default.pnlDock.DockLeftPortion = Default.pnlDock.Width * 0.2; + Default.pnlDock.DockRightPortion = Default.pnlDock.Width * 0.2; + Default.pnlDock.DockTopPortion = Default.pnlDock.Height * 0.25; + Default.pnlDock.DockBottomPortion = Default.pnlDock.Height * 0.25; + + Windows.TreePanel.Show(Default.pnlDock, DockState.DockLeft); + Windows.ConfigPanel.Show(Default.pnlDock); + Windows.ConfigPanel.DockTo(Windows.TreePanel.Pane, DockStyle.Bottom, -1); + + Windows.ScreenshotForm.Hide(); + + Default.pnlDock.Visible = true; + } #endregion #region Events