diff --git a/SharedLibraryNG/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SharedLibraryNG/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 7588ac976..bbaa4fbc5 100644 Binary files a/SharedLibraryNG/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/SharedLibraryNG/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/TestProject/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TestProject/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 7cbb75911..c26ebc5fe 100644 Binary files a/TestProject/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/TestProject/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/TestProject/obj/Debug/mRemoteNG_Accessor.exe b/TestProject/obj/Debug/mRemoteNG_Accessor.exe index dbdb5524c..a70473851 100644 Binary files a/TestProject/obj/Debug/mRemoteNG_Accessor.exe and b/TestProject/obj/Debug/mRemoteNG_Accessor.exe differ diff --git a/TestProject/obj/Debug/mRemoteNG_Accessor.pdb b/TestProject/obj/Debug/mRemoteNG_Accessor.pdb index ee7a1d3a9..42b9c4826 100644 Binary files a/TestProject/obj/Debug/mRemoteNG_Accessor.pdb and b/TestProject/obj/Debug/mRemoteNG_Accessor.pdb differ diff --git a/mRemoteV1.ConvertedToC#/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache b/mRemoteV1.ConvertedToC#/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache index a14dcf842..a66e27a8c 100644 Binary files a/mRemoteV1.ConvertedToC#/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache and b/mRemoteV1.ConvertedToC#/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/mRemoteV1.ConvertedToC#/obj/Debug Portable/Interop.WFICALib.dll b/mRemoteV1.ConvertedToC#/obj/Debug Portable/Interop.WFICALib.dll index 044857dfa..869205682 100644 Binary files a/mRemoteV1.ConvertedToC#/obj/Debug Portable/Interop.WFICALib.dll and b/mRemoteV1.ConvertedToC#/obj/Debug Portable/Interop.WFICALib.dll differ diff --git a/mRemoteV1.ConvertedToC#/obj/Debug Portable/mRemoteV1.Converted.csproj.ResolveComReference.cache b/mRemoteV1.ConvertedToC#/obj/Debug Portable/mRemoteV1.Converted.csproj.ResolveComReference.cache index 1da81edaa..dd2d9b9f0 100644 Binary files a/mRemoteV1.ConvertedToC#/obj/Debug Portable/mRemoteV1.Converted.csproj.ResolveComReference.cache and b/mRemoteV1.ConvertedToC#/obj/Debug Portable/mRemoteV1.Converted.csproj.ResolveComReference.cache differ diff --git a/mRemoteV1.v12.suo b/mRemoteV1.v12.suo index 373d8f97c..228f145f0 100644 Binary files a/mRemoteV1.v12.suo and b/mRemoteV1.v12.suo differ diff --git a/mRemoteV1/CS/App/App.Runtime.cs b/mRemoteV1/CS/App/App.Runtime.cs index aabd6fc86..389d0bdf6 100644 --- a/mRemoteV1/CS/App/App.Runtime.cs +++ b/mRemoteV1/CS/App/App.Runtime.cs @@ -43,7 +43,7 @@ namespace mRemoteNG.App public static frmMain MainForm {get; set;} private static Connection.List _connectionList; - public static List ConnectionList + public static Connection.List ConnectionList { get { @@ -56,7 +56,7 @@ namespace mRemoteNG.App } private static Connection.List _previousConnectionList; - public static List PreviousConnectionList + public static Connection.List PreviousConnectionList { get { @@ -320,104 +320,101 @@ namespace mRemoteNG.App { try { - switch (windowType) - { - case UI.Window.Type.About: - if (aboutForm == null || aboutForm.IsDisposed) - { - aboutForm = new UI.Window.About(aboutPanel); - aboutPanel = aboutForm; - } - - aboutForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.ActiveDirectoryImport: - if (adimportForm == null || adimportForm.IsDisposed) - { - adimportForm = new UI.Window.ActiveDirectoryImport(adimportPanel); - adimportPanel = adimportForm; - } - - adimportPanel.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.Options: - using (OptionsForm optionsForm = new OptionsForm()) - { - optionsForm.ShowDialog(frmMain); - } - - break; - case UI.Window.Type.SSHTransfer: - sshtransferForm = new UI.Window.SSHTransfer(sshtransferPanel); - sshtransferPanel = sshtransferForm; - - sshtransferForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.Update: - if (updateForm == null || updateForm.IsDisposed) - { - updateForm = new UI.Window.Update(updatePanel); - updatePanel = updateForm; - } - - updateForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.Help: - if (helpForm == null || helpForm.IsDisposed) - { - helpForm = new UI.Window.Help(helpPanel); - helpPanel = helpForm; - } - - helpForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.ExternalApps: - if (externalappsForm == null || externalappsForm.IsDisposed) - { - externalappsForm = new UI.Window.ExternalTools(externalappsPanel); - externalappsPanel = externalappsForm; - } - - externalappsForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.PortScan: - portscanForm = new UI.Window.PortScan(portscanPanel, portScanImport); - portscanPanel = portscanForm; - - portscanForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.UltraVNCSC: - if (ultravncscForm == null || ultravncscForm.IsDisposed) - { - ultravncscForm = new UI.Window.UltraVNCSC(ultravncscPanel); - ultravncscPanel = ultravncscForm; - } - - ultravncscForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.ComponentsCheck: - if (componentscheckForm == null || componentscheckForm.IsDisposed) - { - componentscheckForm = new UI.Window.ComponentsCheck(componentscheckPanel); - componentscheckPanel = componentscheckForm; - } - - componentscheckForm.Show(frmMain.Default.pnlDock); - break; - case UI.Window.Type.Announcement: - if (AnnouncementForm == null || AnnouncementForm.IsDisposed) - { - AnnouncementForm = new UI.Window.Announcement(AnnouncementPanel); - AnnouncementPanel = AnnouncementForm; - } - - AnnouncementForm.Show(frmMain.Default.pnlDock); - break; - } + if (windowType.Equals(UI.Window.Type.About)) + { + if (aboutForm == null || aboutForm.IsDisposed) + { + aboutForm = new UI.Window.About(aboutPanel); + aboutPanel = aboutForm; + } + aboutForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.ActiveDirectoryImport)) + { + if (adimportForm == null || adimportForm.IsDisposed) + { + adimportForm = new UI.Window.ActiveDirectoryImport(adimportPanel); + adimportPanel = adimportForm; + } + adimportPanel.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.Options)) + { + using (OptionsForm optionsForm = new OptionsForm()) + { + optionsForm.ShowDialog(frmMain); + } + } + else if (windowType.Equals(UI.Window.Type.SSHTransfer)) + { + sshtransferForm = new UI.Window.SSHTransfer(sshtransferPanel); + sshtransferPanel = sshtransferForm; + sshtransferForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.Update)) + { + if (updateForm == null || updateForm.IsDisposed) + { + updateForm = new UI.Window.Update(updatePanel); + updatePanel = updateForm; + } + updateForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.Help)) + { + if (helpForm == null || helpForm.IsDisposed) + { + helpForm = new UI.Window.Help(helpPanel); + helpPanel = helpForm; + } + helpForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.ExternalApps)) + { + if (externalappsForm == null || externalappsForm.IsDisposed) + { + externalappsForm = new UI.Window.ExternalTools(externalappsPanel); + externalappsPanel = externalappsForm; + } + externalappsForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.PortScan)) + { + portscanForm = new UI.Window.PortScan(portscanPanel, portScanImport); + portscanPanel = portscanForm; + portscanForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.UltraVNCSC)) + { + if (ultravncscForm == null || ultravncscForm.IsDisposed) + { + ultravncscForm = new UI.Window.UltraVNCSC(ultravncscPanel); + ultravncscPanel = ultravncscForm; + } + ultravncscForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.ComponentsCheck)) + { + if (componentscheckForm == null || componentscheckForm.IsDisposed) + { + componentscheckForm = new UI.Window.ComponentsCheck(componentscheckPanel); + componentscheckPanel = componentscheckForm; + } + componentscheckForm.Show(frmMain.Default.pnlDock); + } + else if (windowType.Equals(UI.Window.Type.Announcement)) + { + if (AnnouncementForm == null || AnnouncementForm.IsDisposed) + { + AnnouncementForm = new UI.Window.Announcement(AnnouncementPanel); + AnnouncementPanel = AnnouncementForm; + } + AnnouncementForm.Show(frmMain.Default.pnlDock); + } } catch (Exception ex) { - MessageCollector.AddMessage(MessageClass.ErrorMsg, "App.Runtime.Windows.Show() failed." + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "App.Runtime.Windows.Show() failed." + Constants.vbNewLine + ex.Message, true); } } @@ -715,7 +712,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage("GetUpdateInfoCompleted() failed.", ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("GetUpdateInfoCompleted() failed.", ex, MessageClass.ErrorMsg, true); } } @@ -762,7 +759,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage("GetAnnouncementInfoCompleted() failed.", ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("GetAnnouncementInfoCompleted() failed.", ex, MessageClass.ErrorMsg, true); } } @@ -879,7 +876,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strCommandLineArgsCouldNotBeParsed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strCommandLineArgsCouldNotBeParsed + Constants.vbNewLine + ex.Message); } } @@ -944,7 +941,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strSettingsCouldNotBeSavedOrTrayDispose + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strSettingsCouldNotBeSavedOrTrayDispose + Constants.vbNewLine + ex.Message, true); } } @@ -960,7 +957,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(MessageClass.ErrorMsg, "The update could not be started." + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "The update could not be started." + Constants.vbNewLine + ex.Message, true); } } @@ -1159,7 +1156,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t add panel" + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t add panel" + Constants.vbNewLine + ex.Message); return null; } } @@ -1180,7 +1177,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t rename panel" + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t rename panel" + Constants.vbNewLine + ex.Message); } } @@ -1205,7 +1202,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t enumerate screens" + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t enumerate screens" + Constants.vbNewLine + ex.Message); } } @@ -1292,7 +1289,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strCouldNotCreateNewConnectionsFile, ex, MessageClass.ErrorMsg); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strCouldNotCreateNewConnectionsFile, ex, MessageClass.ErrorMsg); } } @@ -1415,7 +1412,7 @@ namespace mRemoteNG.App { if (My.Settings.Default.UseSQLServer) { - MessageCollector.AddExceptionMessage(My.Language.strLoadFromSqlFailed, ex); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strLoadFromSqlFailed, ex); string commandButtons = string.Join("|", new[] {My.Language.strCommandTryAgain, My.Language.strCommandOpenConnectionFile, string.Format(My.Language.strCommandExitProgram, System.Windows.Forms.Application.ProductName)}); cTaskDialog.ShowCommandBox(System.Windows.Forms.Application.ProductName, My.Language.strLoadFromSqlFailed, My.Language.strLoadFromSqlFailedContent, Misc.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, eSysIcons.Error, null); switch (cTaskDialog.CommandButtonResult) @@ -1436,12 +1433,12 @@ namespace mRemoteNG.App { if (ex is FileNotFoundException&& !withDialog) { - MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoad.ConnectionFileName), ex, MessageClass.InformationMsg); + Runtime.MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoad.ConnectionFileName), ex, MessageClass.InformationMsg); NewConnections(System.Convert.ToString(connectionsLoad.ConnectionFileName)); return ; } - MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotBeLoaded, connectionsLoad.ConnectionFileName), ex); + Runtime.MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotBeLoaded, connectionsLoad.ConnectionFileName), ex); if (!(connectionsLoad.ConnectionFileName == GetStartupConnectionFileName())) { LoadConnections(withDialog, update); @@ -1473,7 +1470,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg); throw; } } @@ -1601,7 +1598,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionsFileCouldNotBeSaved + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionsFileCouldNotBeSaved + Constants.vbNewLine + ex.Message); } finally { @@ -1667,7 +1664,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex); + Runtime.MessageCollector.AddExceptionMessage(string.Format(My.Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex); } finally { @@ -1718,7 +1715,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strQuickConnectFailed, ex, MessageClass.ErrorMsg); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strQuickConnectFailed, ex, MessageClass.ErrorMsg); return null; } } @@ -1731,7 +1728,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1764,7 +1761,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1776,7 +1773,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1788,7 +1785,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1800,7 +1797,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1812,7 +1809,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -1822,7 +1819,7 @@ namespace mRemoteNG.App { if (newConnectionInfo.Hostname == "" && newConnectionInfo.Protocol != Connection.Protocol.Protocols.IntApp) { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strConnectionOpenFailedNoHostname); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strConnectionOpenFailedNoHostname); return; } @@ -1995,7 +1992,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed + Constants.vbNewLine + ex.Message); } } @@ -2021,7 +2018,7 @@ namespace mRemoteNG.App { try { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strProtocolEventDisconnected, DisconnectedMessage), true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strProtocolEventDisconnected, DisconnectedMessage), true); Connection.Protocol.Base Prot = sender; if (Prot.InterfaceControl.Info.Protocol == Connection.Protocol.Protocols.RDP) @@ -2033,18 +2030,18 @@ namespace mRemoteNG.App { if (!string.IsNullOrEmpty(ReasonDescription)) { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strRdpDisconnected + Constants.vbNewLine + ReasonDescription + Constants.vbNewLine + string.Format(My.Language.strErrorCode, ReasonCode)); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strRdpDisconnected + Constants.vbNewLine + ReasonDescription + Constants.vbNewLine + string.Format(My.Language.strErrorCode, ReasonCode)); } else { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strRdpDisconnected + Constants.vbNewLine + string.Format(My.Language.strErrorCode, ReasonCode)); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strRdpDisconnected + Constants.vbNewLine + string.Format(My.Language.strErrorCode, ReasonCode)); } } } } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strProtocolEventDisconnectFailed, ex.Message), true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strProtocolEventDisconnectFailed, ex.Message), true); } } @@ -2054,9 +2051,9 @@ namespace mRemoteNG.App { Connection.Protocol.Base Prot = sender; - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnenctionCloseEvent, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnenctionCloseEvent, true); - MessageCollector.AddMessage(Messages.MessageClass.ReportMsg, string.Format(My.Language.strConnenctionClosedByUser, Prot.InterfaceControl.Info.Hostname, Prot.InterfaceControl.Info.Protocol.ToString(), (new Microsoft.VisualBasic.ApplicationServices.User()).Name)); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ReportMsg, string.Format(My.Language.strConnenctionClosedByUser, Prot.InterfaceControl.Info.Hostname, Prot.InterfaceControl.Info.Protocol.ToString(), (new Microsoft.VisualBasic.ApplicationServices.User()).Name)); Prot.InterfaceControl.Info.OpenConnections.Remove(Prot); @@ -2076,7 +2073,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnenctionCloseEventFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnenctionCloseEventFailed + Constants.vbNewLine + ex.Message, true); } } @@ -2084,15 +2081,15 @@ namespace mRemoteNG.App { mRemoteNG.Connection.Protocol.Base prot = sender; - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnectionEventConnected, true); - MessageCollector.AddMessage(Messages.MessageClass.ReportMsg, string.Format(My.Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol.ToString(), (new Microsoft.VisualBasic.ApplicationServices.User()).Name, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField)); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnectionEventConnected, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ReportMsg, string.Format(My.Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol.ToString(), (new Microsoft.VisualBasic.ApplicationServices.User()).Name, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField)); } public static void Prot_Event_ErrorOccured(object sender, string ErrorMessage) { try { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnectionEventErrorOccured, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strConnectionEventErrorOccured, true); Connection.Protocol.Base Prot = sender; @@ -2100,13 +2097,13 @@ namespace mRemoteNG.App { if (ErrorMessage > -1) { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strConnectionRdpErrorDetail, ErrorMessage, Connection.Protocol.RDP.FatalErrors.GetError(ErrorMessage))); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strConnectionRdpErrorDetail, ErrorMessage, Connection.Protocol.RDP.FatalErrors.GetError(ErrorMessage))); } } } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionEventConnectionFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionEventConnectionFailed + Constants.vbNewLine + ex.Message, true); } } #endregion @@ -2177,7 +2174,7 @@ namespace mRemoteNG.App } catch (Exception) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLogWriteToFileFailed); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLogWriteToFileFailed); } } @@ -2198,7 +2195,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLogWriteToFileFinalLocationFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLogWriteToFileFinalLocationFailed + Constants.vbNewLine + ex.Message, true); return false; } finally @@ -2276,7 +2273,7 @@ namespace mRemoteNG.App { if (UpdateAvailable == true) { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strSqlUpdateCheckUpdateAvailable, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strSqlUpdateCheckUpdateAvailable, true); LoadConnectionsBG(); } } diff --git a/mRemoteV1/CS/App/App.Update.cs b/mRemoteV1/CS/App/App.Update.cs index c3d07630a..fd7475379 100644 --- a/mRemoteV1/CS/App/App.Update.cs +++ b/mRemoteV1/CS/App/App.Update.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,8 +8,6 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.IO; using System.Net; using System.ComponentModel; @@ -22,614 +19,613 @@ using System.Reflection; namespace mRemoteNG.App { public class Update + { + #region Events + private AsyncCompletedEventHandler GetUpdateInfoCompletedEventEvent; + public event AsyncCompletedEventHandler GetUpdateInfoCompletedEvent { -#region Events - private AsyncCompletedEventHandler GetUpdateInfoCompletedEventEvent; - public event AsyncCompletedEventHandler GetUpdateInfoCompletedEvent + add { - add - { - GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetUpdateInfoCompletedEventEvent, value); - } - remove - { - GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetUpdateInfoCompletedEventEvent, value); - } + GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetUpdateInfoCompletedEventEvent, value); } - - private AsyncCompletedEventHandler GetChangeLogCompletedEventEvent; - public event AsyncCompletedEventHandler GetChangeLogCompletedEvent + remove { - add - { - GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetChangeLogCompletedEventEvent, value); - } - remove - { - GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetChangeLogCompletedEventEvent, value); - } + GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetUpdateInfoCompletedEventEvent, value); } + } - private AsyncCompletedEventHandler GetAnnouncementInfoCompletedEventEvent; - public event AsyncCompletedEventHandler GetAnnouncementInfoCompletedEvent + private AsyncCompletedEventHandler GetChangeLogCompletedEventEvent; + public event AsyncCompletedEventHandler GetChangeLogCompletedEvent + { + add { - add - { - GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetAnnouncementInfoCompletedEventEvent, value); - } - remove - { - GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetAnnouncementInfoCompletedEventEvent, value); - } + GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetChangeLogCompletedEventEvent, value); } - - private DownloadProgressChangedEventHandler DownloadUpdateProgressChangedEventEvent; - public event DownloadProgressChangedEventHandler DownloadUpdateProgressChangedEvent + remove { - add - { - DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler) System.Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value); - } - remove - { - DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler) System.Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value); - } + GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetChangeLogCompletedEventEvent, value); } + } - private AsyncCompletedEventHandler DownloadUpdateCompletedEventEvent; - public event AsyncCompletedEventHandler DownloadUpdateCompletedEvent + private AsyncCompletedEventHandler GetAnnouncementInfoCompletedEventEvent; + public event AsyncCompletedEventHandler GetAnnouncementInfoCompletedEvent + { + add { - add - { - DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(DownloadUpdateCompletedEventEvent, value); - } - remove - { - DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(DownloadUpdateCompletedEventEvent, value); - } + GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(GetAnnouncementInfoCompletedEventEvent, value); } - -#endregion - -#region Public Properties - private UpdateInfo _currentUpdateInfo; -public UpdateInfo CurrentUpdateInfo + remove { - get - { - return _currentUpdateInfo; - } + GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(GetAnnouncementInfoCompletedEventEvent, value); } + } - private string _changeLog; -public string ChangeLog + private DownloadProgressChangedEventHandler DownloadUpdateProgressChangedEventEvent; + public event DownloadProgressChangedEventHandler DownloadUpdateProgressChangedEvent + { + add { - get - { - return _changeLog; - } + DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler) System.Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value); } - - private AnnouncementInfo _currentAnnouncementInfo; -public AnnouncementInfo CurrentAnnouncementInfo + remove { - get - { - return _currentAnnouncementInfo; - } + DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler) System.Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value); } + } -public bool IsGetUpdateInfoRunning + private AsyncCompletedEventHandler DownloadUpdateCompletedEventEvent; + public event AsyncCompletedEventHandler DownloadUpdateCompletedEvent + { + add { - get + DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Combine(DownloadUpdateCompletedEventEvent, value); + } + remove + { + DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler) System.Delegate.Remove(DownloadUpdateCompletedEventEvent, value); + } + } + #endregion + + #region Public Properties + private UpdateInfo _currentUpdateInfo; + public UpdateInfo CurrentUpdateInfo + { + get + { + return _currentUpdateInfo; + } + } + + private string _changeLog; + public string ChangeLog + { + get + { + return _changeLog; + } + } + + private AnnouncementInfo _currentAnnouncementInfo; + public AnnouncementInfo CurrentAnnouncementInfo + { + get + { + return _currentAnnouncementInfo; + } + } + + public bool IsGetUpdateInfoRunning + { + get + { + if (_getUpdateInfoThread != null) { - if (_getUpdateInfoThread != null) + if (_getUpdateInfoThread.IsAlive) { - if (_getUpdateInfoThread.IsAlive) - { - return true; - } + return true; } - return false; } + return false; } + } -public bool IsGetChangeLogRunning + public bool IsGetChangeLogRunning + { + get { - get + if (_getChangeLogThread != null) { - if (_getChangeLogThread != null) + if (_getChangeLogThread.IsAlive) { - if (_getChangeLogThread.IsAlive) - { - return true; - } + return true; } - return false; } + return false; } + } -public bool IsGetAnnouncementInfoRunning + public bool IsGetAnnouncementInfoRunning + { + get { - get + if (_getAnnouncementInfoThread != null) { - if (_getAnnouncementInfoThread != null) + if (_getAnnouncementInfoThread.IsAlive) { - if (_getAnnouncementInfoThread.IsAlive) - { - return true; - } + return true; } - return false; } + return false; } + } -public bool IsDownloadUpdateRunning + public bool IsDownloadUpdateRunning + { + get { - get + return (_downloadUpdateWebClient != null); + } + } + #endregion + + #region Public Methods + public Update() + { + SetProxySettings(); + } + + public void SetProxySettings() + { + SetProxySettings(System.Convert.ToBoolean(My.Settings.Default.UpdateUseProxy), System.Convert.ToString(My.Settings.Default.UpdateProxyAddress), System.Convert.ToInt32(My.Settings.Default.UpdateProxyPort), System.Convert.ToBoolean(My.Settings.Default.UpdateProxyUseAuthentication), System.Convert.ToString(My.Settings.Default.UpdateProxyAuthUser), Security.Crypt.Decrypt(System.Convert.ToString(My.Settings.Default.UpdateProxyAuthPass), Info.General.EncryptionKey)); + } + + public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password) + { + if (useProxy && !string.IsNullOrEmpty(address)) + { + if (!(port == 0)) { - return (_downloadUpdateWebClient != null); - } - } -#endregion - -#region Public Methods - public Update() - { - SetProxySettings(); - } - - public void SetProxySettings() - { - SetProxySettings(System.Convert.ToBoolean(My.Settings.Default.UpdateUseProxy), System.Convert.ToString(My.Settings.Default.UpdateProxyAddress), System.Convert.ToInt32(My.Settings.Default.UpdateProxyPort), System.Convert.ToBoolean(My.Settings.Default.UpdateProxyUseAuthentication), System.Convert.ToString(My.Settings.Default.UpdateProxyAuthUser), Security.Crypt.Decrypt(System.Convert.ToString(My.Settings.Default.UpdateProxyAuthPass), Info.General.EncryptionKey)); - } - - public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password) - { - if (useProxy && !string.IsNullOrEmpty(address)) - { - if (!(port == 0)) - { - _webProxy = new WebProxy(address, port); - } - else - { - _webProxy = new WebProxy(address); - } - - if (useAuthentication) - { - _webProxy.Credentials = new NetworkCredential(username, password); - } - else - { - _webProxy.Credentials = null; - } + _webProxy = new WebProxy(address, port); } else { - _webProxy = null; + _webProxy = new WebProxy(address); + } + + if (useAuthentication) + { + _webProxy.Credentials = new NetworkCredential(username, password); + } + else + { + _webProxy.Credentials = null; } } - - public bool IsUpdateAvailable() + else { - if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) - { - return false; - } - - return _currentUpdateInfo.Version > (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version; + _webProxy = null; } + } - public bool IsAnnouncementAvailable() + public bool IsUpdateAvailable() + { + if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) { - if (_currentAnnouncementInfo == null || (!_currentAnnouncementInfo.IsValid || string.IsNullOrEmpty(_currentAnnouncementInfo.Name))) - { - return false; - } - - return !(_currentAnnouncementInfo.Name == My.Settings.Default.LastAnnouncement); + return false; } + + return _currentUpdateInfo.Version > (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version; + } - public void GetUpdateInfoAsync() + public bool IsAnnouncementAvailable() + { + if (_currentAnnouncementInfo == null || (!_currentAnnouncementInfo.IsValid || string.IsNullOrEmpty(_currentAnnouncementInfo.Name))) { - if (IsGetUpdateInfoRunning) - { - _getUpdateInfoThread.Abort(); - } - - _getUpdateInfoThread = new Thread(new System.Threading.ThreadStart(GetUpdateInfo)); - _getUpdateInfoThread.SetApartmentState(ApartmentState.STA); - _getUpdateInfoThread.IsBackground = true; - _getUpdateInfoThread.Start(); + return false; } + + return !(_currentAnnouncementInfo.Name == My.Settings.Default.LastAnnouncement); + } - public void GetChangeLogAsync() + public void GetUpdateInfoAsync() + { + if (IsGetUpdateInfoRunning) { - if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) - { - throw (new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().")); - } - - if (IsGetChangeLogRunning) - { - _getChangeLogThread.Abort(); - } - - _getChangeLogThread = new Thread(new System.Threading.ThreadStart(GetChangeLog)); - _getChangeLogThread.SetApartmentState(ApartmentState.STA); - _getChangeLogThread.IsBackground = true; - _getChangeLogThread.Start(); + _getUpdateInfoThread.Abort(); } + + _getUpdateInfoThread = new Thread(new System.Threading.ThreadStart(GetUpdateInfo)); + _getUpdateInfoThread.SetApartmentState(ApartmentState.STA); + _getUpdateInfoThread.IsBackground = true; + _getUpdateInfoThread.Start(); + } - public void GetAnnouncementInfoAsync() + public void GetChangeLogAsync() + { + if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) { - if (IsGetAnnouncementInfoRunning) - { - _getAnnouncementInfoThread.Abort(); - } - - _getAnnouncementInfoThread = new Thread(new System.Threading.ThreadStart(GetAnnouncementInfo)); - _getAnnouncementInfoThread.SetApartmentState(ApartmentState.STA); - _getAnnouncementInfoThread.IsBackground = true; - _getAnnouncementInfoThread.Start(); + throw (new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().")); } + + if (IsGetChangeLogRunning) + { + _getChangeLogThread.Abort(); + } + + _getChangeLogThread = new Thread(new System.Threading.ThreadStart(GetChangeLog)); + _getChangeLogThread.SetApartmentState(ApartmentState.STA); + _getChangeLogThread.IsBackground = true; + _getChangeLogThread.Start(); + } - public void DownloadUpdateAsync() + public void GetAnnouncementInfoAsync() + { + if (IsGetAnnouncementInfoRunning) + { + _getAnnouncementInfoThread.Abort(); + } + + _getAnnouncementInfoThread = new Thread(new System.Threading.ThreadStart(GetAnnouncementInfo)); + _getAnnouncementInfoThread.SetApartmentState(ApartmentState.STA); + _getAnnouncementInfoThread.IsBackground = true; + _getAnnouncementInfoThread.Start(); + } + + public void DownloadUpdateAsync() + { + if (_downloadUpdateWebClient != null) + { + throw (new InvalidOperationException("A previous call to DownloadUpdateAsync() is still in progress.")); + } + + if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) + { + throw (new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().")); + } + + _currentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "exe")); + DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, _currentUpdateInfo.UpdateFilePath); + } + #endregion + + #region Private Properties + private WebClient _downloadUpdateWebClient; + private WebClient DownloadUpdateWebClient + { + get { if (_downloadUpdateWebClient != null) { - throw (new InvalidOperationException("A previous call to DownloadUpdateAsync() is still in progress.")); - } - - if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) - { - throw (new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().")); - } - - _currentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "exe")); - DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, _currentUpdateInfo.UpdateFilePath); - } -#endregion - -#region Private Properties - private WebClient _downloadUpdateWebClient; -private WebClient DownloadUpdateWebClient - { - get - { - if (_downloadUpdateWebClient != null) - { - return _downloadUpdateWebClient; - } - - _downloadUpdateWebClient = CreateWebClient(); - - _downloadUpdateWebClient.DownloadProgressChanged += DownloadUpdateProgressChanged; - _downloadUpdateWebClient.DownloadFileCompleted += DownloadUpdateCompleted; - return _downloadUpdateWebClient; } + + _downloadUpdateWebClient = CreateWebClient(); + + _downloadUpdateWebClient.DownloadProgressChanged += DownloadUpdateProgressChanged; + _downloadUpdateWebClient.DownloadFileCompleted += DownloadUpdateCompleted; + + return _downloadUpdateWebClient; } -#endregion + } + #endregion -#region Private Fields - private WebProxy _webProxy; - private Thread _getUpdateInfoThread; - private Thread _getChangeLogThread; - private Thread _getAnnouncementInfoThread; -#endregion + #region Private Fields + private WebProxy _webProxy; + private Thread _getUpdateInfoThread; + private Thread _getChangeLogThread; + private Thread _getAnnouncementInfoThread; + #endregion -#region Private Methods - private WebClient CreateWebClient() - { - WebClient webClient = new WebClient(); - webClient.Headers.Add("user-agent", Info.General.UserAgent); - webClient.Proxy = _webProxy; - return webClient; - } + #region Private Methods + private WebClient CreateWebClient() + { + WebClient webClient = new WebClient(); + webClient.Headers.Add("user-agent", Info.General.UserAgent); + webClient.Proxy = _webProxy; + return webClient; + } - private static DownloadStringCompletedEventArgs NewDownloadStringCompletedEventArgs(string result, Exception exception, bool cancelled, object userToken) - { - Type type = typeof(DownloadStringCompletedEventArgs); - const BindingFlags bindingFlags = bindingFlags.NonPublic | bindingFlags.Instance; - Type[] argumentTypes = new Type[] {typeof(string), typeof(Exception), typeof(bool), typeof(object)}; - ConstructorInfo constructor = type.GetConstructor(bindingFlags, null, argumentTypes, null); - object[] arguments = new object[] {result, exception, cancelled, userToken}; + private static DownloadStringCompletedEventArgs NewDownloadStringCompletedEventArgs(string result, Exception exception, bool cancelled, object userToken) + { + Type type = typeof(DownloadStringCompletedEventArgs); + const BindingFlags bindingFlags = bindingFlags.NonPublic | bindingFlags.Instance; + Type[] argumentTypes = new Type[] {typeof(string), typeof(Exception), typeof(bool), typeof(object)}; + ConstructorInfo constructor = type.GetConstructor(bindingFlags, null, argumentTypes, null); + object[] arguments = new object[] {result, exception, cancelled, userToken}; - return constructor.Invoke(arguments); - } + return constructor.Invoke(arguments); + } - private DownloadStringCompletedEventArgs DownloadString(Uri address) - { - WebClient webClient = CreateWebClient(); - string result = string.Empty; - Exception exception = null; - bool cancelled = false; + private DownloadStringCompletedEventArgs DownloadString(Uri address) + { + WebClient webClient = CreateWebClient(); + string result = string.Empty; + Exception exception = null; + bool cancelled = false; + try + { + result = webClient.DownloadString(address); + } + catch (ThreadAbortException) + { + cancelled = true; + } + catch (Exception ex) + { + exception = ex; + } + + return NewDownloadStringCompletedEventArgs(result, exception, cancelled, null); + } + + private void GetUpdateInfo() + { + Uri updateFileUri = new Uri(new Uri(System.Convert.ToString(My.Settings.Default.UpdateAddress)), new Uri(Info.Update.FileName, UriKind.Relative)); + DownloadStringCompletedEventArgs e = DownloadString(updateFileUri); + + if (!e.Cancelled && e.Error == null) + { + _currentUpdateInfo = UpdateInfo.FromString(e.Result); + + My.Settings.Default.CheckForUpdatesLastCheck = DateTime.UtcNow; + if (!My.Settings.Default.UpdatePending) + { + My.Settings.Default.UpdatePending = IsUpdateAvailable(); + } + } + + if (GetUpdateInfoCompletedEventEvent != null) + GetUpdateInfoCompletedEventEvent(this, e); + } + + private void GetChangeLog() + { + DownloadStringCompletedEventArgs e = DownloadString(_currentUpdateInfo.ChangeLogAddress); + + if (!e.Cancelled && e.Error == null) + { + _changeLog = e.Result; + } + + if (GetChangeLogCompletedEventEvent != null) + GetChangeLogCompletedEventEvent(this, e); + } + + private void GetAnnouncementInfo() + { + Uri announcementFileUri = new Uri(System.Convert.ToString(My.Settings.Default.AnnouncementAddress)); + DownloadStringCompletedEventArgs e = DownloadString(announcementFileUri); + + if (!e.Cancelled && e.Error == null) + { + _currentAnnouncementInfo = AnnouncementInfo.FromString(e.Result); + + if (!string.IsNullOrEmpty(_currentAnnouncementInfo.Name)) + { + My.Settings.Default.LastAnnouncement = _currentAnnouncementInfo.Name; + } + } + + if (GetAnnouncementInfoCompletedEventEvent != null) + GetAnnouncementInfoCompletedEventEvent(this, e); + } + + private void DownloadUpdateProgressChanged(object sender, DownloadProgressChangedEventArgs e) + { + if (DownloadUpdateProgressChangedEventEvent != null) + DownloadUpdateProgressChangedEventEvent(sender, e); + } + + private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + { + AsyncCompletedEventArgs raiseEventArgs = e; + + if (!e.Cancelled && e.Error == null) + { try { - result = webClient.DownloadString(address); - } - catch (ThreadAbortException) - { - cancelled = true; + Authenticode updateAuthenticode = new Authenticode(_currentUpdateInfo.UpdateFilePath); + updateAuthenticode.RequireThumbprintMatch = true; + updateAuthenticode.ThumbprintToMatch = _currentUpdateInfo.CertificateThumbprint; + + if (!(updateAuthenticode.Verify() == (int) Authenticode.StatusValue.Verified)) + { + if (updateAuthenticode.Status == Authenticode.StatusValue.UnhandledException) + { + throw (updateAuthenticode.Exception); + } + else + { + throw (new Exception(updateAuthenticode.StatusMessage)); + } + } } catch (Exception ex) { - exception = ex; + raiseEventArgs = new AsyncCompletedEventArgs(ex, false, null); } - - return NewDownloadStringCompletedEventArgs(result, exception, cancelled, null); } - - private void GetUpdateInfo() + + if (raiseEventArgs.Cancelled || raiseEventArgs.Error != null) { - Uri updateFileUri = new Uri(new Uri(System.Convert.ToString(My.Settings.Default.UpdateAddress)), new Uri(Info.Update.FileName, UriKind.Relative)); - DownloadStringCompletedEventArgs e = DownloadString(updateFileUri); - - if (!e.Cancelled && e.Error == null) - { - _currentUpdateInfo = UpdateInfo.FromString(e.Result); - - My.Settings.Default.CheckForUpdatesLastCheck = DateTime.UtcNow; - if (!My.Settings.Default.UpdatePending) - { - My.Settings.Default.UpdatePending = IsUpdateAvailable(); - } - } - - if (GetUpdateInfoCompletedEventEvent != null) - GetUpdateInfoCompletedEventEvent(this, e); + File.Delete(_currentUpdateInfo.UpdateFilePath); } - - private void GetChangeLog() - { - DownloadStringCompletedEventArgs e = DownloadString(_currentUpdateInfo.ChangeLogAddress); - if (!e.Cancelled && e.Error == null) - { - _changeLog = e.Result; - } + if (DownloadUpdateCompletedEventEvent != null) + DownloadUpdateCompletedEventEvent(this, raiseEventArgs); - if (GetChangeLogCompletedEventEvent != null) - GetChangeLogCompletedEventEvent(this, e); - } - - private void GetAnnouncementInfo() - { - Uri announcementFileUri = new Uri(System.Convert.ToString(My.Settings.Default.AnnouncementAddress)); - DownloadStringCompletedEventArgs e = DownloadString(announcementFileUri); - - if (!e.Cancelled && e.Error == null) - { - _currentAnnouncementInfo = AnnouncementInfo.FromString(e.Result); - - if (!string.IsNullOrEmpty(_currentAnnouncementInfo.Name)) - { - My.Settings.Default.LastAnnouncement = _currentAnnouncementInfo.Name; - } - } - - if (GetAnnouncementInfoCompletedEventEvent != null) - GetAnnouncementInfoCompletedEventEvent(this, e); - } - - private void DownloadUpdateProgressChanged(object sender, DownloadProgressChangedEventArgs e) - { - if (DownloadUpdateProgressChangedEventEvent != null) - DownloadUpdateProgressChangedEventEvent(sender, e); - } - - private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - AsyncCompletedEventArgs raiseEventArgs = e; - - if (!e.Cancelled && e.Error == null) - { - try - { - Authenticode updateAuthenticode = new Authenticode(_currentUpdateInfo.UpdateFilePath); - updateAuthenticode.RequireThumbprintMatch = true; - updateAuthenticode.ThumbprintToMatch = _currentUpdateInfo.CertificateThumbprint; - - if (!(updateAuthenticode.Verify() == (int) Authenticode.StatusValue.Verified)) - { - if (updateAuthenticode.Status == Authenticode.StatusValue.UnhandledException) - { - throw (updateAuthenticode.Exception); - } - else - { - throw (new Exception(updateAuthenticode.StatusMessage)); - } - } - } - catch (Exception ex) - { - raiseEventArgs = new AsyncCompletedEventArgs(ex, false, null); - } - } - - if (raiseEventArgs.Cancelled || raiseEventArgs.Error != null) - { - File.Delete(_currentUpdateInfo.UpdateFilePath); - } - - if (DownloadUpdateCompletedEventEvent != null) - DownloadUpdateCompletedEventEvent(this, raiseEventArgs); - - _downloadUpdateWebClient.Dispose(); - _downloadUpdateWebClient = null; - } -#endregion - -#region Public Classes - public class UpdateInfo - { -#region Public Properties - public bool IsValid {get; set;} - public Version Version {get; set;} - public Uri DownloadAddress {get; set;} - public string UpdateFilePath {get; set;} - public Uri ChangeLogAddress {get; set;} - public Uri ImageAddress {get; set;} - public Uri ImageLinkAddress {get; set;} - public string CertificateThumbprint {get; set;} -#endregion - -#region Public Methods - public static UpdateInfo FromString(string input) - { - UpdateInfo newInfo = new UpdateInfo(); - if (string.IsNullOrEmpty(input)) - { - newInfo.IsValid = false; - } - else - { - UpdateFile updateFile = new UpdateFile(input); - newInfo.Version = updateFile.GetVersion("Version"); - newInfo.DownloadAddress = updateFile.GetUri("dURL"); - newInfo.ChangeLogAddress = updateFile.GetUri("clURL"); - newInfo.ImageAddress = updateFile.GetUri("imgURL"); - newInfo.ImageLinkAddress = updateFile.GetUri("imgURLLink"); - newInfo.CertificateThumbprint = updateFile.GetThumbprint("CertificateThumbprint"); - newInfo.IsValid = true; - } - return newInfo; - } -#endregion - } - - public class AnnouncementInfo - { -#region Public Properties - public bool IsValid {get; set;} - public string Name {get; set;} - public Uri Address {get; set;} -#endregion - -#region Public Methods - public static AnnouncementInfo FromString(string input) - { - AnnouncementInfo newInfo = new AnnouncementInfo(); - if (string.IsNullOrEmpty(input)) - { - newInfo.IsValid = false; - } - else - { - UpdateFile updateFile = new UpdateFile(input); - newInfo.Name = updateFile.GetString("Name"); - newInfo.Address = updateFile.GetUri("URL"); - newInfo.IsValid = true; - } - return newInfo; - } -#endregion - } -#endregion - -#region Private Classes - private class UpdateFile - { -#region Public Properties - private Dictionary _items = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - // ReSharper disable MemberCanBePrivate.Local -public Dictionary Items - { - // ReSharper restore MemberCanBePrivate.Local - get - { - return _items; - } - } -#endregion - -#region Public Methods - public UpdateFile(string content) - { - FromString(content); - } - - // ReSharper disable MemberCanBePrivate.Local - public void FromString(string content) - { - // ReSharper restore MemberCanBePrivate.Local - if (string.IsNullOrEmpty(content)) - { - } - else - { - char[] lineSeparators = new char[] {'\n', '\r'}; - char[] keyValueSeparators = new char[] {':', '='}; - char[] commentCharacters = new char[] {'#', ';', '\''}; - - string[] lines = content.Split(lineSeparators.ToString().ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - foreach (string line in lines) - { - line = line.Trim(); - if (line.Length == 0) - { - continue; - } - if (!(line.Substring(0, 1).IndexOfAny(commentCharacters.ToString().ToCharArray()) == -1)) - { - continue; - } - - string[] parts = line.Split(keyValueSeparators.ToString().ToCharArray(), 2); - if (!(parts.Length == 2)) - { - continue; - } - string key = System.Convert.ToString(parts[0].Trim()); - string value = System.Convert.ToString(parts[1].Trim()); - - _items.Add(key, value); - } - } - } - - // ReSharper disable MemberCanBePrivate.Local - public string GetString(string key) - { - // ReSharper restore MemberCanBePrivate.Local - if (!Items.ContainsKey(key)) - { - return string.Empty; - } - return this[key]; - } - - public Version GetVersion(string key) - { - string value = GetString(key); - if (string.IsNullOrEmpty(value)) - { - return null; - } - return new Version(value); - } - - public Uri GetUri(string key) - { - string value = GetString(key); - if (string.IsNullOrEmpty(value)) - { - return null; - } - return new Uri(value); - } - - public string GetThumbprint(string key) - { - return GetString(key).Replace(" ", "").ToUpperInvariant(); - } -#endregion - } -#endregion + _downloadUpdateWebClient.Dispose(); + _downloadUpdateWebClient = null; } + #endregion + + #region Public Classes + public class UpdateInfo + { + #region Public Properties + public bool IsValid {get; set;} + public Version Version {get; set;} + public Uri DownloadAddress {get; set;} + public string UpdateFilePath {get; set;} + public Uri ChangeLogAddress {get; set;} + public Uri ImageAddress {get; set;} + public Uri ImageLinkAddress {get; set;} + public string CertificateThumbprint {get; set;} + #endregion + + #region Public Methods + public static UpdateInfo FromString(string input) + { + UpdateInfo newInfo = new UpdateInfo(); + if (string.IsNullOrEmpty(input)) + { + newInfo.IsValid = false; + } + else + { + UpdateFile updateFile = new UpdateFile(input); + newInfo.Version = updateFile.GetVersion("Version"); + newInfo.DownloadAddress = updateFile.GetUri("dURL"); + newInfo.ChangeLogAddress = updateFile.GetUri("clURL"); + newInfo.ImageAddress = updateFile.GetUri("imgURL"); + newInfo.ImageLinkAddress = updateFile.GetUri("imgURLLink"); + newInfo.CertificateThumbprint = updateFile.GetThumbprint("CertificateThumbprint"); + newInfo.IsValid = true; + } + return newInfo; + } + #endregion + } + + public class AnnouncementInfo + { + #region Public Properties + public bool IsValid {get; set;} + public string Name {get; set;} + public Uri Address {get; set;} + #endregion + + #region Public Methods + public static AnnouncementInfo FromString(string input) + { + AnnouncementInfo newInfo = new AnnouncementInfo(); + if (string.IsNullOrEmpty(input)) + { + newInfo.IsValid = false; + } + else + { + UpdateFile updateFile = new UpdateFile(input); + newInfo.Name = updateFile.GetString("Name"); + newInfo.Address = updateFile.GetUri("URL"); + newInfo.IsValid = true; + } + return newInfo; + } + #endregion + } + #endregion + + #region Private Classes + private class UpdateFile + { + #region Public Properties + private Dictionary _items = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + // ReSharper disable MemberCanBePrivate.Local + public Dictionary Items + { + // ReSharper restore MemberCanBePrivate.Local + get + { + return _items; + } + } + #endregion + + #region Public Methods + public UpdateFile(string content) + { + FromString(content); + } + + // ReSharper disable MemberCanBePrivate.Local + public void FromString(string content) + { + // ReSharper restore MemberCanBePrivate.Local + if (string.IsNullOrEmpty(content)) + { + } + else + { + char[] lineSeparators = new char[] {'\n', '\r'}; + char[] keyValueSeparators = new char[] {':', '='}; + char[] commentCharacters = new char[] {'#', ';', '\''}; + + string[] lines = content.Split(lineSeparators.ToString().ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + foreach (string line in lines) + { + line = line.Trim(); + if (line.Length == 0) + { + continue; + } + if (!(line.Substring(0, 1).IndexOfAny(commentCharacters.ToString().ToCharArray()) == -1)) + { + continue; + } + + string[] parts = line.Split(keyValueSeparators.ToString().ToCharArray(), 2); + if (!(parts.Length == 2)) + { + continue; + } + string key = System.Convert.ToString(parts[0].Trim()); + string value = System.Convert.ToString(parts[1].Trim()); + + _items.Add(key, value); + } + } + } + + // ReSharper disable MemberCanBePrivate.Local + public string GetString(string key) + { + // ReSharper restore MemberCanBePrivate.Local + if (!Items.ContainsKey(key)) + { + return string.Empty; + } + return this[key]; + } + + public Version GetVersion(string key) + { + string value = GetString(key); + if (string.IsNullOrEmpty(value)) + { + return null; + } + return new Version(value); + } + + public Uri GetUri(string key) + { + string value = GetString(key); + if (string.IsNullOrEmpty(value)) + { + return null; + } + return new Uri(value); + } + + public string GetThumbprint(string key) + { + return GetString(key).Replace(" ", "").ToUpperInvariant(); + } + #endregion + } + #endregion + } } diff --git a/mRemoteV1/CS/App/Export.cs b/mRemoteV1/CS/App/Export.cs index 499d5901b..6f44552ed 100644 --- a/mRemoteV1/CS/App/Export.cs +++ b/mRemoteV1/CS/App/Export.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,107 +8,105 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using mRemoteNG.Forms; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.App { public class Export + { + public static void ExportToFile(TreeNode rootTreeNode, TreeNode selectedTreeNode) { - public static void ExportToFile(TreeNode rootTreeNode, TreeNode selectedTreeNode) + try { - try - { - TreeNode exportTreeNode = default(TreeNode); - Security.Save saveSecurity = new Security.Save(); + TreeNode exportTreeNode = default(TreeNode); + Security.Save saveSecurity = new Security.Save(); - using (ExportForm exportForm = new ExportForm()) + using (ExportForm exportForm = new ExportForm()) + { + if (Tree.Node.GetNodeType(selectedTreeNode) == Tree.Node.Type.Container) { - if (Tree.Node.GetNodeType(selectedTreeNode) == Tree.Node.Type.Container) - { - exportForm.SelectedFolder = selectedTreeNode; - } - else if (Tree.Node.GetNodeType(selectedTreeNode) == Tree.Node.Type.Connection) - { - if (Tree.Node.GetNodeType(selectedTreeNode.Parent) == Tree.Node.Type.Container) - { - exportForm.SelectedFolder = selectedTreeNode.Parent; - } - exportForm.SelectedConnection = selectedTreeNode; - } - - if (!(exportForm.ShowDialog(frmMain) == DialogResult.OK)) - { - return ; - } - - switch (exportForm.Scope) - { - case exportForm.ExportScope.SelectedFolder: - exportTreeNode = exportForm.SelectedFolder; - break; - case exportForm.ExportScope.SelectedConnection: - exportTreeNode = exportForm.SelectedConnection; - break; - default: - exportTreeNode = rootTreeNode; - break; - } - - saveSecurity.Username = exportForm.IncludeUsername; - saveSecurity.Password = exportForm.IncludePassword; - saveSecurity.Domain = exportForm.IncludeDomain; - saveSecurity.Inheritance = exportForm.IncludeInheritance; - - SaveExportFile(exportForm.FileName, exportForm.SaveFormat, exportTreeNode, saveSecurity); + exportForm.SelectedFolder = selectedTreeNode; } + else if (Tree.Node.GetNodeType(selectedTreeNode) == Tree.Node.Type.Connection) + { + if (Tree.Node.GetNodeType(selectedTreeNode.Parent) == Tree.Node.Type.Container) + { + exportForm.SelectedFolder = selectedTreeNode.Parent; + } + exportForm.SelectedConnection = selectedTreeNode; + } + + if (!(exportForm.ShowDialog(frmMain) == DialogResult.OK)) + { + return ; + } + + switch (exportForm.Scope) + { + case exportForm.ExportScope.SelectedFolder: + exportTreeNode = exportForm.SelectedFolder; + break; + case exportForm.ExportScope.SelectedConnection: + exportTreeNode = exportForm.SelectedConnection; + break; + default: + exportTreeNode = rootTreeNode; + break; + } + + saveSecurity.Username = exportForm.IncludeUsername; + saveSecurity.Password = exportForm.IncludePassword; + saveSecurity.Domain = exportForm.IncludeDomain; + saveSecurity.Inheritance = exportForm.IncludeInheritance; + + SaveExportFile(exportForm.FileName, exportForm.SaveFormat, exportTreeNode, saveSecurity); + } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "App.Export.ExportToFile() failed.", ex: ex, logOnly: true); - } } - - private static void SaveExportFile(string fileName, mRemoteNG.Config.Connections.Save.Format saveFormat, TreeNode rootNode, Security.Save saveSecurity) + catch (Exception ex) { - bool previousTimerEnabled = false; + Runtime.MessageCollector.AddExceptionMessage(message: "App.Export.ExportToFile() failed.", ex: ex, logOnly: true); + } + } + + private static void SaveExportFile(string fileName, mRemoteNG.Config.Connections.Save.Format saveFormat, TreeNode rootNode, Security.Save saveSecurity) + { + bool previousTimerEnabled = false; - try + try + { + if (TimerSqlWatcher != null) { - if (TimerSqlWatcher != null) - { - previousTimerEnabled = TimerSqlWatcher.Enabled; - TimerSqlWatcher.Enabled = false; - } - - Config.Connections.Save connectionsSave = new Config.Connections.Save(); - connectionsSave.Export = true; - connectionsSave.ConnectionFileName = fileName; - connectionsSave.SaveFormat = saveFormat; - - connectionsSave.ConnectionList = ConnectionList; - connectionsSave.ContainerList = ContainerList; - connectionsSave.RootTreeNode = rootNode; - - connectionsSave.SaveSecurity = saveSecurity; - - connectionsSave.Save_Renamed(); + previousTimerEnabled = TimerSqlWatcher.Enabled; + TimerSqlWatcher.Enabled = false; } - catch (Exception ex) + + Config.Connections.Save connectionsSave = new Config.Connections.Save(); + connectionsSave.Export = true; + connectionsSave.ConnectionFileName = fileName; + connectionsSave.SaveFormat = saveFormat; + + connectionsSave.ConnectionList = ConnectionList; + connectionsSave.ContainerList = ContainerList; + connectionsSave.RootTreeNode = rootNode; + + connectionsSave.SaveSecurity = saveSecurity; + + connectionsSave.Save_Renamed(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(string.Format("Export.SaveExportFile(\"{0}\") failed.", fileName), ex); + } + finally + { + if (TimerSqlWatcher != null) { - MessageCollector.AddExceptionMessage(string.Format("Export.SaveExportFile(\"{0}\") failed.", fileName), ex); - } - finally - { - if (TimerSqlWatcher != null) - { - TimerSqlWatcher.Enabled = previousTimerEnabled; - } + TimerSqlWatcher.Enabled = previousTimerEnabled; } } } + } } diff --git a/mRemoteV1/CS/App/Import.cs b/mRemoteV1/CS/App/Import.cs index 7c76bfa9b..3c30cc4ce 100644 --- a/mRemoteV1/CS/App/Import.cs +++ b/mRemoteV1/CS/App/Import.cs @@ -60,16 +60,16 @@ namespace mRemoteNG.App switch (DetermineFileType(fileName)) { case FileType.mRemoteXml: - Config.import.mRemoteNG.Import(fileName, parentTreeNode); + Config.Import.mRemoteNG.Import(fileName, parentTreeNode); break; case FileType.RemoteDesktopConnection: - Config.import.RemoteDesktopConnection.Import(fileName, parentTreeNode); + Config.Import.RemoteDesktopConnection.Import(fileName, parentTreeNode); break; case FileType.RemoteDesktopConnectionManager: - Config.import.RemoteDesktopConnectionManager.Import(fileName, parentTreeNode); + Config.Import.RemoteDesktopConnectionManager.Import(fileName, parentTreeNode); break; case FileType.PuttyConnectionManager: - Config.import.PuttyConnectionManager.Import(fileName, parentTreeNode); + Config.Import.PuttyConnectionManager.Import(fileName, parentTreeNode); break; default: throw (new FileFormatException("Unrecognized file format.")); @@ -95,7 +95,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromFile() failed.", ex: ex, logOnly: true); + Runtime.MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromFile() failed.", ex: ex, logOnly: true); } } @@ -112,7 +112,7 @@ namespace mRemoteNG.App return ; } - Config.import.ActiveDirectory.Import(ldapPath, parentTreeNode); + Config.Import.ActiveDirectory.Import(ldapPath, parentTreeNode); parentTreeNode.Expand(); Container.Info parentContainer = parentTreeNode.Tag as Container.Info; @@ -125,11 +125,11 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromActiveDirectory() failed.", ex: ex, logOnly: true); + Runtime.MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromActiveDirectory() failed.", ex: ex, logOnly: true); } } - public static void ImportFromPortScan(IEnumerable hosts, Protocol.Protocol.Protocols protocol) + public static void ImportFromPortScan(IEnumerable hosts, Connection.Protocol.Protocols protocol) { try { @@ -155,7 +155,7 @@ namespace mRemoteNG.App } catch (Exception ex) { - MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromPortScan() failed.", ex: ex, logOnly: true); + Runtime.MessageCollector.AddExceptionMessage(message: "App.Import.ImportFromPortScan() failed.", ex: ex, logOnly: true); } } #endregion diff --git a/mRemoteV1/CS/Config/Config.Connections.Load.cs b/mRemoteV1/CS/Config/Config.Connections.Load.cs index 3d873f966..3d6ec9655 100644 --- a/mRemoteV1/CS/Config/Config.Connections.Load.cs +++ b/mRemoteV1/CS/Config/Config.Connections.Load.cs @@ -427,7 +427,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strAddNodesFromSqlFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strAddNodesFromSqlFailed + Constants.vbNewLine + ex.Message, true); } } @@ -604,7 +604,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strGetConnectionInfoFromSqlFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strGetConnectionInfoFromSqlFailed + Constants.vbNewLine + ex.Message, true); } return null; @@ -701,7 +701,7 @@ namespace mRemoteNG.Config.Connections } else { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strOldConffile); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strOldConffile); } const double maxSupportedConfVersion = 2.5; @@ -766,7 +766,7 @@ namespace mRemoteNG.Config.Connections if (import && !isExportFile) { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strCannotImportNormalSessionFile); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strCannotImportNormalSessionFile); return ; } @@ -818,7 +818,7 @@ namespace mRemoteNG.Config.Connections catch (Exception ex) { App.Runtime.IsConnectionsFileLoaded = false; - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLoadFromXmlFailed + Constants.vbNewLine + ex.Message + Constants.vbNewLine + ex.StackTrace, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strLoadFromXmlFailed + Constants.vbNewLine + ex.Message + Constants.vbNewLine + ex.StackTrace, true); throw; } } @@ -920,7 +920,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strAddNodeFromXmlFailed + Constants.vbNewLine + ex.Message + ex.StackTrace, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strAddNodeFromXmlFailed + Constants.vbNewLine + ex.Message + ex.StackTrace, true); throw; } } @@ -1224,7 +1224,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strGetConnectionInfoFromXmlFailed, conI.Name, this.ConnectionFileName, ex.Message), false); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strGetConnectionInfoFromXmlFailed, conI.Name, this.ConnectionFileName, ex.Message), false); } return conI; } diff --git a/mRemoteV1/CS/Config/Config.Connections.Save.cs b/mRemoteV1/CS/Config/Config.Connections.Save.cs index 66211535c..fa8d5a598 100644 --- a/mRemoteV1/CS/Config/Config.Connections.Save.cs +++ b/mRemoteV1/CS/Config/Config.Connections.Save.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,12 +8,10 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Xml; using System.IO; using System.Globalization; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Data.SqlClient; //using mRemoteNG.Tools.Misc; @@ -22,1271 +19,1271 @@ using System.Data.SqlClient; namespace mRemoteNG.Config.Connections { public class Save + { + #region Public Enums + public enum Format + { + None, + mRXML, + mRCSV, + vRDvRE, + vRDCSV, + SQL + } + #endregion + + #region Private Properties + private XmlTextWriter _xmlTextWriter; + private string _password = "mR3m"; + + private SqlConnection _sqlConnection; + private SqlCommand _sqlQuery; + + private int _currentNodeIndex = 0; + private string _parentConstantId = System.Convert.ToString(0); + #endregion + + #region Public Properties + public string SQLHost {get; set;} + public string SQLDatabaseName {get; set;} + public string SQLUsername {get; set;} + public string SQLPassword {get; set;} + + public string ConnectionFileName {get; set;} + public TreeNode RootTreeNode {get; set;} + public bool Export {get; set;} + public Format SaveFormat {get; set;} + public Security.Save SaveSecurity {get; set;} + public Connection.List ConnectionList {get; set;} + public Container.List ContainerList {get; set;} + #endregion + + #region Public Methods + public void Save_Renamed() + { + switch (SaveFormat) { -#region Public Enums - public enum Format - { - None, - mRXML, - mRCSV, - vRDvRE, - vRDCSV, - SQL - } -#endregion - -#region Private Properties - private XmlTextWriter _xmlTextWriter; - private string _password = "mR3m"; - - private SqlConnection _sqlConnection; - private SqlCommand _sqlQuery; - - private int _currentNodeIndex = 0; - private string _parentConstantId = System.Convert.ToString(0); -#endregion - -#region Public Properties - public string SQLHost {get; set;} - public string SQLDatabaseName {get; set;} - public string SQLUsername {get; set;} - public string SQLPassword {get; set;} - - public string ConnectionFileName {get; set;} - public TreeNode RootTreeNode {get; set;} - public bool Export {get; set;} - public Format SaveFormat {get; set;} - public Security.Save SaveSecurity {get; set;} - public Connection.List ConnectionList {get; set;} - public Container.List ContainerList {get; set;} -#endregion - -#region Public Methods - public void Save_Renamed() - { - switch (SaveFormat) + case Format.SQL: + SaveToSQL(); + break; + case Format.mRCSV: + SaveTomRCSV(); + break; + case Format.vRDvRE: + SaveToVRE(); + break; + case Format.vRDCSV: + SaveTovRDCSV(); + break; + default: + SaveToXml(); + if (My.Settings.Default.EncryptCompleteConnectionsFile) { - case Format.SQL: - SaveToSQL(); - break; - case Format.mRCSV: - SaveTomRCSV(); - break; - case Format.vRDvRE: - SaveToVRE(); - break; - case Format.vRDCSV: - SaveTovRDCSV(); - break; - default: - SaveToXml(); - if (My.Settings.Default.EncryptCompleteConnectionsFile) - { - EncryptCompleteFile(); - } - if (!Export) - { - frmMain.Default.ConnectionsFileName = ConnectionFileName; - } - break; + EncryptCompleteFile(); } - frmMain.Default.UsingSqlServer = SaveFormat == Format.SQL; - } -#endregion - -#region SQL - private bool VerifyDatabaseVersion(SqlConnection sqlConnection) - { - bool isVerified = false; - SqlDataReader sqlDataReader = null; - System.Version databaseVersion = null; - try + if (!Export) { - SqlCommand sqlCommand = new SqlCommand("SELECT * FROM tblRoot", sqlConnection); - sqlDataReader = sqlCommand.ExecuteReader(); - if (!sqlDataReader.HasRows) - { - return true; // assume new empty database - } - sqlDataReader.Read(); - - databaseVersion = new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture)); - - sqlDataReader.Close(); - - if (databaseVersion.CompareTo(new System.Version(2, 2)) == 0) // 2.2 - { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.3")); - sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD EnableFontSmoothing bit NOT NULL DEFAULT 0, EnableDesktopComposition bit NOT NULL DEFAULT 0, InheritEnableFontSmoothing bit NOT NULL DEFAULT 0, InheritEnableDesktopComposition bit NOT NULL DEFAULT 0;", sqlConnection); - sqlCommand.ExecuteNonQuery(); - databaseVersion = new System.Version(2, 3); - } - - if (databaseVersion.CompareTo(new System.Version(2, 3)) == 0) // 2.3 - { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.4")); - sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD UseCredSsp bit NOT NULL DEFAULT 1, InheritUseCredSsp bit NOT NULL DEFAULT 0;", sqlConnection); - sqlCommand.ExecuteNonQuery(); - databaseVersion = new Version(2, 4); - } - - if (databaseVersion.CompareTo(new Version(2, 4)) == 0) // 2.4 - { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.5")); - sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD LoadBalanceInfo varchar (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, AutomaticResize bit NOT NULL DEFAULT 1, InheritLoadBalanceInfo bit NOT NULL DEFAULT 0, InheritAutomaticResize bit NOT NULL DEFAULT 0;", sqlConnection); - sqlCommand.ExecuteNonQuery(); - databaseVersion = new Version(2, 5); - } - - if (databaseVersion.CompareTo(new Version(2, 5)) == 0) // 2.5 - { - isVerified = true; - } - - if (isVerified == false) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strErrorBadDatabaseVersion, databaseVersion.ToString(), (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName)); - } + frmMain.Default.ConnectionsFileName = ConnectionFileName; } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorVerifyDatabaseVersionFailed, ex.Message)); - } - finally - { - if (sqlDataReader != null) - { - if (!sqlDataReader.IsClosed) - { - sqlDataReader.Close(); - } - } - } - return isVerified; - } - - private void SaveToSQL() - { - if (SQLUsername != "") - { - _sqlConnection = new SqlConnection("Data Source=" + SQLHost + ";Initial Catalog=" + SQLDatabaseName + ";User Id=" + SQLUsername + ";Password=" + SQLPassword); - } - else - { - _sqlConnection = new SqlConnection("Data Source=" + SQLHost + ";Initial Catalog=" + SQLDatabaseName + ";Integrated Security=True"); - } - - _sqlConnection.Open(); - - if (!VerifyDatabaseVersion(_sqlConnection)) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strErrorConnectionListSaveFailed); - return ; - } - - TreeNode tN = default(TreeNode); - tN = RootTreeNode.Clone(); - - string strProtected = ""; - if (tN.Tag != null) - { - if ((tN.Tag as mRemoteNG.Root.Info).Password == true) - { - _password = System.Convert.ToString((tN.Tag as mRemoteNG.Root.Info).PasswordString); - strProtected = Security.Crypt.Encrypt("ThisIsProtected", _password); - } - else - { - strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); - } - } - else - { - strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); - } - - _sqlQuery = new SqlCommand("DELETE FROM tblRoot", _sqlConnection); - _sqlQuery.ExecuteNonQuery(); - - _sqlQuery = new SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" + PrepareValueForDB(tN.Text) + "\', 0, \'" + strProtected + "\'," + App.Info.Connections.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")", _sqlConnection); - _sqlQuery.ExecuteNonQuery(); - - _sqlQuery = new SqlCommand("DELETE FROM tblCons", _sqlConnection); - _sqlQuery.ExecuteNonQuery(); - - TreeNodeCollection tNC = default(TreeNodeCollection); - tNC = tN.Nodes; - - SaveNodesSQL(tNC); - - _sqlQuery = new SqlCommand("DELETE FROM tblUpdate", _sqlConnection); - _sqlQuery.ExecuteNonQuery(); - _sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + Tools.Misc.DBDate(DateTime.Now) + "\')", _sqlConnection); - _sqlQuery.ExecuteNonQuery(); - - _sqlConnection.Close(); - } - - private void SaveNodesSQL(TreeNodeCollection tnc) - { - foreach (TreeNode node in tnc) - { - _currentNodeIndex++; - - Connection.Info curConI = default(Connection.Info); - _sqlQuery = new SqlCommand("INSERT INTO tblCons (Name, Type, Expanded, Description, Icon, Panel, Username, " + "DomainName, Password, Hostname, Protocol, PuttySession, " + "Port, ConnectToConsole, RenderingEngine, ICAEncryptionStrength, RDPAuthenticationLevel, LoadBalanceInfo, Colors, Resolution, AutomaticResize, DisplayWallpaper, " + "DisplayThemes, EnableFontSmoothing, EnableDesktopComposition, CacheBitmaps, RedirectDiskDrives, RedirectPorts, " + "RedirectPrinters, RedirectSmartCards, RedirectSound, RedirectKeys, " + "Connected, PreExtApp, PostExtApp, MacAddress, UserField, ExtApp, VNCCompression, VNCEncoding, VNCAuthMode, " + "VNCProxyType, VNCProxyIP, VNCProxyPort, VNCProxyUsername, VNCProxyPassword, " + "VNCColors, VNCSmartSizeMode, VNCViewOnly, " + "RDGatewayUsageMethod, RDGatewayHostname, RDGatewayUseConnectionCredentials, RDGatewayUsername, RDGatewayPassword, RDGatewayDomain, " + "UseCredSsp, " + "InheritCacheBitmaps, InheritColors, " + "InheritDescription, InheritDisplayThemes, InheritDisplayWallpaper, InheritEnableFontSmoothing, InheritEnableDesktopComposition, InheritDomain, " + "InheritIcon, InheritPanel, InheritPassword, InheritPort, " + "InheritProtocol, InheritPuttySession, InheritRedirectDiskDrives, " + "InheritRedirectKeys, InheritRedirectPorts, InheritRedirectPrinters, " + "InheritRedirectSmartCards, InheritRedirectSound, InheritResolution, InheritAutomaticResize, " + "InheritUseConsoleSession, InheritRenderingEngine, InheritUsername, InheritICAEncryptionStrength, InheritRDPAuthenticationLevel, InheritLoadBalanceInfo, " + "InheritPreExtApp, InheritPostExtApp, InheritMacAddress, InheritUserField, InheritExtApp, InheritVNCCompression, InheritVNCEncoding, " + "InheritVNCAuthMode, InheritVNCProxyType, InheritVNCProxyIP, InheritVNCProxyPort, " + "InheritVNCProxyUsername, InheritVNCProxyPassword, InheritVNCColors, " + "InheritVNCSmartSizeMode, InheritVNCViewOnly, " + "InheritRDGatewayUsageMethod, InheritRDGatewayHostname, InheritRDGatewayUseConnectionCredentials, InheritRDGatewayUsername, InheritRDGatewayPassword, InheritRDGatewayDomain, " - + "InheritUseCredSsp, " + "PositionID, ParentID, ConstantID, LastChange)" + "VALUES (", _sqlConnection - ); - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) - { - //_xmlTextWriter.WriteStartElement("Node") - _sqlQuery.CommandText += "\'" + PrepareValueForDB(node.Text) + "\',"; //Name - _sqlQuery.CommandText += "\'" + Tree.Node.GetNodeType(node).ToString() + "\',"; //Type - } - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) //container - { - _sqlQuery.CommandText += "\'" + this._ContainerList[node.Tag].IsExpanded + "\',"; //Expanded - curConI = this._ContainerList[node.Tag].ConnectionInfo; - SaveConnectionFieldsSQL(curConI); - - _sqlQuery.CommandText = Tools.Misc.PrepareForDB(_sqlQuery.CommandText); - _sqlQuery.ExecuteNonQuery(); - //_parentConstantId = _currentNodeIndex - SaveNodesSQL(node.Nodes); - //_xmlTextWriter.WriteEndElement() - } - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) - { - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - curConI = this._ConnectionList[node.Tag]; - SaveConnectionFieldsSQL(curConI); - //_xmlTextWriter.WriteEndElement() - _sqlQuery.CommandText = Tools.Misc.PrepareForDB(_sqlQuery.CommandText); - _sqlQuery.ExecuteNonQuery(); - } - - //_parentConstantId = 0 - } - } - - private void SaveConnectionFieldsSQL(Connection.Info curConI) - { - Connection.Info with_1 = curConI; - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Description) + "\',"; - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Icon) + "\',"; - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Panel) + "\',"; - - if (this._SaveSecurity.Username == true) - { - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Username) + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - if (this._SaveSecurity.Domain == true) - { - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Domain) + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - if (this._SaveSecurity.Password == true) - { - _sqlQuery.CommandText += "\'" + PrepareValueForDB(Security.Crypt.Encrypt(with_1.Password, _password)) + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Hostname) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Protocol.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.PuttySession) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Port) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.UseConsoleSession) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RenderingEngine.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.ICAEncryption.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDPAuthenticationLevel.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.LoadBalanceInfo + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Colors.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Resolution.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.AutomaticResize) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.DisplayWallpaper) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.DisplayThemes) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.EnableFontSmoothing) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.EnableDesktopComposition) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.CacheBitmaps) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectDiskDrives) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectPorts) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectPrinters) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectSmartCards) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RedirectSound.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectKeys) + "\',"; - - if (curConI.OpenConnections.Count > 0) - { - _sqlQuery.CommandText += 1 + ","; - } - else - { - _sqlQuery.CommandText += 0 + ","; - } - - _sqlQuery.CommandText += "\'" + with_1.PreExtApp + "\',"; - _sqlQuery.CommandText += "\'" + with_1.PostExtApp + "\',"; - _sqlQuery.CommandText += "\'" + with_1.MacAddress + "\',"; - _sqlQuery.CommandText += "\'" + with_1.UserField + "\',"; - _sqlQuery.CommandText += "\'" + with_1.ExtApp + "\',"; - - _sqlQuery.CommandText += "\'" + with_1.VNCCompression.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCEncoding.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCAuthMode.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCProxyType.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCProxyIP + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.VNCProxyPort) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCProxyUsername + "\',"; - _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.VNCProxyPassword, _password) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCColors.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCSmartSizeMode.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.VNCViewOnly) + "\',"; - - _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsageMethod.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDGatewayHostname + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDGatewayUseConnectionCredentials.ToString() + "\',"; - - if (this._SaveSecurity.Username == true) - { - _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsername + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - if (this._SaveSecurity.Password == true) - { - _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.RDGatewayPassword, _password) + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - if (this._SaveSecurity.Domain == true) - { - _sqlQuery.CommandText += "\'" + with_1.RDGatewayDomain + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + "" + "\',"; - } - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.UseCredSsp) + "\',"; - - if (this._SaveSecurity.Inheritance == true) - { - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.CacheBitmaps) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Colors) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Description) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.DisplayThemes) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.DisplayWallpaper) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.EnableFontSmoothing) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.EnableDesktopComposition) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Domain) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Icon) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Panel) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Password) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Port) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Protocol) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PuttySession) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectDiskDrives) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectKeys) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectPorts) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectPrinters) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectSmartCards) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectSound) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Resolution) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.AutomaticResize) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UseConsoleSession) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RenderingEngine) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Username) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.ICAEncryption) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDPAuthenticationLevel) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.LoadBalanceInfo) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PreExtApp) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PostExtApp) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.MacAddress) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UserField) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.ExtApp) + "\',"; - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCCompression) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCEncoding) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCAuthMode) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyType) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyIP) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyPort) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyUsername) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyPassword) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCColors) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCSmartSizeMode) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCViewOnly) + "\',"; - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUsageMethod) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayHostname) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUseConnectionCredentials) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUsername) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayPassword) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayDomain) + "\',"; - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UseCredSsp) + "\',"; - } - else - { - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .AutomaticResize - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .LoadBalanceInfo - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUsageMethod - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayHostname - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUseConnectionCredentials - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUsername - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayPassword - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayDomain - - _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .UseCredSsp - } - - with_1.PositionID = _currentNodeIndex; - - if (with_1.IsContainer == false) - { - if (with_1.Parent != null) - { - _parentConstantId = System.Convert.ToString((with_1.Parent as Container.Info).ConnectionInfo.ConstantID); - } - else - { - _parentConstantId = System.Convert.ToString(0); - } - } - else - { - if ((with_1.Parent as Container.Info).Parent != null) - { - _parentConstantId = System.Convert.ToString(((with_1.Parent as Container.Info).Parent as Container.Info).ConnectionInfo.ConstantID); - } - else - { - _parentConstantId = System.Convert.ToString(0); - } - } - - _sqlQuery.CommandText += _currentNodeIndex + ",\'" + _parentConstantId + "\',\'" + with_1.ConstantID + "\',\'" + Tools.Misc.DBDate(DateTime.Now) + "\')"; - } -#endregion - -#region XML - private void EncryptCompleteFile() - { - StreamReader streamReader = new StreamReader(ConnectionFileName); - - string fileContents = ""; - fileContents = streamReader.ReadToEnd(); - streamReader.Close(); - - if (!string.IsNullOrEmpty(fileContents)) - { - StreamWriter streamWriter = new StreamWriter(ConnectionFileName); - streamWriter.Write(Security.Crypt.Encrypt(fileContents, _password)); - streamWriter.Close(); - } - } - - private void SaveToXml() - { - try - { - if (!IsConnectionsFileLoaded) - { - return; - } - - TreeNode treeNode = default(TreeNode); - - if (Tree.Node.GetNodeType(RootTreeNode) == Tree.Node.Type.Root) - { - treeNode = RootTreeNode.Clone(); - } - else - { - treeNode = new TreeNode("mR|Export (" + Tools.Misc.DBDate(DateTime.Now) + ")"); - treeNode.Nodes.Add(System.Convert.ToString(RootTreeNode.Clone())); - } - - string tempFileName = Path.GetTempFileName(); - _xmlTextWriter = new XmlTextWriter(tempFileName, System.Text.Encoding.UTF8); - - _xmlTextWriter.Formatting = Formatting.Indented; - _xmlTextWriter.Indentation = 4; - - _xmlTextWriter.WriteStartDocument(); - - _xmlTextWriter.WriteStartElement("Connections"); // Do not localize - _xmlTextWriter.WriteAttributeString("Name", "", treeNode.Text); - _xmlTextWriter.WriteAttributeString("Export", "", System.Convert.ToString(Export)); - - if (Export) - { - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); - } - else - { - if ((treeNode.Tag as Root.Info).Password == true) - { - _password = System.Convert.ToString((treeNode.Tag as Root.Info).PasswordString); - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsProtected", _password)); - } - else - { - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); - } - } - - _xmlTextWriter.WriteAttributeString("ConfVersion", "", App.Info.Connections.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture)); - - TreeNodeCollection treeNodeCollection = default(TreeNodeCollection); - treeNodeCollection = treeNode.Nodes; - - SaveNode(treeNodeCollection); - - _xmlTextWriter.WriteEndElement(); - _xmlTextWriter.Close(); - - if (File.Exists(ConnectionFileName)) - { - if (Export) - { - File.Delete(ConnectionFileName); - } - else - { - string backupFileName = ConnectionFileName +".backup"; - File.Delete(backupFileName); - File.Move(ConnectionFileName, backupFileName); - } - } - File.Move(tempFileName, ConnectionFileName); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveToXml failed" + Constants.vbNewLine + ex.Message, false); - } - } - - private void SaveNode(TreeNodeCollection tNC) - { - try - { - foreach (TreeNode node in tNC) - { - Connection.Info curConI = default(Connection.Info); - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) - { - _xmlTextWriter.WriteStartElement("Node"); - _xmlTextWriter.WriteAttributeString("Name", "", node.Text); - _xmlTextWriter.WriteAttributeString("Type", "", Tree.Node.GetNodeType(node).ToString()); - } - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) //container - { - _xmlTextWriter.WriteAttributeString("Expanded", "", System.Convert.ToString(this._ContainerList[node.Tag].TreeNode.IsExpanded)); - curConI = this._ContainerList[node.Tag].ConnectionInfo; - SaveConnectionFields(curConI); - SaveNode(node.Nodes); - _xmlTextWriter.WriteEndElement(); - } - - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) - { - curConI = this._ConnectionList[node.Tag]; - SaveConnectionFields(curConI); - _xmlTextWriter.WriteEndElement(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveNode failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void SaveConnectionFields(Connection.Info curConI) - { - try - { - _xmlTextWriter.WriteAttributeString("Descr", "", curConI.Description); - - _xmlTextWriter.WriteAttributeString("Icon", "", curConI.Icon); - - _xmlTextWriter.WriteAttributeString("Panel", "", curConI.Panel); - - if (this._SaveSecurity.Username == true) - { - _xmlTextWriter.WriteAttributeString("Username", "", curConI.Username); - } - else - { - _xmlTextWriter.WriteAttributeString("Username", "", ""); - } - - if (this._SaveSecurity.Domain == true) - { - _xmlTextWriter.WriteAttributeString("Domain", "", curConI.Domain); - } - else - { - _xmlTextWriter.WriteAttributeString("Domain", "", ""); - } - - if (this._SaveSecurity.Password == true) - { - _xmlTextWriter.WriteAttributeString("Password", "", Security.Crypt.Encrypt(curConI.Password, _password)); - } - else - { - _xmlTextWriter.WriteAttributeString("Password", "", ""); - } - - _xmlTextWriter.WriteAttributeString("Hostname", "", curConI.Hostname); - - _xmlTextWriter.WriteAttributeString("Protocol", "", curConI.Protocol.ToString()); - - _xmlTextWriter.WriteAttributeString("PuttySession", "", curConI.PuttySession); - - _xmlTextWriter.WriteAttributeString("Port", "", System.Convert.ToString(curConI.Port)); - - _xmlTextWriter.WriteAttributeString("ConnectToConsole", "", System.Convert.ToString(curConI.UseConsoleSession)); - - _xmlTextWriter.WriteAttributeString("UseCredSsp", "", System.Convert.ToString(curConI.UseCredSsp)); - - _xmlTextWriter.WriteAttributeString("RenderingEngine", "", curConI.RenderingEngine.ToString()); - - _xmlTextWriter.WriteAttributeString("ICAEncryptionStrength", "", curConI.ICAEncryption.ToString()); - - _xmlTextWriter.WriteAttributeString("RDPAuthenticationLevel", "", curConI.RDPAuthenticationLevel.ToString()); - - _xmlTextWriter.WriteAttributeString("LoadBalanceInfo", "", curConI.LoadBalanceInfo); - - _xmlTextWriter.WriteAttributeString("Colors", "", curConI.Colors.ToString()); - - _xmlTextWriter.WriteAttributeString("Resolution", "", curConI.Resolution.ToString()); - - _xmlTextWriter.WriteAttributeString("AutomaticResize", "", System.Convert.ToString(curConI.AutomaticResize)); - - _xmlTextWriter.WriteAttributeString("DisplayWallpaper", "", System.Convert.ToString(curConI.DisplayWallpaper)); - - _xmlTextWriter.WriteAttributeString("DisplayThemes", "", System.Convert.ToString(curConI.DisplayThemes)); - - _xmlTextWriter.WriteAttributeString("EnableFontSmoothing", "", System.Convert.ToString(curConI.EnableFontSmoothing)); - - _xmlTextWriter.WriteAttributeString("EnableDesktopComposition", "", System.Convert.ToString(curConI.EnableDesktopComposition)); - - _xmlTextWriter.WriteAttributeString("CacheBitmaps", "", System.Convert.ToString(curConI.CacheBitmaps)); - - _xmlTextWriter.WriteAttributeString("RedirectDiskDrives", "", System.Convert.ToString(curConI.RedirectDiskDrives)); - - _xmlTextWriter.WriteAttributeString("RedirectPorts", "", System.Convert.ToString(curConI.RedirectPorts)); - - _xmlTextWriter.WriteAttributeString("RedirectPrinters", "", System.Convert.ToString(curConI.RedirectPrinters)); - - _xmlTextWriter.WriteAttributeString("RedirectSmartCards", "", System.Convert.ToString(curConI.RedirectSmartCards)); - - _xmlTextWriter.WriteAttributeString("RedirectSound", "", curConI.RedirectSound.ToString()); - - _xmlTextWriter.WriteAttributeString("RedirectKeys", "", System.Convert.ToString(curConI.RedirectKeys)); - - if (curConI.OpenConnections.Count > 0) - { - _xmlTextWriter.WriteAttributeString("Connected", "", System.Convert.ToString(true)); - } - else - { - _xmlTextWriter.WriteAttributeString("Connected", "", System.Convert.ToString(false)); - } - - _xmlTextWriter.WriteAttributeString("PreExtApp", "", curConI.PreExtApp); - _xmlTextWriter.WriteAttributeString("PostExtApp", "", curConI.PostExtApp); - _xmlTextWriter.WriteAttributeString("MacAddress", "", curConI.MacAddress); - _xmlTextWriter.WriteAttributeString("UserField", "", curConI.UserField); - _xmlTextWriter.WriteAttributeString("ExtApp", "", curConI.ExtApp); - - _xmlTextWriter.WriteAttributeString("VNCCompression", "", curConI.VNCCompression.ToString()); - _xmlTextWriter.WriteAttributeString("VNCEncoding", "", curConI.VNCEncoding.ToString()); - _xmlTextWriter.WriteAttributeString("VNCAuthMode", "", curConI.VNCAuthMode.ToString()); - _xmlTextWriter.WriteAttributeString("VNCProxyType", "", curConI.VNCProxyType.ToString()); - _xmlTextWriter.WriteAttributeString("VNCProxyIP", "", curConI.VNCProxyIP); - _xmlTextWriter.WriteAttributeString("VNCProxyPort", "", System.Convert.ToString(curConI.VNCProxyPort)); - _xmlTextWriter.WriteAttributeString("VNCProxyUsername", "", curConI.VNCProxyUsername); - _xmlTextWriter.WriteAttributeString("VNCProxyPassword", "", Security.Crypt.Encrypt(curConI.VNCProxyPassword, _password)); - _xmlTextWriter.WriteAttributeString("VNCColors", "", curConI.VNCColors.ToString()); - _xmlTextWriter.WriteAttributeString("VNCSmartSizeMode", "", curConI.VNCSmartSizeMode.ToString()); - _xmlTextWriter.WriteAttributeString("VNCViewOnly", "", System.Convert.ToString(curConI.VNCViewOnly)); - - _xmlTextWriter.WriteAttributeString("RDGatewayUsageMethod", "", curConI.RDGatewayUsageMethod.ToString()); - _xmlTextWriter.WriteAttributeString("RDGatewayHostname", "", curConI.RDGatewayHostname); - - _xmlTextWriter.WriteAttributeString("RDGatewayUseConnectionCredentials", "", curConI.RDGatewayUseConnectionCredentials.ToString()); - - if (this._SaveSecurity.Username == true) - { - _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", curConI.RDGatewayUsername); - } - else - { - _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", ""); - } - - if (this._SaveSecurity.Password == true) - { - _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", Security.Crypt.Encrypt(curConI.RDGatewayPassword, _password)); - } - else - { - _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", ""); - } - - if (this._SaveSecurity.Domain == true) - { - _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", curConI.RDGatewayDomain); - } - else - { - _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", ""); - } - - if (this._SaveSecurity.Inheritance == true) - { - _xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", System.Convert.ToString(curConI.Inherit.CacheBitmaps)); - _xmlTextWriter.WriteAttributeString("InheritColors", "", System.Convert.ToString(curConI.Inherit.Colors)); - _xmlTextWriter.WriteAttributeString("InheritDescription", "", System.Convert.ToString(curConI.Inherit.Description)); - _xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", System.Convert.ToString(curConI.Inherit.DisplayThemes)); - _xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", System.Convert.ToString(curConI.Inherit.DisplayWallpaper)); - _xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", System.Convert.ToString(curConI.Inherit.EnableFontSmoothing)); - _xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", System.Convert.ToString(curConI.Inherit.EnableDesktopComposition)); - _xmlTextWriter.WriteAttributeString("InheritDomain", "", System.Convert.ToString(curConI.Inherit.Domain)); - _xmlTextWriter.WriteAttributeString("InheritIcon", "", System.Convert.ToString(curConI.Inherit.Icon)); - _xmlTextWriter.WriteAttributeString("InheritPanel", "", System.Convert.ToString(curConI.Inherit.Panel)); - _xmlTextWriter.WriteAttributeString("InheritPassword", "", System.Convert.ToString(curConI.Inherit.Password)); - _xmlTextWriter.WriteAttributeString("InheritPort", "", System.Convert.ToString(curConI.Inherit.Port)); - _xmlTextWriter.WriteAttributeString("InheritProtocol", "", System.Convert.ToString(curConI.Inherit.Protocol)); - _xmlTextWriter.WriteAttributeString("InheritPuttySession", "", System.Convert.ToString(curConI.Inherit.PuttySession)); - _xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", System.Convert.ToString(curConI.Inherit.RedirectDiskDrives)); - _xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", System.Convert.ToString(curConI.Inherit.RedirectKeys)); - _xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", System.Convert.ToString(curConI.Inherit.RedirectPorts)); - _xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", System.Convert.ToString(curConI.Inherit.RedirectPrinters)); - _xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", System.Convert.ToString(curConI.Inherit.RedirectSmartCards)); - _xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", System.Convert.ToString(curConI.Inherit.RedirectSound)); - _xmlTextWriter.WriteAttributeString("InheritResolution", "", System.Convert.ToString(curConI.Inherit.Resolution)); - _xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", System.Convert.ToString(curConI.Inherit.AutomaticResize)); - _xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", System.Convert.ToString(curConI.Inherit.UseConsoleSession)); - _xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", System.Convert.ToString(curConI.Inherit.UseCredSsp)); - _xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", System.Convert.ToString(curConI.Inherit.RenderingEngine)); - _xmlTextWriter.WriteAttributeString("InheritUsername", "", System.Convert.ToString(curConI.Inherit.Username)); - _xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", System.Convert.ToString(curConI.Inherit.ICAEncryption)); - _xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", System.Convert.ToString(curConI.Inherit.RDPAuthenticationLevel)); - _xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", System.Convert.ToString(curConI.Inherit.LoadBalanceInfo)); - _xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", System.Convert.ToString(curConI.Inherit.PreExtApp)); - _xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", System.Convert.ToString(curConI.Inherit.PostExtApp)); - _xmlTextWriter.WriteAttributeString("InheritMacAddress", "", System.Convert.ToString(curConI.Inherit.MacAddress)); - _xmlTextWriter.WriteAttributeString("InheritUserField", "", System.Convert.ToString(curConI.Inherit.UserField)); - _xmlTextWriter.WriteAttributeString("InheritExtApp", "", System.Convert.ToString(curConI.Inherit.ExtApp)); - _xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", System.Convert.ToString(curConI.Inherit.VNCCompression)); - _xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", System.Convert.ToString(curConI.Inherit.VNCEncoding)); - _xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", System.Convert.ToString(curConI.Inherit.VNCAuthMode)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", System.Convert.ToString(curConI.Inherit.VNCProxyType)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", System.Convert.ToString(curConI.Inherit.VNCProxyIP)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", System.Convert.ToString(curConI.Inherit.VNCProxyPort)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", System.Convert.ToString(curConI.Inherit.VNCProxyUsername)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", System.Convert.ToString(curConI.Inherit.VNCProxyPassword)); - _xmlTextWriter.WriteAttributeString("InheritVNCColors", "", System.Convert.ToString(curConI.Inherit.VNCColors)); - _xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", System.Convert.ToString(curConI.Inherit.VNCSmartSizeMode)); - _xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", System.Convert.ToString(curConI.Inherit.VNCViewOnly)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsageMethod", "", System.Convert.ToString(curConI.Inherit.RDGatewayUsageMethod)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", System.Convert.ToString(curConI.Inherit.RDGatewayHostname)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", System.Convert.ToString(curConI.Inherit.RDGatewayUseConnectionCredentials)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", System.Convert.ToString(curConI.Inherit.RDGatewayUsername)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", System.Convert.ToString(curConI.Inherit.RDGatewayPassword)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", System.Convert.ToString(curConI.Inherit.RDGatewayDomain)); - } - else - { - _xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritColors", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritDescription", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritDomain", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritIcon", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPanel", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPassword", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPort", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritProtocol", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPuttySession", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritResolution", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritUsername", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritMacAddress", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritUserField", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritExtApp", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCColors", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", System.Convert.ToString(false)); - _xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", System.Convert.ToString(false)); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveConnectionFields failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region CSV - private StreamWriter csvWr; - - private void SaveTomRCSV() - { - if (App.Runtime.IsConnectionsFileLoaded == false) - { - return; - } - - TreeNode tN = default(TreeNode); - tN = RootTreeNode.Clone(); - - TreeNodeCollection tNC = default(TreeNodeCollection); - tNC = tN.Nodes; - - csvWr = new StreamWriter(ConnectionFileName); - - - string csvLn = string.Empty; - - csvLn += "Name;Folder;Description;Icon;Panel;"; - - if (SaveSecurity.Username) - { - csvLn += "Username;"; - } - - if (SaveSecurity.Password) - { - csvLn += "Password;"; - } - - if (SaveSecurity.Domain) - { - csvLn += "Domain;"; - } - - csvLn += "Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;"; - - if (SaveSecurity.Inheritance) - { - csvLn += "InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain"; - } - - csvWr.WriteLine(csvLn); - - SaveNodemRCSV(tNC); - - csvWr.Close(); - } - - private void SaveNodemRCSV(TreeNodeCollection tNC) - { - foreach (TreeNode node in tNC) - { - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) - { - Connection.Info curConI = node.Tag; - - WritemRCSVLine(curConI); - } - else if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) - { - SaveNodemRCSV(node.Nodes); - } - } - } - - private void WritemRCSVLine(Connection.Info con) - { - string nodePath = con.TreeNode.FullPath; - - int firstSlash = nodePath.IndexOf("\\"); - nodePath = nodePath.Remove(0, firstSlash + 1); - int lastSlash = nodePath.LastIndexOf("\\"); - - if (lastSlash > 0) - { - nodePath = nodePath.Remove(lastSlash); - } - else - { - nodePath = ""; - } - - string csvLn = string.Empty; - - csvLn += con.Name + ";" + nodePath + ";" + con.Description + ";" + con.Icon + ";" + con.Panel + ";"; - - if (SaveSecurity.Username) - { - csvLn += con.Username + ";"; - } - - if (SaveSecurity.Password) - { - csvLn += con.Password + ";"; - } - - if (SaveSecurity.Domain) - { - csvLn += con.Domain + ";"; - } - - csvLn += con.Hostname + ";" + con.Protocol.ToString() + ";" + con.PuttySession + ";" + System.Convert.ToString(con.Port) + ";" + System.Convert.ToString(con.UseConsoleSession) + ";" + System.Convert.ToString(con.UseCredSsp) + ";" + con.RenderingEngine.ToString() + ";" + con.ICAEncryption.ToString() + ";" + con.RDPAuthenticationLevel.ToString() + ";" + con.LoadBalanceInfo + ";" + con.Colors.ToString() + ";" + con.Resolution.ToString() + ";" + System.Convert.ToString(con.AutomaticResize) + ";" + System.Convert.ToString(con.DisplayWallpaper) + ";" + System.Convert.ToString(con.DisplayThemes) + ";" + System.Convert.ToString(con.EnableFontSmoothing) + ";" + System.Convert.ToString(con.EnableDesktopComposition) + ";" + System.Convert.ToString(con.CacheBitmaps) + ";" + System.Convert.ToString(con.RedirectDiskDrives) + ";" + System.Convert.ToString(con.RedirectPorts) + ";" + System.Convert.ToString(con.RedirectPrinters) + ";" + System.Convert.ToString(con.RedirectSmartCards) + ";" + con.RedirectSound.ToString() + ";" + System.Convert.ToString(con.RedirectKeys) + ";" + con.PreExtApp + ";" + con.PostExtApp + ";" + con.MacAddress + ";" + con.UserField + ";" + con.ExtApp + ";" + con.VNCCompression.ToString() + ";" + con.VNCEncoding.ToString() + ";" + con.VNCAuthMode.ToString() + ";" + con.VNCProxyType.ToString() + ";" + con.VNCProxyIP + ";" + System.Convert.ToString(con.VNCProxyPort) + ";" + con.VNCProxyUsername + ";" + con.VNCProxyPassword + ";" + con.VNCColors.ToString() + ";" + con.VNCSmartSizeMode.ToString() + ";" + System.Convert.ToString(con.VNCViewOnly) + ";"; - - if (SaveSecurity.Inheritance) - { - csvLn += con.Inherit.CacheBitmaps + ";" + System.Convert.ToString(con.Inherit.Colors) + ";" + System.Convert.ToString(con.Inherit.Description) + ";" + System.Convert.ToString(con.Inherit.DisplayThemes) + ";" + System.Convert.ToString(con.Inherit.DisplayWallpaper) + ";" + System.Convert.ToString(con.Inherit.EnableFontSmoothing) + ";" + System.Convert.ToString(con.Inherit.EnableDesktopComposition) + ";" + System.Convert.ToString(con.Inherit.Domain) + ";" + System.Convert.ToString(con.Inherit.Icon) + ";" + System.Convert.ToString(con.Inherit.Panel) + ";" + System.Convert.ToString(con.Inherit.Password) + ";" + System.Convert.ToString(con.Inherit.Port) + ";" + System.Convert.ToString(con.Inherit.Protocol) + ";" + System.Convert.ToString(con.Inherit.PuttySession) + ";" + System.Convert.ToString(con.Inherit.RedirectDiskDrives) + ";" + System.Convert.ToString(con.Inherit.RedirectKeys) + ";" + System.Convert.ToString(con.Inherit.RedirectPorts) + ";" + System.Convert.ToString(con.Inherit.RedirectPrinters) + ";" + System.Convert.ToString(con.Inherit.RedirectSmartCards) + ";" + System.Convert.ToString(con.Inherit.RedirectSound) + ";" + System.Convert.ToString(con.Inherit.Resolution) + ";" + System.Convert.ToString(con.Inherit.AutomaticResize) + ";" + System.Convert.ToString(con.Inherit.UseConsoleSession) + ";" + System.Convert.ToString(con.Inherit.UseCredSsp) + ";" + System.Convert.ToString(con.Inherit.RenderingEngine) + ";" + System.Convert.ToString(con.Inherit.Username) + ";" + System.Convert.ToString(con.Inherit.ICAEncryption) + ";" + System.Convert.ToString(con.Inherit.RDPAuthenticationLevel) + ";" + System.Convert.ToString(con.Inherit.LoadBalanceInfo) + ";" + System.Convert.ToString(con.Inherit.PreExtApp) + ";" + System.Convert.ToString(con.Inherit.PostExtApp) + ";" + System.Convert.ToString(con.Inherit.MacAddress) + ";" + System.Convert.ToString(con.Inherit.UserField) + ";" + System.Convert.ToString(con.Inherit.ExtApp) + ";" + System.Convert.ToString(con.Inherit.VNCCompression) + ";" - + System.Convert.ToString(con.Inherit.VNCEncoding) + ";" + System.Convert.ToString(con.Inherit.VNCAuthMode) + ";" + System.Convert.ToString(con.Inherit.VNCProxyType) + ";" + System.Convert.ToString(con.Inherit.VNCProxyIP) + ";" + System.Convert.ToString(con.Inherit.VNCProxyPort) + ";" + System.Convert.ToString(con.Inherit.VNCProxyUsername) + ";" + System.Convert.ToString(con.Inherit.VNCProxyPassword) + ";" + System.Convert.ToString(con.Inherit.VNCColors) + ";" + System.Convert.ToString(con.Inherit.VNCSmartSizeMode) + ";" + System.Convert.ToString(con.Inherit.VNCViewOnly); - } - - csvWr.WriteLine(csvLn); - } -#endregion - -#region vRD CSV - private void SaveTovRDCSV() - { - if (App.Runtime.IsConnectionsFileLoaded == false) - { - return; - } - - TreeNode tN = default(TreeNode); - tN = RootTreeNode.Clone(); - - TreeNodeCollection tNC = default(TreeNodeCollection); - tNC = tN.Nodes; - - csvWr = new StreamWriter(ConnectionFileName); - - SaveNodevRDCSV(tNC); - - csvWr.Close(); - } - - private void SaveNodevRDCSV(TreeNodeCollection tNC) - { - foreach (TreeNode node in tNC) - { - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) - { - Connection.Info curConI = node.Tag; - - if (curConI.Protocol == Connection.Protocol.Protocols.RDP) - { - WritevRDCSVLine(curConI); - } - } - else if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) - { - SaveNodevRDCSV(node.Nodes); - } - } - } - - private void WritevRDCSVLine(Connection.Info con) - { - string nodePath = con.TreeNode.FullPath; - - int firstSlash = nodePath.IndexOf("\\"); - nodePath = nodePath.Remove(0, firstSlash + 1); - int lastSlash = nodePath.LastIndexOf("\\"); - - if (lastSlash > 0) - { - nodePath = nodePath.Remove(lastSlash); - } - else - { - nodePath = ""; - } - - csvWr.WriteLine(con.Name + ";" + con.Hostname + ";" + con.MacAddress + ";;" + System.Convert.ToString(con.Port) + ";" + System.Convert.ToString(con.UseConsoleSession) + ";" + nodePath); - } -#endregion - -#region vRD VRE - private void SaveToVRE() - { - if (App.Runtime.IsConnectionsFileLoaded == false) - { - return; - } - - TreeNode tN = default(TreeNode); - tN = RootTreeNode.Clone(); - - TreeNodeCollection tNC = default(TreeNodeCollection); - tNC = tN.Nodes; - - _xmlTextWriter = new XmlTextWriter(ConnectionFileName, System.Text.Encoding.UTF8); - _xmlTextWriter.Formatting = Formatting.Indented; - _xmlTextWriter.Indentation = 4; - - _xmlTextWriter.WriteStartDocument(); - - _xmlTextWriter.WriteStartElement("vRDConfig"); - _xmlTextWriter.WriteAttributeString("Version", "", "2.0"); - - _xmlTextWriter.WriteStartElement("Connections"); - SaveNodeVRE(tNC); - _xmlTextWriter.WriteEndElement(); - - _xmlTextWriter.WriteEndElement(); - _xmlTextWriter.WriteEndDocument(); - _xmlTextWriter.Close(); - } - - private void SaveNodeVRE(TreeNodeCollection tNC) - { - foreach (TreeNode node in tNC) - { - if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) - { - Connection.Info curConI = node.Tag; - - if (curConI.Protocol == Connection.Protocol.Protocols.RDP) - { - _xmlTextWriter.WriteStartElement("Connection"); - _xmlTextWriter.WriteAttributeString("Id", "", ""); - - WriteVREitem(curConI); - - _xmlTextWriter.WriteEndElement(); - } - } - else - { - SaveNodeVRE(node.Nodes); - } - } - } - - private void WriteVREitem(Connection.Info con) - { - //Name - _xmlTextWriter.WriteStartElement("ConnectionName"); - _xmlTextWriter.WriteValue(con.Name); - _xmlTextWriter.WriteEndElement(); - - //Hostname - _xmlTextWriter.WriteStartElement("ServerName"); - _xmlTextWriter.WriteValue(con.Hostname); - _xmlTextWriter.WriteEndElement(); - - //Mac Adress - _xmlTextWriter.WriteStartElement("MACAddress"); - _xmlTextWriter.WriteValue(con.MacAddress); - _xmlTextWriter.WriteEndElement(); - - //Management Board URL - _xmlTextWriter.WriteStartElement("MgmtBoardUrl"); - _xmlTextWriter.WriteValue(""); - _xmlTextWriter.WriteEndElement(); - - //Description - _xmlTextWriter.WriteStartElement("Description"); - _xmlTextWriter.WriteValue(con.Description); - _xmlTextWriter.WriteEndElement(); - - //Port - _xmlTextWriter.WriteStartElement("Port"); - _xmlTextWriter.WriteValue(con.Port); - _xmlTextWriter.WriteEndElement(); - - //Console Session - _xmlTextWriter.WriteStartElement("Console"); - _xmlTextWriter.WriteValue(con.UseConsoleSession); - _xmlTextWriter.WriteEndElement(); - - //Redirect Clipboard - _xmlTextWriter.WriteStartElement("ClipBoard"); - _xmlTextWriter.WriteValue(true); - _xmlTextWriter.WriteEndElement(); - - //Redirect Printers - _xmlTextWriter.WriteStartElement("Printer"); - _xmlTextWriter.WriteValue(con.RedirectPrinters); - _xmlTextWriter.WriteEndElement(); - - //Redirect Ports - _xmlTextWriter.WriteStartElement("Serial"); - _xmlTextWriter.WriteValue(con.RedirectPorts); - _xmlTextWriter.WriteEndElement(); - - //Redirect Disks - _xmlTextWriter.WriteStartElement("LocalDrives"); - _xmlTextWriter.WriteValue(con.RedirectDiskDrives); - _xmlTextWriter.WriteEndElement(); - - //Redirect Smartcards - _xmlTextWriter.WriteStartElement("SmartCard"); - _xmlTextWriter.WriteValue(con.RedirectSmartCards); - _xmlTextWriter.WriteEndElement(); - - //Connection Place - _xmlTextWriter.WriteStartElement("ConnectionPlace"); - _xmlTextWriter.WriteValue("2"); //---------------------------------------------------------- - _xmlTextWriter.WriteEndElement(); - - //Smart Size - _xmlTextWriter.WriteStartElement("AutoSize"); - _xmlTextWriter.WriteValue(con.Resolution == Connection.Protocol.RDP.RDPResolutions.SmartSize); - _xmlTextWriter.WriteEndElement(); - - //SeparateResolutionX - _xmlTextWriter.WriteStartElement("SeparateResolutionX"); - _xmlTextWriter.WriteValue("1024"); - _xmlTextWriter.WriteEndElement(); - - //SeparateResolutionY - _xmlTextWriter.WriteStartElement("SeparateResolutionY"); - _xmlTextWriter.WriteValue("768"); - _xmlTextWriter.WriteEndElement(); - - Rectangle resolution = Connection.Protocol.RDP.GetResolutionRectangle(con.Resolution); - if (resolution.Width == 0) - { - resolution.Width = 1024; - } - if (resolution.Height == 0) - { - resolution.Height = 768; - } - - //TabResolutionX - _xmlTextWriter.WriteStartElement("TabResolutionX"); - _xmlTextWriter.WriteValue(resolution.Width); - _xmlTextWriter.WriteEndElement(); - - //TabResolutionY - _xmlTextWriter.WriteStartElement("TabResolutionY"); - _xmlTextWriter.WriteValue(resolution.Height); - _xmlTextWriter.WriteEndElement(); - - //RDPColorDepth - _xmlTextWriter.WriteStartElement("RDPColorDepth"); - _xmlTextWriter.WriteValue(con.Colors.ToString().Replace("Colors", "").Replace("Bit", "")); - _xmlTextWriter.WriteEndElement(); - - //Bitmap Caching - _xmlTextWriter.WriteStartElement("BitmapCaching"); - _xmlTextWriter.WriteValue(con.CacheBitmaps); - _xmlTextWriter.WriteEndElement(); - - //Themes - _xmlTextWriter.WriteStartElement("Themes"); - _xmlTextWriter.WriteValue(con.DisplayThemes); - _xmlTextWriter.WriteEndElement(); - - //Wallpaper - _xmlTextWriter.WriteStartElement("Wallpaper"); - _xmlTextWriter.WriteValue(con.DisplayWallpaper); - _xmlTextWriter.WriteEndElement(); - } -#endregion + break; } + frmMain.Default.UsingSqlServer = SaveFormat == Format.SQL; + } + #endregion + + #region SQL + private bool VerifyDatabaseVersion(SqlConnection sqlConnection) + { + bool isVerified = false; + SqlDataReader sqlDataReader = null; + System.Version databaseVersion = null; + try + { + SqlCommand sqlCommand = new SqlCommand("SELECT * FROM tblRoot", sqlConnection); + sqlDataReader = sqlCommand.ExecuteReader(); + if (!sqlDataReader.HasRows) + { + return true; // assume new empty database + } + sqlDataReader.Read(); + + databaseVersion = new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture)); + + sqlDataReader.Close(); + + if (databaseVersion.CompareTo(new System.Version(2, 2)) == 0) // 2.2 + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.3")); + sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD EnableFontSmoothing bit NOT NULL DEFAULT 0, EnableDesktopComposition bit NOT NULL DEFAULT 0, InheritEnableFontSmoothing bit NOT NULL DEFAULT 0, InheritEnableDesktopComposition bit NOT NULL DEFAULT 0;", sqlConnection); + sqlCommand.ExecuteNonQuery(); + databaseVersion = new System.Version(2, 3); + } + + if (databaseVersion.CompareTo(new System.Version(2, 3)) == 0) // 2.3 + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.4")); + sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD UseCredSsp bit NOT NULL DEFAULT 1, InheritUseCredSsp bit NOT NULL DEFAULT 0;", sqlConnection); + sqlCommand.ExecuteNonQuery(); + databaseVersion = new Version(2, 4); + } + + if (databaseVersion.CompareTo(new Version(2, 4)) == 0) // 2.4 + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.5")); + sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD LoadBalanceInfo varchar (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, AutomaticResize bit NOT NULL DEFAULT 1, InheritLoadBalanceInfo bit NOT NULL DEFAULT 0, InheritAutomaticResize bit NOT NULL DEFAULT 0;", sqlConnection); + sqlCommand.ExecuteNonQuery(); + databaseVersion = new Version(2, 5); + } + + if (databaseVersion.CompareTo(new Version(2, 5)) == 0) // 2.5 + { + isVerified = true; + } + + if (isVerified == false) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strErrorBadDatabaseVersion, databaseVersion.ToString(), (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName)); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorVerifyDatabaseVersionFailed, ex.Message)); + } + finally + { + if (sqlDataReader != null) + { + if (!sqlDataReader.IsClosed) + { + sqlDataReader.Close(); + } + } + } + return isVerified; + } + + private void SaveToSQL() + { + if (SQLUsername != "") + { + _sqlConnection = new SqlConnection("Data Source=" + SQLHost + ";Initial Catalog=" + SQLDatabaseName + ";User Id=" + SQLUsername + ";Password=" + SQLPassword); + } + else + { + _sqlConnection = new SqlConnection("Data Source=" + SQLHost + ";Initial Catalog=" + SQLDatabaseName + ";Integrated Security=True"); + } + + _sqlConnection.Open(); + + if (!VerifyDatabaseVersion(_sqlConnection)) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strErrorConnectionListSaveFailed); + return ; + } + + TreeNode tN = default(TreeNode); + tN = RootTreeNode.Clone(); + + string strProtected = ""; + if (tN.Tag != null) + { + if ((tN.Tag as mRemoteNG.Root.Info).Password == true) + { + _password = System.Convert.ToString((tN.Tag as mRemoteNG.Root.Info).PasswordString); + strProtected = Security.Crypt.Encrypt("ThisIsProtected", _password); + } + else + { + strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); + } + } + else + { + strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); + } + + _sqlQuery = new SqlCommand("DELETE FROM tblRoot", _sqlConnection); + _sqlQuery.ExecuteNonQuery(); + + _sqlQuery = new SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" + PrepareValueForDB(tN.Text) + "\', 0, \'" + strProtected + "\'," + App.Info.Connections.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")", _sqlConnection); + _sqlQuery.ExecuteNonQuery(); + + _sqlQuery = new SqlCommand("DELETE FROM tblCons", _sqlConnection); + _sqlQuery.ExecuteNonQuery(); + + TreeNodeCollection tNC = default(TreeNodeCollection); + tNC = tN.Nodes; + + SaveNodesSQL(tNC); + + _sqlQuery = new SqlCommand("DELETE FROM tblUpdate", _sqlConnection); + _sqlQuery.ExecuteNonQuery(); + _sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + Tools.Misc.DBDate(DateTime.Now) + "\')", _sqlConnection); + _sqlQuery.ExecuteNonQuery(); + + _sqlConnection.Close(); + } + + private void SaveNodesSQL(TreeNodeCollection tnc) + { + foreach (TreeNode node in tnc) + { + _currentNodeIndex++; + + Connection.Info curConI = default(Connection.Info); + _sqlQuery = new SqlCommand("INSERT INTO tblCons (Name, Type, Expanded, Description, Icon, Panel, Username, " + "DomainName, Password, Hostname, Protocol, PuttySession, " + "Port, ConnectToConsole, RenderingEngine, ICAEncryptionStrength, RDPAuthenticationLevel, LoadBalanceInfo, Colors, Resolution, AutomaticResize, DisplayWallpaper, " + "DisplayThemes, EnableFontSmoothing, EnableDesktopComposition, CacheBitmaps, RedirectDiskDrives, RedirectPorts, " + "RedirectPrinters, RedirectSmartCards, RedirectSound, RedirectKeys, " + "Connected, PreExtApp, PostExtApp, MacAddress, UserField, ExtApp, VNCCompression, VNCEncoding, VNCAuthMode, " + "VNCProxyType, VNCProxyIP, VNCProxyPort, VNCProxyUsername, VNCProxyPassword, " + "VNCColors, VNCSmartSizeMode, VNCViewOnly, " + "RDGatewayUsageMethod, RDGatewayHostname, RDGatewayUseConnectionCredentials, RDGatewayUsername, RDGatewayPassword, RDGatewayDomain, " + "UseCredSsp, " + "InheritCacheBitmaps, InheritColors, " + "InheritDescription, InheritDisplayThemes, InheritDisplayWallpaper, InheritEnableFontSmoothing, InheritEnableDesktopComposition, InheritDomain, " + "InheritIcon, InheritPanel, InheritPassword, InheritPort, " + "InheritProtocol, InheritPuttySession, InheritRedirectDiskDrives, " + "InheritRedirectKeys, InheritRedirectPorts, InheritRedirectPrinters, " + "InheritRedirectSmartCards, InheritRedirectSound, InheritResolution, InheritAutomaticResize, " + "InheritUseConsoleSession, InheritRenderingEngine, InheritUsername, InheritICAEncryptionStrength, InheritRDPAuthenticationLevel, InheritLoadBalanceInfo, " + "InheritPreExtApp, InheritPostExtApp, InheritMacAddress, InheritUserField, InheritExtApp, InheritVNCCompression, InheritVNCEncoding, " + "InheritVNCAuthMode, InheritVNCProxyType, InheritVNCProxyIP, InheritVNCProxyPort, " + "InheritVNCProxyUsername, InheritVNCProxyPassword, InheritVNCColors, " + "InheritVNCSmartSizeMode, InheritVNCViewOnly, " + "InheritRDGatewayUsageMethod, InheritRDGatewayHostname, InheritRDGatewayUseConnectionCredentials, InheritRDGatewayUsername, InheritRDGatewayPassword, InheritRDGatewayDomain, " + + "InheritUseCredSsp, " + "PositionID, ParentID, ConstantID, LastChange)" + "VALUES (", _sqlConnection + ); + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) + { + //_xmlTextWriter.WriteStartElement("Node") + _sqlQuery.CommandText += "\'" + PrepareValueForDB(node.Text) + "\',"; //Name + _sqlQuery.CommandText += "\'" + Tree.Node.GetNodeType(node).ToString() + "\',"; //Type + } + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) //container + { + _sqlQuery.CommandText += "\'" + this._ContainerList[node.Tag].IsExpanded + "\',"; //Expanded + curConI = this._ContainerList[node.Tag].ConnectionInfo; + SaveConnectionFieldsSQL(curConI); + + _sqlQuery.CommandText = Tools.Misc.PrepareForDB(_sqlQuery.CommandText); + _sqlQuery.ExecuteNonQuery(); + //_parentConstantId = _currentNodeIndex + SaveNodesSQL(node.Nodes); + //_xmlTextWriter.WriteEndElement() + } + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) + { + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + curConI = this._ConnectionList[node.Tag]; + SaveConnectionFieldsSQL(curConI); + //_xmlTextWriter.WriteEndElement() + _sqlQuery.CommandText = Tools.Misc.PrepareForDB(_sqlQuery.CommandText); + _sqlQuery.ExecuteNonQuery(); + } + + //_parentConstantId = 0 + } + } + + private void SaveConnectionFieldsSQL(Connection.Info curConI) + { + Connection.Info with_1 = curConI; + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Description) + "\',"; + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Icon) + "\',"; + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Panel) + "\',"; + + if (this._SaveSecurity.Username == true) + { + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Username) + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + if (this._SaveSecurity.Domain == true) + { + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Domain) + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + if (this._SaveSecurity.Password == true) + { + _sqlQuery.CommandText += "\'" + PrepareValueForDB(Security.Crypt.Encrypt(with_1.Password, _password)) + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.Hostname) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Protocol.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + PrepareValueForDB(with_1.PuttySession) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Port) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.UseConsoleSession) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RenderingEngine.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.ICAEncryption.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDPAuthenticationLevel.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.LoadBalanceInfo + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Colors.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Resolution.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.AutomaticResize) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.DisplayWallpaper) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.DisplayThemes) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.EnableFontSmoothing) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.EnableDesktopComposition) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.CacheBitmaps) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectDiskDrives) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectPorts) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectPrinters) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectSmartCards) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RedirectSound.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.RedirectKeys) + "\',"; + + if (curConI.OpenConnections.Count > 0) + { + _sqlQuery.CommandText += 1 + ","; + } + else + { + _sqlQuery.CommandText += 0 + ","; + } + + _sqlQuery.CommandText += "\'" + with_1.PreExtApp + "\',"; + _sqlQuery.CommandText += "\'" + with_1.PostExtApp + "\',"; + _sqlQuery.CommandText += "\'" + with_1.MacAddress + "\',"; + _sqlQuery.CommandText += "\'" + with_1.UserField + "\',"; + _sqlQuery.CommandText += "\'" + with_1.ExtApp + "\',"; + + _sqlQuery.CommandText += "\'" + with_1.VNCCompression.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCEncoding.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCAuthMode.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCProxyType.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCProxyIP + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.VNCProxyPort) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCProxyUsername + "\',"; + _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.VNCProxyPassword, _password) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCColors.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCSmartSizeMode.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.VNCViewOnly) + "\',"; + + _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsageMethod.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDGatewayHostname + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDGatewayUseConnectionCredentials.ToString() + "\',"; + + if (this._SaveSecurity.Username == true) + { + _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsername + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + if (this._SaveSecurity.Password == true) + { + _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.RDGatewayPassword, _password) + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + if (this._SaveSecurity.Domain == true) + { + _sqlQuery.CommandText += "\'" + with_1.RDGatewayDomain + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + "" + "\',"; + } + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.UseCredSsp) + "\',"; + + if (this._SaveSecurity.Inheritance == true) + { + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.CacheBitmaps) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Colors) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Description) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.DisplayThemes) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.DisplayWallpaper) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.EnableFontSmoothing) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.EnableDesktopComposition) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Domain) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Icon) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Panel) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Password) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Port) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Protocol) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PuttySession) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectDiskDrives) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectKeys) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectPorts) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectPrinters) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectSmartCards) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RedirectSound) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Resolution) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.AutomaticResize) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UseConsoleSession) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RenderingEngine) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.Username) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.ICAEncryption) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDPAuthenticationLevel) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.LoadBalanceInfo) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PreExtApp) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.PostExtApp) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.MacAddress) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UserField) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.ExtApp) + "\',"; + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCCompression) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCEncoding) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCAuthMode) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyType) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyIP) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyPort) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyUsername) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCProxyPassword) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCColors) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCSmartSizeMode) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.VNCViewOnly) + "\',"; + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUsageMethod) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayHostname) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUseConnectionCredentials) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayUsername) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayPassword) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.RDGatewayDomain) + "\',"; + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(with_1.Inherit.UseCredSsp) + "\',"; + } + else + { + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .AutomaticResize + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .LoadBalanceInfo + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUsageMethod + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayHostname + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUseConnectionCredentials + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayUsername + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayPassword + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .RDGatewayDomain + + _sqlQuery.CommandText += "\'" + System.Convert.ToString(false) + "\',"; // .UseCredSsp + } + + with_1.PositionID = _currentNodeIndex; + + if (with_1.IsContainer == false) + { + if (with_1.Parent != null) + { + _parentConstantId = System.Convert.ToString((with_1.Parent as Container.Info).ConnectionInfo.ConstantID); + } + else + { + _parentConstantId = System.Convert.ToString(0); + } + } + else + { + if ((with_1.Parent as Container.Info).Parent != null) + { + _parentConstantId = System.Convert.ToString(((with_1.Parent as Container.Info).Parent as Container.Info).ConnectionInfo.ConstantID); + } + else + { + _parentConstantId = System.Convert.ToString(0); + } + } + + _sqlQuery.CommandText += _currentNodeIndex + ",\'" + _parentConstantId + "\',\'" + with_1.ConstantID + "\',\'" + Tools.Misc.DBDate(DateTime.Now) + "\')"; + } + #endregion + + #region XML + private void EncryptCompleteFile() + { + StreamReader streamReader = new StreamReader(ConnectionFileName); + + string fileContents = ""; + fileContents = streamReader.ReadToEnd(); + streamReader.Close(); + + if (!string.IsNullOrEmpty(fileContents)) + { + StreamWriter streamWriter = new StreamWriter(ConnectionFileName); + streamWriter.Write(Security.Crypt.Encrypt(fileContents, _password)); + streamWriter.Close(); + } + } + + private void SaveToXml() + { + try + { + if (!IsConnectionsFileLoaded) + { + return; + } + + TreeNode treeNode = default(TreeNode); + + if (Tree.Node.GetNodeType(RootTreeNode) == Tree.Node.Type.Root) + { + treeNode = RootTreeNode.Clone(); + } + else + { + treeNode = new TreeNode("mR|Export (" + Tools.Misc.DBDate(DateTime.Now) + ")"); + treeNode.Nodes.Add(System.Convert.ToString(RootTreeNode.Clone())); + } + + string tempFileName = Path.GetTempFileName(); + _xmlTextWriter = new XmlTextWriter(tempFileName, System.Text.Encoding.UTF8); + + _xmlTextWriter.Formatting = Formatting.Indented; + _xmlTextWriter.Indentation = 4; + + _xmlTextWriter.WriteStartDocument(); + + _xmlTextWriter.WriteStartElement("Connections"); // Do not localize + _xmlTextWriter.WriteAttributeString("Name", "", treeNode.Text); + _xmlTextWriter.WriteAttributeString("Export", "", System.Convert.ToString(Export)); + + if (Export) + { + _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); + } + else + { + if ((treeNode.Tag as Root.Info).Password == true) + { + _password = System.Convert.ToString((treeNode.Tag as Root.Info).PasswordString); + _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsProtected", _password)); + } + else + { + _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); + } + } + + _xmlTextWriter.WriteAttributeString("ConfVersion", "", App.Info.Connections.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture)); + + TreeNodeCollection treeNodeCollection = default(TreeNodeCollection); + treeNodeCollection = treeNode.Nodes; + + SaveNode(treeNodeCollection); + + _xmlTextWriter.WriteEndElement(); + _xmlTextWriter.Close(); + + if (File.Exists(ConnectionFileName)) + { + if (Export) + { + File.Delete(ConnectionFileName); + } + else + { + string backupFileName = ConnectionFileName +".backup"; + File.Delete(backupFileName); + File.Move(ConnectionFileName, backupFileName); + } + } + File.Move(tempFileName, ConnectionFileName); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveToXml failed" + Constants.vbNewLine + ex.Message, false); + } + } + + private void SaveNode(TreeNodeCollection tNC) + { + try + { + foreach (TreeNode node in tNC) + { + Connection.Info curConI = default(Connection.Info); + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) + { + _xmlTextWriter.WriteStartElement("Node"); + _xmlTextWriter.WriteAttributeString("Name", "", node.Text); + _xmlTextWriter.WriteAttributeString("Type", "", Tree.Node.GetNodeType(node).ToString()); + } + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) //container + { + _xmlTextWriter.WriteAttributeString("Expanded", "", System.Convert.ToString(this._ContainerList[node.Tag].TreeNode.IsExpanded)); + curConI = this._ContainerList[node.Tag].ConnectionInfo; + SaveConnectionFields(curConI); + SaveNode(node.Nodes); + _xmlTextWriter.WriteEndElement(); + } + + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) + { + curConI = this._ConnectionList[node.Tag]; + SaveConnectionFields(curConI); + _xmlTextWriter.WriteEndElement(); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveNode failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void SaveConnectionFields(Connection.Info curConI) + { + try + { + _xmlTextWriter.WriteAttributeString("Descr", "", curConI.Description); + + _xmlTextWriter.WriteAttributeString("Icon", "", curConI.Icon); + + _xmlTextWriter.WriteAttributeString("Panel", "", curConI.Panel); + + if (this._SaveSecurity.Username == true) + { + _xmlTextWriter.WriteAttributeString("Username", "", curConI.Username); + } + else + { + _xmlTextWriter.WriteAttributeString("Username", "", ""); + } + + if (this._SaveSecurity.Domain == true) + { + _xmlTextWriter.WriteAttributeString("Domain", "", curConI.Domain); + } + else + { + _xmlTextWriter.WriteAttributeString("Domain", "", ""); + } + + if (this._SaveSecurity.Password == true) + { + _xmlTextWriter.WriteAttributeString("Password", "", Security.Crypt.Encrypt(curConI.Password, _password)); + } + else + { + _xmlTextWriter.WriteAttributeString("Password", "", ""); + } + + _xmlTextWriter.WriteAttributeString("Hostname", "", curConI.Hostname); + + _xmlTextWriter.WriteAttributeString("Protocol", "", curConI.Protocol.ToString()); + + _xmlTextWriter.WriteAttributeString("PuttySession", "", curConI.PuttySession); + + _xmlTextWriter.WriteAttributeString("Port", "", System.Convert.ToString(curConI.Port)); + + _xmlTextWriter.WriteAttributeString("ConnectToConsole", "", System.Convert.ToString(curConI.UseConsoleSession)); + + _xmlTextWriter.WriteAttributeString("UseCredSsp", "", System.Convert.ToString(curConI.UseCredSsp)); + + _xmlTextWriter.WriteAttributeString("RenderingEngine", "", curConI.RenderingEngine.ToString()); + + _xmlTextWriter.WriteAttributeString("ICAEncryptionStrength", "", curConI.ICAEncryption.ToString()); + + _xmlTextWriter.WriteAttributeString("RDPAuthenticationLevel", "", curConI.RDPAuthenticationLevel.ToString()); + + _xmlTextWriter.WriteAttributeString("LoadBalanceInfo", "", curConI.LoadBalanceInfo); + + _xmlTextWriter.WriteAttributeString("Colors", "", curConI.Colors.ToString()); + + _xmlTextWriter.WriteAttributeString("Resolution", "", curConI.Resolution.ToString()); + + _xmlTextWriter.WriteAttributeString("AutomaticResize", "", System.Convert.ToString(curConI.AutomaticResize)); + + _xmlTextWriter.WriteAttributeString("DisplayWallpaper", "", System.Convert.ToString(curConI.DisplayWallpaper)); + + _xmlTextWriter.WriteAttributeString("DisplayThemes", "", System.Convert.ToString(curConI.DisplayThemes)); + + _xmlTextWriter.WriteAttributeString("EnableFontSmoothing", "", System.Convert.ToString(curConI.EnableFontSmoothing)); + + _xmlTextWriter.WriteAttributeString("EnableDesktopComposition", "", System.Convert.ToString(curConI.EnableDesktopComposition)); + + _xmlTextWriter.WriteAttributeString("CacheBitmaps", "", System.Convert.ToString(curConI.CacheBitmaps)); + + _xmlTextWriter.WriteAttributeString("RedirectDiskDrives", "", System.Convert.ToString(curConI.RedirectDiskDrives)); + + _xmlTextWriter.WriteAttributeString("RedirectPorts", "", System.Convert.ToString(curConI.RedirectPorts)); + + _xmlTextWriter.WriteAttributeString("RedirectPrinters", "", System.Convert.ToString(curConI.RedirectPrinters)); + + _xmlTextWriter.WriteAttributeString("RedirectSmartCards", "", System.Convert.ToString(curConI.RedirectSmartCards)); + + _xmlTextWriter.WriteAttributeString("RedirectSound", "", curConI.RedirectSound.ToString()); + + _xmlTextWriter.WriteAttributeString("RedirectKeys", "", System.Convert.ToString(curConI.RedirectKeys)); + + if (curConI.OpenConnections.Count > 0) + { + _xmlTextWriter.WriteAttributeString("Connected", "", System.Convert.ToString(true)); + } + else + { + _xmlTextWriter.WriteAttributeString("Connected", "", System.Convert.ToString(false)); + } + + _xmlTextWriter.WriteAttributeString("PreExtApp", "", curConI.PreExtApp); + _xmlTextWriter.WriteAttributeString("PostExtApp", "", curConI.PostExtApp); + _xmlTextWriter.WriteAttributeString("MacAddress", "", curConI.MacAddress); + _xmlTextWriter.WriteAttributeString("UserField", "", curConI.UserField); + _xmlTextWriter.WriteAttributeString("ExtApp", "", curConI.ExtApp); + + _xmlTextWriter.WriteAttributeString("VNCCompression", "", curConI.VNCCompression.ToString()); + _xmlTextWriter.WriteAttributeString("VNCEncoding", "", curConI.VNCEncoding.ToString()); + _xmlTextWriter.WriteAttributeString("VNCAuthMode", "", curConI.VNCAuthMode.ToString()); + _xmlTextWriter.WriteAttributeString("VNCProxyType", "", curConI.VNCProxyType.ToString()); + _xmlTextWriter.WriteAttributeString("VNCProxyIP", "", curConI.VNCProxyIP); + _xmlTextWriter.WriteAttributeString("VNCProxyPort", "", System.Convert.ToString(curConI.VNCProxyPort)); + _xmlTextWriter.WriteAttributeString("VNCProxyUsername", "", curConI.VNCProxyUsername); + _xmlTextWriter.WriteAttributeString("VNCProxyPassword", "", Security.Crypt.Encrypt(curConI.VNCProxyPassword, _password)); + _xmlTextWriter.WriteAttributeString("VNCColors", "", curConI.VNCColors.ToString()); + _xmlTextWriter.WriteAttributeString("VNCSmartSizeMode", "", curConI.VNCSmartSizeMode.ToString()); + _xmlTextWriter.WriteAttributeString("VNCViewOnly", "", System.Convert.ToString(curConI.VNCViewOnly)); + + _xmlTextWriter.WriteAttributeString("RDGatewayUsageMethod", "", curConI.RDGatewayUsageMethod.ToString()); + _xmlTextWriter.WriteAttributeString("RDGatewayHostname", "", curConI.RDGatewayHostname); + + _xmlTextWriter.WriteAttributeString("RDGatewayUseConnectionCredentials", "", curConI.RDGatewayUseConnectionCredentials.ToString()); + + if (this._SaveSecurity.Username == true) + { + _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", curConI.RDGatewayUsername); + } + else + { + _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", ""); + } + + if (this._SaveSecurity.Password == true) + { + _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", Security.Crypt.Encrypt(curConI.RDGatewayPassword, _password)); + } + else + { + _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", ""); + } + + if (this._SaveSecurity.Domain == true) + { + _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", curConI.RDGatewayDomain); + } + else + { + _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", ""); + } + + if (this._SaveSecurity.Inheritance == true) + { + _xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", System.Convert.ToString(curConI.Inherit.CacheBitmaps)); + _xmlTextWriter.WriteAttributeString("InheritColors", "", System.Convert.ToString(curConI.Inherit.Colors)); + _xmlTextWriter.WriteAttributeString("InheritDescription", "", System.Convert.ToString(curConI.Inherit.Description)); + _xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", System.Convert.ToString(curConI.Inherit.DisplayThemes)); + _xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", System.Convert.ToString(curConI.Inherit.DisplayWallpaper)); + _xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", System.Convert.ToString(curConI.Inherit.EnableFontSmoothing)); + _xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", System.Convert.ToString(curConI.Inherit.EnableDesktopComposition)); + _xmlTextWriter.WriteAttributeString("InheritDomain", "", System.Convert.ToString(curConI.Inherit.Domain)); + _xmlTextWriter.WriteAttributeString("InheritIcon", "", System.Convert.ToString(curConI.Inherit.Icon)); + _xmlTextWriter.WriteAttributeString("InheritPanel", "", System.Convert.ToString(curConI.Inherit.Panel)); + _xmlTextWriter.WriteAttributeString("InheritPassword", "", System.Convert.ToString(curConI.Inherit.Password)); + _xmlTextWriter.WriteAttributeString("InheritPort", "", System.Convert.ToString(curConI.Inherit.Port)); + _xmlTextWriter.WriteAttributeString("InheritProtocol", "", System.Convert.ToString(curConI.Inherit.Protocol)); + _xmlTextWriter.WriteAttributeString("InheritPuttySession", "", System.Convert.ToString(curConI.Inherit.PuttySession)); + _xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", System.Convert.ToString(curConI.Inherit.RedirectDiskDrives)); + _xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", System.Convert.ToString(curConI.Inherit.RedirectKeys)); + _xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", System.Convert.ToString(curConI.Inherit.RedirectPorts)); + _xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", System.Convert.ToString(curConI.Inherit.RedirectPrinters)); + _xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", System.Convert.ToString(curConI.Inherit.RedirectSmartCards)); + _xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", System.Convert.ToString(curConI.Inherit.RedirectSound)); + _xmlTextWriter.WriteAttributeString("InheritResolution", "", System.Convert.ToString(curConI.Inherit.Resolution)); + _xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", System.Convert.ToString(curConI.Inherit.AutomaticResize)); + _xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", System.Convert.ToString(curConI.Inherit.UseConsoleSession)); + _xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", System.Convert.ToString(curConI.Inherit.UseCredSsp)); + _xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", System.Convert.ToString(curConI.Inherit.RenderingEngine)); + _xmlTextWriter.WriteAttributeString("InheritUsername", "", System.Convert.ToString(curConI.Inherit.Username)); + _xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", System.Convert.ToString(curConI.Inherit.ICAEncryption)); + _xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", System.Convert.ToString(curConI.Inherit.RDPAuthenticationLevel)); + _xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", System.Convert.ToString(curConI.Inherit.LoadBalanceInfo)); + _xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", System.Convert.ToString(curConI.Inherit.PreExtApp)); + _xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", System.Convert.ToString(curConI.Inherit.PostExtApp)); + _xmlTextWriter.WriteAttributeString("InheritMacAddress", "", System.Convert.ToString(curConI.Inherit.MacAddress)); + _xmlTextWriter.WriteAttributeString("InheritUserField", "", System.Convert.ToString(curConI.Inherit.UserField)); + _xmlTextWriter.WriteAttributeString("InheritExtApp", "", System.Convert.ToString(curConI.Inherit.ExtApp)); + _xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", System.Convert.ToString(curConI.Inherit.VNCCompression)); + _xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", System.Convert.ToString(curConI.Inherit.VNCEncoding)); + _xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", System.Convert.ToString(curConI.Inherit.VNCAuthMode)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", System.Convert.ToString(curConI.Inherit.VNCProxyType)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", System.Convert.ToString(curConI.Inherit.VNCProxyIP)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", System.Convert.ToString(curConI.Inherit.VNCProxyPort)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", System.Convert.ToString(curConI.Inherit.VNCProxyUsername)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", System.Convert.ToString(curConI.Inherit.VNCProxyPassword)); + _xmlTextWriter.WriteAttributeString("InheritVNCColors", "", System.Convert.ToString(curConI.Inherit.VNCColors)); + _xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", System.Convert.ToString(curConI.Inherit.VNCSmartSizeMode)); + _xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", System.Convert.ToString(curConI.Inherit.VNCViewOnly)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsageMethod", "", System.Convert.ToString(curConI.Inherit.RDGatewayUsageMethod)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", System.Convert.ToString(curConI.Inherit.RDGatewayHostname)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", System.Convert.ToString(curConI.Inherit.RDGatewayUseConnectionCredentials)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", System.Convert.ToString(curConI.Inherit.RDGatewayUsername)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", System.Convert.ToString(curConI.Inherit.RDGatewayPassword)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", System.Convert.ToString(curConI.Inherit.RDGatewayDomain)); + } + else + { + _xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritColors", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritDescription", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritDomain", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritIcon", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPanel", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPassword", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPort", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritProtocol", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPuttySession", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritResolution", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritUsername", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritMacAddress", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritUserField", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritExtApp", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCColors", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", System.Convert.ToString(false)); + _xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", System.Convert.ToString(false)); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveConnectionFields failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region CSV + private StreamWriter csvWr; + + private void SaveTomRCSV() + { + if (App.Runtime.IsConnectionsFileLoaded == false) + { + return; + } + + TreeNode tN = default(TreeNode); + tN = RootTreeNode.Clone(); + + TreeNodeCollection tNC = default(TreeNodeCollection); + tNC = tN.Nodes; + + csvWr = new StreamWriter(ConnectionFileName); + + + string csvLn = string.Empty; + + csvLn += "Name;Folder;Description;Icon;Panel;"; + + if (SaveSecurity.Username) + { + csvLn += "Username;"; + } + + if (SaveSecurity.Password) + { + csvLn += "Password;"; + } + + if (SaveSecurity.Domain) + { + csvLn += "Domain;"; + } + + csvLn += "Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;"; + + if (SaveSecurity.Inheritance) + { + csvLn += "InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain"; + } + + csvWr.WriteLine(csvLn); + + SaveNodemRCSV(tNC); + + csvWr.Close(); + } + + private void SaveNodemRCSV(TreeNodeCollection tNC) + { + foreach (TreeNode node in tNC) + { + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) + { + Connection.Info curConI = node.Tag; + + WritemRCSVLine(curConI); + } + else if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) + { + SaveNodemRCSV(node.Nodes); + } + } + } + + private void WritemRCSVLine(Connection.Info con) + { + string nodePath = con.TreeNode.FullPath; + + int firstSlash = nodePath.IndexOf("\\"); + nodePath = nodePath.Remove(0, firstSlash + 1); + int lastSlash = nodePath.LastIndexOf("\\"); + + if (lastSlash > 0) + { + nodePath = nodePath.Remove(lastSlash); + } + else + { + nodePath = ""; + } + + string csvLn = string.Empty; + + csvLn += con.Name + ";" + nodePath + ";" + con.Description + ";" + con.Icon + ";" + con.Panel + ";"; + + if (SaveSecurity.Username) + { + csvLn += con.Username + ";"; + } + + if (SaveSecurity.Password) + { + csvLn += con.Password + ";"; + } + + if (SaveSecurity.Domain) + { + csvLn += con.Domain + ";"; + } + + csvLn += con.Hostname + ";" + con.Protocol.ToString() + ";" + con.PuttySession + ";" + System.Convert.ToString(con.Port) + ";" + System.Convert.ToString(con.UseConsoleSession) + ";" + System.Convert.ToString(con.UseCredSsp) + ";" + con.RenderingEngine.ToString() + ";" + con.ICAEncryption.ToString() + ";" + con.RDPAuthenticationLevel.ToString() + ";" + con.LoadBalanceInfo + ";" + con.Colors.ToString() + ";" + con.Resolution.ToString() + ";" + System.Convert.ToString(con.AutomaticResize) + ";" + System.Convert.ToString(con.DisplayWallpaper) + ";" + System.Convert.ToString(con.DisplayThemes) + ";" + System.Convert.ToString(con.EnableFontSmoothing) + ";" + System.Convert.ToString(con.EnableDesktopComposition) + ";" + System.Convert.ToString(con.CacheBitmaps) + ";" + System.Convert.ToString(con.RedirectDiskDrives) + ";" + System.Convert.ToString(con.RedirectPorts) + ";" + System.Convert.ToString(con.RedirectPrinters) + ";" + System.Convert.ToString(con.RedirectSmartCards) + ";" + con.RedirectSound.ToString() + ";" + System.Convert.ToString(con.RedirectKeys) + ";" + con.PreExtApp + ";" + con.PostExtApp + ";" + con.MacAddress + ";" + con.UserField + ";" + con.ExtApp + ";" + con.VNCCompression.ToString() + ";" + con.VNCEncoding.ToString() + ";" + con.VNCAuthMode.ToString() + ";" + con.VNCProxyType.ToString() + ";" + con.VNCProxyIP + ";" + System.Convert.ToString(con.VNCProxyPort) + ";" + con.VNCProxyUsername + ";" + con.VNCProxyPassword + ";" + con.VNCColors.ToString() + ";" + con.VNCSmartSizeMode.ToString() + ";" + System.Convert.ToString(con.VNCViewOnly) + ";"; + + if (SaveSecurity.Inheritance) + { + csvLn += con.Inherit.CacheBitmaps + ";" + System.Convert.ToString(con.Inherit.Colors) + ";" + System.Convert.ToString(con.Inherit.Description) + ";" + System.Convert.ToString(con.Inherit.DisplayThemes) + ";" + System.Convert.ToString(con.Inherit.DisplayWallpaper) + ";" + System.Convert.ToString(con.Inherit.EnableFontSmoothing) + ";" + System.Convert.ToString(con.Inherit.EnableDesktopComposition) + ";" + System.Convert.ToString(con.Inherit.Domain) + ";" + System.Convert.ToString(con.Inherit.Icon) + ";" + System.Convert.ToString(con.Inherit.Panel) + ";" + System.Convert.ToString(con.Inherit.Password) + ";" + System.Convert.ToString(con.Inherit.Port) + ";" + System.Convert.ToString(con.Inherit.Protocol) + ";" + System.Convert.ToString(con.Inherit.PuttySession) + ";" + System.Convert.ToString(con.Inherit.RedirectDiskDrives) + ";" + System.Convert.ToString(con.Inherit.RedirectKeys) + ";" + System.Convert.ToString(con.Inherit.RedirectPorts) + ";" + System.Convert.ToString(con.Inherit.RedirectPrinters) + ";" + System.Convert.ToString(con.Inherit.RedirectSmartCards) + ";" + System.Convert.ToString(con.Inherit.RedirectSound) + ";" + System.Convert.ToString(con.Inherit.Resolution) + ";" + System.Convert.ToString(con.Inherit.AutomaticResize) + ";" + System.Convert.ToString(con.Inherit.UseConsoleSession) + ";" + System.Convert.ToString(con.Inherit.UseCredSsp) + ";" + System.Convert.ToString(con.Inherit.RenderingEngine) + ";" + System.Convert.ToString(con.Inherit.Username) + ";" + System.Convert.ToString(con.Inherit.ICAEncryption) + ";" + System.Convert.ToString(con.Inherit.RDPAuthenticationLevel) + ";" + System.Convert.ToString(con.Inherit.LoadBalanceInfo) + ";" + System.Convert.ToString(con.Inherit.PreExtApp) + ";" + System.Convert.ToString(con.Inherit.PostExtApp) + ";" + System.Convert.ToString(con.Inherit.MacAddress) + ";" + System.Convert.ToString(con.Inherit.UserField) + ";" + System.Convert.ToString(con.Inherit.ExtApp) + ";" + System.Convert.ToString(con.Inherit.VNCCompression) + ";" + + System.Convert.ToString(con.Inherit.VNCEncoding) + ";" + System.Convert.ToString(con.Inherit.VNCAuthMode) + ";" + System.Convert.ToString(con.Inherit.VNCProxyType) + ";" + System.Convert.ToString(con.Inherit.VNCProxyIP) + ";" + System.Convert.ToString(con.Inherit.VNCProxyPort) + ";" + System.Convert.ToString(con.Inherit.VNCProxyUsername) + ";" + System.Convert.ToString(con.Inherit.VNCProxyPassword) + ";" + System.Convert.ToString(con.Inherit.VNCColors) + ";" + System.Convert.ToString(con.Inherit.VNCSmartSizeMode) + ";" + System.Convert.ToString(con.Inherit.VNCViewOnly); + } + + csvWr.WriteLine(csvLn); + } + #endregion + + #region vRD CSV + private void SaveTovRDCSV() + { + if (App.Runtime.IsConnectionsFileLoaded == false) + { + return; + } + + TreeNode tN = default(TreeNode); + tN = RootTreeNode.Clone(); + + TreeNodeCollection tNC = default(TreeNodeCollection); + tNC = tN.Nodes; + + csvWr = new StreamWriter(ConnectionFileName); + + SaveNodevRDCSV(tNC); + + csvWr.Close(); + } + + private void SaveNodevRDCSV(TreeNodeCollection tNC) + { + foreach (TreeNode node in tNC) + { + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) + { + Connection.Info curConI = node.Tag; + + if (curConI.Protocol == Connection.Protocol.Protocols.RDP) + { + WritevRDCSVLine(curConI); + } + } + else if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Container) + { + SaveNodevRDCSV(node.Nodes); + } + } + } + + private void WritevRDCSVLine(Connection.Info con) + { + string nodePath = con.TreeNode.FullPath; + + int firstSlash = nodePath.IndexOf("\\"); + nodePath = nodePath.Remove(0, firstSlash + 1); + int lastSlash = nodePath.LastIndexOf("\\"); + + if (lastSlash > 0) + { + nodePath = nodePath.Remove(lastSlash); + } + else + { + nodePath = ""; + } + + csvWr.WriteLine(con.Name + ";" + con.Hostname + ";" + con.MacAddress + ";;" + System.Convert.ToString(con.Port) + ";" + System.Convert.ToString(con.UseConsoleSession) + ";" + nodePath); + } + #endregion + + #region vRD VRE + private void SaveToVRE() + { + if (App.Runtime.IsConnectionsFileLoaded == false) + { + return; + } + + TreeNode tN = default(TreeNode); + tN = RootTreeNode.Clone(); + + TreeNodeCollection tNC = default(TreeNodeCollection); + tNC = tN.Nodes; + + _xmlTextWriter = new XmlTextWriter(ConnectionFileName, System.Text.Encoding.UTF8); + _xmlTextWriter.Formatting = Formatting.Indented; + _xmlTextWriter.Indentation = 4; + + _xmlTextWriter.WriteStartDocument(); + + _xmlTextWriter.WriteStartElement("vRDConfig"); + _xmlTextWriter.WriteAttributeString("Version", "", "2.0"); + + _xmlTextWriter.WriteStartElement("Connections"); + SaveNodeVRE(tNC); + _xmlTextWriter.WriteEndElement(); + + _xmlTextWriter.WriteEndElement(); + _xmlTextWriter.WriteEndDocument(); + _xmlTextWriter.Close(); + } + + private void SaveNodeVRE(TreeNodeCollection tNC) + { + foreach (TreeNode node in tNC) + { + if (Tree.Node.GetNodeType(node) == Tree.Node.Type.Connection) + { + Connection.Info curConI = node.Tag; + + if (curConI.Protocol == Connection.Protocol.Protocols.RDP) + { + _xmlTextWriter.WriteStartElement("Connection"); + _xmlTextWriter.WriteAttributeString("Id", "", ""); + + WriteVREitem(curConI); + + _xmlTextWriter.WriteEndElement(); + } + } + else + { + SaveNodeVRE(node.Nodes); + } + } + } + + private void WriteVREitem(Connection.Info con) + { + //Name + _xmlTextWriter.WriteStartElement("ConnectionName"); + _xmlTextWriter.WriteValue(con.Name); + _xmlTextWriter.WriteEndElement(); + + //Hostname + _xmlTextWriter.WriteStartElement("ServerName"); + _xmlTextWriter.WriteValue(con.Hostname); + _xmlTextWriter.WriteEndElement(); + + //Mac Adress + _xmlTextWriter.WriteStartElement("MACAddress"); + _xmlTextWriter.WriteValue(con.MacAddress); + _xmlTextWriter.WriteEndElement(); + + //Management Board URL + _xmlTextWriter.WriteStartElement("MgmtBoardUrl"); + _xmlTextWriter.WriteValue(""); + _xmlTextWriter.WriteEndElement(); + + //Description + _xmlTextWriter.WriteStartElement("Description"); + _xmlTextWriter.WriteValue(con.Description); + _xmlTextWriter.WriteEndElement(); + + //Port + _xmlTextWriter.WriteStartElement("Port"); + _xmlTextWriter.WriteValue(con.Port); + _xmlTextWriter.WriteEndElement(); + + //Console Session + _xmlTextWriter.WriteStartElement("Console"); + _xmlTextWriter.WriteValue(con.UseConsoleSession); + _xmlTextWriter.WriteEndElement(); + + //Redirect Clipboard + _xmlTextWriter.WriteStartElement("ClipBoard"); + _xmlTextWriter.WriteValue(true); + _xmlTextWriter.WriteEndElement(); + + //Redirect Printers + _xmlTextWriter.WriteStartElement("Printer"); + _xmlTextWriter.WriteValue(con.RedirectPrinters); + _xmlTextWriter.WriteEndElement(); + + //Redirect Ports + _xmlTextWriter.WriteStartElement("Serial"); + _xmlTextWriter.WriteValue(con.RedirectPorts); + _xmlTextWriter.WriteEndElement(); + + //Redirect Disks + _xmlTextWriter.WriteStartElement("LocalDrives"); + _xmlTextWriter.WriteValue(con.RedirectDiskDrives); + _xmlTextWriter.WriteEndElement(); + + //Redirect Smartcards + _xmlTextWriter.WriteStartElement("SmartCard"); + _xmlTextWriter.WriteValue(con.RedirectSmartCards); + _xmlTextWriter.WriteEndElement(); + + //Connection Place + _xmlTextWriter.WriteStartElement("ConnectionPlace"); + _xmlTextWriter.WriteValue("2"); //---------------------------------------------------------- + _xmlTextWriter.WriteEndElement(); + + //Smart Size + _xmlTextWriter.WriteStartElement("AutoSize"); + _xmlTextWriter.WriteValue(con.Resolution == Connection.Protocol.RDP.RDPResolutions.SmartSize); + _xmlTextWriter.WriteEndElement(); + + //SeparateResolutionX + _xmlTextWriter.WriteStartElement("SeparateResolutionX"); + _xmlTextWriter.WriteValue("1024"); + _xmlTextWriter.WriteEndElement(); + + //SeparateResolutionY + _xmlTextWriter.WriteStartElement("SeparateResolutionY"); + _xmlTextWriter.WriteValue("768"); + _xmlTextWriter.WriteEndElement(); + + Rectangle resolution = Connection.Protocol.RDP.GetResolutionRectangle(con.Resolution); + if (resolution.Width == 0) + { + resolution.Width = 1024; + } + if (resolution.Height == 0) + { + resolution.Height = 768; + } + + //TabResolutionX + _xmlTextWriter.WriteStartElement("TabResolutionX"); + _xmlTextWriter.WriteValue(resolution.Width); + _xmlTextWriter.WriteEndElement(); + + //TabResolutionY + _xmlTextWriter.WriteStartElement("TabResolutionY"); + _xmlTextWriter.WriteValue(resolution.Height); + _xmlTextWriter.WriteEndElement(); + + //RDPColorDepth + _xmlTextWriter.WriteStartElement("RDPColorDepth"); + _xmlTextWriter.WriteValue(con.Colors.ToString().Replace("Colors", "").Replace("Bit", "")); + _xmlTextWriter.WriteEndElement(); + + //Bitmap Caching + _xmlTextWriter.WriteStartElement("BitmapCaching"); + _xmlTextWriter.WriteValue(con.CacheBitmaps); + _xmlTextWriter.WriteEndElement(); + + //Themes + _xmlTextWriter.WriteStartElement("Themes"); + _xmlTextWriter.WriteValue(con.DisplayThemes); + _xmlTextWriter.WriteEndElement(); + + //Wallpaper + _xmlTextWriter.WriteStartElement("Wallpaper"); + _xmlTextWriter.WriteValue(con.DisplayWallpaper); + _xmlTextWriter.WriteEndElement(); + } + #endregion + } } diff --git a/mRemoteV1/CS/Config/Config.Settings.Save.cs b/mRemoteV1/CS/Config/Config.Settings.Save.cs index e9cede46b..8b6da4e80 100644 --- a/mRemoteV1/CS/Config/Config.Settings.Save.cs +++ b/mRemoteV1/CS/Config/Config.Settings.Save.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,9 +8,7 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Xml; using System.IO; @@ -19,120 +16,120 @@ using System.IO; namespace mRemoteNG.Config.Settings { public class Save + { + #region Public Methods + public static void Save_Renamed() + { + try { -#region Public Methods - public static void Save_Renamed() + frmMain with_1 = frmMain; + Tools.WindowPlacement windowPlacement = new Tools.WindowPlacement(frmMain); + if (with_1.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized) { - try - { - frmMain with_1 = frmMain; - Tools.WindowPlacement windowPlacement = new Tools.WindowPlacement(frmMain); - if (with_1.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized) - { - with_1.Opacity = 0; - with_1.WindowState = FormWindowState.Maximized; - } - - My.Settings.Default.MainFormLocation = with_1.Location; - My.Settings.Default.MainFormSize = with_1.Size; - - if (!(with_1.WindowState == FormWindowState.Normal)) - { - My.Settings.Default.MainFormRestoreLocation = with_1.RestoreBounds.Location; - My.Settings.Default.MainFormRestoreSize = with_1.RestoreBounds.Size; - } - - My.Settings.Default.MainFormState = with_1.WindowState; - - My.Settings.Default.MainFormKiosk = with_1.Fullscreen.Value; - - My.Settings.Default.FirstStart = false; - My.Settings.Default.ResetPanels = false; - My.Settings.Default.ResetToolbars = false; - My.Settings.Default.NoReconnect = false; - - My.Settings.Default.ExtAppsTBLocation = with_1.tsExternalTools.Location; - if (with_1.tsExternalTools.Parent != null) - { - My.Settings.Default.ExtAppsTBParentDock = with_1.tsExternalTools.Parent.Dock.ToString(); - } - My.Settings.Default.ExtAppsTBVisible = with_1.tsExternalTools.Visible; - My.Settings.Default.ExtAppsTBShowText = with_1.cMenToolbarShowText.Checked; - - My.Settings.Default.QuickyTBLocation = with_1.tsQuickConnect.Location; - if (with_1.tsQuickConnect.Parent != null) - { - My.Settings.Default.QuickyTBParentDock = with_1.tsQuickConnect.Parent.Dock.ToString(); - } - My.Settings.Default.QuickyTBVisible = with_1.tsQuickConnect.Visible; - - My.Settings.Default.ConDefaultPassword = Security.Crypt.Encrypt(System.Convert.ToString(My.Settings.Default.ConDefaultPassword), App.Info.General.EncryptionKey); - - My.Settings.Default.Save(); - - SavePanelsToXML(); - SaveExternalAppsToXML(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Saving settings failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); - } + with_1.Opacity = 0; + with_1.WindowState = FormWindowState.Maximized; } - - public static void SavePanelsToXML() + + My.Settings.Default.MainFormLocation = with_1.Location; + My.Settings.Default.MainFormSize = with_1.Size; + + if (!(with_1.WindowState == FormWindowState.Normal)) { - try - { - if (Directory.Exists(App.Info.Settings.SettingsPath) == false) - { - Directory.CreateDirectory(App.Info.Settings.SettingsPath); - } - - frmMain.Default.pnlDock.SaveAsXml(App.Info.Settings.SettingsPath + "\\" + App.Info.Settings.LayoutFileName); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SavePanelsToXML failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); - } + My.Settings.Default.MainFormRestoreLocation = with_1.RestoreBounds.Location; + My.Settings.Default.MainFormRestoreSize = with_1.RestoreBounds.Size; } - - public static void SaveExternalAppsToXML() + + My.Settings.Default.MainFormState = with_1.WindowState; + + My.Settings.Default.MainFormKiosk = with_1.Fullscreen.Value; + + My.Settings.Default.FirstStart = false; + My.Settings.Default.ResetPanels = false; + My.Settings.Default.ResetToolbars = false; + My.Settings.Default.NoReconnect = false; + + My.Settings.Default.ExtAppsTBLocation = with_1.tsExternalTools.Location; + if (with_1.tsExternalTools.Parent != null) { - try - { - if (Directory.Exists(App.Info.Settings.SettingsPath) == false) - { - Directory.CreateDirectory(App.Info.Settings.SettingsPath); - } - - XmlTextWriter xmlTextWriter = new XmlTextWriter(App.Info.Settings.SettingsPath + "\\" + App.Info.Settings.ExtAppsFilesName, System.Text.Encoding.UTF8); - xmlTextWriter.Formatting = Formatting.Indented; - xmlTextWriter.Indentation = 4; - - xmlTextWriter.WriteStartDocument(); - xmlTextWriter.WriteStartElement("Apps"); - - foreach (Tools.ExternalTool extA in ExternalTools) - { - xmlTextWriter.WriteStartElement("App"); - xmlTextWriter.WriteAttributeString("DisplayName", "", extA.DisplayName); - xmlTextWriter.WriteAttributeString("FileName", "", extA.FileName); - xmlTextWriter.WriteAttributeString("Arguments", "", extA.Arguments); - xmlTextWriter.WriteAttributeString("WaitForExit", "", System.Convert.ToString(extA.WaitForExit)); - xmlTextWriter.WriteAttributeString("TryToIntegrate", "", System.Convert.ToString(extA.TryIntegrate)); - xmlTextWriter.WriteEndElement(); - } - - xmlTextWriter.WriteEndElement(); - xmlTextWriter.WriteEndDocument(); - - xmlTextWriter.Close(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveExternalAppsToXML failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); - } + My.Settings.Default.ExtAppsTBParentDock = with_1.tsExternalTools.Parent.Dock.ToString(); } -#endregion + My.Settings.Default.ExtAppsTBVisible = with_1.tsExternalTools.Visible; + My.Settings.Default.ExtAppsTBShowText = with_1.cMenToolbarShowText.Checked; + + My.Settings.Default.QuickyTBLocation = with_1.tsQuickConnect.Location; + if (with_1.tsQuickConnect.Parent != null) + { + My.Settings.Default.QuickyTBParentDock = with_1.tsQuickConnect.Parent.Dock.ToString(); + } + My.Settings.Default.QuickyTBVisible = with_1.tsQuickConnect.Visible; + + My.Settings.Default.ConDefaultPassword = Security.Crypt.Encrypt(System.Convert.ToString(My.Settings.Default.ConDefaultPassword), App.Info.General.EncryptionKey); + + My.Settings.Default.Save(); + + SavePanelsToXML(); + SaveExternalAppsToXML(); } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Saving settings failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); + } + } + + public static void SavePanelsToXML() + { + try + { + if (Directory.Exists(App.Info.Settings.SettingsPath) == false) + { + Directory.CreateDirectory(App.Info.Settings.SettingsPath); + } + + frmMain.Default.pnlDock.SaveAsXml(App.Info.Settings.SettingsPath + "\\" + App.Info.Settings.LayoutFileName); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SavePanelsToXML failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); + } + } + + public static void SaveExternalAppsToXML() + { + try + { + if (Directory.Exists(App.Info.Settings.SettingsPath) == false) + { + Directory.CreateDirectory(App.Info.Settings.SettingsPath); + } + + XmlTextWriter xmlTextWriter = new XmlTextWriter(App.Info.Settings.SettingsPath + "\\" + App.Info.Settings.ExtAppsFilesName, System.Text.Encoding.UTF8); + xmlTextWriter.Formatting = Formatting.Indented; + xmlTextWriter.Indentation = 4; + + xmlTextWriter.WriteStartDocument(); + xmlTextWriter.WriteStartElement("Apps"); + + foreach (Tools.ExternalTool extA in ExternalTools) + { + xmlTextWriter.WriteStartElement("App"); + xmlTextWriter.WriteAttributeString("DisplayName", "", extA.DisplayName); + xmlTextWriter.WriteAttributeString("FileName", "", extA.FileName); + xmlTextWriter.WriteAttributeString("Arguments", "", extA.Arguments); + xmlTextWriter.WriteAttributeString("WaitForExit", "", System.Convert.ToString(extA.WaitForExit)); + xmlTextWriter.WriteAttributeString("TryToIntegrate", "", System.Convert.ToString(extA.TryIntegrate)); + xmlTextWriter.WriteEndElement(); + } + + xmlTextWriter.WriteEndElement(); + xmlTextWriter.WriteEndDocument(); + + xmlTextWriter.Close(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveExternalAppsToXML failed" + Constants.vbNewLine + Constants.vbNewLine + ex.Message, false); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/Config/Import/ActiveDirectory.cs b/mRemoteV1/CS/Config/Import/ActiveDirectory.cs index e6e7e6b23..f4b4341bc 100644 --- a/mRemoteV1/CS/Config/Import/ActiveDirectory.cs +++ b/mRemoteV1/CS/Config/Import/ActiveDirectory.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,10 +8,8 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.DirectoryServices; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Text.RegularExpressions; using mRemoteNG.My; @@ -20,110 +17,110 @@ using mRemoteNG.My; namespace mRemoteNG.Config.Import { public class ActiveDirectory + { + public static void Import(string ldapPath, TreeNode parentTreeNode) { - public static void Import(string ldapPath, TreeNode parentTreeNode) + try { - try + TreeNode treeNode = Tree.Node.AddNode(Tree.Node.Type.Container); + + Container.Info containerInfo = new Container.Info(); + containerInfo.TreeNode = treeNode; + containerInfo.ConnectionInfo = new Connection.Info(containerInfo); + + string name = ""; + Match match = Regex.Match(ldapPath, "ou=([^,]*)", RegexOptions.IgnoreCase); + if (match.Success) { - TreeNode treeNode = Tree.Node.AddNode(Tree.Node.Type.Container); - - Container.Info containerInfo = new Container.Info(); - containerInfo.TreeNode = treeNode; - containerInfo.ConnectionInfo = new Connection.Info(containerInfo); - - string name = ""; - Match match = Regex.Match(ldapPath, "ou=([^,]*)", RegexOptions.IgnoreCase); - if (match.Success) - { - name = match.Groups[1].Captures[0].Value; - } - else - { - name = My.Language.strActiveDirectory; - } - - containerInfo.Name = name; - - // We can only inherit from a container node, not the root node or connection nodes - if (Tree.Node.GetNodeType(parentTreeNode) == Tree.Node.Type.Container) - { - containerInfo.Parent = parentTreeNode.Tag; - } - else - { - containerInfo.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); - } - - treeNode.Text = name; - treeNode.Name = name; - treeNode.Tag = containerInfo; - ContainerList.Add(containerInfo); - - ImportComputers(ldapPath, treeNode); - - parentTreeNode.Nodes.Add(treeNode); + name = match.Groups[1].Captures[0].Value; } - catch (Exception ex) + else { - MessageCollector.AddExceptionMessage(message: "Config.Import.ActiveDirectory.Import() failed.", ex: ex, logOnly: true); + name = My.Language.strActiveDirectory; } + + containerInfo.Name = name; + + // We can only inherit from a container node, not the root node or connection nodes + if (Tree.Node.GetNodeType(parentTreeNode) == Tree.Node.Type.Container) + { + containerInfo.Parent = parentTreeNode.Tag; + } + else + { + containerInfo.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); + } + + treeNode.Text = name; + treeNode.Name = name; + treeNode.Tag = containerInfo; + ContainerList.Add(containerInfo); + + ImportComputers(ldapPath, treeNode); + + parentTreeNode.Nodes.Add(treeNode); } - - private static void ImportComputers(string ldapPath, TreeNode parentTreeNode) + catch (Exception ex) { - try - { - string strDisplayName = ""; - string strDescription = ""; - string strHostName = ""; - - const string ldapFilter = "(objectClass=computer)"; - - DirectorySearcher ldapSearcher = new DirectorySearcher(); - SearchResultCollection ldapResults = default(SearchResultCollection); - SearchResult ldapResult = default(SearchResult); - - ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath); - ldapSearcher.PropertiesToLoad.AddRange(new[] {"securityEquals", "cn"}); - ldapSearcher.Filter = ldapFilter; - ldapSearcher.SearchScope = SearchScope.OneLevel; - - ldapResults = ldapSearcher.FindAll(); - - foreach (SearchResult tempLoopVar_ldapResult in ldapResults) - { - ldapResult = tempLoopVar_ldapResult; - System.DirectoryServices.DirectoryEntry with_2 = ldapResult.GetDirectoryEntry(); - strDisplayName = System.Convert.ToString(with_2.Properties["cn"].Value); - strDescription = System.Convert.ToString(with_2.Properties["Description"].Value); - strHostName = System.Convert.ToString(with_2.Properties["dNSHostName"].Value); - - TreeNode treeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, strDisplayName); - - Connection.Info connectionInfo = new Connection.Info(); - Connection.Info.Inheritance inheritanceInfo = new Connection.Info.Inheritance(connectionInfo, true); - inheritanceInfo.Description = false; - if (parentTreeNode.Tag is Container.Info) - { - connectionInfo.Parent = parentTreeNode.Tag; - } - connectionInfo.Inherit = inheritanceInfo; - connectionInfo.Name = strDisplayName; - connectionInfo.Hostname = strHostName; - connectionInfo.Description = strDescription; - connectionInfo.TreeNode = treeNode; - treeNode.Name = strDisplayName; - treeNode.Tag = connectionInfo; //set the nodes tag to the conI - //add connection to connections - ConnectionList.Add(connectionInfo); - - parentTreeNode.Nodes.Add(treeNode); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "Config.Import.ActiveDirectory.ImportComputers() failed.", ex: ex, logOnly: true); - } + Runtime.MessageCollector.AddExceptionMessage(message: "Config.Import.ActiveDirectory.Import() failed.", ex: ex, logOnly: true); } } + + private static void ImportComputers(string ldapPath, TreeNode parentTreeNode) + { + try + { + string strDisplayName = ""; + string strDescription = ""; + string strHostName = ""; + + const string ldapFilter = "(objectClass=computer)"; + + DirectorySearcher ldapSearcher = new DirectorySearcher(); + SearchResultCollection ldapResults = default(SearchResultCollection); + SearchResult ldapResult = default(SearchResult); + + ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath); + ldapSearcher.PropertiesToLoad.AddRange(new[] {"securityEquals", "cn"}); + ldapSearcher.Filter = ldapFilter; + ldapSearcher.SearchScope = SearchScope.OneLevel; + + ldapResults = ldapSearcher.FindAll(); + + foreach (SearchResult tempLoopVar_ldapResult in ldapResults) + { + ldapResult = tempLoopVar_ldapResult; + System.DirectoryServices.DirectoryEntry with_2 = ldapResult.GetDirectoryEntry(); + strDisplayName = System.Convert.ToString(with_2.Properties["cn"].Value); + strDescription = System.Convert.ToString(with_2.Properties["Description"].Value); + strHostName = System.Convert.ToString(with_2.Properties["dNSHostName"].Value); + + TreeNode treeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, strDisplayName); + + Connection.Info connectionInfo = new Connection.Info(); + Connection.Info.Inheritance inheritanceInfo = new Connection.Info.Inheritance(connectionInfo, true); + inheritanceInfo.Description = false; + if (parentTreeNode.Tag is Container.Info) + { + connectionInfo.Parent = parentTreeNode.Tag; + } + connectionInfo.Inherit = inheritanceInfo; + connectionInfo.Name = strDisplayName; + connectionInfo.Hostname = strHostName; + connectionInfo.Description = strDescription; + connectionInfo.TreeNode = treeNode; + treeNode.Name = strDisplayName; + treeNode.Tag = connectionInfo; //set the nodes tag to the conI + //add connection to connections + ConnectionList.Add(connectionInfo); + + parentTreeNode.Nodes.Add(treeNode); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "Config.Import.ActiveDirectory.ImportComputers() failed.", ex: ex, logOnly: true); + } + } + } } diff --git a/mRemoteV1/CS/Config/Import/RemoteDesktopConnection.cs b/mRemoteV1/CS/Config/Import/RemoteDesktopConnection.cs index a10ca1b2c..b781e3696 100644 --- a/mRemoteV1/CS/Config/Import/RemoteDesktopConnection.cs +++ b/mRemoteV1/CS/Config/Import/RemoteDesktopConnection.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,221 +8,219 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.IO; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Config.Import { public class RemoteDesktopConnection + { + public static void Import(string fileName, TreeNode parentTreeNode) { - public static void Import(string fileName, TreeNode parentTreeNode) + string[] lines = File.ReadAllLines(fileName); + + string name = Path.GetFileNameWithoutExtension(fileName); + TreeNode treeNode = new TreeNode(name); + parentTreeNode.Nodes.Add(treeNode); + + Connection.Info connectionInfo = new Connection.Info(); + connectionInfo.Inherit = new Connection.Info.Inheritance(connectionInfo); + connectionInfo.Name = name; + connectionInfo.TreeNode = treeNode; + + if (treeNode.Parent.Tag is Container.Info) { - string[] lines = File.ReadAllLines(fileName); - - string name = Path.GetFileNameWithoutExtension(fileName); - TreeNode treeNode = new TreeNode(name); - parentTreeNode.Nodes.Add(treeNode); - - Connection.Info connectionInfo = new Connection.Info(); - connectionInfo.Inherit = new Connection.Info.Inheritance(connectionInfo); - connectionInfo.Name = name; - connectionInfo.TreeNode = treeNode; - - if (treeNode.Parent.Tag is Container.Info) - { - connectionInfo.Parent = treeNode.Parent.Tag; - } - - treeNode.Name = name; - treeNode.Tag = connectionInfo; - treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; - - foreach (string line in lines) - { - string[] parts = line.Split(new char[] {':'}, 3); - if (parts.Length < 3) - { - continue; - } - - string key = parts[0]; - string value = parts[2]; - - SetConnectionInfoParameter(connectionInfo, key, value); - } - - ConnectionList.Add(connectionInfo); + connectionInfo.Parent = treeNode.Parent.Tag; } - - private static void SetConnectionInfoParameter(Protocol.Info connectionInfo, string key, string value) + + treeNode.Name = name; + treeNode.Tag = connectionInfo; + treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; + + foreach (string line in lines) { - switch (key.ToLower()) + string[] parts = line.Split(new char[] {':'}, 3); + if (parts.Length < 3) { - case "full address": - Uri uri = new Uri("dummyscheme" + System.Uri.SchemeDelimiter + value); - if (!string.IsNullOrEmpty(uri.Host)) - { - connectionInfo.Hostname = uri.Host; - } - if (!(uri.Port == -1)) - { - connectionInfo.Port = uri.Port; - } - break; - case "server port": - connectionInfo.Port = (int) value; - break; - case "username": - connectionInfo.Username = value; - break; - case "domain": - connectionInfo.Domain = value; - break; - case "session bpp": - switch (value) - { - case 8: - connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors256; - break; - case 15: - connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors15Bit; - break; - case 16: - connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors16Bit; - break; - case 24: - connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors24Bit; - break; - case 32: - connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors32Bit; - break; - } - break; - case "bitmapcachepersistenable": - if (value == 1) - { - connectionInfo.CacheBitmaps = true; - } - else - { - connectionInfo.CacheBitmaps = false; - } - break; - case "screen mode id": - if (value == 2) - { - connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.Fullscreen; - } - else - { - connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.FitToWindow; - } - break; - case "connect to console": - if (value == 1) - { - connectionInfo.UseConsoleSession = true; - } - break; - case "disable wallpaper": - if (value == 1) - { - connectionInfo.DisplayWallpaper = true; - } - else - { - connectionInfo.DisplayWallpaper = false; - } - break; - case "disable themes": - if (value == 1) - { - connectionInfo.DisplayThemes = true; - } - else - { - connectionInfo.DisplayThemes = false; - } - break; - case "allow font smoothing": - if (value == 1) - { - connectionInfo.EnableFontSmoothing = true; - } - else - { - connectionInfo.EnableFontSmoothing = false; - } - break; - case "allow desktop composition": - if (value == 1) - { - connectionInfo.EnableDesktopComposition = true; - } - else - { - connectionInfo.EnableDesktopComposition = false; - } - break; - case "redirectsmartcards": - if (value == 1) - { - connectionInfo.RedirectSmartCards = true; - } - else - { - connectionInfo.RedirectSmartCards = false; - } - break; - case "redirectdrives": - if (value == 1) - { - connectionInfo.RedirectDiskDrives = true; - } - else - { - connectionInfo.RedirectDiskDrives = false; - } - break; - case "redirectcomports": - if (value == 1) - { - connectionInfo.RedirectPorts = true; - } - else - { - connectionInfo.RedirectPorts = false; - } - break; - case "redirectprinters": - if (value == 1) - { - connectionInfo.RedirectPrinters = true; - } - else - { - connectionInfo.RedirectPrinters = false; - } - break; - case "audiomode": - switch (value) - { - case 0: - connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.BringToThisComputer; - break; - case 1: - connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.LeaveAtRemoteComputer; - break; - case 2: - connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.DoNotPlay; - break; - } - break; + continue; } + + string key = parts[0]; + string value = parts[2]; + + SetConnectionInfoParameter(connectionInfo, key, value); + } + + ConnectionList.Add(connectionInfo); + } + + private static void SetConnectionInfoParameter(Connection.Info connectionInfo, string key, string value) + { + switch (key.ToLower()) + { + case "full address": + Uri uri = new Uri("dummyscheme" + System.Uri.SchemeDelimiter + value); + if (!string.IsNullOrEmpty(uri.Host)) + { + connectionInfo.Hostname = uri.Host; + } + if (!(uri.Port == -1)) + { + connectionInfo.Port = uri.Port; + } + break; + case "server port": + connectionInfo.Port = value; + break; + case "username": + connectionInfo.Username = value; + break; + case "domain": + connectionInfo.Domain = value; + break; + case "session bpp": + switch (value) + { + case "8": + connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors256; + break; + case "15": + connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors15Bit; + break; + case "16": + connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors16Bit; + break; + case "24": + connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors24Bit; + break; + case "32": + connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors32Bit; + break; + } + break; + case "bitmapcachepersistenable": + if (value == "1") + { + connectionInfo.CacheBitmaps = true; + } + else + { + connectionInfo.CacheBitmaps = false; + } + break; + case "screen mode id": + if (value == "2") + { + connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.Fullscreen; + } + else + { + connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.FitToWindow; + } + break; + case "connect to console": + if (value == "1") + { + connectionInfo.UseConsoleSession = true; + } + break; + case "disable wallpaper": + if (value == "1") + { + connectionInfo.DisplayWallpaper = true; + } + else + { + connectionInfo.DisplayWallpaper = false; + } + break; + case "disable themes": + if (value == "1") + { + connectionInfo.DisplayThemes = true; + } + else + { + connectionInfo.DisplayThemes = false; + } + break; + case "allow font smoothing": + if (value == "1") + { + connectionInfo.EnableFontSmoothing = true; + } + else + { + connectionInfo.EnableFontSmoothing = false; + } + break; + case "allow desktop composition": + if (value == "1") + { + connectionInfo.EnableDesktopComposition = true; + } + else + { + connectionInfo.EnableDesktopComposition = false; + } + break; + case "redirectsmartcards": + if (value == "1") + { + connectionInfo.RedirectSmartCards = true; + } + else + { + connectionInfo.RedirectSmartCards = false; + } + break; + case "redirectdrives": + if (value == "1") + { + connectionInfo.RedirectDiskDrives = true; + } + else + { + connectionInfo.RedirectDiskDrives = false; + } + break; + case "redirectcomports": + if (value == "1") + { + connectionInfo.RedirectPorts = true; + } + else + { + connectionInfo.RedirectPorts = false; + } + break; + case "redirectprinters": + if (value == "1") + { + connectionInfo.RedirectPrinters = true; + } + else + { + connectionInfo.RedirectPrinters = false; + } + break; + case "audiomode": + switch (value) + { + case "0": + connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.BringToThisComputer; + break; + case "1": + connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.LeaveAtRemoteComputer; + break; + case "2": + connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.DoNotPlay; + break; + } + break; } } + } } diff --git a/mRemoteV1/CS/Config/Import/RemoteDesktopConnectionManager.cs b/mRemoteV1/CS/Config/Import/RemoteDesktopConnectionManager.cs index 10759a07b..988e374c3 100644 --- a/mRemoteV1/CS/Config/Import/RemoteDesktopConnectionManager.cs +++ b/mRemoteV1/CS/Config/Import/RemoteDesktopConnectionManager.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,387 +8,385 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Xml; using System.IO; using System.Runtime.InteropServices; using mRemoteNG.Connection.Protocol; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Config.Import { public class RemoteDesktopConnectionManager + { + public static void Import(string fileName, TreeNode parentTreeNode) { - public static void Import(string fileName, TreeNode parentTreeNode) + XmlDocument xmlDocument = new XmlDocument(); + xmlDocument.Load(fileName); + + XmlNode rdcManNode = xmlDocument.SelectSingleNode("/RDCMan"); + int schemaVersion = (int) (rdcManNode.Attributes["schemaVersion"].Value); + if (!(schemaVersion == 1)) { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(fileName); - - XmlNode rdcManNode = xmlDocument.SelectSingleNode("/RDCMan"); - int schemaVersion = (int) (rdcManNode.Attributes["schemaVersion"].Value); - if (!(schemaVersion == 1)) - { - throw (new FileFormatException(string.Format("Unsupported schema version ({0}).", schemaVersion))); - } - - XmlNode versionNode = rdcManNode.SelectSingleNode("./version"); - Version version = new Version(versionNode.InnerText); - if (!(version == new Version(2, 2))) - { - throw (new FileFormatException(string.Format("Unsupported file version ({0}).", version))); - } - - XmlNode fileNode = rdcManNode.SelectSingleNode("./file"); - ImportFileOrGroup(fileNode, parentTreeNode); + throw (new FileFormatException(string.Format("Unsupported schema version ({0}).", schemaVersion))); } - - private static void ImportFileOrGroup(XmlNode xmlNode, TreeNode parentTreeNode) + + XmlNode versionNode = rdcManNode.SelectSingleNode("./version"); + Version version = new Version(versionNode.InnerText); + if (!(version == new Version(2, 2))) { - XmlNode propertiesNode = xmlNode.SelectSingleNode("./properties"); - string name = propertiesNode.SelectSingleNode("./name").InnerText; - - TreeNode treeNode = new TreeNode(name); - parentTreeNode.Nodes.Add(treeNode); - - Container.Info containerInfo = new Container.Info(); - containerInfo.TreeNode = treeNode; - containerInfo.Name = name; - - Connection.Info connectionInfo = ConnectionInfoFromXml(propertiesNode); - connectionInfo.Parent = containerInfo; - connectionInfo.IsContainer = true; - containerInfo.ConnectionInfo = connectionInfo; - - // We can only inherit from a container node, not the root node or connection nodes - if (Tree.Node.GetNodeType(parentTreeNode) == Tree.Node.Type.Container) - { - containerInfo.Parent = parentTreeNode.Tag; - } - else - { - connectionInfo.Inherit.TurnOffInheritanceCompletely(); - } - - treeNode.Name = name; - treeNode.Tag = containerInfo; - treeNode.ImageIndex = Images.Enums.TreeImage.Container; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; - - foreach (XmlNode childNode in xmlNode.SelectNodes("./group|./server")) - { - switch (childNode.Name) - { - case "group": - ImportFileOrGroup(childNode, treeNode); - break; - case "server": - ImportServer(childNode, treeNode); - break; - } - } - - containerInfo.IsExpanded = bool.Parse(propertiesNode.SelectSingleNode("./expanded").InnerText); - if (containerInfo.IsExpanded) - { - treeNode.Expand(); - } - - ContainerList.Add(containerInfo); + throw (new FileFormatException(string.Format("Unsupported file version ({0}).", version))); } + + XmlNode fileNode = rdcManNode.SelectSingleNode("./file"); + ImportFileOrGroup(fileNode, parentTreeNode); + } - private static void ImportServer(XmlNode serverNode, TreeNode parentTreeNode) + private static void ImportFileOrGroup(XmlNode xmlNode, TreeNode parentTreeNode) + { + XmlNode propertiesNode = xmlNode.SelectSingleNode("./properties"); + string name = propertiesNode.SelectSingleNode("./name").InnerText; + + TreeNode treeNode = new TreeNode(name); + parentTreeNode.Nodes.Add(treeNode); + + Container.Info containerInfo = new Container.Info(); + containerInfo.TreeNode = treeNode; + containerInfo.Name = name; + + Connection.Info connectionInfo = ConnectionInfoFromXml(propertiesNode); + connectionInfo.Parent = containerInfo; + connectionInfo.IsContainer = true; + containerInfo.ConnectionInfo = connectionInfo; + + // We can only inherit from a container node, not the root node or connection nodes + if (Tree.Node.GetNodeType(parentTreeNode) == Tree.Node.Type.Container) { - string name = serverNode.SelectSingleNode("./displayName").InnerText; - TreeNode treeNode = new TreeNode(name); - parentTreeNode.Nodes.Add(treeNode); - - Connection.Info connectionInfo = ConnectionInfoFromXml(serverNode); - connectionInfo.TreeNode = treeNode; - connectionInfo.Parent = parentTreeNode.Tag; - - treeNode.Name = name; - treeNode.Tag = connectionInfo; - treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; - - ConnectionList.Add(connectionInfo); + containerInfo.Parent = parentTreeNode.Tag; } - - private static Protocol.Info ConnectionInfoFromXml(XmlNode xmlNode) + else { - Connection.Info connectionInfo = new Connection.Info(); - connectionInfo.Inherit = new Connection.Info.Inheritance(connectionInfo); - - string name = xmlNode.SelectSingleNode("./name").InnerText; - - string displayName = ""; - XmlNode displayNameNode = xmlNode.SelectSingleNode("./displayName"); - if (displayNameNode == null) - { - displayName = name; - } - else - { - displayName = displayNameNode.InnerText; - } - - connectionInfo.Name = displayName; - connectionInfo.Description = xmlNode.SelectSingleNode("./comment").InnerText; - connectionInfo.Hostname = name; - - XmlNode logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials"); - if (logonCredentialsNode.Attributes["inherit"].Value == "None") - { - connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName").InnerText; - - XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password"); - if (passwordNode.Attributes["storeAsClearText"].Value == "True") - { - connectionInfo.Password = passwordNode.InnerText; - } - else - { - connectionInfo.Password = DecryptPassword(passwordNode.InnerText); - } - - connectionInfo.Domain = logonCredentialsNode.SelectSingleNode("./domain").InnerText; - } - else - { - connectionInfo.Inherit.Username = true; - connectionInfo.Inherit.Password = true; - connectionInfo.Inherit.Domain = true; - } - - XmlNode connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings"); - if (connectionSettingsNode.Attributes["inherit"].Value == "None") - { - connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole").InnerText); - // ./startProgram - // ./workingDir - connectionInfo.Port = (int) (connectionSettingsNode.SelectSingleNode("./port").InnerText); - } - else - { - connectionInfo.Inherit.UseConsoleSession = true; - connectionInfo.Inherit.Port = true; - } - - XmlNode gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings"); - if (gatewaySettingsNode.Attributes["inherit"].Value == "None") - { - if (gatewaySettingsNode.SelectSingleNode("./enabled").InnerText == "True") - { - connectionInfo.RDGatewayUsageMethod = RDP.RDGatewayUsageMethod.Always; - } - else - { - connectionInfo.RDGatewayUsageMethod = RDP.RDGatewayUsageMethod.Never; - } - - connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName").InnerText; - connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName").InnerText; - - XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password"); - if (passwordNode.Attributes["storeAsClearText"].Value == "True") - { - connectionInfo.RDGatewayPassword = passwordNode.InnerText; - } - else - { - connectionInfo.Password = DecryptPassword(passwordNode.InnerText); - } - - connectionInfo.RDGatewayDomain = gatewaySettingsNode.SelectSingleNode("./domain").InnerText; - // ./logonMethod - // ./localBypass - // ./credSharing - } - else - { - connectionInfo.Inherit.RDGatewayUsageMethod = true; - connectionInfo.Inherit.RDGatewayHostname = true; - connectionInfo.Inherit.RDGatewayUsername = true; - connectionInfo.Inherit.RDGatewayPassword = true; - connectionInfo.Inherit.RDGatewayDomain = true; - } - - XmlNode remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop"); - if (remoteDesktopNode.Attributes["inherit"].Value == "None") - { - string resolutionString = System.Convert.ToString(remoteDesktopNode.SelectSingleNode("./size").InnerText.Replace(" ", "")); - try - { - connectionInfo.Resolution = "Res" + System.Convert.ToString(Tools.Misc.StringToEnum(typeof(Connection.Protocol.RDP.RDPResolutions), resolutionString)); - } - catch (ArgumentException) - { - connectionInfo.Resolution = RDP.RDPResolutions.FitToWindow; - } - - if (remoteDesktopNode.SelectSingleNode("./sameSizeAsClientArea").InnerText == "True") - { - connectionInfo.Resolution = RDP.RDPResolutions.FitToWindow; - } - - if (remoteDesktopNode.SelectSingleNode("./fullScreen").InnerText == "True") - { - connectionInfo.Resolution = RDP.RDPResolutions.Fullscreen; - } - - connectionInfo.Colors = remoteDesktopNode.SelectSingleNode("./colorDepth").InnerText; - } - else - { - connectionInfo.Inherit.Resolution = true; - connectionInfo.Inherit.Colors = true; - } - - XmlNode localResourcesNode = xmlNode.SelectSingleNode("./localResources"); - if (localResourcesNode.Attributes["inherit"].Value == "None") - { - switch (localResourcesNode.SelectSingleNode("./audioRedirection").InnerText) - { - case 0: // Bring to this computer - connectionInfo.RedirectSound = RDP.RDPSounds.BringToThisComputer; - break; - case 1: // Leave at remote computer - connectionInfo.RedirectSound = RDP.RDPSounds.LeaveAtRemoteComputer; - break; - case 2: // Do not play - connectionInfo.RedirectSound = RDP.RDPSounds.DoNotPlay; - break; - } - - // ./audioRedirectionQuality - // ./audioCaptureRedirection - - switch (localResourcesNode.SelectSingleNode("./keyboardHook").InnerText) - { - case 0: // On the local computer - connectionInfo.RedirectKeys = false; - break; - case 1: // On the remote computer - connectionInfo.RedirectKeys = true; - break; - case 2: // In full screen mode only - connectionInfo.RedirectKeys = false; - break; - } - - // ./redirectClipboard - connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode.SelectSingleNode("./redirectDrives").InnerText); - connectionInfo.RedirectPorts = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPorts").InnerText); - connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPrinters").InnerText); - connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode.SelectSingleNode("./redirectSmartCards").InnerText); - } - else - { - connectionInfo.Inherit.RedirectSound = true; - connectionInfo.Inherit.RedirectKeys = true; - connectionInfo.Inherit.RedirectDiskDrives = true; - connectionInfo.Inherit.RedirectPorts = true; - connectionInfo.Inherit.RedirectPrinters = true; - connectionInfo.Inherit.RedirectSmartCards = true; - } - - XmlNode securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings"); - if (securitySettingsNode.Attributes["inherit"].Value == "None") - { - switch (securitySettingsNode.SelectSingleNode("./authentication").InnerText) - { - case 0: // No authentication - connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.NoAuth; - break; - case 1: // Do not connect if authentication fails - connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.AuthRequired; - break; - case 2: // Warn if authentication fails - connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.WarnOnFailedAuth; - break; - } - } - else - { - connectionInfo.Inherit.RDPAuthenticationLevel = true; - } - - // ./displaySettings/thumbnailScale - // ./displaySettings/liveThumbnailUpdates - // ./displaySettings/showDisconnectedThumbnails - - return connectionInfo; + connectionInfo.Inherit.TurnOffInheritanceCompletely(); } - - private static string DecryptPassword(string ciphertext) - { - if (string.IsNullOrEmpty(ciphertext)) - { - return null; - } - GCHandle gcHandle = new GCHandle(); - Win32.DATA_BLOB plaintextData = new Win32.DATA_BLOB(); + treeNode.Name = name; + treeNode.Tag = containerInfo; + treeNode.ImageIndex = Images.Enums.TreeImage.Container; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; + + foreach (XmlNode childNode in xmlNode.SelectNodes("./group|./server")) + { + switch (childNode.Name) + { + case "group": + ImportFileOrGroup(childNode, treeNode); + break; + case "server": + ImportServer(childNode, treeNode); + break; + } + } + + containerInfo.IsExpanded = bool.Parse(propertiesNode.SelectSingleNode("./expanded").InnerText); + if (containerInfo.IsExpanded) + { + treeNode.Expand(); + } + + Runtime.ContainerList.Add(containerInfo); + } + + private static void ImportServer(XmlNode serverNode, TreeNode parentTreeNode) + { + string name = serverNode.SelectSingleNode("./displayName").InnerText; + TreeNode treeNode = new TreeNode(name); + parentTreeNode.Nodes.Add(treeNode); + + Connection.Info connectionInfo = ConnectionInfoFromXml(serverNode); + connectionInfo.TreeNode = treeNode; + connectionInfo.Parent = parentTreeNode.Tag; + + treeNode.Name = name; + treeNode.Tag = connectionInfo; + treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; + + Runtime.ConnectionList.Add(connectionInfo); + } + + private static Protocol.Info ConnectionInfoFromXml(XmlNode xmlNode) + { + Connection.Info connectionInfo = new Connection.Info(); + connectionInfo.Inherit = new Connection.Info.Inheritance(connectionInfo); + + string name = xmlNode.SelectSingleNode("./name").InnerText; + + string displayName = ""; + XmlNode displayNameNode = xmlNode.SelectSingleNode("./displayName"); + if (displayNameNode == null) + { + displayName = name; + } + else + { + displayName = displayNameNode.InnerText; + } + + connectionInfo.Name = displayName; + connectionInfo.Description = xmlNode.SelectSingleNode("./comment").InnerText; + connectionInfo.Hostname = name; + + XmlNode logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials"); + if (logonCredentialsNode.Attributes["inherit"].Value == "None") + { + connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName").InnerText; + + XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password"); + if (passwordNode.Attributes["storeAsClearText"].Value == "True") + { + connectionInfo.Password = passwordNode.InnerText; + } + else + { + connectionInfo.Password = DecryptPassword(passwordNode.InnerText); + } + + connectionInfo.Domain = logonCredentialsNode.SelectSingleNode("./domain").InnerText; + } + else + { + connectionInfo.Inherit.Username = true; + connectionInfo.Inherit.Password = true; + connectionInfo.Inherit.Domain = true; + } + + XmlNode connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings"); + if (connectionSettingsNode.Attributes["inherit"].Value == "None") + { + connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole").InnerText); + // ./startProgram + // ./workingDir + connectionInfo.Port = (int) (connectionSettingsNode.SelectSingleNode("./port").InnerText); + } + else + { + connectionInfo.Inherit.UseConsoleSession = true; + connectionInfo.Inherit.Port = true; + } + + XmlNode gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings"); + if (gatewaySettingsNode.Attributes["inherit"].Value == "None") + { + if (gatewaySettingsNode.SelectSingleNode("./enabled").InnerText == "True") + { + connectionInfo.RDGatewayUsageMethod = RDP.RDGatewayUsageMethod.Always; + } + else + { + connectionInfo.RDGatewayUsageMethod = RDP.RDGatewayUsageMethod.Never; + } + + connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName").InnerText; + connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName").InnerText; + + XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password"); + if (passwordNode.Attributes["storeAsClearText"].Value == "True") + { + connectionInfo.RDGatewayPassword = passwordNode.InnerText; + } + else + { + connectionInfo.Password = DecryptPassword(passwordNode.InnerText); + } + + connectionInfo.RDGatewayDomain = gatewaySettingsNode.SelectSingleNode("./domain").InnerText; + // ./logonMethod + // ./localBypass + // ./credSharing + } + else + { + connectionInfo.Inherit.RDGatewayUsageMethod = true; + connectionInfo.Inherit.RDGatewayHostname = true; + connectionInfo.Inherit.RDGatewayUsername = true; + connectionInfo.Inherit.RDGatewayPassword = true; + connectionInfo.Inherit.RDGatewayDomain = true; + } + + XmlNode remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop"); + if (remoteDesktopNode.Attributes["inherit"].Value == "None") + { + string resolutionString = System.Convert.ToString(remoteDesktopNode.SelectSingleNode("./size").InnerText.Replace(" ", "")); try { - byte[] ciphertextArray = Convert.FromBase64String(ciphertext); - gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(ciphertextArray, GCHandleType.Pinned); - - Win32.DATA_BLOB ciphertextData = new Win32.DATA_BLOB(); - ciphertextData.cbData = ciphertextArray.Length; - ciphertextData.pbData = gcHandle.AddrOfPinnedObject(); - - Win32.DATA_BLOB temp_optionalEntropy = null; - IntPtr temp_promptStruct = null; - if (!Win32.CryptUnprotectData(ref ciphertextData, null, ref temp_optionalEntropy, null, ref temp_promptStruct, 0, ref plaintextData)) - { - return null; - } - - int plaintextLength = (int) ((double) plaintextData.cbData / 2); // Char = 2 bytes - char[] plaintextArray = new char[plaintextLength - 1 + 1]; - Marshal.Copy(plaintextData.pbData, plaintextArray, 0, plaintextLength); - - return new string(plaintextArray); + connectionInfo.Resolution = "Res" + System.Convert.ToString(Tools.Misc.StringToEnum(typeof(Connection.Protocol.RDP.RDPResolutions), resolutionString)); } - catch (Exception ex) + catch (ArgumentException) + { + connectionInfo.Resolution = RDP.RDPResolutions.FitToWindow; + } + + if (remoteDesktopNode.SelectSingleNode("./sameSizeAsClientArea").InnerText == "True") + { + connectionInfo.Resolution = RDP.RDPResolutions.FitToWindow; + } + + if (remoteDesktopNode.SelectSingleNode("./fullScreen").InnerText == "True") + { + connectionInfo.Resolution = RDP.RDPResolutions.Fullscreen; + } + + connectionInfo.Colors = remoteDesktopNode.SelectSingleNode("./colorDepth").InnerText; + } + else + { + connectionInfo.Inherit.Resolution = true; + connectionInfo.Inherit.Colors = true; + } + + XmlNode localResourcesNode = xmlNode.SelectSingleNode("./localResources"); + if (localResourcesNode.Attributes["inherit"].Value == "None") + { + switch (localResourcesNode.SelectSingleNode("./audioRedirection").InnerText) + { + case 0: // Bring to this computer + connectionInfo.RedirectSound = RDP.RDPSounds.BringToThisComputer; + break; + case 1: // Leave at remote computer + connectionInfo.RedirectSound = RDP.RDPSounds.LeaveAtRemoteComputer; + break; + case 2: // Do not play + connectionInfo.RedirectSound = RDP.RDPSounds.DoNotPlay; + break; + } + + // ./audioRedirectionQuality + // ./audioCaptureRedirection + + switch (localResourcesNode.SelectSingleNode("./keyboardHook").InnerText) + { + case 0: // On the local computer + connectionInfo.RedirectKeys = false; + break; + case 1: // On the remote computer + connectionInfo.RedirectKeys = true; + break; + case 2: // In full screen mode only + connectionInfo.RedirectKeys = false; + break; + } + + // ./redirectClipboard + connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode.SelectSingleNode("./redirectDrives").InnerText); + connectionInfo.RedirectPorts = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPorts").InnerText); + connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPrinters").InnerText); + connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode.SelectSingleNode("./redirectSmartCards").InnerText); + } + else + { + connectionInfo.Inherit.RedirectSound = true; + connectionInfo.Inherit.RedirectKeys = true; + connectionInfo.Inherit.RedirectDiskDrives = true; + connectionInfo.Inherit.RedirectPorts = true; + connectionInfo.Inherit.RedirectPrinters = true; + connectionInfo.Inherit.RedirectSmartCards = true; + } + + XmlNode securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings"); + if (securitySettingsNode.Attributes["inherit"].Value == "None") + { + switch (securitySettingsNode.SelectSingleNode("./authentication").InnerText) + { + case 0: // No authentication + connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.NoAuth; + break; + case 1: // Do not connect if authentication fails + connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.AuthRequired; + break; + case 2: // Warn if authentication fails + connectionInfo.RDPAuthenticationLevel = RDP.AuthenticationLevel.WarnOnFailedAuth; + break; + } + } + else + { + connectionInfo.Inherit.RDPAuthenticationLevel = true; + } + + // ./displaySettings/thumbnailScale + // ./displaySettings/liveThumbnailUpdates + // ./displaySettings/showDisconnectedThumbnails + + return connectionInfo; + } + + private static string DecryptPassword(string ciphertext) + { + if (string.IsNullOrEmpty(ciphertext)) + { + return null; + } + + GCHandle gcHandle = new GCHandle(); + Win32.DATA_BLOB plaintextData = new Win32.DATA_BLOB(); + try + { + byte[] ciphertextArray = Convert.FromBase64String(ciphertext); + gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(ciphertextArray, GCHandleType.Pinned); + + Win32.DATA_BLOB ciphertextData = new Win32.DATA_BLOB(); + ciphertextData.cbData = ciphertextArray.Length; + ciphertextData.pbData = gcHandle.AddrOfPinnedObject(); + + Win32.DATA_BLOB temp_optionalEntropy = null; + IntPtr temp_promptStruct = null; + if (!Win32.CryptUnprotectData(ref ciphertextData, null, ref temp_optionalEntropy, null, ref temp_promptStruct, 0, ref plaintextData)) { - MessageCollector.AddExceptionMessage(message: "RemoteDesktopConnectionManager.DecryptPassword() failed.", ex: ex, logOnly: true); return null; } - finally - { - if (gcHandle.IsAllocated) - { - gcHandle.Free(); - } - if (!(plaintextData.pbData == IntPtr.Zero)) - { - Win32.LocalFree(plaintextData.pbData); - } - } + + int plaintextLength = (int) ((double) plaintextData.cbData / 2); // Char = 2 bytes + char[] plaintextArray = new char[plaintextLength - 1 + 1]; + Marshal.Copy(plaintextData.pbData, plaintextArray, 0, plaintextLength); + + return new string(plaintextArray); } - - // ReSharper disable once ClassNeverInstantiated.Local - private class Win32 + catch (Exception ex) { - // ReSharper disable InconsistentNaming - // ReSharper disable IdentifierTypo - // ReSharper disable StringLiteralTypo - [DllImport("crypt32.dll", CharSet = CharSet.Unicode)]public static extern bool CryptUnprotectData(ref DATA_BLOB dataIn, string description, ref DATA_BLOB optionalEntropy, IntPtr reserved, ref IntPtr promptStruct, int flags, ref DATA_BLOB dataOut); - - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]public static extern void LocalFree(IntPtr ptr); - - public struct DATA_BLOB + Runtime.MessageCollector.AddExceptionMessage(message: "RemoteDesktopConnectionManager.DecryptPassword() failed.", ex: ex, logOnly: true); + return null; + } + finally + { + if (gcHandle.IsAllocated) { - public int cbData; - public IntPtr pbData; + gcHandle.Free(); + } + if (!(plaintextData.pbData == IntPtr.Zero)) + { + Win32.LocalFree(plaintextData.pbData); } - // ReSharper restore StringLiteralTypo - // ReSharper restore IdentifierTypo - // ReSharper restore InconsistentNaming } } + + // ReSharper disable once ClassNeverInstantiated.Local + private class Win32 + { + // ReSharper disable InconsistentNaming + // ReSharper disable IdentifierTypo + // ReSharper disable StringLiteralTypo + [DllImport("crypt32.dll", CharSet = CharSet.Unicode)]public static extern bool CryptUnprotectData(ref DATA_BLOB dataIn, string description, ref DATA_BLOB optionalEntropy, IntPtr reserved, ref IntPtr promptStruct, int flags, ref DATA_BLOB dataOut); + + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]public static extern void LocalFree(IntPtr ptr); + + public struct DATA_BLOB + { + public int cbData; + public IntPtr pbData; + } + // ReSharper restore StringLiteralTypo + // ReSharper restore IdentifierTypo + // ReSharper restore InconsistentNaming + } + } } diff --git a/mRemoteV1/CS/Config/KeyboardShortcuts.cs b/mRemoteV1/CS/Config/KeyboardShortcuts.cs index 53d9f4fbe..5d47a3dae 100644 --- a/mRemoteV1/CS/Config/KeyboardShortcuts.cs +++ b/mRemoteV1/CS/Config/KeyboardShortcuts.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,11 +8,9 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Runtime.InteropServices; using System.ComponentModel; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using SharedLibraryNG; @@ -21,9 +18,9 @@ namespace mRemoteNG.Config { public class KeyboardShortcuts { -#region Public Properties + #region Public Properties private static KeyboardShortcutMap _defaultMap = null; -public static KeyboardShortcutMap DefaultMap + public static KeyboardShortcutMap DefaultMap { get { @@ -33,7 +30,7 @@ public static KeyboardShortcutMap DefaultMap } private static KeyboardShortcutMap _map; -public static KeyboardShortcutMap Map + public static KeyboardShortcutMap Map { get { @@ -48,9 +45,9 @@ public static KeyboardShortcutMap Map RequestKeyNotifications(_handle); } } -#endregion + #endregion -#region Public Methods + #region Public Methods public static void RequestKeyNotifications(IntPtr handle) { // ReSharper disable LocalizableElement @@ -75,16 +72,16 @@ public static KeyboardShortcutMap Map KeyboardHook.HookKeyMsgData msgData = Marshal.PtrToStructure(m.LParam, typeof(KeyboardHook.HookKeyMsgData)); return Map.GetCommand(msgData.KeyCode, msgData.ModifierKeys); } -#endregion + #endregion -#region Private Fields + #region Private Fields // ReSharper disable once UnusedMember.Local private static KeyboardHook _keyboardHook = new KeyboardHook(); private static bool _mapLoaded = false; private static IntPtr _handle = IntPtr.Zero; -#endregion + #endregion -#region Private Methods + #region Private Methods private static void LoadDefaultMap() { if (_defaultMap != null) @@ -129,24 +126,24 @@ public static KeyboardShortcutMap Map KeyboardHook.CancelKeyNotification(_handle, shortcutMapping.Key.KeyCode, shortcutMapping.Key.ModifierKeys, false); } } -#endregion + #endregion } public class KeyboardShortcutMap : ICloneable { -#region Public Properties + #region Public Properties private List _mappings; -public List Mappings + public List Mappings { get { return _mappings; } } -#endregion + #endregion -#region Constructors + #region Constructors public KeyboardShortcutMap() { _mappings = new List(); @@ -156,9 +153,9 @@ public List Mappings { _mappings = mappings; } -#endregion + #endregion -#region Public Methods + #region Public Methods public void Add(ShortcutCommand command, ShortcutKey shortcutKey) { if (Mappings.Contains(new ShortcutMapping(command, shortcutKey))) @@ -229,9 +226,9 @@ public List Mappings newMappings.AddRange(Mappings); return new KeyboardShortcutMap(newMappings); } -#endregion + #endregion -#region Private Methods + #region Private Methods private static ShortcutKey[] ParseConfigString(string shortcutKeysString) { List shortcutKeys = new List(); @@ -243,7 +240,7 @@ public List Mappings } catch (Exception ex) { - MessageCollector.AddExceptionMessage(message: string.Format("KeyboardShortcuts.ParseShortcutKeysString({0}) failed at {1}.", shortcutKeysString, shortcutKeyString), ex: ex, logOnly: true); + Runtime.MessageCollector.AddExceptionMessage(message: string.Format("KeyboardShortcuts.ParseShortcutKeysString({0}) failed at {1}.", shortcutKeysString, shortcutKeyString), ex: ex, logOnly: true); continue; } } @@ -288,15 +285,15 @@ public List Mappings Mappings.Remove(mapping); } } -#endregion + #endregion } - [ImmutableObject(true)]public class ShortcutMapping : IEquatable + [ImmutableObject(true)] + public class ShortcutMapping : IEquatable { - -#region Public Properties + #region Public Properties private ShortcutCommand _command; -public ShortcutCommand Command + public ShortcutCommand Command { get { @@ -305,24 +302,24 @@ public ShortcutCommand Command } private ShortcutKey _key; -public ShortcutKey Key + public ShortcutKey Key { get { return _key; } } -#endregion + #endregion -#region Constructors + #region Constructors public ShortcutMapping(ShortcutCommand command, ShortcutKey key) { _command = command; _key = key; } -#endregion + #endregion -#region Public Methods + #region Public Methods public bool Equals(ShortcutMapping other) { if (!(Command == other.Command)) @@ -335,15 +332,15 @@ public ShortcutKey Key } return true; } -#endregion + #endregion } - [ImmutableObject(true)]public class ShortcutKey : IEquatable + [ImmutableObject(true)] + public class ShortcutKey : IEquatable { - -#region Public Properties + #region Public Properties private int _keyCode; -public int KeyCode + public int KeyCode { get { @@ -352,16 +349,16 @@ public int KeyCode } private KeyboardHook.ModifierKeys _modifierKeys; -public KeyboardHook.ModifierKeys ModifierKeys + public KeyboardHook.ModifierKeys ModifierKeys { get { return _modifierKeys; } } -#endregion + #endregion -#region Constructors + #region Constructors public ShortcutKey(int keyCode, KeyboardHook.ModifierKeys modifierKeys) { _keyCode = keyCode; @@ -384,9 +381,9 @@ public KeyboardHook.ModifierKeys ModifierKeys _modifierKeys = _modifierKeys | KeyboardHook.ModifierKeys.Alt; } } -#endregion + #endregion -#region Public Methods + #region Public Methods public string ToConfigString() { return string.Join("/", new string[] {KeyCode, Convert.ToInt32(ModifierKeys)}); @@ -419,9 +416,9 @@ public KeyboardHook.ModifierKeys ModifierKeys } return true; } -#endregion + #endregion -#region Operators + #region Operators public static bool operator ==(ShortcutKey shortcutKey1, ShortcutKey shortcutKey2) { return shortcutKey1.Equals(shortcutKey2); @@ -455,13 +452,13 @@ public KeyboardHook.ModifierKeys ModifierKeys { return new ShortcutKey(keys); } -#endregion + #endregion } public enum ShortcutCommand - { - None = 0, - PreviousTab, - NextTab - } + { + None = 0, + PreviousTab, + NextTab + } } diff --git a/mRemoteV1/CS/Connection/Connection.Icon.cs b/mRemoteV1/CS/Connection/Connection.Icon.cs index 45a6a3d9d..9f0f132bd 100644 --- a/mRemoteV1/CS/Connection/Connection.Icon.cs +++ b/mRemoteV1/CS/Connection/Connection.Icon.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,53 +8,50 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.ComponentModel; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Connection { public class Icon : StringConverter + { + public static string[] Icons = new string[] {}; + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - - public static string[] Icons = new string[] {}; - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - return new StandardValuesCollection(Icons); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) - { - return true; - } - - public static System.Drawing.Icon FromString(string IconName) - { - try - { - string IconPath = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\Icons\\" + IconName +".ico"; - - if (System.IO.File.Exists(IconPath)) - { - System.Drawing.Icon nI = new System.Drawing.Icon(IconPath); - - return nI; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get Icon from String" + Constants.vbNewLine + ex.Message); - } - - return null; - } + return new StandardValuesCollection(Icons); } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) + { + return true; + } + + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + + public static System.Drawing.Icon FromString(string IconName) + { + try + { + string IconPath = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\Icons\\" + IconName +".ico"; + + if (System.IO.File.Exists(IconPath)) + { + System.Drawing.Icon nI = new System.Drawing.Icon(IconPath); + + return nI; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get Icon from String" + Constants.vbNewLine + ex.Message); + } + + return null; + } + } } diff --git a/mRemoteV1/CS/Connection/Connection.Info.cs b/mRemoteV1/CS/Connection/Connection.Info.cs index 2395f690f..1ba0331f3 100644 --- a/mRemoteV1/CS/Connection/Connection.Info.cs +++ b/mRemoteV1/CS/Connection/Connection.Info.cs @@ -17,10 +17,11 @@ using mRemoteNG.App; namespace mRemoteNG.Connection { - [DefaultProperty("Name")]public partial class Info + [DefaultProperty("Name")] + public partial class Info { -#region Public Properties -#region Display + #region Public Properties + #region Display [LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1), LocalizedAttributes.LocalizedDisplayName("strPropertyNameName"), LocalizedAttributes.LocalizedDescription("strPropertyDescriptionName")] @@ -74,8 +75,8 @@ namespace mRemoteNG.Connection _panel = value; } } -#endregion -#region Connection + #endregion + #region Connection private string _hostname = string.Empty; [LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2), LocalizedAttributes.LocalizedDisplayName("strPropertyNameAddress"), @@ -147,8 +148,8 @@ namespace mRemoteNG.Connection _domain = value.Trim(); } } -#endregion -#region Protocol + #endregion + #region Protocol private Protocol.Protocols _protocol; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3), LocalizedAttributes.LocalizedDisplayName("strPropertyNameProtocol"), @@ -316,8 +317,8 @@ namespace mRemoteNG.Connection _useCredSsp = value; } } -#endregion -#region RD Gateway + #endregion + #region RD Gateway private Protocol.RDP.RDGatewayUsageMethod _rdGatewayUsageMethod; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4), LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsageMethod"), @@ -416,8 +417,8 @@ namespace mRemoteNG.Connection _rdGatewayDomain = value.Trim(); } } -#endregion -#region Appearance + #endregion + #region Appearance private Protocol.RDP.RDPResolutions _resolution; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5), LocalizedAttributes.LocalizedDisplayName("strPropertyNameResolution"), @@ -553,8 +554,8 @@ namespace mRemoteNG.Connection _enableDesktopComposition = value; } } -#endregion -#region Redirect + #endregion + #region Redirect private bool _redirectKeys; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6), LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectKeys"), @@ -656,8 +657,8 @@ namespace mRemoteNG.Connection _redirectSound = value; } } -#endregion -#region Misc + #endregion + #region Misc private string _preExtApp; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7), LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolBefore"), @@ -723,8 +724,8 @@ namespace mRemoteNG.Connection _userField = value; } } -#endregion -#region VNC + #endregion + #region VNC private Protocol.VNC.Compression _vncCompression; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors. [LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5), Browsable(false), @@ -918,10 +919,11 @@ namespace mRemoteNG.Connection _vncViewOnly = value; } } -#endregion - - [Browsable(false)]private Inheritance _Inherit = -@privateprivate ;Inheritance Inherit + #endregion + + [Browsable(false)] + private Inheritance _Inherit; + public Inheritance Inherit { get { @@ -932,9 +934,10 @@ namespace mRemoteNG.Connection _Inherit = value; } } - - [Browsable(false)]private Protocol.List _OpenConnections = -@privateprivate ;Protocol.List OpenConnections + + [Browsable(false)] + private Protocol.List _OpenConnections = new Protocol.List(); + public Protocol.List OpenConnections { get { @@ -946,8 +949,9 @@ namespace mRemoteNG.Connection } } - [Browsable(false)]private bool _IsContainer = false; - private bool IsContainer + [Browsable(false)] + private bool _IsContainer = false; + public bool IsContainer { get { @@ -959,8 +963,9 @@ namespace mRemoteNG.Connection } } - [Browsable(false)]private bool _IsDefault = false; - private bool IsDefault + [Browsable(false)] + private bool _IsDefault = false; + public bool IsDefault { get { @@ -972,10 +977,12 @@ namespace mRemoteNG.Connection } } - [Browsable(false)]public Container.Info Parent {get; set;} + [Browsable(false)] + public Container.Info Parent {get; set;} - [Browsable(false)]private int _PositionID = 0; - private int PositionID + [Browsable(false)] + private int _PositionID = 0; + public int PositionID { get { @@ -987,12 +994,15 @@ namespace mRemoteNG.Connection } } - [Browsable(false)]public string ConstantID {get; set;} + [Browsable(false)] + public string ConstantID {get; set;} - [Browsable(false)]public TreeNode TreeNode {get; set;} + [Browsable(false)] + public TreeNode TreeNode {get; set;} - [Browsable(false)]private bool _IsQuickConnect = false; - private bool IsQuickConnect + [Browsable(false)] + private bool _IsQuickConnect = false; + public bool IsQuickConnect { get { @@ -1004,8 +1014,9 @@ namespace mRemoteNG.Connection } } - [Browsable(false)]private bool _PleaseConnect = false; - private bool PleaseConnect + [Browsable(false)] + private bool _PleaseConnect = false; + public bool PleaseConnect { get { @@ -1018,7 +1029,7 @@ namespace mRemoteNG.Connection } #endregion -#region Constructors + #region Constructors public Info() { // VBConversions Note: Non-static class variable initialization is below. Class variables cannot be initially assigned non-static values in C#. @@ -1034,9 +1045,9 @@ namespace mRemoteNG.Connection IsContainer = true; this.Parent = parent; } -#endregion + #endregion -#region Public Methods + #region Public Methods public Info Copy() { Info newConnectionInfo = (Info)MemberwiseClone(); @@ -1062,9 +1073,9 @@ namespace mRemoteNG.Connection { Port = GetDefaultPort(); } -#endregion + #endregion -#region Public Enumerations + #region Public Enumerations [Flags()]public enum Force { None = 0, @@ -1075,9 +1086,9 @@ namespace mRemoteNG.Connection DontUseConsoleSession = 16, NoCredentials = 32 } -#endregion + #endregion -#region Private Methods + #region Private Methods private TPropertyType GetInheritedPropertyValue(string propertyName, TPropertyType value) { Type inheritType = Inherit.GetType(); @@ -1162,6 +1173,6 @@ namespace mRemoteNG.Connection Runtime.MessageCollector.AddExceptionMessage(My.Language.strConnectionSetDefaultPortFailed, ex, Messages.MessageClass.ErrorMsg); } } -#endregion + #endregion } } diff --git a/mRemoteV1/CS/Connection/Connection.List.cs b/mRemoteV1/CS/Connection/Connection.List.cs index 32ef5284c..341900739 100644 --- a/mRemoteV1/CS/Connection/Connection.List.cs +++ b/mRemoteV1/CS/Connection/Connection.List.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,22 +8,20 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports namespace mRemoteNG.Connection { public class List : CollectionBase { - -#region Public Properties -public Connection.Info this[object Index] + #region Public Properties + public Connection.Info this[object Index] { get { if (Index is Connection.Info) { - return Index; + return (Connection.Info)Index; } else { @@ -33,16 +30,13 @@ public Connection.Info this[object Index] } } -public new int Count + public new int Count { - get - { - return List.Count; - } + get { return List.Count; } } -#endregion + #endregion -#region Public Methods + #region Public Methods public Connection.Info Add(Connection.Info cInfo) { this.List.Add(cInfo); @@ -80,7 +74,7 @@ public new int Count { try { - return this.MemberwiseClone(); + return (Connection.List)this.MemberwiseClone(); } catch (Exception) { @@ -93,6 +87,6 @@ public new int Count { this.List.Clear(); } -#endregion + #endregion } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.Base.cs b/mRemoteV1/CS/Connection/Connection.Protocol.Base.cs index fbe45df4f..acb62f24e 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.Base.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.Base.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,389 +8,387 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Threading; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Connection.Protocol { public class Base + { + #region Properties + #region Control + private string _Name; + public string Name + { + get { -#region Properties -#region Control - private string _Name; -public string Name - { - get - { - return this._Name; - } - set - { - this._Name = value; - } - } - - private UI.Window.Connection _connectionWindow; -public UI.Window.Connection ConnectionWindow - { - get - { - return _connectionWindow; - } - set - { - _connectionWindow = value; - _connectionWindow.ResizeBegin += ResizeBegin; - _connectionWindow.Resize += Resize; - _connectionWindow.ResizeEnd += ResizeEnd; - } - } - - private InterfaceControl _interfaceControl; -public InterfaceControl InterfaceControl - { - get - { - return _interfaceControl; - } - set - { - _interfaceControl = value; - ConnectionWindow = _interfaceControl.GetContainerControl() as UI.Window.Connection; - } - } - - private Control _Control; -public Control Control - { - get - { - return this._Control; - } - set - { - this._Control = value; - } - } -#endregion - - private mRemoteNG.Connection.Info.Force _Force; -public mRemoteNG.Connection.Info.Force Force - { - get - { - return this._Force; - } - set - { - this._Force = value; - } - } - - public System.Timers.Timer tmrReconnect = new System.Timers.Timer(2000); - public ReconnectGroup ReconnectGroup; -#endregion - -#region Methods - public virtual void Focus() - { - try - { - this._Control.Focus(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t focus Control (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); - } - } - - public virtual void ResizeBegin(System.Object sender, EventArgs e) - { - - } - - public virtual void Resize(System.Object sender, EventArgs e) - { - - } - - public virtual void ResizeEnd(System.Object sender, EventArgs e) - { - - } - - public virtual bool SetProps() - { - try - { - this._interfaceControl.Parent.Tag = this._interfaceControl; - this._interfaceControl.Show(); - - if (this._Control != null) - { - this._Control.Name = this._Name; - this._Control.Parent = this._interfaceControl; - this._Control.Location = this._interfaceControl.Location; - this._Control.Size = this.InterfaceControl.Size; - this._Control.Anchor = this._interfaceControl.Anchor; - } - - return true; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t SetProps (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); - return false; - } - } - - public virtual bool Connect() - { - if (InterfaceControl.Info.Protocol != Protocols.RDP) - { - if (ConnectedEvent != null) - ConnectedEvent(this); - } - } - - public virtual void Disconnect() - { - this.Close(); - } - - public virtual void Close() - { - Thread t = new Thread(new System.Threading.ThreadStart(CloseBG)); - t.SetApartmentState(System.Threading.ApartmentState.STA); - t.IsBackground = true; - t.Start(); - } - - private void CloseBG() - { - if (ClosedEvent != null) - ClosedEvent(this); - - try - { - tmrReconnect.Enabled = false; - - if (this._Control != null) - { - try - { - this.DisposeControl(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Could not dispose control, probably form is already closed (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); - } - } - - if (this._interfaceControl != null) - { - try - { - if (this._interfaceControl.Parent != null) - { - if (this._interfaceControl.Parent.Tag != null) - { - this.SetTagToNothing(); - } - - this.DisposeInterface(); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Could not set InterfaceControl.Parent.Tag or Dispose Interface, probably form is already closed (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t Close InterfaceControl BG (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); - } - } - - private delegate void DisposeInterfaceCB(); - private void DisposeInterface() - { - if (this._interfaceControl.InvokeRequired) - { - DisposeInterfaceCB s = new DisposeInterfaceCB(DisposeInterface); - this._interfaceControl.Invoke(s); - } - else - { - this._interfaceControl.Dispose(); - } - } - - private delegate void SetTagToNothingCB(); - private void SetTagToNothing() - { - if (this._interfaceControl.Parent.InvokeRequired) - { - SetTagToNothingCB s = new SetTagToNothingCB(SetTagToNothing); - this._interfaceControl.Parent.Invoke(s); - } - else - { - this._interfaceControl.Parent.Tag = null; - } - } - - private delegate void DisposeControlCB(); - private void DisposeControl() - { - if (this._Control.InvokeRequired) - { - DisposeControlCB s = new DisposeControlCB(DisposeControl); - this._Control.Invoke(s); - } - else - { - this._Control.Dispose(); - } - } -#endregion - -#region Events - public delegate void ConnectingEventHandler(object sender); - private ConnectingEventHandler ConnectingEvent; - - public event ConnectingEventHandler Connecting - { - add - { - ConnectingEvent = (ConnectingEventHandler) System.Delegate.Combine(ConnectingEvent, value); - } - remove - { - ConnectingEvent = (ConnectingEventHandler) System.Delegate.Remove(ConnectingEvent, value); - } - } - - public delegate void ConnectedEventHandler(object sender); - private ConnectedEventHandler ConnectedEvent; - - public event ConnectedEventHandler Connected - { - add - { - ConnectedEvent = (ConnectedEventHandler) System.Delegate.Combine(ConnectedEvent, value); - } - remove - { - ConnectedEvent = (ConnectedEventHandler) System.Delegate.Remove(ConnectedEvent, value); - } - } - - public delegate void DisconnectedEventHandler(object sender, string DisconnectedMessage); - private DisconnectedEventHandler DisconnectedEvent; - - public event DisconnectedEventHandler Disconnected - { - add - { - DisconnectedEvent = (DisconnectedEventHandler) System.Delegate.Combine(DisconnectedEvent, value); - } - remove - { - DisconnectedEvent = (DisconnectedEventHandler) System.Delegate.Remove(DisconnectedEvent, value); - } - } - - public delegate void ErrorOccuredEventHandler(object sender, string ErrorMessage); - private ErrorOccuredEventHandler ErrorOccuredEvent; - - public event ErrorOccuredEventHandler ErrorOccured - { - add - { - ErrorOccuredEvent = (ErrorOccuredEventHandler) System.Delegate.Combine(ErrorOccuredEvent, value); - } - remove - { - ErrorOccuredEvent = (ErrorOccuredEventHandler) System.Delegate.Remove(ErrorOccuredEvent, value); - } - } - - public delegate void ClosingEventHandler(object sender); - private ClosingEventHandler ClosingEvent; - - public event ClosingEventHandler Closing - { - add - { - ClosingEvent = (ClosingEventHandler) System.Delegate.Combine(ClosingEvent, value); - } - remove - { - ClosingEvent = (ClosingEventHandler) System.Delegate.Remove(ClosingEvent, value); - } - } - - public delegate void ClosedEventHandler(object sender); - private ClosedEventHandler ClosedEvent; - - public event ClosedEventHandler Closed - { - add - { - ClosedEvent = (ClosedEventHandler) System.Delegate.Combine(ClosedEvent, value); - } - remove - { - ClosedEvent = (ClosedEventHandler) System.Delegate.Remove(ClosedEvent, value); - } - } - - - public void Event_Closing(object sender) - { - if (ClosingEvent != null) - ClosingEvent(sender); - } - - public void Event_Closed(object sender) - { - if (ClosedEvent != null) - ClosedEvent(sender); - } - - public void Event_Connecting(object sender) - { - if (ConnectingEvent != null) - ConnectingEvent(sender); - } - - public void Event_Connected(object sender) - { - if (ConnectedEvent != null) - ConnectedEvent(sender); - } - - public void Event_Disconnected(object sender, string DisconnectedMessage) - { - if (DisconnectedEvent != null) - DisconnectedEvent(sender, DisconnectedMessage); - } - - public void Event_ErrorOccured(object sender, string ErrorMsg) - { - if (ErrorOccuredEvent != null) - ErrorOccuredEvent(sender, ErrorMsg); - } - - public void Event_ReconnectGroupCloseClicked() - { - Close(); - } -#endregion + return this._Name; } + set + { + this._Name = value; + } + } + + private UI.Window.Connection _connectionWindow; + public UI.Window.Connection ConnectionWindow + { + get + { + return _connectionWindow; + } + set + { + _connectionWindow = value; + _connectionWindow.ResizeBegin += ResizeBegin; + _connectionWindow.Resize += Resize; + _connectionWindow.ResizeEnd += ResizeEnd; + } + } + + private InterfaceControl _interfaceControl; + public InterfaceControl InterfaceControl + { + get + { + return _interfaceControl; + } + set + { + _interfaceControl = value; + ConnectionWindow = _interfaceControl.GetContainerControl() as UI.Window.Connection; + } + } + + private Control _Control; + public Control Control + { + get + { + return this._Control; + } + set + { + this._Control = value; + } + } + #endregion + + private mRemoteNG.Connection.Info.Force _Force; + public mRemoteNG.Connection.Info.Force Force + { + get + { + return this._Force; + } + set + { + this._Force = value; + } + } + + public System.Timers.Timer tmrReconnect = new System.Timers.Timer(2000); + public ReconnectGroup ReconnectGroup; + #endregion + + #region Methods + public virtual void Focus() + { + try + { + this._Control.Focus(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t focus Control (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); + } + } + + public virtual void ResizeBegin(System.Object sender, EventArgs e) + { + + } + + public virtual void Resize(System.Object sender, EventArgs e) + { + + } + + public virtual void ResizeEnd(System.Object sender, EventArgs e) + { + + } + + public virtual bool SetProps() + { + try + { + this._interfaceControl.Parent.Tag = this._interfaceControl; + this._interfaceControl.Show(); + + if (this._Control != null) + { + this._Control.Name = this._Name; + this._Control.Parent = this._interfaceControl; + this._Control.Location = this._interfaceControl.Location; + this._Control.Size = this.InterfaceControl.Size; + this._Control.Anchor = this._interfaceControl.Anchor; + } + + return true; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t SetProps (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); + return false; + } + } + + public virtual bool Connect() + { + if (InterfaceControl.Info.Protocol != Protocols.RDP) + { + if (ConnectedEvent != null) + ConnectedEvent(this); + } + } + + public virtual void Disconnect() + { + this.Close(); + } + + public virtual void Close() + { + Thread t = new Thread(new System.Threading.ThreadStart(CloseBG)); + t.SetApartmentState(System.Threading.ApartmentState.STA); + t.IsBackground = true; + t.Start(); + } + + private void CloseBG() + { + if (ClosedEvent != null) + ClosedEvent(this); + + try + { + tmrReconnect.Enabled = false; + + if (this._Control != null) + { + try + { + this.DisposeControl(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Could not dispose control, probably form is already closed (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); + } + } + + if (this._interfaceControl != null) + { + try + { + if (this._interfaceControl.Parent != null) + { + if (this._interfaceControl.Parent.Tag != null) + { + this.SetTagToNothing(); + } + + this.DisposeInterface(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Could not set InterfaceControl.Parent.Tag or Dispose Interface, probably form is already closed (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t Close InterfaceControl BG (Connection.Protocol.Base)" + Constants.vbNewLine + ex.Message, true); + } + } + + private delegate void DisposeInterfaceCB(); + private void DisposeInterface() + { + if (this._interfaceControl.InvokeRequired) + { + DisposeInterfaceCB s = new DisposeInterfaceCB(DisposeInterface); + this._interfaceControl.Invoke(s); + } + else + { + this._interfaceControl.Dispose(); + } + } + + private delegate void SetTagToNothingCB(); + private void SetTagToNothing() + { + if (this._interfaceControl.Parent.InvokeRequired) + { + SetTagToNothingCB s = new SetTagToNothingCB(SetTagToNothing); + this._interfaceControl.Parent.Invoke(s); + } + else + { + this._interfaceControl.Parent.Tag = null; + } + } + + private delegate void DisposeControlCB(); + private void DisposeControl() + { + if (this._Control.InvokeRequired) + { + DisposeControlCB s = new DisposeControlCB(DisposeControl); + this._Control.Invoke(s); + } + else + { + this._Control.Dispose(); + } + } + #endregion + + #region Events + public delegate void ConnectingEventHandler(object sender); + private ConnectingEventHandler ConnectingEvent; + + public event ConnectingEventHandler Connecting + { + add + { + ConnectingEvent = (ConnectingEventHandler) System.Delegate.Combine(ConnectingEvent, value); + } + remove + { + ConnectingEvent = (ConnectingEventHandler) System.Delegate.Remove(ConnectingEvent, value); + } + } + + public delegate void ConnectedEventHandler(object sender); + private ConnectedEventHandler ConnectedEvent; + + public event ConnectedEventHandler Connected + { + add + { + ConnectedEvent = (ConnectedEventHandler) System.Delegate.Combine(ConnectedEvent, value); + } + remove + { + ConnectedEvent = (ConnectedEventHandler) System.Delegate.Remove(ConnectedEvent, value); + } + } + + public delegate void DisconnectedEventHandler(object sender, string DisconnectedMessage); + private DisconnectedEventHandler DisconnectedEvent; + + public event DisconnectedEventHandler Disconnected + { + add + { + DisconnectedEvent = (DisconnectedEventHandler) System.Delegate.Combine(DisconnectedEvent, value); + } + remove + { + DisconnectedEvent = (DisconnectedEventHandler) System.Delegate.Remove(DisconnectedEvent, value); + } + } + + public delegate void ErrorOccuredEventHandler(object sender, string ErrorMessage); + private ErrorOccuredEventHandler ErrorOccuredEvent; + + public event ErrorOccuredEventHandler ErrorOccured + { + add + { + ErrorOccuredEvent = (ErrorOccuredEventHandler) System.Delegate.Combine(ErrorOccuredEvent, value); + } + remove + { + ErrorOccuredEvent = (ErrorOccuredEventHandler) System.Delegate.Remove(ErrorOccuredEvent, value); + } + } + + public delegate void ClosingEventHandler(object sender); + private ClosingEventHandler ClosingEvent; + + public event ClosingEventHandler Closing + { + add + { + ClosingEvent = (ClosingEventHandler) System.Delegate.Combine(ClosingEvent, value); + } + remove + { + ClosingEvent = (ClosingEventHandler) System.Delegate.Remove(ClosingEvent, value); + } + } + + public delegate void ClosedEventHandler(object sender); + private ClosedEventHandler ClosedEvent; + + public event ClosedEventHandler Closed + { + add + { + ClosedEvent = (ClosedEventHandler) System.Delegate.Combine(ClosedEvent, value); + } + remove + { + ClosedEvent = (ClosedEventHandler) System.Delegate.Remove(ClosedEvent, value); + } + } + + + public void Event_Closing(object sender) + { + if (ClosingEvent != null) + ClosingEvent(sender); + } + + public void Event_Closed(object sender) + { + if (ClosedEvent != null) + ClosedEvent(sender); + } + + public void Event_Connecting(object sender) + { + if (ConnectingEvent != null) + ConnectingEvent(sender); + } + + public void Event_Connected(object sender) + { + if (ConnectedEvent != null) + ConnectedEvent(sender); + } + + public void Event_Disconnected(object sender, string DisconnectedMessage) + { + if (DisconnectedEvent != null) + DisconnectedEvent(sender, DisconnectedMessage); + } + + public void Event_ErrorOccured(object sender, string ErrorMsg) + { + if (ErrorOccuredEvent != null) + ErrorOccuredEvent(sender, ErrorMsg); + } + + public void Event_ReconnectGroupCloseClicked() + { + Close(); + } + #endregion + } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.HTTPBase.cs b/mRemoteV1/CS/Connection/Connection.Protocol.HTTPBase.cs index dc8e7ddf4..6b241b285 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.HTTPBase.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.HTTPBase.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -10,9 +9,7 @@ using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; using mRemoteNG.Tools; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; //using mRemoteNG.Tools.LocalizedAttributes; @@ -20,15 +17,14 @@ namespace mRemoteNG.Connection.Protocol { public class HTTPBase : Base { - -#region Private Properties + #region Private Properties private Control wBrowser; public string httpOrS; public int defaultPort; private string tabTitle; -#endregion + #endregion -#region Public Methods + #region Public Methods public HTTPBase(RenderingEngine RenderingEngine) { try @@ -47,7 +43,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpConnectionFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpConnectionFailed + Constants.vbNewLine + ex.Message, true); } } @@ -96,7 +92,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpSetPropsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpSetPropsFailed + Constants.vbNewLine + ex.Message, true); return false; } } @@ -162,16 +158,16 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpConnectFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strHttpConnectFailed + Constants.vbNewLine + ex.Message, true); return false; } } -#endregion + #endregion -#region Private Methods -#endregion + #region Private Methods + #endregion -#region Events + #region Events private void wBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) { WebBrowser objWebBrowser = wBrowser as WebBrowser; @@ -249,12 +245,12 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strHttpDocumentTileChangeFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strHttpDocumentTileChangeFailed + Constants.vbNewLine + ex.Message, true); } } -#endregion + #endregion -#region Enums + #region Enums public enum RenderingEngine { [LocalizedAttributes.LocalizedDescription("strHttpInternetExplorer")] @@ -282,6 +278,6 @@ namespace mRemoteNG.Connection.Protocol NWMF_INACTIVETAB = 0x100000 // ReSharper restore InconsistentNaming } -#endregion + #endregion } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.ICA.cs b/mRemoteV1/CS/Connection/Connection.Protocol.ICA.cs index 76aac20a0..657c2c0c2 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.ICA.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.ICA.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,9 +8,7 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Threading; using mRemoteNG.Tools; //using mRemoteNG.Tools.LocalizedAttributes; @@ -21,9 +18,7 @@ namespace mRemoteNG.Connection.Protocol { public class ICA : Base { - -#region Default Instance - + #region Default Instance private static ICA defaultInstance; /// @@ -51,15 +46,14 @@ namespace mRemoteNG.Connection.Protocol { defaultInstance = null; } + #endregion -#endregion - -#region Private Properties + #region Private Properties private AxICAClient ICA_Renamed; private Connection.Info Info; -#endregion + #endregion -#region Public Methods + #region Public Methods public ICA() { try @@ -68,7 +62,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaControlFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaControlFailed + Constants.vbNewLine + ex.Message, true); } } @@ -130,7 +124,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetPropsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetPropsFailed + Constants.vbNewLine + ex.Message, true); return false; } } @@ -147,13 +141,13 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaConnectionFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaConnectionFailed + Constants.vbNewLine + ex.Message); return false; } } -#endregion + #endregion -#region Private Methods + #region Private Methods private void SetCredentials() { try @@ -216,7 +210,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetCredentialsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetCredentialsFailed + Constants.vbNewLine + ex.Message, true); } } @@ -253,7 +247,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetResolutionFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetResolutionFailed + Constants.vbNewLine + ex.Message, true); } } @@ -310,12 +304,12 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strIcaSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); } } -#endregion + #endregion -#region Private Events & Handlers + #region Private Events & Handlers private void ICAEvent_OnConnecting(object sender, System.EventArgs e) { base.Event_Connecting(this); @@ -350,9 +344,9 @@ namespace mRemoteNG.Connection.Protocol base.Close(); } } -#endregion + #endregion -#region Reconnect Stuff + #region Reconnect Stuff public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { bool srvReady = Tools.PortScan.Scanner.IsPortOpen(Info.Hostname, System.Convert.ToString(Info.Port)); @@ -366,9 +360,9 @@ namespace mRemoteNG.Connection.Protocol ICA_Renamed.Default.Connect(); } } -#endregion + #endregion -#region Enums + #region Enums public enum Defaults { Port = 1494, @@ -388,6 +382,6 @@ namespace mRemoteNG.Connection.Protocol [LocalizedAttributes.LocalizedDescription("strEnc128Bit")] Encr128Bit = 128 } -#endregion + #endregion } } \ No newline at end of file diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.IntegratedProgram.cs b/mRemoteV1/CS/Connection/Connection.Protocol.IntegratedProgram.cs index fe2b56137..bcff2b47a 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.IntegratedProgram.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.IntegratedProgram.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,167 +8,165 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - //using mRemoteNG.App.Native; using System.Threading; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using mRemoteNG.Tools; namespace mRemoteNG.Connection.Protocol { public class IntegratedProgram : Base + { + #region Public Methods + public override bool SetProps() + { + if (InterfaceControl.Info != null) { -#region Public Methods - public override bool SetProps() - { - if (InterfaceControl.Info != null) - { - _externalTool = GetExtAppByName(System.Convert.ToString(InterfaceControl.Info.ExtApp)); - _externalTool.ConnectionInfo = InterfaceControl.Info; - } - - return base.SetProps(); - } - - public override bool Connect() - { - try - { - if (_externalTool.TryIntegrate == false) - { - _externalTool.Start(InterfaceControl.Info); - Close(); - return null; - } - - _process = new Process(); - - _process.StartInfo.UseShellExecute = true; - _process.StartInfo.FileName = _externalTool.ParseArguments(_externalTool.FileName); - _process.StartInfo.Arguments = _externalTool.ParseArguments(_externalTool.Arguments); - - _process.EnableRaisingEvents = true; - _process.Exited += ProcessExited; - - _process.Start(); - _process.WaitForInputIdle(System.Convert.ToInt32(My.Settings.Default.MaxPuttyWaitTime * 1000)); - - int startTicks = Environment.TickCount; - while (_handle.ToInt32() == 0 & Environment.TickCount < startTicks + (My.Settings.Default.MaxPuttyWaitTime * 1000)) - { - _process.Refresh(); - if (!(_process.MainWindowTitle == "Default IME")) - { - _handle = _process.MainWindowHandle; - } - if (_handle.ToInt32() == 0) - { - Thread.Sleep(0); - } - } - - SetParent(_handle, InterfaceControl.Handle); - - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strIntAppStuff, true); - - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppHandle, _handle.ToString()), true); - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppTitle, _process.MainWindowTitle), true); - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppParentHandle, InterfaceControl.Parent.Handle.ToString()), true); - - Resize(this, new EventArgs()); - - base.Connect(); - return true; - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(My.Language.strIntAppConnectionFailed, ex); - return false; - } - } - - public override void Focus() - { - try - { - if (ConnectionWindow.InTabDrag) - { - return ; - } - SetForegroundWindow(_handle); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: My.Language.strIntAppFocusFailed, ex: ex, logOnly: true); - } - } - - public override void Resize(object sender, EventArgs e) - { - try - { - if (InterfaceControl.Size == Size.Empty) - { - return ; - } - MoveWindow(_handle, System.Convert.ToInt32(- SystemInformation.FrameBorderSize.Width), System.Convert.ToInt32(- (SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height)), InterfaceControl.Width + (SystemInformation.FrameBorderSize.Width * 2), InterfaceControl.Height + SystemInformation.CaptionHeight + (SystemInformation.FrameBorderSize.Height * 2), true); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: My.Language.strIntAppResizeFailed, ex: ex, logOnly: true); - } - } - - public override void Close() - { - try - { - if (!_process.HasExited) - { - _process.Kill(); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: My.Language.strIntAppKillFailed, ex: ex, logOnly: true); - } - - try - { - if (!_process.HasExited) - { - _process.Dispose(); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: My.Language.strIntAppDisposeFailed, ex: ex, logOnly: true); - } - - base.Close(); - } -#endregion - -#region Private Fields - private ExternalTool _externalTool; - private IntPtr _handle; - private Process _process; -#endregion - -#region Private Methods - private void ProcessExited(object sender, EventArgs e) - { - Event_Closed(this); - } -#endregion - -#region Enumerations - public enum Defaults - { - Port = 0 - } -#endregion + _externalTool = GetExtAppByName(System.Convert.ToString(InterfaceControl.Info.ExtApp)); + _externalTool.ConnectionInfo = InterfaceControl.Info; } + + return base.SetProps(); + } + + public override bool Connect() + { + try + { + if (_externalTool.TryIntegrate == false) + { + _externalTool.Start(InterfaceControl.Info); + Close(); + return null; + } + + _process = new Process(); + + _process.StartInfo.UseShellExecute = true; + _process.StartInfo.FileName = _externalTool.ParseArguments(_externalTool.FileName); + _process.StartInfo.Arguments = _externalTool.ParseArguments(_externalTool.Arguments); + + _process.EnableRaisingEvents = true; + _process.Exited += ProcessExited; + + _process.Start(); + _process.WaitForInputIdle(System.Convert.ToInt32(My.Settings.Default.MaxPuttyWaitTime * 1000)); + + int startTicks = Environment.TickCount; + while (_handle.ToInt32() == 0 & Environment.TickCount < startTicks + (My.Settings.Default.MaxPuttyWaitTime * 1000)) + { + _process.Refresh(); + if (!(_process.MainWindowTitle == "Default IME")) + { + _handle = _process.MainWindowHandle; + } + if (_handle.ToInt32() == 0) + { + Thread.Sleep(0); + } + } + + SetParent(_handle, InterfaceControl.Handle); + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strIntAppStuff, true); + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppHandle, _handle.ToString()), true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppTitle, _process.MainWindowTitle), true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(My.Language.strIntAppParentHandle, InterfaceControl.Parent.Handle.ToString()), true); + + Resize(this, new EventArgs()); + + base.Connect(); + return true; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(My.Language.strIntAppConnectionFailed, ex); + return false; + } + } + + public override void Focus() + { + try + { + if (ConnectionWindow.InTabDrag) + { + return ; + } + SetForegroundWindow(_handle); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: My.Language.strIntAppFocusFailed, ex: ex, logOnly: true); + } + } + + public override void Resize(object sender, EventArgs e) + { + try + { + if (InterfaceControl.Size == Size.Empty) + { + return ; + } + MoveWindow(_handle, System.Convert.ToInt32(- SystemInformation.FrameBorderSize.Width), System.Convert.ToInt32(- (SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height)), InterfaceControl.Width + (SystemInformation.FrameBorderSize.Width * 2), InterfaceControl.Height + SystemInformation.CaptionHeight + (SystemInformation.FrameBorderSize.Height * 2), true); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: My.Language.strIntAppResizeFailed, ex: ex, logOnly: true); + } + } + + public override void Close() + { + try + { + if (!_process.HasExited) + { + _process.Kill(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: My.Language.strIntAppKillFailed, ex: ex, logOnly: true); + } + + try + { + if (!_process.HasExited) + { + _process.Dispose(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: My.Language.strIntAppDisposeFailed, ex: ex, logOnly: true); + } + + base.Close(); + } + #endregion + + #region Private Fields + private ExternalTool _externalTool; + private IntPtr _handle; + private Process _process; + #endregion + + #region Private Methods + private void ProcessExited(object sender, EventArgs e) + { + Event_Closed(this); + } + #endregion + + #region Enumerations + public enum Defaults + { + Port = 0 + } + #endregion + } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.PuttyBase.cs b/mRemoteV1/CS/Connection/Connection.Protocol.PuttyBase.cs index fa84c69e4..4e99a8cbc 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.PuttyBase.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.PuttyBase.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,15 +8,13 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Runtime.InteropServices; using System.ComponentModel; using mRemoteNG.Messages; //using mRemoteNG.App.Native; using System.Threading; using Microsoft.Win32; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Text.RegularExpressions; using mRemoteNG.Tools; @@ -25,19 +22,18 @@ using mRemoteNG.Tools; namespace mRemoteNG.Connection.Protocol { public class PuttyBase : Base - { - -#region Constants + { + #region Constants private const int IDM_RECONF = 0x50; // PuTTY Settings Menu ID -#endregion + #endregion -#region Private Properties + #region Private Properties bool _isPuttyNg; -#endregion + #endregion -#region Public Properties + #region Public Properties private Putty_Protocol _PuttyProtocol; -public Putty_Protocol PuttyProtocol + public Putty_Protocol PuttyProtocol { get { @@ -50,7 +46,7 @@ public Putty_Protocol PuttyProtocol } private Putty_SSHVersion _PuttySSHVersion; -public Putty_SSHVersion PuttySSHVersion + public Putty_SSHVersion PuttySSHVersion { get { @@ -63,7 +59,7 @@ public Putty_SSHVersion PuttySSHVersion } private IntPtr _PuttyHandle; -public IntPtr PuttyHandle + public IntPtr PuttyHandle { get { @@ -76,7 +72,7 @@ public IntPtr PuttyHandle } private Process _PuttyProcess; -public Process PuttyProcess + public Process PuttyProcess { get { @@ -89,7 +85,7 @@ public Process PuttyProcess } private static string _PuttyPath; -public static string PuttyPath + public static string PuttyPath { get { @@ -101,7 +97,7 @@ public static string PuttyPath } } -public bool Focused + public bool Focused { get { @@ -115,16 +111,16 @@ public bool Focused } } } -#endregion + #endregion -#region Private Events & Handlers + #region Private Events & Handlers private void ProcessExited(object sender, System.EventArgs e) { base.EVENT_CLOSED(this); } -#endregion + #endregion -#region Public Methods + #region Public Methods public PuttyBase() { @@ -237,11 +233,11 @@ public bool Focused SetParent(PuttyHandle, InterfaceControl.Handle); } - MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strPuttyStuff, true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strPuttyStuff, true); - MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyHandle, PuttyHandle.ToString()), true); - MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true); - MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyParentHandle, InterfaceControl.Parent.Handle.ToString()), true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyHandle, PuttyHandle.ToString()), true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strPuttyParentHandle, InterfaceControl.Parent.Handle.ToString()), true); Resize(this, new EventArgs()); @@ -250,7 +246,7 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strPuttyConnectionFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strPuttyConnectionFailed + Constants.vbNewLine + ex.Message); return false; } } @@ -267,7 +263,7 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyFocusFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyFocusFailed + Constants.vbNewLine + ex.Message, true); } } @@ -283,7 +279,7 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyResizeFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyResizeFailed + Constants.vbNewLine + ex.Message, true); } } @@ -298,7 +294,7 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyKillFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyKillFailed + Constants.vbNewLine + ex.Message, true); } try @@ -307,7 +303,7 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyDisposeFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyDisposeFailed + Constants.vbNewLine + ex.Message, true); } base.Close(); @@ -322,12 +318,12 @@ public bool Focused } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyShowSettingsDialogFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPuttyShowSettingsDialogFailed + Constants.vbNewLine + ex.Message, true); } } -#endregion + #endregion -#region Enums + #region Enums public enum Putty_Protocol { ssh = 0, @@ -342,6 +338,6 @@ public bool Focused ssh1 = 1, ssh2 = 2 } -#endregion + #endregion } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.RDP.cs b/mRemoteV1/CS/Connection/Connection.Protocol.RDP.cs index 40ef4079e..450574dd9 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.RDP.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.RDP.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,13 +8,11 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Threading; using EOLWTSCOM; using System.ComponentModel; using mRemoteNG.Messages; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; //using mRemoteNG.Tools.LocalizedAttributes; using MSTSCLib; using mRemoteNG.Tools; @@ -25,7 +22,7 @@ namespace mRemoteNG.Connection.Protocol { public class RDP : Base { -#region Properties + #region Properties public bool SmartSize { get @@ -75,20 +72,20 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetRedirectKeysFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetRedirectKeysFailed + Constants.vbNewLine + ex.Message, true); } } } -#endregion + #endregion -#region Private Declarations + #region Private Declarations private MSTSCLib.MsRdpClient5NotSafeForScripting _rdpClient; private Version _rdpVersion; private Info _connectionInfo; private bool _loginComplete; -#endregion + #endregion -#region Public Methods + #region Public Methods public RDP() { Control = new AxMsRdpClient5NotSafeForScripting(); @@ -115,7 +112,7 @@ namespace mRemoteNG.Connection.Protocol } catch (System.Runtime.InteropServices.COMException ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpControlCreationFailed, ex); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpControlCreationFailed, ex); Control.Dispose(); return false; } @@ -164,7 +161,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPropsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPropsFailed + Constants.vbNewLine + ex.Message, true); return false; } } @@ -182,7 +179,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpConnectionOpenFailed + Constants.vbNewLine + ex.Message); } return false; @@ -196,7 +193,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpDisconnectFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpDisconnectFailed + Constants.vbNewLine + ex.Message, true); base.Close(); } } @@ -209,7 +206,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpToggleFullscreenFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpToggleFullscreenFailed + Constants.vbNewLine + ex.Message, true); } } @@ -221,7 +218,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpToggleSmartSizeFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpToggleSmartSizeFailed + Constants.vbNewLine + ex.Message, true); } } @@ -236,7 +233,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpFocusFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpFocusFailed + Constants.vbNewLine + ex.Message, true); } } @@ -264,9 +261,9 @@ namespace mRemoteNG.Connection.Protocol } _controlBeginningSize = Size.Empty; } -#endregion + #endregion -#region Private Methods + #region Private Methods private bool DoResize() { Control.Location = InterfaceControl.Location; @@ -328,12 +325,12 @@ namespace mRemoteNG.Connection.Protocol { if (_rdpClient.TransportSettings.GatewayIsSupported == 0) { - MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strRdpGatewayNotSupported, true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strRdpGatewayNotSupported, true); return ; } else { - MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strRdpGatewayIsSupported, true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, My.Language.strRdpGatewayIsSupported, true); } if (!(_connectionInfo.RDGatewayUsageMethod == RDGatewayUsageMethod.Never)) @@ -369,7 +366,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strRdpSetGatewayFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, My.Language.strRdpSetGatewayFailed + Constants.vbNewLine + ex.Message, true); } } @@ -394,18 +391,18 @@ namespace mRemoteNG.Connection.Protocol if (_rdpVersion >= Versions.RDC61) { - MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strRdpSetConsoleSwitch, "6.1"), true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strRdpSetConsoleSwitch, "6.1"), true); _rdpClient.AdvancedSettings7.ConnectToAdministerServer = value; } else { - MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strRdpSetConsoleSwitch, "6.0"), true); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(My.Language.strRdpSetConsoleSwitch, "6.0"), true); _rdpClient.AdvancedSettings2.ConnectToServerConsole = value; } } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpSetConsoleSessionFailed, ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpSetConsoleSessionFailed, ex, MessageClass.ErrorMsg, true); } } @@ -471,7 +468,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetCredentialsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetCredentialsFailed + Constants.vbNewLine + ex.Message, true); } } @@ -508,7 +505,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetResolutionFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetResolutionFailed + Constants.vbNewLine + ex.Message, true); } } @@ -523,7 +520,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPortFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPortFailed + Constants.vbNewLine + ex.Message, true); } } @@ -539,7 +536,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetRedirectionFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetRedirectionFailed + Constants.vbNewLine + ex.Message, true); } } @@ -572,7 +569,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPerformanceFlagsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetPerformanceFlagsFailed + Constants.vbNewLine + ex.Message, true); } } @@ -584,7 +581,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetAuthenticationLevelFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetAuthenticationLevelFailed + Constants.vbNewLine + ex.Message, true); } } @@ -600,7 +597,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage("Unable to set load balance info.", ex); + Runtime.MessageCollector.AddExceptionMessage("Unable to set load balance info.", ex); } } @@ -617,12 +614,12 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); } } -#endregion + #endregion -#region Private Events & Handlers + #region Private Events & Handlers private void RDPEvent_OnFatalError(int errorCode) { Event_ErrorOccured(this, System.Convert.ToString(errorCode)); @@ -674,9 +671,9 @@ namespace mRemoteNG.Connection.Protocol if (LeaveFullscreenEvent != null) LeaveFullscreenEvent(this, new EventArgs()); } -#endregion + #endregion -#region Public Events & Handlers + #region Public Events & Handlers public delegate void LeaveFullscreenEventHandler(Connection.Protocol.RDP sender, System.EventArgs e); private LeaveFullscreenEventHandler LeaveFullscreenEvent; @@ -691,10 +688,9 @@ namespace mRemoteNG.Connection.Protocol LeaveFullscreenEvent = (LeaveFullscreenEventHandler) System.Delegate.Remove(LeaveFullscreenEvent, value); } } + #endregion -#endregion - -#region Enums + #region Enums public enum Defaults { Colors = RDPColors.Colors16Bit, @@ -796,9 +792,9 @@ namespace mRemoteNG.Connection.Protocol [LocalizedAttributes.LocalizedDescription("strUseSmartCard")] SmartCard = 2 } -#endregion + #endregion -#region Resolution + #region Resolution public static Rectangle GetResolutionRectangle(RDPResolutions resolution) { string[] resolutionParts = null; @@ -815,7 +811,7 @@ namespace mRemoteNG.Connection.Protocol return new Rectangle(0, 0, (int) (resolutionParts[0]), (int) (resolutionParts[1])); } } -#endregion + #endregion public class Versions { @@ -825,7 +821,7 @@ namespace mRemoteNG.Connection.Protocol public static Version RDC80 = new Version(6, 2, 9200); } -#region Terminal Sessions + #region Terminal Sessions public class TerminalSessions { private WTSCOM _wtsCom; @@ -838,7 +834,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage("TerminalSessions.New() failed.", ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("TerminalSessions.New() failed.", ex, MessageClass.ErrorMsg, true); } } @@ -855,7 +851,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpOpenConnectionFailed, ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpOpenConnectionFailed, ex, MessageClass.ErrorMsg, true); } } @@ -872,7 +868,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpCloseConnectionFailed, ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpCloseConnectionFailed, ex, MessageClass.ErrorMsg, true); } } @@ -916,7 +912,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpGetSessionsFailed, ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpGetSessionsFailed, ex, MessageClass.ErrorMsg, true); } return sessions; @@ -937,7 +933,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage("TerminalSessions.KillSession() failed.", ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("TerminalSessions.KillSession() failed.", ex, MessageClass.ErrorMsg, true); } return result; @@ -978,7 +974,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddExceptionMessage(My.Language.strRdpAddSessionFailed, ex, MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage(My.Language.strRdpAddSessionFailed, ex, MessageClass.ErrorMsg, true); } return newSession; @@ -998,9 +994,9 @@ namespace mRemoteNG.Connection.Protocol public string SessionUser {get; set;} public string SessionName {get; set;} } -#endregion + #endregion -#region Fatal Errors + #region Fatal Errors public class FatalErrors { public FatalErrors() @@ -1019,14 +1015,14 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpErrorGetFailure + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpErrorGetFailure + Constants.vbNewLine + ex.Message, true); return string.Format(My.Language.strRdpErrorUnknown, id); } } } -#endregion + #endregion -#region Reconnect Stuff + #region Reconnect Stuff public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { bool srvReady = Tools.PortScan.Scanner.IsPortOpen(_connectionInfo.Hostname, System.Convert.ToString(_connectionInfo.Port)); @@ -1041,6 +1037,6 @@ namespace mRemoteNG.Connection.Protocol _rdpClient.Connect(); } } -#endregion + #endregion } } diff --git a/mRemoteV1/CS/Connection/Connection.Protocol.VNC.cs b/mRemoteV1/CS/Connection/Connection.Protocol.VNC.cs index 3f8391e8e..d87c8ab53 100644 --- a/mRemoteV1/CS/Connection/Connection.Protocol.VNC.cs +++ b/mRemoteV1/CS/Connection/Connection.Protocol.VNC.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,9 +8,7 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.ComponentModel; using mRemoteNG.Tools; //using mRemoteNG.Tools.LocalizedAttributes; @@ -21,8 +18,7 @@ namespace mRemoteNG.Connection.Protocol { public class VNC : Base { - -#region Properties + #region Properties public bool SmartSize { get { return VNC_Renamed.Scaled; } @@ -34,14 +30,14 @@ namespace mRemoteNG.Connection.Protocol get { return VNC_Renamed.ViewOnly; } set { VNC_Renamed.ViewOnly = value; } } -#endregion + #endregion -#region Private Declarations + #region Private Declarations private VncSharp.RemoteDesktop VNC_Renamed; private Connection.Info Info; -#endregion + #endregion -#region Public Methods + #region Public Methods public VNC() { this.Control = new VncSharp.RemoteDesktop(); @@ -126,7 +122,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSetPropsFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSetPropsFailed + Constants.vbNewLine + ex.Message, true); return false; } } @@ -141,7 +137,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncConnectionOpenFailed + Constants.vbNewLine + ex.Message); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncConnectionOpenFailed + Constants.vbNewLine + ex.Message); return false; } @@ -156,7 +152,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncConnectionDisconnectFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncConnectionDisconnectFailed + Constants.vbNewLine + ex.Message, true); } } @@ -176,7 +172,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSendSpecialKeysFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSendSpecialKeysFailed + Constants.vbNewLine + ex.Message, true); } } @@ -189,7 +185,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncToggleSmartSizeFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncToggleSmartSizeFailed + Constants.vbNewLine + ex.Message, true); } } @@ -201,7 +197,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncToggleViewOnlyFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncToggleViewOnlyFailed + Constants.vbNewLine + ex.Message, true); } } @@ -218,7 +214,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncStartChatFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncStartChatFailed + Constants.vbNewLine + ex.Message, true); } } @@ -246,130 +242,130 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncRefreshFailed + Constants.vbNewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncRefreshFailed + Constants.vbNewLine + ex.Message, true); } } -#endregion + #endregion -#region Private Methods - private void SetEventHandlers() + #region Private Methods + private void SetEventHandlers() + { + try + { + VNC_Renamed.ConnectComplete += VNCEvent_Connected; + VNC_Renamed.ConnectionLost += VNCEvent_Disconnected; + mRemoteNG.frmMain.clipboardchange += VNCEvent_ClipboardChanged; + if (!((Force & Info.Force.NoCredentials) == (int) Info.Force.NoCredentials) && !string.IsNullOrEmpty(Info.Password)) { - try - { - VNC_Renamed.ConnectComplete += VNCEvent_Connected; - VNC_Renamed.ConnectionLost += VNCEvent_Disconnected; - mRemoteNG.frmMain.clipboardchange += VNCEvent_ClipboardChanged; - if (!((Force & Info.Force.NoCredentials) == (int) Info.Force.NoCredentials) && !string.IsNullOrEmpty(Info.Password)) - { - VNC_Renamed.GetPassword = new System.EventHandler(VNCEvent_Authenticate); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); - } + VNC_Renamed.GetPassword = new System.EventHandler(VNCEvent_Authenticate); } -#endregion - -#region Private Events & Handlers - private void VNCEvent_Connected(object sender, EventArgs e) - { - base.Event_Connected(this); - VNC_Renamed.AutoScroll = Info.VNCSmartSizeMode == SmartSizeMode.SmartSNo; - } - - private void VNCEvent_Disconnected(object sender, EventArgs e) - { - base.Event_Disconnected(sender, e.ToString()); - base.Close(); - } - - private void VNCEvent_ClipboardChanged() - { - this.VNC_Renamed.FillServerClipboard(); - } - - private string VNCEvent_Authenticate() - { - return Info.Password; - } -#endregion - -#region Enums - public enum Defaults - { - Port = 5900 - } - - public enum SpecialKeys - { - CtrlAltDel, - CtrlEsc - } - - public enum Compression - { - [LocalizedAttributes.LocalizedDescription("strNoCompression")]CompNone = 99, - [Description("0")]Comp0 = 0, - [Description("1")]Comp1 = 1, - [Description("2")]Comp2 = 2, - [Description("3")]Comp3 = 3, - [Description("4")]Comp4 = 4, - [Description("5")]Comp5 = 5, - [Description("6")]Comp6 = 6, - [Description("7")]Comp7 = 7, - [Description("8")]Comp8 = 8, - [Description("9")]Comp9 = 9 - } - - public enum Encoding - { - [Description("Raw")]EncRaw, - [Description("RRE")]EncRRE, - [Description("CoRRE")]EncCorre, - [Description("Hextile")]EncHextile, - [Description("Zlib")]EncZlib, - [Description("Tight")]EncTight, - [Description("ZlibHex")]EncZLibHex, - [Description("ZRLE")]EncZRLE - } - - public enum AuthMode - { - [LocalizedAttributes.LocalizedDescription("VNC")] - AuthVNC, - [LocalizedAttributes.LocalizedDescription("Windows")] - AuthWin - } - - public enum ProxyType - { - [LocalizedAttributes.LocalizedDescription("strNone")] - ProxyNone, - [LocalizedAttributes.LocalizedDescription("strHttp")] - ProxyHTTP, - [LocalizedAttributes.LocalizedDescription("strSocks5")] - ProxySocks5, - [LocalizedAttributes.LocalizedDescription("strUltraVncRepeater")] - ProxyUltra - } - - public enum Colors - { - [LocalizedAttributes.LocalizedDescription("strNormal")] - ColNormal, - [Description("8-bit")]Col8Bit - } - - public enum SmartSizeMode - { - [LocalizedAttributes.LocalizedDescription("strNoSmartSize")] - SmartSNo, - [LocalizedAttributes.LocalizedDescription("strFree")] - SmartSFree, - [LocalizedAttributes.LocalizedDescription("strAspect")] - SmartSAspect - } -#endregion } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strVncSetEventHandlersFailed + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Private Events & Handlers + private void VNCEvent_Connected(object sender, EventArgs e) + { + base.Event_Connected(this); + VNC_Renamed.AutoScroll = Info.VNCSmartSizeMode == SmartSizeMode.SmartSNo; + } + + private void VNCEvent_Disconnected(object sender, EventArgs e) + { + base.Event_Disconnected(sender, e.ToString()); + base.Close(); + } + + private void VNCEvent_ClipboardChanged() + { + this.VNC_Renamed.FillServerClipboard(); + } + + private string VNCEvent_Authenticate() + { + return Info.Password; + } + #endregion + + #region Enums + public enum Defaults + { + Port = 5900 + } + + public enum SpecialKeys + { + CtrlAltDel, + CtrlEsc + } + + public enum Compression + { + [LocalizedAttributes.LocalizedDescription("strNoCompression")]CompNone = 99, + [Description("0")]Comp0 = 0, + [Description("1")]Comp1 = 1, + [Description("2")]Comp2 = 2, + [Description("3")]Comp3 = 3, + [Description("4")]Comp4 = 4, + [Description("5")]Comp5 = 5, + [Description("6")]Comp6 = 6, + [Description("7")]Comp7 = 7, + [Description("8")]Comp8 = 8, + [Description("9")]Comp9 = 9 + } + + public enum Encoding + { + [Description("Raw")]EncRaw, + [Description("RRE")]EncRRE, + [Description("CoRRE")]EncCorre, + [Description("Hextile")]EncHextile, + [Description("Zlib")]EncZlib, + [Description("Tight")]EncTight, + [Description("ZlibHex")]EncZLibHex, + [Description("ZRLE")]EncZRLE + } + + public enum AuthMode + { + [LocalizedAttributes.LocalizedDescription("VNC")] + AuthVNC, + [LocalizedAttributes.LocalizedDescription("Windows")] + AuthWin + } + + public enum ProxyType + { + [LocalizedAttributes.LocalizedDescription("strNone")] + ProxyNone, + [LocalizedAttributes.LocalizedDescription("strHttp")] + ProxyHTTP, + [LocalizedAttributes.LocalizedDescription("strSocks5")] + ProxySocks5, + [LocalizedAttributes.LocalizedDescription("strUltraVncRepeater")] + ProxyUltra + } + + public enum Colors + { + [LocalizedAttributes.LocalizedDescription("strNormal")] + ColNormal, + [Description("8-bit")]Col8Bit + } + + public enum SmartSizeMode + { + [LocalizedAttributes.LocalizedDescription("strNoSmartSize")] + SmartSNo, + [LocalizedAttributes.LocalizedDescription("strFree")] + SmartSFree, + [LocalizedAttributes.LocalizedDescription("strAspect")] + SmartSAspect + } + #endregion + } } diff --git a/mRemoteV1/CS/Forms/OptionsForm.cs b/mRemoteV1/CS/Forms/OptionsForm.cs index d2db6cf25..2c77bd305 100644 --- a/mRemoteV1/CS/Forms/OptionsForm.cs +++ b/mRemoteV1/CS/Forms/OptionsForm.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,260 +8,258 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using mRemoteNG.Forms.OptionsPages; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using mRemoteNG.My; namespace mRemoteNG.Forms { public partial class OptionsForm + { + #region Constructors + public OptionsForm() { -#region Constructors - public OptionsForm() - { - // This call is required by the designer. - InitializeComponent(); - // Add any initialization after the InitializeComponent() call. + // This call is required by the designer. + InitializeComponent(); + // Add any initialization after the InitializeComponent() call. - FontOverride(this); + FontOverride(this); - _pages.Add(new Forms.OptionsPages.StartupExitPage(), new PageInfo()); - _pages.Add(new AppearancePage(), new PageInfo()); - _pages.Add(new TabsPanelsPage(), new PageInfo()); - _pages.Add(new ConnectionsPage(), new PageInfo()); - _pages.Add(new SqlServerPage(), new PageInfo()); - _pages.Add(new UpdatesPage(), new PageInfo()); - _pages.Add(new ThemePage(), new PageInfo()); - _pages.Add(new KeyboardPage(), new PageInfo()); - _pages.Add(new AdvancedPage(), new PageInfo()); + _pages.Add(new Forms.OptionsPages.StartupExitPage(), new PageInfo()); + _pages.Add(new AppearancePage(), new PageInfo()); + _pages.Add(new TabsPanelsPage(), new PageInfo()); + _pages.Add(new ConnectionsPage(), new PageInfo()); + _pages.Add(new SqlServerPage(), new PageInfo()); + _pages.Add(new UpdatesPage(), new PageInfo()); + _pages.Add(new ThemePage(), new PageInfo()); + _pages.Add(new KeyboardPage(), new PageInfo()); + _pages.Add(new AdvancedPage(), new PageInfo()); - _startPage = GetPageFromType(typeof(Forms.OptionsPages.StartupExitPage)); + _startPage = GetPageFromType(typeof(Forms.OptionsPages.StartupExitPage)); - _pageIconImageList.ColorDepth = ColorDepth.Depth32Bit; - PageListView.LargeImageList = _pageIconImageList; - } -#endregion - -#region Public Methods - public DialogResult ShowDialog(IWin32Window ownerWindow, Type pageType) - { - _startPage = GetPageFromType(pageType); - return ShowDialog(ownerWindow); - } -#endregion - -#region Private Fields - private Dictionary _pages = new Dictionary(); - private ImageList _pageIconImageList = new ImageList(); - - private OptionsPage _startPage; - private OptionsPage _selectedPage = null; -#endregion - -#region Private Methods -#region Event Handlers - public void OptionsForm_Load(System.Object sender, EventArgs e) - { - foreach (KeyValuePair keyValuePair in _pages) - { - OptionsPage page = KeyValuePair.Key; - PageInfo pageInfo = KeyValuePair.Value; - _pageIconImageList.Images.Add(pageInfo.IconKey, page.PageIcon); - pageInfo.ListViewItem = PageListView.Items.Add(page.PageName, pageInfo.IconKey); - } - - ApplyLanguage(); - LoadSettings(); - - ShowPage(_startPage); - } - - public void OptionsForm_FormClosing(System.Object sender, FormClosingEventArgs e) - { - if (DialogResult == DialogResult.OK) - { - SaveSettings(); - } - else - { - RevertSettings(); - } - } - - public void PageListView_ItemSelectionChanged(System.Object sender, ListViewItemSelectionChangedEventArgs e) - { - if (!e.IsSelected) - { - return ; - } - if (_pages.Count < 1) - { - return ; - } - OptionsPage page = GetPageFromListViewItem(e.Item); - if (_selectedPage != page) - { - ShowPage(page); - } - SelectNextControl(PageListView, true, true, true, true); - } - - public void PageListView_MouseUp(System.Object sender, MouseEventArgs e) - { - if (PageListView.SelectedIndices.Count == 0) - { - PageInfo pageInfo = _pages[_selectedPage]; - pageInfo.ListViewItem.Selected = true; - } - SelectNextControl(PageListView, true, true, true, true); - } - - public void OkButton_Click(System.Object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - Close(); - } - - public void CancelButtonControl_Click(System.Object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } -#endregion - - private void ApplyLanguage() - { - Text = Language.strMenuOptions; - OkButton.Text = Language.strButtonOK; - CancelButtonControl.Text = Language.strButtonCancel; - - foreach (OptionsPage page in _pages.Keys) - { - try - { - page.ApplyLanguage(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.ApplyLanguage() failed for page {0}.", page.PageName), ex: ex, logOnly: true); - } - } - } - - private void LoadSettings() - { - foreach (OptionsPage page in _pages.Keys) - { - try - { - page.LoadSettings(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.LoadSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); - } - } - } - - private void SaveSettings() - { - foreach (OptionsPage page in _pages.Keys) - { - try - { - page.SaveSettings(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.SaveSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); - } - } - } - - private void RevertSettings() - { - foreach (OptionsPage page in _pages.Keys) - { - try - { - page.RevertSettings(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.RevertSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); - } - } - } - - private OptionsPage GetPageFromType(Type pageType) - { - foreach (OptionsPage page in _pages.Keys) - { - if (page.GetType() == pageType) - { - return page; - } - } - return null; - } - - private OptionsPage GetPageFromListViewItem(ListViewItem listViewItem) - { - foreach (KeyValuePair keyValuePair in _pages) - { - OptionsPage page = KeyValuePair.Key; - PageInfo pageInfo = KeyValuePair.Value; - if (pageInfo.ListViewItem == listViewItem) - { - return page; - } - } - return null; - } - - private void ShowPage(OptionsPage newPage) - { - if (_selectedPage != null) - { - OptionsPage oldPage = _selectedPage; - oldPage.Visible = false; - if (_pages.ContainsKey(oldPage)) - { - PageInfo oldPageInfo = _pages[oldPage]; - oldPageInfo.ListViewItem.Selected = false; - } - } - - _selectedPage = newPage; - - if (newPage != null) - { - newPage.Parent = PagePanel; - newPage.Dock = DockStyle.Fill; - newPage.Visible = true; - if (_pages.ContainsKey(newPage)) - { - PageInfo newPageInfo = _pages[newPage]; - newPageInfo.ListViewItem.Selected = true; - } - } - } -#endregion - -#region Private Classes - private class PageInfo - { - public string IconKey {get; set;} - public ListViewItem ListViewItem {get; set;} - - public PageInfo() - { - IconKey = Guid.NewGuid().ToString(); - } - } -#endregion + _pageIconImageList.ColorDepth = ColorDepth.Depth32Bit; + PageListView.LargeImageList = _pageIconImageList; } + #endregion + + #region Public Methods + public DialogResult ShowDialog(IWin32Window ownerWindow, Type pageType) + { + _startPage = GetPageFromType(pageType); + return ShowDialog(ownerWindow); + } + #endregion + + #region Private Fields + private Dictionary _pages = new Dictionary(); + private ImageList _pageIconImageList = new ImageList(); + + private OptionsPage _startPage; + private OptionsPage _selectedPage = null; + #endregion + + #region Private Methods + #region Event Handlers + public void OptionsForm_Load(System.Object sender, EventArgs e) + { + foreach (KeyValuePair keyValuePair in _pages) + { + OptionsPage page = KeyValuePair.Key; + PageInfo pageInfo = KeyValuePair.Value; + _pageIconImageList.Images.Add(pageInfo.IconKey, page.PageIcon); + pageInfo.ListViewItem = PageListView.Items.Add(page.PageName, pageInfo.IconKey); + } + + ApplyLanguage(); + LoadSettings(); + + ShowPage(_startPage); + } + + public void OptionsForm_FormClosing(System.Object sender, FormClosingEventArgs e) + { + if (DialogResult == DialogResult.OK) + { + SaveSettings(); + } + else + { + RevertSettings(); + } + } + + public void PageListView_ItemSelectionChanged(System.Object sender, ListViewItemSelectionChangedEventArgs e) + { + if (!e.IsSelected) + { + return ; + } + if (_pages.Count < 1) + { + return ; + } + OptionsPage page = GetPageFromListViewItem(e.Item); + if (_selectedPage != page) + { + ShowPage(page); + } + SelectNextControl(PageListView, true, true, true, true); + } + + public void PageListView_MouseUp(System.Object sender, MouseEventArgs e) + { + if (PageListView.SelectedIndices.Count == 0) + { + PageInfo pageInfo = _pages[_selectedPage]; + pageInfo.ListViewItem.Selected = true; + } + SelectNextControl(PageListView, true, true, true, true); + } + + public void OkButton_Click(System.Object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + Close(); + } + + public void CancelButtonControl_Click(System.Object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + #endregion + + private void ApplyLanguage() + { + Text = Language.strMenuOptions; + OkButton.Text = Language.strButtonOK; + CancelButtonControl.Text = Language.strButtonCancel; + + foreach (OptionsPage page in _pages.Keys) + { + try + { + page.ApplyLanguage(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.ApplyLanguage() failed for page {0}.", page.PageName), ex: ex, logOnly: true); + } + } + } + + private void LoadSettings() + { + foreach (OptionsPage page in _pages.Keys) + { + try + { + page.LoadSettings(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.LoadSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); + } + } + } + + private void SaveSettings() + { + foreach (OptionsPage page in _pages.Keys) + { + try + { + page.SaveSettings(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.SaveSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); + } + } + } + + private void RevertSettings() + { + foreach (OptionsPage page in _pages.Keys) + { + try + { + page.RevertSettings(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: string.Format("OptionsPage.RevertSettings() failed for page {0}.", page.PageName), ex: ex, logOnly: true); + } + } + } + + private OptionsPage GetPageFromType(Type pageType) + { + foreach (OptionsPage page in _pages.Keys) + { + if (page.GetType() == pageType) + { + return page; + } + } + return null; + } + + private OptionsPage GetPageFromListViewItem(ListViewItem listViewItem) + { + foreach (KeyValuePair keyValuePair in _pages) + { + OptionsPage page = KeyValuePair.Key; + PageInfo pageInfo = KeyValuePair.Value; + if (pageInfo.ListViewItem == listViewItem) + { + return page; + } + } + return null; + } + + private void ShowPage(OptionsPage newPage) + { + if (_selectedPage != null) + { + OptionsPage oldPage = _selectedPage; + oldPage.Visible = false; + if (_pages.ContainsKey(oldPage)) + { + PageInfo oldPageInfo = _pages[oldPage]; + oldPageInfo.ListViewItem.Selected = false; + } + } + + _selectedPage = newPage; + + if (newPage != null) + { + newPage.Parent = PagePanel; + newPage.Dock = DockStyle.Fill; + newPage.Visible = true; + if (_pages.ContainsKey(newPage)) + { + PageInfo newPageInfo = _pages[newPage]; + newPageInfo.ListViewItem.Selected = true; + } + } + } + #endregion + + #region Private Classes + private class PageInfo + { + public string IconKey {get; set;} + public ListViewItem ListViewItem {get; set;} + + public PageInfo() + { + IconKey = Guid.NewGuid().ToString(); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/Forms/frmMain.cs b/mRemoteV1/CS/Forms/frmMain.cs index 78fbb7233..e1fe88857 100644 --- a/mRemoteV1/CS/Forms/frmMain.cs +++ b/mRemoteV1/CS/Forms/frmMain.cs @@ -968,7 +968,7 @@ namespace mRemoteNG } catch (Exception ex) { - MessageCollector.AddExceptionMessage("btnQuickConnect_ButtonClick() failed.", ex, Messages.MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("btnQuickConnect_ButtonClick() failed.", ex, Messages.MessageClass.ErrorMsg, true); } } @@ -1080,7 +1080,7 @@ namespace mRemoteNG } catch (Exception ex) { - MessageCollector.AddExceptionMessage("frmMain.AddNodeToMenu() failed", ex, Messages.MessageClass.ErrorMsg, true); + Runtime.MessageCollector.AddExceptionMessage("frmMain.AddNodeToMenu() failed", ex, Messages.MessageClass.ErrorMsg, true); } } diff --git a/mRemoteV1/CS/Security/Security.Crypt.cs b/mRemoteV1/CS/Security/Security.Crypt.cs index 8ad2c6473..9439ce524 100644 --- a/mRemoteV1/CS/Security/Security.Crypt.cs +++ b/mRemoteV1/CS/Security/Security.Crypt.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,117 +8,115 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.IO; using System.Security.Cryptography; using System.Text; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Security { public class Crypt + { + public static string Encrypt(string StrToEncrypt, string StrSecret) { - public static string Encrypt(string StrToEncrypt, string StrSecret) + if (StrToEncrypt == "" || StrSecret == "") { - if (StrToEncrypt == "" || StrSecret == "") - { - return StrToEncrypt; - } - - try - { - RijndaelManaged rd = new RijndaelManaged(); - - MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); - byte[] key = md5.ComputeHash(Encoding.UTF8.GetBytes(StrSecret)); - - md5.Clear(); - rd.Key = key; - rd.GenerateIV(); - - byte[] iv = rd.IV; - MemoryStream ms = new MemoryStream(); - - ms.Write(iv, 0, iv.Length); - - CryptoStream cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write); - byte[] data = System.Text.Encoding.UTF8.GetBytes(StrToEncrypt); - - cs.Write(data, 0, data.Length); - cs.FlushFinalBlock(); - - byte[] encdata = ms.ToArray(); - cs.Close(); - rd.Clear(); - - return Convert.ToBase64String(encdata); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorEncryptionFailed, ex.Message)); - } - return StrToEncrypt; } - - public static string Decrypt(string ciphertextBase64, string password) + + try { - if (string.IsNullOrEmpty(ciphertextBase64) || string.IsNullOrEmpty(password)) - { - return ciphertextBase64; - } - - try - { - string plaintext = ""; - - using (RijndaelManaged rijndaelManaged = new RijndaelManaged()) - { - using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) - { - byte[] key = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); - rijndaelManaged.Key = key; - } - - - byte[] ciphertext = Convert.FromBase64String(ciphertextBase64); - - using (MemoryStream memoryStream = new MemoryStream(ciphertext)) - { - const int ivLength = 16; - byte[] iv = new byte[ivLength - 1 + 1]; - memoryStream.Read(iv, 0, ivLength); - rijndaelManaged.IV = iv; - - using (CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(), CryptoStreamMode.Read)) - { - using (StreamReader streamReader = new StreamReader(cryptoStream, System.Text.Encoding.UTF8, true)) - { - plaintext = streamReader.ReadToEnd(); - } - - rijndaelManaged.Clear(); - } // cryptoStream - - } // memoryStream - - } // rijndaelManaged - - - return plaintext; - } - catch (Exception ex) - { - // Ignore CryptographicException "Padding is invalid and cannot be removed." when password is incorrect. - if (!(ex is CryptographicException)) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorDecryptionFailed, ex.Message)); - } - } + RijndaelManaged rd = new RijndaelManaged(); + + MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); + byte[] key = md5.ComputeHash(Encoding.UTF8.GetBytes(StrSecret)); + + md5.Clear(); + rd.Key = key; + rd.GenerateIV(); + + byte[] iv = rd.IV; + MemoryStream ms = new MemoryStream(); + + ms.Write(iv, 0, iv.Length); + + CryptoStream cs = new CryptoStream(ms, rd.CreateEncryptor(), CryptoStreamMode.Write); + byte[] data = System.Text.Encoding.UTF8.GetBytes(StrToEncrypt); + + cs.Write(data, 0, data.Length); + cs.FlushFinalBlock(); + + byte[] encdata = ms.ToArray(); + cs.Close(); + rd.Clear(); + + return Convert.ToBase64String(encdata); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorEncryptionFailed, ex.Message)); + } + return StrToEncrypt; + } + + public static string Decrypt(string ciphertextBase64, string password) + { + if (string.IsNullOrEmpty(ciphertextBase64) || string.IsNullOrEmpty(password)) + { return ciphertextBase64; } + + try + { + string plaintext = ""; + + using (RijndaelManaged rijndaelManaged = new RijndaelManaged()) + { + using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) + { + byte[] key = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); + rijndaelManaged.Key = key; + } + + + byte[] ciphertext = Convert.FromBase64String(ciphertextBase64); + + using (MemoryStream memoryStream = new MemoryStream(ciphertext)) + { + const int ivLength = 16; + byte[] iv = new byte[ivLength - 1 + 1]; + memoryStream.Read(iv, 0, ivLength); + rijndaelManaged.IV = iv; + + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(), CryptoStreamMode.Read)) + { + using (StreamReader streamReader = new StreamReader(cryptoStream, System.Text.Encoding.UTF8, true)) + { + plaintext = streamReader.ReadToEnd(); + } + + rijndaelManaged.Clear(); + } // cryptoStream + + } // memoryStream + + } // rijndaelManaged + + + return plaintext; + } + catch (Exception ex) + { + // Ignore CryptographicException "Padding is invalid and cannot be removed." when password is incorrect. + if (!(ex is CryptographicException)) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(My.Language.strErrorDecryptionFailed, ex.Message)); + } + } + + return ciphertextBase64; } + } } diff --git a/mRemoteV1/CS/Security/Security.Impersonator.cs b/mRemoteV1/CS/Security/Security.Impersonator.cs index d520f3004..bf14362ed 100644 --- a/mRemoteV1/CS/Security/Security.Impersonator.cs +++ b/mRemoteV1/CS/Security/Security.Impersonator.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,12 +8,10 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Runtime.InteropServices; using System.Security.Principal; using System.Security.Permissions; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; [assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum,UnmanagedCode=true)] @@ -23,102 +20,102 @@ using System.Security.Permissions; namespace mRemoteNG.Security { public class Impersonator + { + #region Logon API + private const int LOGON32_PROVIDER_DEFAULT = 0; + private const int LOGON32_LOGON_NEW_CREDENTIALS = 9; + + private const int SecurityImpersonation = 2; + + [DllImport("advapi32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] + private static extern int LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); + + private const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x100; + private const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x200; + private const int FORMAT_MESSAGE_FROM_SYSTEM = 0x1000; + + [DllImport("kernel32.dll")]private static extern int FormatMessage(int dwFlags, ref IntPtr lpSource, int dwMessageId, int dwLanguageId, ref string lpBuffer, int nSize, ref IntPtr Arguments); + + [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] + private static extern bool CloseHandle(IntPtr handle); + + [DllImport("advapi32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] + private static extern int DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle); + #endregion + + private IntPtr tokenHandle = new IntPtr(0); + private WindowsImpersonationContext impersonatedUser = null; + + // GetErrorMessage formats and returns an error message corresponding to the input errorCode. + private string GetErrorMessage(int errorCode) { -#region Logon API - private const int LOGON32_PROVIDER_DEFAULT = 0; - private const int LOGON32_LOGON_NEW_CREDENTIALS = 9; + int messageSize = 255; + string lpMsgBuf = ""; + int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + + IntPtr ptrlpSource = IntPtr.Zero; + IntPtr prtArguments = IntPtr.Zero; + + int retVal = FormatMessage(dwFlags, ref ptrlpSource, errorCode, 0, ref lpMsgBuf, messageSize, ref prtArguments); + return lpMsgBuf.Trim(new char[] {char.Parse(Constants.vbCr), char.Parse(Constants.vbLf)}); + } - private const int SecurityImpersonation = 2; - - [DllImport("advapi32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] - private static extern int LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); - - private const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x100; - private const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x200; - private const int FORMAT_MESSAGE_FROM_SYSTEM = 0x1000; - - [DllImport("kernel32.dll")]private static extern int FormatMessage(int dwFlags, ref IntPtr lpSource, int dwMessageId, int dwLanguageId, ref string lpBuffer, int nSize, ref IntPtr Arguments); - - [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] - private static extern bool CloseHandle(IntPtr handle); - - [DllImport("advapi32.dll", ExactSpelling=true, CharSet=CharSet.Auto, SetLastError=true)] - private static extern int DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle); -#endregion - - private IntPtr tokenHandle = new IntPtr(0); - private WindowsImpersonationContext impersonatedUser = null; - - // GetErrorMessage formats and returns an error message corresponding to the input errorCode. - private string GetErrorMessage(int errorCode) + [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]public void StartImpersonation(string DomainName, string UserName, string Password) + { + try { - int messageSize = 255; - string lpMsgBuf = ""; - int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; - - IntPtr ptrlpSource = IntPtr.Zero; - IntPtr prtArguments = IntPtr.Zero; - - int retVal = FormatMessage(dwFlags, ref ptrlpSource, errorCode, 0, ref lpMsgBuf, messageSize, ref prtArguments); - return lpMsgBuf.Trim(new char[] {char.Parse(Constants.vbCr), char.Parse(Constants.vbLf)}); + if (!(impersonatedUser == null)) + { + throw (new Exception("Already impersonating a user.")); + } + + tokenHandle = IntPtr.Zero; + + int returnValue = System.Convert.ToInt32(LogonUser(UserName, DomainName, Password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref tokenHandle)); + + if (0 == returnValue) + { + int errCode = Marshal.GetLastWin32Error(); + string errMsg = "LogonUser failed with error code: " + errCode.ToString() + "(" + GetErrorMessage(errCode) + ")"; + ApplicationException exLogon = new ApplicationException(errMsg); + throw (exLogon); + } + + WindowsIdentity newId = new WindowsIdentity(tokenHandle); + impersonatedUser = newId.Impersonate(); } - - [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]public void StartImpersonation(string DomainName, string UserName, string Password) + catch (Exception ex) { - try - { - if (!(impersonatedUser == null)) - { - throw (new Exception("Already impersonating a user.")); - } - - tokenHandle = IntPtr.Zero; - - int returnValue = System.Convert.ToInt32(LogonUser(UserName, DomainName, Password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref tokenHandle)); - - if (0 == returnValue) - { - int errCode = Marshal.GetLastWin32Error(); - string errMsg = "LogonUser failed with error code: " + errCode.ToString() + "(" + GetErrorMessage(errCode) + ")"; - ApplicationException exLogon = new ApplicationException(errMsg); - throw (exLogon); - } - - WindowsIdentity newId = new WindowsIdentity(tokenHandle); - impersonatedUser = newId.Impersonate(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Starting Impersonation failed (Sessions feature will not work)" + Constants.vbNewLine + ex.Message, true); - } - } - - [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]public void StopImpersonation() - { - if (impersonatedUser == null) - { - return; - } - - try - { - impersonatedUser.Undo(); // Stop impersonating the user. - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Stopping Impersonation failed" + Constants.vbNewLine + ex.Message, true); - throw; - } - finally - { - - if (!System.IntPtr.op_Equality(tokenHandle, IntPtr.Zero)) - { - CloseHandle(tokenHandle); - } - - impersonatedUser = null; - } + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Starting Impersonation failed (Sessions feature will not work)" + Constants.vbNewLine + ex.Message, true); } } + + [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]public void StopImpersonation() + { + if (impersonatedUser == null) + { + return; + } + + try + { + impersonatedUser.Undo(); // Stop impersonating the user. + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Stopping Impersonation failed" + Constants.vbNewLine + ex.Message, true); + throw; + } + finally + { + + if (!System.IntPtr.op_Equality(tokenHandle, IntPtr.Zero)) + { + CloseHandle(tokenHandle); + } + + impersonatedUser = null; + } + } + } } diff --git a/mRemoteV1/CS/Tools/ExternalTool.cs b/mRemoteV1/CS/Tools/ExternalTool.cs index 524ce7b10..6a7dd0ea2 100644 --- a/mRemoteV1/CS/Tools/ExternalTool.cs +++ b/mRemoteV1/CS/Tools/ExternalTool.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,9 +8,7 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.IO; using System.ComponentModel; @@ -20,7 +17,7 @@ namespace mRemoteNG.Tools { public class ExternalTool { -#region Public Properties + #region Public Properties public string DisplayName {get; set;} public string FileName {get; set;} public bool WaitForExit {get; set;} @@ -57,18 +54,18 @@ namespace mRemoteNG.Tools } } } -#endregion + #endregion -#region Constructors + #region Constructors public ExternalTool(string displayName = "", string fileName = "", string arguments = "") { this.DisplayName = displayName; this.FileName = fileName; this.Arguments = arguments; } -#endregion + #endregion -#region Public Methods + #region Public Methods // Start external app public void Start(Connection.Info startConnectionInfo = null) { @@ -101,7 +98,7 @@ namespace mRemoteNG.Tools } catch (Exception ex) { - MessageCollector.AddExceptionMessage("ExternalApp.Start() failed.", ex); + Runtime.MessageCollector.AddExceptionMessage("ExternalApp.Start() failed.", ex); } } @@ -129,7 +126,7 @@ namespace mRemoteNG.Tools } catch (Exception ex) { - MessageCollector.AddExceptionMessage(message: "ExternalApp.StartIntegrated() failed.", ex: ex, logOnly: true); + Runtime.MessageCollector.AddExceptionMessage(message: "ExternalApp.StartIntegrated() failed.", ex: ex, logOnly: true); } } @@ -319,9 +316,9 @@ namespace mRemoteNG.Tools return result; } -#endregion + #endregion -#region Private Methods + #region Private Methods private string GetVariableReplacement(string variable, string original) { string replacement = ""; @@ -424,43 +421,43 @@ namespace mRemoteNG.Tools } return replacement; } -#endregion + #endregion } public class ExternalToolsTypeConverter : StringConverter + { + + public static string[] ExternalTools { - - public static string[] ExternalTools + get { - get + List externalToolList = new List(); + + // Add a blank entry to signify that no external tool is selected + externalToolList.Add(string.Empty); + + foreach (ExternalTool externalTool in App.Runtime.ExternalTools) { - List externalToolList = new List(); - - // Add a blank entry to signify that no external tool is selected - externalToolList.Add(string.Empty); - - foreach (ExternalTool externalTool in App.Runtime.ExternalTools) - { - externalToolList.Add(externalTool.DisplayName); - } - - return externalToolList.ToArray(); + externalToolList.Add(externalTool.DisplayName); } - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - return new StandardValuesCollection(ExternalTools); - } - - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) - { - return true; + + return externalToolList.ToArray(); } } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) + { + return new StandardValuesCollection(ExternalTools); + } + + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) + { + return true; + } + + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + } } diff --git a/mRemoteV1/CS/Tools/IeBrowserEmulation.cs b/mRemoteV1/CS/Tools/IeBrowserEmulation.cs index 29dcb8b5e..63e28fe41 100644 --- a/mRemoteV1/CS/Tools/IeBrowserEmulation.cs +++ b/mRemoteV1/CS/Tools/IeBrowserEmulation.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,68 +8,66 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.IO; using Microsoft.Win32; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Tools { public class IeBrowserEmulation + { + private const string BrowserEmulationKey = "Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION"; + private static int _previousIeBrowserEmulationValue = 0; + public static void Register() { - private const string BrowserEmulationKey = "Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION"; - private static int _previousIeBrowserEmulationValue = 0; - public static void Register() + try { - try + RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); + if (registryKey == null) { - RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); - if (registryKey == null) - { - Registry.CurrentUser.CreateSubKey(BrowserEmulationKey); - registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); - if (registryKey == null) - { - return ; - } - } - string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); - _previousIeBrowserEmulationValue = System.Convert.ToInt32(registryKey.GetValue(exeName, 0)); - registryKey.SetValue(exeName, 11000, RegistryValueKind.DWord); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "IeBrowserEmulation.Register() failed.", ex: ex, logOnly: true); - } - } - - public static void Unregister() - { -#if PORTABLE - try - { - RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); + Registry.CurrentUser.CreateSubKey(BrowserEmulationKey); + registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); if (registryKey == null) { return ; } - string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); - if (_previousIeBrowserEmulationValue == 0) - { - registryKey.DeleteValue(exeName); - } - else - { - registryKey.SetValue(exeName, _previousIeBrowserEmulationValue, RegistryValueKind.DWord); - } } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "IeBrowserEmulation.Unregister() failed.", ex: ex, logOnly: true); - } -#endif + string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); + _previousIeBrowserEmulationValue = System.Convert.ToInt32(registryKey.GetValue(exeName, 0)); + registryKey.SetValue(exeName, 11000, RegistryValueKind.DWord); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "IeBrowserEmulation.Register() failed.", ex: ex, logOnly: true); } } + + public static void Unregister() + { + #if PORTABLE + try + { + RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); + if (registryKey == null) + { + return ; + } + string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); + if (_previousIeBrowserEmulationValue == 0) + { + registryKey.DeleteValue(exeName); + } + else + { + registryKey.SetValue(exeName, _previousIeBrowserEmulationValue, RegistryValueKind.DWord); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "IeBrowserEmulation.Unregister() failed.", ex: ex, logOnly: true); + } + #endif + } + } } diff --git a/mRemoteV1/CS/Tools/Tools.Controls.cs b/mRemoteV1/CS/Tools/Tools.Controls.cs index 481f99917..6ee791ade 100644 --- a/mRemoteV1/CS/Tools/Tools.Controls.cs +++ b/mRemoteV1/CS/Tools/Tools.Controls.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,306 +8,304 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.Tools { public class Controls + { + public class ComboBoxItem { - public class ComboBoxItem + private string _Text; + public string Text { - private string _Text; -public string Text - { - get - { - return this._Text; - } - set - { - this._Text = value; - } - } - - private object _Tag; -public object Tag - { - get - { - return this._Tag; - } - set - { - this._Tag = value; - } - } - - public ComboBoxItem(string Text, object Tag = null) - { - this._Text = Text; - if (Tag != null) - { - this._Tag = Tag; - } - } - - public override string ToString() + get { return this._Text; } + set + { + this._Text = value; + } } - - - public class NotificationAreaIcon + + private object _Tag; + public object Tag { - private NotifyIcon _nI; - - private ContextMenuStrip _cMen; - private ToolStripMenuItem _cMenCons; - private ToolStripSeparator _cMenSep1; - private ToolStripMenuItem _cMenExit; - - private bool _Disposed; -public bool Disposed + get { - get + return this._Tag; + } + set + { + this._Tag = value; + } + } + + public ComboBoxItem(string Text, object Tag = null) + { + this._Text = Text; + if (Tag != null) + { + this._Tag = Tag; + } + } + + public override string ToString() + { + return this._Text; + } + } + + + public class NotificationAreaIcon + { + private NotifyIcon _nI; + + private ContextMenuStrip _cMen; + private ToolStripMenuItem _cMenCons; + private ToolStripSeparator _cMenSep1; + private ToolStripMenuItem _cMenExit; + + private bool _Disposed; + public bool Disposed + { + get + { + return _Disposed; + } + set + { + _Disposed = value; + } + } + + + //Public Event MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) + //Public Event MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) + + + public NotificationAreaIcon() + { + try + { + this._cMenCons = new ToolStripMenuItem(); + this._cMenCons.Text = My.Language.strConnections; + this._cMenCons.Image = global::My.Resources.Root; + + this._cMenSep1 = new ToolStripSeparator(); + + this._cMenExit = new ToolStripMenuItem(); + this._cMenExit.Text = My.Language.strMenuExit; + this._cMenExit.Click += cMenExit_Click; + + this._cMen = new ContextMenuStrip(); + this._cMen.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this._cMen.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this._cMen.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this._cMenCons, this._cMenSep1, this._cMenExit}); + + this._nI = new NotifyIcon(); + this._nI.Text = "mRemote"; + this._nI.BalloonTipText = "mRemote"; + this._nI.Icon = global::My.Resources.mRemote_Icon; + this._nI.ContextMenuStrip = this._cMen; + this._nI.Visible = true; + + this._nI.MouseClick += nI_MouseClick; + this._nI.MouseDoubleClick += nI_MouseDoubleClick; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Creating new SysTrayIcon failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void Dispose() + { + try + { + this._nI.Visible = false; + this._nI.Dispose(); + this._cMen.Dispose(); + this._Disposed = true; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Disposing SysTrayIcon failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void nI_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + this._cMenCons.DropDownItems.Clear(); + + foreach (TreeNode tNode in App.Runtime.Windows.treeForm.tvConnections.Nodes) { - return _Disposed; - } - set - { - _Disposed = value; + AddNodeToMenu(tNode.Nodes, this._cMenCons); } } + } - - //Public Event MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) - //Public Event MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) - - - public NotificationAreaIcon() + private void AddNodeToMenu(TreeNodeCollection tnc, ToolStripMenuItem menToolStrip) + { + try { - try + foreach (TreeNode tNode in tnc) { - this._cMenCons = new ToolStripMenuItem(); - this._cMenCons.Text = My.Language.strConnections; - this._cMenCons.Image = global::My.Resources.Root; - - this._cMenSep1 = new ToolStripSeparator(); - - this._cMenExit = new ToolStripMenuItem(); - this._cMenExit.Text = My.Language.strMenuExit; - this._cMenExit.Click += cMenExit_Click; - - this._cMen = new ContextMenuStrip(); - this._cMen.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this._cMen.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this._cMen.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this._cMenCons, this._cMenSep1, this._cMenExit}); - - this._nI = new NotifyIcon(); - this._nI.Text = "mRemote"; - this._nI.BalloonTipText = "mRemote"; - this._nI.Icon = global::My.Resources.mRemote_Icon; - this._nI.ContextMenuStrip = this._cMen; - this._nI.Visible = true; - - this._nI.MouseClick += nI_MouseClick; - this._nI.MouseDoubleClick += nI_MouseDoubleClick; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Creating new SysTrayIcon failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public void Dispose() - { - try - { - this._nI.Visible = false; - this._nI.Dispose(); - this._cMen.Dispose(); - this._Disposed = true; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Disposing SysTrayIcon failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void nI_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - this._cMenCons.DropDownItems.Clear(); - - foreach (TreeNode tNode in App.Runtime.Windows.treeForm.tvConnections.Nodes) - { - AddNodeToMenu(tNode.Nodes, this._cMenCons); - } - } - } - - private void AddNodeToMenu(TreeNodeCollection tnc, ToolStripMenuItem menToolStrip) - { - try - { - foreach (TreeNode tNode in tnc) - { - ToolStripMenuItem tMenItem = new ToolStripMenuItem(); - tMenItem.Text = tNode.Text; - tMenItem.Tag = tNode; + ToolStripMenuItem tMenItem = new ToolStripMenuItem(); + tMenItem.Text = tNode.Text; + tMenItem.Tag = tNode; - if (Tree.Node.GetNodeType(tNode) == Tree.Node.Type.Container) - { - tMenItem.Image = global::My.Resources.Folder; - tMenItem.Tag = tNode.Tag; - - menToolStrip.DropDownItems.Add(tMenItem); - AddNodeToMenu(tNode.Nodes, tMenItem); - } - else if (Tree.Node.GetNodeType(tNode) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(tNode) == Tree.Node.Type.PuttySession) - { - tMenItem.Image = Windows.treeForm.imgListTree.Images[tNode.ImageIndex]; - tMenItem.Tag = tNode.Tag; - - menToolStrip.DropDownItems.Add(tMenItem); - } - - tMenItem.MouseUp += ConMenItem_MouseUp; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddNodeToMenu failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void nI_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) - { - if (frmMain.Default.Visible == true) - { - HideForm(); - } - else - { - ShowForm(); - } - } - - private void ShowForm() - { - frmMain.Default.Show(); - frmMain.Default.WindowState = frmMain.Default.PreviousWindowState; - - if (My.Settings.Default.ShowSystemTrayIcon == false) - { - App.Runtime.NotificationAreaIcon.Dispose(); - App.Runtime.NotificationAreaIcon = null; - } - } - - private void HideForm() - { - frmMain.Default.Hide(); - frmMain.Default.PreviousWindowState = frmMain.Default.WindowState; - } - - private void ConMenItem_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (sender.Tag is Connection.Info) + if (Tree.Node.GetNodeType(tNode) == Tree.Node.Type.Container) { - if (frmMain.Default.Visible == false) - { - ShowForm(); - } - App.Runtime.OpenConnection(sender.Tag); + tMenItem.Image = global::My.Resources.Folder; + tMenItem.Tag = tNode.Tag; + + menToolStrip.DropDownItems.Add(tMenItem); + AddNodeToMenu(tNode.Nodes, tMenItem); } + else if (Tree.Node.GetNodeType(tNode) == Tree.Node.Type.Connection | Tree.Node.GetNodeType(tNode) == Tree.Node.Type.PuttySession) + { + tMenItem.Image = Windows.treeForm.imgListTree.Images[tNode.ImageIndex]; + tMenItem.Tag = tNode.Tag; + + menToolStrip.DropDownItems.Add(tMenItem); + } + + tMenItem.MouseUp += ConMenItem_MouseUp; } } - - private void cMenExit_Click(System.Object sender, System.EventArgs e) + catch (Exception ex) { - App.Runtime.Shutdown.Quit(); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddNodeToMenu failed" + Constants.vbNewLine + ex.Message, true); } } - - public static SaveFileDialog ConnectionsSaveAsDialog() + + private void nI_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) { - SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.CheckPathExists = true; - saveFileDialog.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; - saveFileDialog.FileName = App.Info.Connections.DefaultConnectionsFile; - saveFileDialog.OverwritePrompt = true; - - saveFileDialog.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFilterAll + "|*.*"; - - return saveFileDialog; - } - - public static SaveFileDialog ConnectionsExportDialog() - { - SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.CheckPathExists = true; - saveFileDialog.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; - saveFileDialog.FileName = App.Info.Connections.DefaultConnectionsFile; - saveFileDialog.OverwritePrompt = true; - - saveFileDialog.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFiltermRemoteCSV + "|*.csv|" + My.Language.strFiltervRD2008CSV + "|*.csv|" + My.Language.strFilterAll + "|*.*"; - - return saveFileDialog; - } - - public static OpenFileDialog ConnectionsLoadDialog() - { - OpenFileDialog lDlg = new OpenFileDialog(); - lDlg.CheckFileExists = true; - lDlg.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; - lDlg.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFilterAll + "|*.*"; - - return lDlg; - } - - public static OpenFileDialog ImportConnectionsRdpFileDialog() - { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.CheckFileExists = true; - openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); - openFileDialog.Filter = string.Join("|", new[] {My.Language.strFilterRDP, "*.rdp", My.Language.strFilterAll, "*.*"}); - openFileDialog.Multiselect = true; - return openFileDialog; - } - - public class TreeNodeSorter : IComparer - { - - public System.Windows.Forms.SortOrder Sorting {get; set;} - - public TreeNodeSorter(SortOrder sortOrder = System.Windows.Forms.SortOrder.None) + if (frmMain.Default.Visible == true) { - Sorting = sortOrder; + HideForm(); } - - public int Compare(object x, object y) + else { - TreeNode tx = (TreeNode) x; - TreeNode ty = (TreeNode) y; + ShowForm(); + } + } + + private void ShowForm() + { + frmMain.Default.Show(); + frmMain.Default.WindowState = frmMain.Default.PreviousWindowState; - switch (Sorting) + if (My.Settings.Default.ShowSystemTrayIcon == false) + { + App.Runtime.NotificationAreaIcon.Dispose(); + App.Runtime.NotificationAreaIcon = null; + } + } + + private void HideForm() + { + frmMain.Default.Hide(); + frmMain.Default.PreviousWindowState = frmMain.Default.WindowState; + } + + private void ConMenItem_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (sender.Tag is Connection.Info) { - case SortOrder.Ascending: - return string.Compare(tx.Text, ty.Text); - case SortOrder.Descending: - return string.Compare(ty.Text, tx.Text); - default: - return 0; + if (frmMain.Default.Visible == false) + { + ShowForm(); + } + App.Runtime.OpenConnection(sender.Tag); } } } + + private void cMenExit_Click(System.Object sender, System.EventArgs e) + { + App.Runtime.Shutdown.Quit(); + } + } + + public static SaveFileDialog ConnectionsSaveAsDialog() + { + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.CheckPathExists = true; + saveFileDialog.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; + saveFileDialog.FileName = App.Info.Connections.DefaultConnectionsFile; + saveFileDialog.OverwritePrompt = true; + + saveFileDialog.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFilterAll + "|*.*"; + + return saveFileDialog; + } + + public static SaveFileDialog ConnectionsExportDialog() + { + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.CheckPathExists = true; + saveFileDialog.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; + saveFileDialog.FileName = App.Info.Connections.DefaultConnectionsFile; + saveFileDialog.OverwritePrompt = true; + + saveFileDialog.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFiltermRemoteCSV + "|*.csv|" + My.Language.strFiltervRD2008CSV + "|*.csv|" + My.Language.strFilterAll + "|*.*"; + + return saveFileDialog; + } + + public static OpenFileDialog ConnectionsLoadDialog() + { + OpenFileDialog lDlg = new OpenFileDialog(); + lDlg.CheckFileExists = true; + lDlg.InitialDirectory = App.Info.Connections.DefaultConnectionsPath; + lDlg.Filter = My.Language.strFiltermRemoteXML + "|*.xml|" + My.Language.strFilterAll + "|*.*"; + + return lDlg; + } + + public static OpenFileDialog ImportConnectionsRdpFileDialog() + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.CheckFileExists = true; + openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); + openFileDialog.Filter = string.Join("|", new[] {My.Language.strFilterRDP, "*.rdp", My.Language.strFilterAll, "*.*"}); + openFileDialog.Multiselect = true; + return openFileDialog; + } + + public class TreeNodeSorter : IComparer + { + + public System.Windows.Forms.SortOrder Sorting {get; set;} + + public TreeNodeSorter(SortOrder sortOrder = System.Windows.Forms.SortOrder.None) + { + Sorting = sortOrder; + } + + public int Compare(object x, object y) + { + TreeNode tx = (TreeNode) x; + TreeNode ty = (TreeNode) y; + + switch (Sorting) + { + case SortOrder.Ascending: + return string.Compare(tx.Text, ty.Text); + case SortOrder.Descending: + return string.Compare(ty.Text, tx.Text); + default: + return 0; + } + } } + } } diff --git a/mRemoteV1/CS/Tools/Tools.Misc.cs b/mRemoteV1/CS/Tools/Tools.Misc.cs index 70964244e..53d9d83fa 100644 --- a/mRemoteV1/CS/Tools/Tools.Misc.cs +++ b/mRemoteV1/CS/Tools/Tools.Misc.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,15 +8,13 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Reflection; using System.ComponentModel; using System.Runtime.InteropServices; using System.Collections.Specialized; using System.Text.RegularExpressions; using mRemoteNG.Forms; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.IO; using System.Data.SqlClient; @@ -25,507 +22,507 @@ using System.Data.SqlClient; namespace mRemoteNG.Tools { public class Misc + { + private struct SHFILEINFO { - private struct SHFILEINFO + public IntPtr hIcon; // : icon + public int iIcon; // : icondex + public int dwAttributes; // : SFGAO_ flags + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]public string szDisplayName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]public string szTypeName; + } + + [DllImport("shell32.dll")]private static extern IntPtr SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, int uFlags); + + private const int SHGFI_ICON = 0x100; + private const int SHGFI_SMALLICON = 0x1; + //Private Const SHGFI_LARGEICON = &H0 ' Large icon + + public static Icon GetIconFromFile(string FileName) + { + try { - public IntPtr hIcon; // : icon - public int iIcon; // : icondex - public int dwAttributes; // : SFGAO_ flags - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]public string szDisplayName; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]public string szTypeName; - } - - [DllImport("shell32.dll")]private static extern IntPtr SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, int uFlags); - - private const int SHGFI_ICON = 0x100; - private const int SHGFI_SMALLICON = 0x1; - //Private Const SHGFI_LARGEICON = &H0 ' Large icon - - public static Icon GetIconFromFile(string FileName) - { - try + if (File.Exists(FileName) == false) { - if (File.Exists(FileName) == false) - { - return null; - } - - IntPtr hImgSmall; //The handle to the system image list. - //Dim hImgLarge As IntPtr 'The handle to the system image list. - SHFILEINFO shinfo = new SHFILEINFO(); - shinfo = new SHFILEINFO(); - - shinfo.szDisplayName = new string('\0', 260); - shinfo.szTypeName = new string('\0', 80); - - //Use this to get the small icon. - hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON); - - //Use this to get the large icon. - //hImgLarge = SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON); - - //The icon is returned in the hIcon member of the - //shinfo struct. - System.Drawing.Icon myIcon = default(System.Drawing.Icon); - myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); - - return myIcon; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "GetIconFromFile failed (Tools.Misc)" + Constants.vbNewLine + ex.Message, true); return null; } - } - - public delegate void SQLUpdateCheckFinishedEventHandler(bool UpdateAvailable); - private static SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinishedEvent; - - public static event SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinished - { - add - { - SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler) System.Delegate.Combine(SQLUpdateCheckFinishedEvent, value); - } - remove - { - SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler) System.Delegate.Remove(SQLUpdateCheckFinishedEvent, value); - } - } - - public static void IsSQLUpdateAvailableBG() - { - System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(IsSQLUpdateAvailable)); - t.SetApartmentState(System.Threading.ApartmentState.STA); - t.Start(); - } - - public static bool IsSQLUpdateAvailable() - { - try - { - SqlConnection sqlCon = default(SqlConnection); - SqlCommand sqlQuery = default(SqlCommand); - SqlDataReader sqlRd = default(SqlDataReader); - DateTime LastUpdateInDB = default(DateTime); + IntPtr hImgSmall; //The handle to the system image list. + //Dim hImgLarge As IntPtr 'The handle to the system image list. + SHFILEINFO shinfo = new SHFILEINFO(); + shinfo = new SHFILEINFO(); - if (My.Settings.Default.SQLUser != "") - { - sqlCon = new SqlConnection("Data Source=" + My.Settings.Default.SQLHost + ";Initial Catalog=" + My.Settings.Default.SQLDatabaseName + ";User Id=" + My.Settings.Default.SQLUser + ";Password=" + Security.Crypt.Decrypt(System.Convert.ToString(My.Settings.Default.SQLPass), App.Info.General.EncryptionKey)); - } - else - { - sqlCon = new SqlConnection("Data Source=" + My.Settings.Default.SQLHost + ";Initial Catalog=" + My.Settings.Default.SQLDatabaseName + ";Integrated Security=True"); - } + shinfo.szDisplayName = new string('\0', 260); + shinfo.szTypeName = new string('\0', 80); - sqlCon.Open(); + //Use this to get the small icon. + hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON); - sqlQuery = new SqlCommand("SELECT * FROM tblUpdate", sqlCon); - sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection); + //Use this to get the large icon. + //hImgLarge = SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON); - sqlRd.Read(); + //The icon is returned in the hIcon member of the + //shinfo struct. + System.Drawing.Icon myIcon = default(System.Drawing.Icon); + myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); - if (sqlRd.HasRows) - { - LastUpdateInDB = System.Convert.ToDateTime(sqlRd["LastUpdate"]); - - if (LastUpdateInDB > LastSqlUpdate) - { - if (SQLUpdateCheckFinishedEvent != null) - SQLUpdateCheckFinishedEvent(true); - return true; - } - } - - if (SQLUpdateCheckFinishedEvent != null) - SQLUpdateCheckFinishedEvent(false); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "IsSQLUpdateAvailable failed (Tools.Misc)" + Constants.vbNewLine + ex.Message, true); - } - - return false; + return myIcon; } - - public static string PasswordDialog(string passwordName = null, bool verify = true) + catch (Exception ex) { - PasswordForm passwordForm = new PasswordForm(passwordName, verify); - - if (passwordForm.ShowDialog() == DialogResult.OK) - { - return passwordForm.Password; - } - else - { - return ""; - } - } - - public static string CreateConstantID() - { - return Guid.NewGuid().ToString(); - } - - public static string LeadingZero(string Number) - { - if (Number < 10) - { - return "0" + Number; - } - else - { - return Number; - } - } - - public static string DBDate(DateTime Dt) - { - string strDate = ""; - - strDate = Dt.Year + LeadingZero(System.Convert.ToString(Dt.Month)) + LeadingZero(System.Convert.ToString(Dt.Day)) + " " + LeadingZero(System.Convert.ToString(Dt.Hour)) + ":" + LeadingZero(System.Convert.ToString(Dt.Minute)) + ":" + LeadingZero(System.Convert.ToString(Dt.Second)); - - return strDate; - } - - public static string PrepareForDB(string Text) - { - Text = Strings.Replace(Expression: Text, Find: "\'True\'", Replacement: "1", Compare: CompareMethod.Text); - Text = Strings.Replace(Expression: Text, Find: "\'False\'", Replacement: "0", Compare: CompareMethod.Text); - - return Text; - } - - public static string PrepareValueForDB(string Text) - { - Text = Strings.Replace(Expression: Text, Find: "\'", Replacement: "\'\'", Compare: CompareMethod.Text); - - return Text; - } - - public static object StringToEnum(Type t, string value) - { - return Enum.Parse(t, value); - } - - public static string GetExceptionMessageRecursive(Exception ex, string separator = Constants.vbNewLine) - { - string message = ex.Message; - if (ex.InnerException != null) - { - string innerMessage = GetExceptionMessageRecursive(ex.InnerException, separator); - message = string.Join(separator, new string[] {message, innerMessage}); - } - return message; - } - - public static Image TakeScreenshot(UI.Window.Connection sender) - { - try - { - int LeftStart = sender.TabController.SelectedTab.PointToScreen(new Point(sender.TabController.SelectedTab.Left)).X; //Me.Left + Splitter.SplitterDistance + 11 - int TopStart = sender.TabController.SelectedTab.PointToScreen(new Point(sender.TabController.SelectedTab.Top)).Y; //Me.Top + Splitter.Top + TabController.Top + TabController.SelectedTab.Top * 2 - 3 - int LeftWidth = sender.TabController.SelectedTab.Width; //Me.Width - (Splitter.SplitterDistance + 16) - int TopHeight = sender.TabController.SelectedTab.Height; //Me.Height - (Splitter.Top + TabController.Top + TabController.SelectedTab.Top * 2 + 2) - - Size currentFormSize = new Size(LeftWidth, TopHeight); - Bitmap ScreenToBitmap = new Bitmap(LeftWidth, TopHeight); - System.Drawing.Graphics gGraphics = System.Drawing.Graphics.FromImage(ScreenToBitmap); - - gGraphics.CopyFromScreen(new Point(LeftStart, TopStart), new Point(0, 0), currentFormSize); - - return ScreenToBitmap; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Taking Screenshot failed" + Constants.vbNewLine + ex.Message, true); - } - + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "GetIconFromFile failed (Tools.Misc)" + Constants.vbNewLine + ex.Message, true); return null; } + } - public class EnumTypeConverter : EnumConverter + public delegate void SQLUpdateCheckFinishedEventHandler(bool UpdateAvailable); + private static SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinishedEvent; + + public static event SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinished + { + add { - private System.Type _enumType; - - public EnumTypeConverter(System.Type type) : base(type) - { - _enumType = type; - } - - public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destType) - { - return destType == typeof(string); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destType) - { - FieldInfo fi = _enumType.GetField(Enum.GetName(_enumType, value)); - DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute))); + SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler) System.Delegate.Combine(SQLUpdateCheckFinishedEvent, value); + } + remove + { + SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler) System.Delegate.Remove(SQLUpdateCheckFinishedEvent, value); + } + } + + public static void IsSQLUpdateAvailableBG() + { + System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(IsSQLUpdateAvailable)); + t.SetApartmentState(System.Threading.ApartmentState.STA); + t.Start(); + } + + public static bool IsSQLUpdateAvailable() + { + try + { + SqlConnection sqlCon = default(SqlConnection); + SqlCommand sqlQuery = default(SqlCommand); + SqlDataReader sqlRd = default(SqlDataReader); - if (dna != null) - { - return dna.Description; - } - else - { - return value.ToString(); - } - } - - public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type srcType) + DateTime LastUpdateInDB = default(DateTime); + + if (My.Settings.Default.SQLUser != "") { - return srcType == typeof(string); + sqlCon = new SqlConnection("Data Source=" + My.Settings.Default.SQLHost + ";Initial Catalog=" + My.Settings.Default.SQLDatabaseName + ";User Id=" + My.Settings.Default.SQLUser + ";Password=" + Security.Crypt.Decrypt(System.Convert.ToString(My.Settings.Default.SQLPass), App.Info.General.EncryptionKey)); } - - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + else { - foreach (FieldInfo fi in _enumType.GetFields()) - { - DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute))); + sqlCon = new SqlConnection("Data Source=" + My.Settings.Default.SQLHost + ";Initial Catalog=" + My.Settings.Default.SQLDatabaseName + ";Integrated Security=True"); + } + + sqlCon.Open(); + + sqlQuery = new SqlCommand("SELECT * FROM tblUpdate", sqlCon); + sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection); + + sqlRd.Read(); + + if (sqlRd.HasRows) + { + LastUpdateInDB = System.Convert.ToDateTime(sqlRd["LastUpdate"]); - if ((dna != null) && (((string) value) == dna.Description)) - { - return Enum.Parse(_enumType, fi.Name); - } + if (LastUpdateInDB > LastSqlUpdate) + { + if (SQLUpdateCheckFinishedEvent != null) + SQLUpdateCheckFinishedEvent(true); + return true; } + } - return Enum.Parse(_enumType, (string) value); + if (SQLUpdateCheckFinishedEvent != null) + SQLUpdateCheckFinishedEvent(false); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "IsSQLUpdateAvailable failed (Tools.Misc)" + Constants.vbNewLine + ex.Message, true); + } + + return false; + } + + public static string PasswordDialog(string passwordName = null, bool verify = true) + { + PasswordForm passwordForm = new PasswordForm(passwordName, verify); + + if (passwordForm.ShowDialog() == DialogResult.OK) + { + return passwordForm.Password; + } + else + { + return ""; + } + } + + public static string CreateConstantID() + { + return Guid.NewGuid().ToString(); + } + + public static string LeadingZero(string Number) + { + if (Number < 10) + { + return "0" + Number; + } + else + { + return Number; + } + } + + public static string DBDate(DateTime Dt) + { + string strDate = ""; + + strDate = Dt.Year + LeadingZero(System.Convert.ToString(Dt.Month)) + LeadingZero(System.Convert.ToString(Dt.Day)) + " " + LeadingZero(System.Convert.ToString(Dt.Hour)) + ":" + LeadingZero(System.Convert.ToString(Dt.Minute)) + ":" + LeadingZero(System.Convert.ToString(Dt.Second)); + + return strDate; + } + + public static string PrepareForDB(string Text) + { + Text = Strings.Replace(Expression: Text, Find: "\'True\'", Replacement: "1", Compare: CompareMethod.Text); + Text = Strings.Replace(Expression: Text, Find: "\'False\'", Replacement: "0", Compare: CompareMethod.Text); + + return Text; + } + + public static string PrepareValueForDB(string Text) + { + Text = Strings.Replace(Expression: Text, Find: "\'", Replacement: "\'\'", Compare: CompareMethod.Text); + + return Text; + } + + public static object StringToEnum(Type t, string value) + { + return Enum.Parse(t, value); + } + + public static string GetExceptionMessageRecursive(Exception ex, string separator = Constants.vbNewLine) + { + string message = ex.Message; + if (ex.InnerException != null) + { + string innerMessage = GetExceptionMessageRecursive(ex.InnerException, separator); + message = string.Join(separator, new string[] {message, innerMessage}); + } + return message; + } + + public static Image TakeScreenshot(UI.Window.Connection sender) + { + try + { + int LeftStart = sender.TabController.SelectedTab.PointToScreen(new Point(sender.TabController.SelectedTab.Left)).X; //Me.Left + Splitter.SplitterDistance + 11 + int TopStart = sender.TabController.SelectedTab.PointToScreen(new Point(sender.TabController.SelectedTab.Top)).Y; //Me.Top + Splitter.Top + TabController.Top + TabController.SelectedTab.Top * 2 - 3 + int LeftWidth = sender.TabController.SelectedTab.Width; //Me.Width - (Splitter.SplitterDistance + 16) + int TopHeight = sender.TabController.SelectedTab.Height; //Me.Height - (Splitter.Top + TabController.Top + TabController.SelectedTab.Top * 2 + 2) + + Size currentFormSize = new Size(LeftWidth, TopHeight); + Bitmap ScreenToBitmap = new Bitmap(LeftWidth, TopHeight); + System.Drawing.Graphics gGraphics = System.Drawing.Graphics.FromImage(ScreenToBitmap); + + gGraphics.CopyFromScreen(new Point(LeftStart, TopStart), new Point(0, 0), currentFormSize); + + return ScreenToBitmap; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Taking Screenshot failed" + Constants.vbNewLine + ex.Message, true); + } + + return null; + } + + public class EnumTypeConverter : EnumConverter + { + private System.Type _enumType; + + public EnumTypeConverter(System.Type type) : base(type) + { + _enumType = type; + } + + public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destType) + { + return destType == typeof(string); + } + + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destType) + { + FieldInfo fi = _enumType.GetField(Enum.GetName(_enumType, value)); + DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute))); + + if (dna != null) + { + return dna.Description; + } + else + { + return value.ToString(); } } - - public class YesNoTypeConverter : TypeConverter + + public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type srcType) { + return srcType == typeof(string); + } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + foreach (FieldInfo fi in _enumType.GetFields()) { - if (sourceType == typeof(string)) - { - return true; - } - - return base.CanConvertFrom(context, sourceType); - } - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(string)) - { - return true; - } - - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) - { - if (value.GetType() == typeof(string)) - { - if ((value).ToString().ToLower() == My.Language.strYes.ToLower()) - { - return true; - } + DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute))); - if ((value).ToString().ToLower() == My.Language.strNo.ToLower()) - { - return false; - } - - throw (new Exception("Values must be \"Yes\" or \"No\"")); - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) - { - if (destinationType == typeof(string)) + if ((dna != null) && (((string) value) == dna.Description)) { - return ((System.Convert.ToBoolean(value)) ? My.Language.strYes : My.Language.strNo); + return Enum.Parse(_enumType, fi.Name); } - - return base.ConvertTo(context, culture, value, destinationType); } + + return Enum.Parse(_enumType, (string) value); + } + } + + public class YesNoTypeConverter : TypeConverter + { - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) { return true; } + + return base.CanConvertFrom(context, sourceType); + } - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + if (destinationType == typeof(string)) { - bool[] bools = new bool[] {true, false}; + return true; + } - System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools); + return base.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + if (value.GetType() == typeof(string)) + { + if ((value).ToString().ToLower() == My.Language.strYes.ToLower()) + { + return true; + } + + if ((value).ToString().ToLower() == My.Language.strNo.ToLower()) + { + return false; + } + + throw (new Exception("Values must be \"Yes\" or \"No\"")); + } - return svc; + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string)) + { + return ((System.Convert.ToBoolean(value)) ? My.Language.strYes : My.Language.strNo); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + { + bool[] bools = new bool[] {true, false}; + + System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools); + + return svc; + } + } + + public class Fullscreen + { + public Fullscreen(Form handledForm) + { + _handledForm = handledForm; + } + + private Form _handledForm; + private FormWindowState _savedWindowState; + private FormBorderStyle _savedBorderStyle; + private Rectangle _savedBounds; + + private bool _value = false; + public bool Value + { + get + { + return _value; + } + set + { + if (_value == value) + { + return ; + } + if (!_value) + { + EnterFullscreen(); + } + else + { + ExitFullscreen(); + } + _value = value; } } - - public class Fullscreen + + private void EnterFullscreen() { - public Fullscreen(Form handledForm) - { - _handledForm = handledForm; - } - - private Form _handledForm; - private FormWindowState _savedWindowState; - private FormBorderStyle _savedBorderStyle; - private Rectangle _savedBounds; - - private bool _value = false; -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; + _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 = FormBorderStyle.None; + if (_handledForm.WindowState == FormWindowState.Maximized) { - _handledForm.FormBorderStyle = _savedBorderStyle; - _handledForm.WindowState = _savedWindowState; - _handledForm.Bounds = _savedBounds; + _handledForm.WindowState = FormWindowState.Normal; + } + _handledForm.WindowState = FormWindowState.Maximized; + } + + private void ExitFullscreen() + { + _handledForm.FormBorderStyle = _savedBorderStyle; + _handledForm.WindowState = _savedWindowState; + _handledForm.Bounds = _savedBounds; + } + } + + + // + //* Arguments class: application arguments interpreter + //* + //* Authors: R. LOPES + //* Contributors: R. LOPES + //* Created: 25 October 2002 + //* Modified: 28 October 2002 + //* + //* Version: 1.0 + // + public class CMDArguments + { + private StringDictionary Parameters; + + // Retrieve a parameter value if it exists + public string this[string Param] + { + get + { + return (Parameters[Param]); } } - - - // - //* Arguments class: application arguments interpreter - //* - //* Authors: R. LOPES - //* Contributors: R. LOPES - //* Created: 25 October 2002 - //* Modified: 28 October 2002 - //* - //* Version: 1.0 - // - public class CMDArguments + + public CMDArguments(string[] Args) { - private StringDictionary Parameters; - - // Retrieve a parameter value if it exists -public string this[string Param] - { - get - { - return (Parameters[Param]); - } - } - - public CMDArguments(string[] Args) - { - Parameters = new StringDictionary(); - Regex Spliter = new Regex("^-{1,2}|^/|=|:", (System.Text.RegularExpressions.RegexOptions) (RegexOptions.IgnoreCase | RegexOptions.Compiled)); - Regex Remover = new Regex("^[\'\"]?(.*?)[\'\"]?$", (System.Text.RegularExpressions.RegexOptions) (RegexOptions.IgnoreCase | RegexOptions.Compiled)); - string Parameter = null; - string[] Parts = null; + Parameters = new StringDictionary(); + Regex Spliter = new Regex("^-{1,2}|^/|=|:", (System.Text.RegularExpressions.RegexOptions) (RegexOptions.IgnoreCase | RegexOptions.Compiled)); + Regex Remover = new Regex("^[\'\"]?(.*?)[\'\"]?$", (System.Text.RegularExpressions.RegexOptions) (RegexOptions.IgnoreCase | RegexOptions.Compiled)); + string Parameter = null; + string[] Parts = null; - // Valid parameters forms: - // {-,/,--}param{ ,=,:}((",')value(",')) - // Examples: -param1 value1 --param2 /param3:"Test-:-work" /param4=happy -param5 '--=nice=--' + // Valid parameters forms: + // {-,/,--}param{ ,=,:}((",')value(",')) + // Examples: -param1 value1 --param2 /param3:"Test-:-work" /param4=happy -param5 '--=nice=--' - try + try + { + foreach (string Txt in Args) { - foreach (string Txt in Args) + // Look for new parameters (-,/ or --) and a possible enclosed value (=,:) + Parts = Spliter.Split(Txt, 3); + switch (Parts.Length) { - // Look for new parameters (-,/ or --) and a possible enclosed value (=,:) - Parts = Spliter.Split(Txt, 3); - switch (Parts.Length) - { - case 1: - // Found a value (for the last parameter found (space separator)) - if (Parameter != null) - { - if (!Parameters.ContainsKey(Parameter)) - { - Parts[0] = Remover.Replace(Parts[0], "$1"); - Parameters.Add(Parameter, Parts[0]); - } - Parameter = null; - } - // else Error: no parameter waiting for a value (skipped) - break; - case 2: - // Found just a parameter - // The last parameter is still waiting. With no value, set it to true. - if (Parameter != null) - { - if (!Parameters.ContainsKey(Parameter)) - { - Parameters.Add(Parameter, "true"); - } - } - Parameter = Parts[1]; - break; - case 3: - // Parameter with enclosed value - // The last parameter is still waiting. With no value, set it to true. - if (Parameter != null) - { - if (!Parameters.ContainsKey(Parameter)) - { - Parameters.Add(Parameter, "true"); - } - } - Parameter = Parts[1]; - // Remove possible enclosing characters (",') + case 1: + // Found a value (for the last parameter found (space separator)) + if (Parameter != null) + { if (!Parameters.ContainsKey(Parameter)) { - Parts[2] = Remover.Replace(Parts[2], "$1"); - Parameters.Add(Parameter, Parts[2]); + Parts[0] = Remover.Replace(Parts[0], "$1"); + Parameters.Add(Parameter, Parts[0]); } Parameter = null; - break; - } - } - // In case a parameter is still waiting - if (Parameter != null) - { - if (!Parameters.ContainsKey(Parameter)) - { - Parameters.Add(Parameter, "true"); - } + } + // else Error: no parameter waiting for a value (skipped) + break; + case 2: + // Found just a parameter + // The last parameter is still waiting. With no value, set it to true. + if (Parameter != null) + { + if (!Parameters.ContainsKey(Parameter)) + { + Parameters.Add(Parameter, "true"); + } + } + Parameter = Parts[1]; + break; + case 3: + // Parameter with enclosed value + // The last parameter is still waiting. With no value, set it to true. + if (Parameter != null) + { + if (!Parameters.ContainsKey(Parameter)) + { + Parameters.Add(Parameter, "true"); + } + } + Parameter = Parts[1]; + // Remove possible enclosing characters (",') + if (!Parameters.ContainsKey(Parameter)) + { + Parts[2] = Remover.Replace(Parts[2], "$1"); + Parameters.Add(Parameter, Parts[2]); + } + Parameter = null; + break; } } - catch (Exception ex) + // In case a parameter is still waiting + if (Parameter != null) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Creating new Args failed" + Constants.vbNewLine + ex.Message, true); + if (!Parameters.ContainsKey(Parameter)) + { + Parameters.Add(Parameter, "true"); + } } } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Creating new Args failed" + Constants.vbNewLine + ex.Message, true); + } } } + } } diff --git a/mRemoteV1/CS/Tools/Tools.PortScan.cs b/mRemoteV1/CS/Tools/Tools.PortScan.cs index 03b7135f7..7191c9629 100644 --- a/mRemoteV1/CS/Tools/Tools.PortScan.cs +++ b/mRemoteV1/CS/Tools/Tools.PortScan.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,10 +8,8 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Threading; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Net.NetworkInformation; using System.Net; @@ -21,9 +18,9 @@ namespace mRemoteNG.Tools.PortScan { public class ScanHost { -#region Properties + #region Properties private static int _SSHPort = Connection.Protocol.SSH1.Defaults.Port; -public static int SSHPort + public static int SSHPort { get { @@ -36,7 +33,7 @@ public static int SSHPort } private static int _TelnetPort = Connection.Protocol.Telnet.Defaults.Port; -public static int TelnetPort + public static int TelnetPort { get { @@ -49,7 +46,7 @@ public static int TelnetPort } private static int _HTTPPort = Connection.Protocol.HTTP.Defaults.Port; -public static int HTTPPort + public static int HTTPPort { get { @@ -62,7 +59,7 @@ public static int HTTPPort } private static int _HTTPSPort = Connection.Protocol.HTTPS.Defaults.Port; -public static int HTTPSPort + public static int HTTPSPort { get { @@ -75,7 +72,7 @@ public static int HTTPSPort } private static int _RloginPort = Connection.Protocol.Rlogin.Defaults.Port; -public static int RloginPort + public static int RloginPort { get { @@ -88,7 +85,7 @@ public static int RloginPort } private static int _RDPPort = Connection.Protocol.RDP.Defaults.Port; -public static int RDPPort + public static int RDPPort { get { @@ -101,7 +98,7 @@ public static int RDPPort } private static int _VNCPort = Connection.Protocol.VNC.Defaults.Port; -public static int VNCPort + public static int VNCPort { get { @@ -114,7 +111,7 @@ public static int VNCPort } private string _hostName = ""; -public string HostName + public string HostName { get { @@ -126,7 +123,7 @@ public string HostName } } -public string HostNameWithoutDomain + public string HostNameWithoutDomain { get { @@ -139,7 +136,7 @@ public string HostNameWithoutDomain } private string _hostIp; -public string HostIp + public string HostIp { get { @@ -152,7 +149,7 @@ public string HostIp } private ArrayList _openPorts = new ArrayList(); -public ArrayList OpenPorts + public ArrayList OpenPorts { get { @@ -165,7 +162,7 @@ public ArrayList OpenPorts } private ArrayList _closedPorts; -public ArrayList ClosedPorts + public ArrayList ClosedPorts { get { @@ -178,7 +175,7 @@ public ArrayList ClosedPorts } private bool _RDP; -public bool RDP + public bool RDP { get { @@ -191,7 +188,7 @@ public bool RDP } private bool _VNC; -public bool VNC + public bool VNC { get { @@ -204,7 +201,7 @@ public bool VNC } private bool _SSH; -public bool SSH + public bool SSH { get { @@ -217,7 +214,7 @@ public bool SSH } private bool _Telnet; -public bool Telnet + public bool Telnet { get { @@ -230,7 +227,7 @@ public bool Telnet } private bool _Rlogin; -public bool Rlogin + public bool Rlogin { get { @@ -243,7 +240,7 @@ public bool Rlogin } private bool _HTTP; -public bool HTTP + public bool HTTP { get { @@ -256,7 +253,7 @@ public bool HTTP } private bool _HTTPS; -public bool HTTPS + public bool HTTPS { get { @@ -267,9 +264,9 @@ public bool HTTPS _HTTPS = value; } } -#endregion + #endregion -#region Methods + #region Methods public ScanHost(string host) { _hostIp = host; @@ -285,7 +282,7 @@ public bool HTTPS } catch (Exception) { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "ToString failed (Tools.PortScan)", true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "ToString failed (Tools.PortScan)", true); return ""; } } @@ -338,7 +335,7 @@ public bool HTTPS } catch (Exception ex) { - MessageCollector.AddExceptionMessage("Tools.PortScan.ToListViewItem() failed.", ex, Messages.MessageClass.WarningMsg, true); + Runtime.MessageCollector.AddExceptionMessage("Tools.PortScan.ToListViewItem() failed.", ex, Messages.MessageClass.WarningMsg, true); return null; } } @@ -365,323 +362,322 @@ public bool HTTPS _HTTPS = value; _HTTP = value; } -#endregion + #endregion } public class Scanner + { + #region Private Members + private List _ipAddresses = new List(); + private List _ports = new List(); + + private Thread _scanThread; + private List _scannedHosts = new List(); + #endregion + + #region Public Methods + public Scanner(IPAddress ipAddress1, IPAddress ipAddress2) + { + IPAddress ipAddressStart = IpAddressMin(ipAddress1, ipAddress2); + IPAddress ipAddressEnd = IpAddressMax(ipAddress1, ipAddress2); + + _ports.Clear(); + _ports.AddRange(new int[] {scanHost.SSHPort, scanHost.TelnetPort, scanHost.HTTPPort, scanHost.HTTPSPort, scanHost.RloginPort, scanHost.RDPPort, scanHost.VNCPort}); + + _ipAddresses.Clear(); + _ipAddresses.AddRange(IpAddressArrayFromRange(ipAddressStart, ipAddressEnd)); + + _scannedHosts.Clear(); + } + + public Scanner(IPAddress ipAddress1, IPAddress ipAddress2, int port1, int port2) : this(ipAddress1, ipAddress2) + { + + int portStart = Math.Min(port1, port2); + int portEnd = Math.Max(port1, port2); + + _ports.Clear(); + for (int port = portStart; port <= portEnd; port++) { -#region Private Members - private List _ipAddresses = new List(); - private List _ports = new List(); + _ports.Add(port); + } + } - private Thread _scanThread; - private List _scannedHosts = new List(); -#endregion + public void StartScan() + { + _scanThread = new Thread(new System.Threading.ThreadStart(ScanAsync)); + _scanThread.SetApartmentState(ApartmentState.STA); + _scanThread.IsBackground = true; + _scanThread.Start(); + } -#region Public Methods - public Scanner(IPAddress ipAddress1, IPAddress ipAddress2) - { - IPAddress ipAddressStart = IpAddressMin(ipAddress1, ipAddress2); - IPAddress ipAddressEnd = IpAddressMax(ipAddress1, ipAddress2); - - _ports.Clear(); - _ports.AddRange(new int[] {scanHost.SSHPort, scanHost.TelnetPort, scanHost.HTTPPort, scanHost.HTTPSPort, scanHost.RloginPort, scanHost.RDPPort, scanHost.VNCPort}); - - _ipAddresses.Clear(); - _ipAddresses.AddRange(IpAddressArrayFromRange(ipAddressStart, ipAddressEnd)); - - _scannedHosts.Clear(); - } + public void StopScan() + { + _scanThread.Abort(); + } - public Scanner(IPAddress ipAddress1, IPAddress ipAddress2, int port1, int port2) : this(ipAddress1, ipAddress2) - { - - int portStart = Math.Min(port1, port2); - int portEnd = Math.Max(port1, port2); - - _ports.Clear(); - for (int port = portStart; port <= portEnd; port++) - { - _ports.Add(port); - } - } + public static bool IsPortOpen(string hostname, string port) + { + try + { + // ReSharper disable UnusedVariable + System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(hostname, (int) port); + // ReSharper restore UnusedVariable + return true; + } + catch (Exception) + { + return false; + } + } + #endregion - public void StartScan() - { - _scanThread = new Thread(new System.Threading.ThreadStart(ScanAsync)); - _scanThread.SetApartmentState(ApartmentState.STA); - _scanThread.IsBackground = true; - _scanThread.Start(); - } - - public void StopScan() - { - _scanThread.Abort(); - } - - public static bool IsPortOpen(string hostname, string port) - { - try - { - // ReSharper disable UnusedVariable - System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(hostname, (int) port); - // ReSharper restore UnusedVariable - return true; - } - catch (Exception) - { - return false; - } - } -#endregion - -#region Private Methods - private void ScanAsync() - { - try - { - int hostCount = 0; + #region Private Methods + private void ScanAsync() + { + try + { + int hostCount = 0; - foreach (IPAddress ipAddress in _ipAddresses) + foreach (IPAddress ipAddress in _ipAddresses) + { + if (BeginHostScanEvent != null) + BeginHostScanEvent(ipAddress.ToString()); + + ScanHost scanHost = new ScanHost(ipAddress.ToString()); + hostCount++; + + if (!IsHostAlive(ipAddress)) + { + scanHost.ClosedPorts.AddRange(_ports); + scanHost.SetAllProtocols(false); + } + else + { + foreach (int port in _ports) { - if (BeginHostScanEvent != null) - BeginHostScanEvent(ipAddress.ToString()); - - ScanHost scanHost = new ScanHost(ipAddress.ToString()); - hostCount++; - - if (!IsHostAlive(ipAddress)) - { - scanHost.ClosedPorts.AddRange(_ports); - scanHost.SetAllProtocols(false); - } - else - { - foreach (int port in _ports) - { - bool isPortOpen = false; + bool isPortOpen = false; - try - { - // ReSharper disable UnusedVariable - System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(ipAddress.ToString(), port); - // ReSharper restore UnusedVariable - - isPortOpen = true; - scanHost.OpenPorts.Add(port); - } - catch (Exception) - { - isPortOpen = false; - scanHost.ClosedPorts.Add(port); - } - - if (port == scanHost.SSHPort) - { - scanHost.SSH = isPortOpen; - } - else if (port == scanHost.TelnetPort) - { - scanHost.Telnet = isPortOpen; - } - else if (port == scanHost.HTTPPort) - { - scanHost.HTTP = isPortOpen; - } - else if (port == scanHost.HTTPSPort) - { - scanHost.HTTPS = isPortOpen; - } - else if (port == scanHost.RloginPort) - { - scanHost.Rlogin = isPortOpen; - } - else if (port == scanHost.RDPPort) - { - scanHost.RDP = isPortOpen; - } - else if (port == scanHost.VNCPort) - { - scanHost.VNC = isPortOpen; - } - } - } - try { - scanHost.HostName = Dns.GetHostEntry(scanHost.HostIp).HostName; + // ReSharper disable UnusedVariable + System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(ipAddress.ToString(), port); + // ReSharper restore UnusedVariable + + isPortOpen = true; + scanHost.OpenPorts.Add(port); } catch (Exception) { + isPortOpen = false; + scanHost.ClosedPorts.Add(port); } - if (string.IsNullOrEmpty(scanHost.HostName)) + + if (port == scanHost.SSHPort) { - scanHost.HostName = scanHost.HostIp; + scanHost.SSH = isPortOpen; + } + else if (port == scanHost.TelnetPort) + { + scanHost.Telnet = isPortOpen; + } + else if (port == scanHost.HTTPPort) + { + scanHost.HTTP = isPortOpen; + } + else if (port == scanHost.HTTPSPort) + { + scanHost.HTTPS = isPortOpen; + } + else if (port == scanHost.RloginPort) + { + scanHost.Rlogin = isPortOpen; + } + else if (port == scanHost.RDPPort) + { + scanHost.RDP = isPortOpen; + } + else if (port == scanHost.VNCPort) + { + scanHost.VNC = isPortOpen; } - - _scannedHosts.Add(scanHost); - if (HostScannedEvent != null) - HostScannedEvent(scanHost, hostCount, _ipAddresses.Count); } - - if (ScanCompleteEvent != null) - ScanCompleteEvent(_scannedHosts); } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "StartScanBG failed (Tools.PortScan)" + Constants.vbNewLine + ex.Message, true); - } - } - - private static bool IsHostAlive(IPAddress ipAddress) - { - Ping pingSender = new Ping(); - PingReply pingReply; - + try { - pingReply = pingSender.Send(ipAddress); - - if (pingReply.Status == IPStatus.Success) - { - return true; - } - else - { - return false; - } + scanHost.HostName = Dns.GetHostEntry(scanHost.HostIp).HostName; } catch (Exception) { - return false; } + if (string.IsNullOrEmpty(scanHost.HostName)) + { + scanHost.HostName = scanHost.HostIp; + } + + _scannedHosts.Add(scanHost); + if (HostScannedEvent != null) + HostScannedEvent(scanHost, hostCount, _ipAddresses.Count); } - - private static IPAddress[] IpAddressArrayFromRange(IPAddress ipAddress1, IPAddress ipAddress2) - { - IPAddress startIpAddress = IpAddressMin(ipAddress1, ipAddress2); - IPAddress endIpAddress = IpAddressMax(ipAddress1, ipAddress2); - - int startAddress = IpAddressToInt32(startIpAddress); - int endAddress = IpAddressToInt32(endIpAddress); - int addressCount = endAddress - startAddress; - - IPAddress[] addressArray = new IPAddress[addressCount + 1]; - int index = 0; - for (int address = startAddress; address <= endAddress; address++) - { - addressArray[index] = IpAddressFromInt32(address); - index++; - } - - return addressArray; - } - - private static IPAddress IpAddressMin(IPAddress ipAddress1, IPAddress ipAddress2) - { - if (IpAddressCompare(ipAddress1, ipAddress2) < 0) // ipAddress1 < ipAddress2 - { - return ipAddress1; - } - else - { - return ipAddress2; - } - } - - private static IPAddress IpAddressMax(IPAddress ipAddress1, IPAddress ipAddress2) - { - if (IpAddressCompare(ipAddress1, ipAddress2) > 0) // ipAddress1 > ipAddress2 - { - return ipAddress1; - } - else - { - return ipAddress2; - } - } - - private static int IpAddressCompare(IPAddress ipAddress1, IPAddress ipAddress2) - { - return IpAddressToInt32(ipAddress1) - IpAddressToInt32(ipAddress2); - } - - private static int IpAddressToInt32(IPAddress ipAddress) - { - if (!(ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)) - { - throw (new ArgumentException("ipAddress")); - } - - byte[] addressBytes = ipAddress.GetAddressBytes(); // in network order (big-endian) - if (BitConverter.IsLittleEndian) - { - Array.Reverse(addressBytes); // to host order (little-endian) - } - Debug.Assert(addressBytes.Length == 4); - - return BitConverter.ToInt32(addressBytes, 0); - } - - private static IPAddress IpAddressFromInt32(int ipAddress) - { - byte[] addressBytes = BitConverter.GetBytes(ipAddress); // in host order - if (BitConverter.IsLittleEndian) - { - Array.Reverse(addressBytes); // to network order (big-endian) - } - Debug.Assert(addressBytes.Length == 4); - - return new ipAddress(addressBytes); - } -#endregion - -#region Events - public delegate void BeginHostScanEventHandler(string host); - private BeginHostScanEventHandler BeginHostScanEvent; - - public event BeginHostScanEventHandler BeginHostScan - { - add - { - BeginHostScanEvent = (BeginHostScanEventHandler) System.Delegate.Combine(BeginHostScanEvent, value); - } - remove - { - BeginHostScanEvent = (BeginHostScanEventHandler) System.Delegate.Remove(BeginHostScanEvent, value); - } - } - - public delegate void HostScannedEventHandler(ScanHost scanHost, int scannedHostCount, int totalHostCount); - private HostScannedEventHandler HostScannedEvent; - - public event HostScannedEventHandler HostScanned - { - add - { - HostScannedEvent = (HostScannedEventHandler) System.Delegate.Combine(HostScannedEvent, value); - } - remove - { - HostScannedEvent = (HostScannedEventHandler) System.Delegate.Remove(HostScannedEvent, value); - } - } - - public delegate void ScanCompleteEventHandler(List hosts); - private ScanCompleteEventHandler ScanCompleteEvent; - - public event ScanCompleteEventHandler ScanComplete - { - add - { - ScanCompleteEvent = (ScanCompleteEventHandler) System.Delegate.Combine(ScanCompleteEvent, value); - } - remove - { - ScanCompleteEvent = (ScanCompleteEventHandler) System.Delegate.Remove(ScanCompleteEvent, value); - } - } - -#endregion + + if (ScanCompleteEvent != null) + ScanCompleteEvent(_scannedHosts); } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "StartScanBG failed (Tools.PortScan)" + Constants.vbNewLine + ex.Message, true); + } + } + + private static bool IsHostAlive(IPAddress ipAddress) + { + Ping pingSender = new Ping(); + PingReply pingReply; + + try + { + pingReply = pingSender.Send(ipAddress); + + if (pingReply.Status == IPStatus.Success) + { + return true; + } + else + { + return false; + } + } + catch (Exception) + { + return false; + } + } + + private static IPAddress[] IpAddressArrayFromRange(IPAddress ipAddress1, IPAddress ipAddress2) + { + IPAddress startIpAddress = IpAddressMin(ipAddress1, ipAddress2); + IPAddress endIpAddress = IpAddressMax(ipAddress1, ipAddress2); + + int startAddress = IpAddressToInt32(startIpAddress); + int endAddress = IpAddressToInt32(endIpAddress); + int addressCount = endAddress - startAddress; + + IPAddress[] addressArray = new IPAddress[addressCount + 1]; + int index = 0; + for (int address = startAddress; address <= endAddress; address++) + { + addressArray[index] = IpAddressFromInt32(address); + index++; + } + + return addressArray; + } + + private static IPAddress IpAddressMin(IPAddress ipAddress1, IPAddress ipAddress2) + { + if (IpAddressCompare(ipAddress1, ipAddress2) < 0) // ipAddress1 < ipAddress2 + { + return ipAddress1; + } + else + { + return ipAddress2; + } + } + + private static IPAddress IpAddressMax(IPAddress ipAddress1, IPAddress ipAddress2) + { + if (IpAddressCompare(ipAddress1, ipAddress2) > 0) // ipAddress1 > ipAddress2 + { + return ipAddress1; + } + else + { + return ipAddress2; + } + } + + private static int IpAddressCompare(IPAddress ipAddress1, IPAddress ipAddress2) + { + return IpAddressToInt32(ipAddress1) - IpAddressToInt32(ipAddress2); + } + + private static int IpAddressToInt32(IPAddress ipAddress) + { + if (!(ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)) + { + throw (new ArgumentException("ipAddress")); + } + + byte[] addressBytes = ipAddress.GetAddressBytes(); // in network order (big-endian) + if (BitConverter.IsLittleEndian) + { + Array.Reverse(addressBytes); // to host order (little-endian) + } + Debug.Assert(addressBytes.Length == 4); + + return BitConverter.ToInt32(addressBytes, 0); + } + + private static IPAddress IpAddressFromInt32(int ipAddress) + { + byte[] addressBytes = BitConverter.GetBytes(ipAddress); // in host order + if (BitConverter.IsLittleEndian) + { + Array.Reverse(addressBytes); // to network order (big-endian) + } + Debug.Assert(addressBytes.Length == 4); + + return new ipAddress(addressBytes); + } + #endregion + + #region Events + public delegate void BeginHostScanEventHandler(string host); + private BeginHostScanEventHandler BeginHostScanEvent; + + public event BeginHostScanEventHandler BeginHostScan + { + add + { + BeginHostScanEvent = (BeginHostScanEventHandler) System.Delegate.Combine(BeginHostScanEvent, value); + } + remove + { + BeginHostScanEvent = (BeginHostScanEventHandler) System.Delegate.Remove(BeginHostScanEvent, value); + } + } + + public delegate void HostScannedEventHandler(ScanHost scanHost, int scannedHostCount, int totalHostCount); + private HostScannedEventHandler HostScannedEvent; + + public event HostScannedEventHandler HostScanned + { + add + { + HostScannedEvent = (HostScannedEventHandler) System.Delegate.Combine(HostScannedEvent, value); + } + remove + { + HostScannedEvent = (HostScannedEventHandler) System.Delegate.Remove(HostScannedEvent, value); + } + } + + public delegate void ScanCompleteEventHandler(List hosts); + private ScanCompleteEventHandler ScanCompleteEvent; + + public event ScanCompleteEventHandler ScanComplete + { + add + { + ScanCompleteEvent = (ScanCompleteEventHandler) System.Delegate.Combine(ScanCompleteEvent, value); + } + remove + { + ScanCompleteEvent = (ScanCompleteEventHandler) System.Delegate.Remove(ScanCompleteEvent, value); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/Tree/Tree.Node.cs b/mRemoteV1/CS/Tree/Tree.Node.cs index f03947f7d..1410d4cb4 100644 --- a/mRemoteV1/CS/Tree/Tree.Node.cs +++ b/mRemoteV1/CS/Tree/Tree.Node.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,689 +8,692 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.DirectoryServices; namespace mRemoteNG.Tree { public class Node + { + #region Enums + public enum Type { - public enum Type + None = 0, + Root = 1, + Container = 2, + Connection = 3, + PuttyRoot = 4, + PuttySession = 5 + } + #endregion + + #region Public Properties + private static TreeView _TreeView; + public static TreeView TreeView + { + get { - None = 0, - Root = 1, - Container = 2, - Connection = 3, - PuttyRoot = 4, - PuttySession = 5 + return _TreeView; } - - private static TreeView _TreeView; -public static TreeView TreeView + set { - get - { - return _TreeView; - } - set - { - _TreeView = value; - } + _TreeView = value; } + } -public static TreeNode SelectedNode + public static TreeNode SelectedNode + { + get { - get - { - return _TreeView.SelectedNode; - } - set - { - treeNodeToBeSelected = value; - SelectNode(); - } + return _TreeView.SelectedNode; } - - private static TreeNode treeNodeToBeSelected; - private delegate void SelectNodeCB(); - private static void SelectNode() + set { - if (_TreeView.InvokeRequired == true) - { - SelectNodeCB d = new SelectNodeCB(SelectNode); - _TreeView.Invoke(d); - } - else - { - _TreeView.SelectedNode = treeNodeToBeSelected; - } + treeNodeToBeSelected = value; + SelectNode(); } - - - public static string GetConstantID(TreeNode node) + } + #endregion + + #region Public Methods + private static TreeNode treeNodeToBeSelected; + private delegate void SelectNodeCB(); + private static void SelectNode() + { + if (_TreeView.InvokeRequired == true) { - if (GetNodeType(node) == Type.Connection) - { - return (node.Tag as mRemoteNG.Connection.Info).ConstantID; - } - else if (GetNodeType(node) == Type.Container) - { - return (node.Tag as mRemoteNG.Container.Info).ConnectionInfo.ConstantID; - } + SelectNodeCB d = new SelectNodeCB(SelectNode); + _TreeView.Invoke(d); + } + else + { + _TreeView.SelectedNode = treeNodeToBeSelected; + } + } + + + public static string GetConstantID(TreeNode node) + { + if (GetNodeType(node) == Type.Connection) + { + return (node.Tag as mRemoteNG.Connection.Info).ConstantID; + } + else if (GetNodeType(node) == Type.Container) + { + return (node.Tag as mRemoteNG.Container.Info).ConnectionInfo.ConstantID; + } - return null; - } + return null; + } - public static TreeNode GetNodeFromPositionID(int id) + public static TreeNode GetNodeFromPositionID(int id) + { + foreach (Connection.Info conI in Runtime.ConnectionList) { - foreach (Connection.Info conI in ConnectionList) + if (conI.PositionID == id) { - if (conI.PositionID == id) + if (conI.IsContainer) { - if (conI.IsContainer) - { - return (conI.Parent as Container.Info).TreeNode; - } - else - { - return conI.TreeNode; - } - } - } - - return null; - } - - public static TreeNode GetNodeFromConstantID(string id) - { - foreach (Connection.Info conI in ConnectionList) - { - if (conI.ConstantID == id) - { - if (conI.IsContainer) - { - return (conI.Parent as Container.Info).TreeNode; - } - else - { - return conI.TreeNode; - } - } - } - - return null; - } - - public static Tree.Node.Type GetNodeType(TreeNode treeNode) - { - try - { - if (treeNode == null) - { - return Type.None; - } - - if (treeNode.Tag == null) - { - return Type.None; - } - - if (treeNode.Tag is Root.PuttySessions.Info) - { - return Type.PuttyRoot; - } - else if (treeNode.Tag is Root.Info) - { - return Type.Root; - } - else if (treeNode.Tag is Container.Info) - { - return Type.Container; - } - else if (treeNode.Tag is Connection.PuttySession.Info) - { - return Type.PuttySession; - } - else if (treeNode.Tag is Connection.Info) - { - return Type.Connection; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get node type" + Constants.vbNewLine + ex.Message, true); - } - - return Type.None; - } - - public static Tree.Node.Type GetNodeTypeFromString(string str) - { - try - { - switch (str.ToLower()) - { - case "root": - return Type.Root; - case "container": - return Type.Container; - case "connection": - return Type.Connection; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get node type from string" + Constants.vbNewLine + ex.Message, true); - } - - return Type.None; - } - - public static TreeNode Find(TreeNode treeNode, string searchFor) - { - TreeNode tmpNode = default(TreeNode); - - try - { - if ((treeNode.Text.ToLower()).IndexOf(searchFor.ToLower()) + 1 > 0) - { - return treeNode; + return (conI.Parent as Container.Info).TreeNode; } else { - foreach (TreeNode childNode in treeNode.Nodes) - { - tmpNode = Find(childNode, searchFor); - if (!(tmpNode == null)) - { - return tmpNode; - } - } + return conI.TreeNode; } } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Constants.vbNewLine + ex.Message, true); - } - - return null; } - - public static TreeNode Find(TreeNode treeNode, Connection.Info conInfo) - { - TreeNode tmpNode = default(TreeNode); - try + return null; + } + + public static TreeNode GetNodeFromConstantID(string id) + { + foreach (Connection.Info conI in Runtime.ConnectionList) + { + if (conI.ConstantID == id) { - if (treeNode.Tag == conInfo) + if (conI.IsContainer) { - return treeNode; + return (conI.Parent as Container.Info).TreeNode; } else { - foreach (TreeNode childNode in treeNode.Nodes) - { - tmpNode = Find(childNode, conInfo); - if (!(tmpNode == null)) - { - return tmpNode; - } - } + return conI.TreeNode; } } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Constants.vbNewLine + ex.Message, true); - } + } - return null; - } + return null; + } - public static bool IsEmpty(TreeNode treeNode) + public static Tree.Node.Type GetNodeType(TreeNode treeNode) + { + try { - try - { - if (treeNode.Nodes.Count <= 0) - { - return false; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "IsEmpty (Tree.Node) failed" + Constants.vbNewLine + ex.Message, true); - } - - return true; - } - - - - public static TreeNode AddNode(Type nodeType, string name = null) - { - try - { - TreeNode treeNode = new TreeNode(); - string defaultName = ""; - - switch (nodeType) - { - case Type.Connection: - case Type.PuttySession: - defaultName = My.Language.strNewConnection; - treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; - break; - case Type.Container: - defaultName = My.Language.strNewFolder; - treeNode.ImageIndex = Images.Enums.TreeImage.Container; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; - break; - case Type.Root: - defaultName = My.Language.strNewRoot; - treeNode.ImageIndex = Images.Enums.TreeImage.Root; - treeNode.SelectedImageIndex = Images.Enums.TreeImage.Root; - break; - } - - if (!string.IsNullOrEmpty(name)) - { - treeNode.Name = name; - } - else - { - treeNode.Name = defaultName; - } - treeNode.Text = treeNode.Name; - - return treeNode; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddNode failed" + Constants.vbNewLine + ex.Message, true); - } - - return null; - } - - public static void CloneNode(TreeNode oldTreeNode, TreeNode parentNode = null) - { - try - { - if (GetNodeType(oldTreeNode) == Type.Connection) - { - Connection.Info oldConnectionInfo = (Connection.Info) oldTreeNode.Tag; - - Connection.Info newConnectionInfo = oldConnectionInfo.Copy(); - Connection.Info.Inheritance newInheritance = oldConnectionInfo.Inherit.Copy(); - newInheritance.Parent = newConnectionInfo; - newConnectionInfo.Inherit = newInheritance; - - ConnectionList.Add(newConnectionInfo); - - TreeNode newTreeNode = new TreeNode(newConnectionInfo.Name); - newTreeNode.Tag = newConnectionInfo; - newTreeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; - newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; - - newConnectionInfo.TreeNode = newTreeNode; - - if (parentNode == null) - { - oldTreeNode.Parent.Nodes.Insert(oldTreeNode.Index + 1, newTreeNode); - TreeView.SelectedNode = newTreeNode; - } - else - { - Container.Info parentContainerInfo = parentNode.Tag as Container.Info; - if (parentContainerInfo != null) - { - newConnectionInfo.Parent = parentContainerInfo; - } - parentNode.Nodes.Add(newTreeNode); - } - } - else if (GetNodeType(oldTreeNode) == Type.Container) - { - Container.Info oldContainerInfo = (Container.Info) oldTreeNode.Tag; - - Container.Info newContainerInfo = oldContainerInfo.Copy(); - Connection.Info newConnectionInfo = oldContainerInfo.ConnectionInfo.Copy(); - newContainerInfo.ConnectionInfo = newConnectionInfo; - - TreeNode newTreeNode = new TreeNode(newContainerInfo.Name); - newTreeNode.Tag = newContainerInfo; - newTreeNode.ImageIndex = Images.Enums.TreeImage.Container; - newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; - newContainerInfo.ConnectionInfo.Parent = newContainerInfo; - - ContainerList.Add(newContainerInfo); - - if (parentNode == null) - { - oldTreeNode.Parent.Nodes.Insert(oldTreeNode.Index + 1, newTreeNode); - TreeView.SelectedNode = newTreeNode; - } - else - { - parentNode.Nodes.Add(newTreeNode); - } - - foreach (TreeNode childTreeNode in oldTreeNode.Nodes) - { - CloneNode(childTreeNode, newTreeNode); - } - - newTreeNode.Expand(); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strErrorCloneNodeFailed, ex.Message)); - } - } - - public static void SetNodeImage(TreeNode treeNode, Images.Enums.TreeImage Img) - { - SetNodeImageIndex(treeNode, Img); - } - - private delegate void SetNodeImageIndexDelegate(TreeNode treeNode, int imageIndex); - private static void SetNodeImageIndex(TreeNode treeNode, int imageIndex) - { - if (treeNode == null || treeNode.TreeView == null) - { - return ; - } - if (treeNode.TreeView.InvokeRequired) - { - treeNode.TreeView.Invoke(new SetNodeImageIndexDelegate(SetNodeImageIndex), new object[] {treeNode, imageIndex}); - return ; - } - - treeNode.ImageIndex = imageIndex; - treeNode.SelectedImageIndex = imageIndex; - } - - // VBConversions Note: Former VB static variables moved to class level because they aren't supported in C#. - static TreeNode SetNodeToolTip_old_node = default(TreeNode); - - public static void SetNodeToolTip(MouseEventArgs e, ToolTip tTip) - { - try - { - if (My.Settings.Default.ShowDescriptionTooltipsInTree) - { - //Find the node under the mouse. - // static TreeNode old_node = default(TreeNode); VBConversions Note: Static variable moved to class level and renamed SetNodeToolTip_old_node. Local static variables are not supported in C#. - TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); - if (new_node == SetNodeToolTip_old_node) - { - return; - } - SetNodeToolTip_old_node = new_node; - - //See if we have a node. - if (SetNodeToolTip_old_node == null) - { - tTip.SetToolTip(_TreeView, ""); - } - else - { - //Get this node's object data. - if (GetNodeType(SetNodeToolTip_old_node) == Type.Connection) - { - tTip.SetToolTip(_TreeView, (SetNodeToolTip_old_node.Tag as mRemoteNG.Connection.Info).Description); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SetNodeToolTip failed" + Constants.vbNewLine + ex.Message, true); - } - } - - - public static void DeleteSelectedNode() - { - try - { - if (SelectedNode == null) - { - return ; - } - - if (Tree.Node.GetNodeType(SelectedNode) == Type.Root) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "The root item cannot be deleted!"); - } - else if (Tree.Node.GetNodeType(SelectedNode) == Type.Container) - { - if (Tree.Node.IsEmpty(SelectedNode) == false) - { - if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeFolder, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) - { - SelectedNode.Remove(); - } - } - else - { - if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) - { - foreach (TreeNode tNode in SelectedNode.Nodes) - { - tNode.Remove(); - } - SelectedNode.Remove(); - } - } - } - else if (Tree.Node.GetNodeType(SelectedNode) == Type.Connection) - { - if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeConnection, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) - { - SelectedNode.Remove(); - } - } - else - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Deleting selected node failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public static void StartRenameSelectedNode() - { - if (SelectedNode != null) - { - SelectedNode.BeginEdit(); - } - } - - public static void FinishRenameSelectedNode(string newName) - { - if (newName == null) - { - return ; - } - - if (newName.Length > 0) - { - SelectedNode.Tag.Name = newName; - - if (My.Settings.Default.SetHostnameLikeDisplayName) - { - Connection.Info connectionInfo = SelectedNode.Tag as Connection.Info; - if (connectionInfo != null) - { - connectionInfo.Hostname = newName; - } - } - } - } - - public static void MoveNodeUp() - { - try - { - if (SelectedNode != null) - { - if (!(SelectedNode.PrevNode == null)) - { - TreeView.BeginUpdate(); - TreeView.Sorted = false; - - TreeNode newNode = SelectedNode.Clone(); - SelectedNode.Parent.Nodes.Insert(SelectedNode.Index - 1, newNode); - SelectedNode.Remove(); - SelectedNode = newNode; - - TreeView.EndUpdate(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeUp failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public static void MoveNodeDown() - { - try - { - if (SelectedNode != null) - { - if (!(SelectedNode.NextNode == null)) - { - TreeView.BeginUpdate(); - TreeView.Sorted = false; - - TreeNode newNode = SelectedNode.Clone(); - SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 2, newNode); - SelectedNode.Remove(); - SelectedNode = newNode; - - TreeView.EndUpdate(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeDown failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public static void ExpandAllNodes() - { - TreeView.BeginUpdate(); - TreeView.ExpandAll(); - TreeView.EndUpdate(); - } - - public static void CollapseAllNodes() - { - TreeView.BeginUpdate(); - foreach (TreeNode treeNode in TreeView.Nodes[0].Nodes) - { - treeNode.Collapse(false); - } - TreeView.EndUpdate(); - } - - public static void Sort(TreeNode treeNode, System.Windows.Forms.SortOrder sorting) - { - if (TreeView == null) - { - return ; - } - - TreeView.BeginUpdate(); - if (treeNode == null) { - if (TreeView.Nodes.Count > 0) - { - treeNode = TreeView.Nodes[0]; - } - else - { - return ; - } + return Type.None; } - else if (GetNodeType(treeNode) == Type.Connection) - { - treeNode = treeNode.Parent; - if (treeNode == null) - { - return ; - } - } - - Sort(treeNode, new Tools.Controls.TreeNodeSorter(sorting)); - - TreeView.EndUpdate(); - } - - // Adapted from http://www.codeproject.com/Tips/252234/ASP-NET-TreeView-Sort - private static void Sort(TreeNode treeNode, Tools.Controls.TreeNodeSorter nodeSorter) - { - foreach (TreeNode childNode in treeNode.Nodes) - { - Sort(childNode, nodeSorter); - } - - try - { - List sortedNodes = new List(); - TreeNode currentNode = null; - while (treeNode.Nodes.Count > 0) - { - foreach (TreeNode childNode in treeNode.Nodes) - { - if (currentNode == null || nodeSorter.Compare(childNode, currentNode) < 0) - { - currentNode = childNode; - } - } - treeNode.Nodes.Remove(currentNode); - sortedNodes.Add(currentNode); - currentNode = null; - } - foreach (TreeNode childNode in sortedNodes) - { - treeNode.Nodes.Add(childNode); - } - } - catch (Exception ex) + if (treeNode.Tag == null) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Sort nodes failed" + Constants.vbNewLine + ex.Message, true); + return Type.None; + } + + if (treeNode.Tag is Root.PuttySessions.Info) + { + return Type.PuttyRoot; + } + else if (treeNode.Tag is Root.Info) + { + return Type.Root; + } + else if (treeNode.Tag is Container.Info) + { + return Type.Container; + } + else if (treeNode.Tag is Connection.PuttySession.Info) + { + return Type.PuttySession; + } + else if (treeNode.Tag is Connection.Info) + { + return Type.Connection; } } - - private delegate void ResetTreeDelegate(); - public static void ResetTree() + catch (Exception ex) { - if (TreeView.InvokeRequired) + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get node type" + Constants.vbNewLine + ex.Message, true); + } + + return Type.None; + } + + public static Tree.Node.Type GetNodeTypeFromString(string str) + { + try + { + switch (str.ToLower()) { - ResetTreeDelegate resetTreeDelegate = new ResetTreeDelegate(ResetTree); - Windows.treeForm.Invoke(resetTreeDelegate); + case "root": + return Type.Root; + case "container": + return Type.Container; + case "connection": + return Type.Connection; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t get node type from string" + Constants.vbNewLine + ex.Message, true); + } + + return Type.None; + } + + public static TreeNode Find(TreeNode treeNode, string searchFor) + { + TreeNode tmpNode = default(TreeNode); + + try + { + if ((treeNode.Text.ToLower()).IndexOf(searchFor.ToLower()) + 1 > 0) + { + return treeNode; } else { - TreeView.BeginUpdate(); - TreeView.Nodes.Clear(); - TreeView.Nodes.Add(My.Language.strConnections); - TreeView.EndUpdate(); + foreach (TreeNode childNode in treeNode.Nodes) + { + tmpNode = Find(childNode, searchFor); + if (!(tmpNode == null)) + { + return tmpNode; + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Constants.vbNewLine + ex.Message, true); + } + + return null; + } + + public static TreeNode Find(TreeNode treeNode, Connection.Info conInfo) + { + TreeNode tmpNode = default(TreeNode); + + try + { + if (treeNode.Tag == conInfo) + { + return treeNode; + } + else + { + foreach (TreeNode childNode in treeNode.Nodes) + { + tmpNode = Find(childNode, conInfo); + if (!(tmpNode == null)) + { + return tmpNode; + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Constants.vbNewLine + ex.Message, true); + } + + return null; + } + + public static bool IsEmpty(TreeNode treeNode) + { + try + { + if (treeNode.Nodes.Count <= 0) + { + return false; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "IsEmpty (Tree.Node) failed" + Constants.vbNewLine + ex.Message, true); + } + + return true; + } + + + + public static TreeNode AddNode(Type nodeType, string name = null) + { + try + { + TreeNode treeNode = new TreeNode(); + string defaultName = ""; + + switch (nodeType) + { + case Type.Connection: + case Type.PuttySession: + defaultName = My.Language.strNewConnection; + treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; + break; + case Type.Container: + defaultName = My.Language.strNewFolder; + treeNode.ImageIndex = Images.Enums.TreeImage.Container; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; + break; + case Type.Root: + defaultName = My.Language.strNewRoot; + treeNode.ImageIndex = Images.Enums.TreeImage.Root; + treeNode.SelectedImageIndex = Images.Enums.TreeImage.Root; + break; + } + + if (!string.IsNullOrEmpty(name)) + { + treeNode.Name = name; + } + else + { + treeNode.Name = defaultName; + } + treeNode.Text = treeNode.Name; + + return treeNode; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddNode failed" + Constants.vbNewLine + ex.Message, true); + } + + return null; + } + + public static void CloneNode(TreeNode oldTreeNode, TreeNode parentNode = null) + { + try + { + if (GetNodeType(oldTreeNode) == Type.Connection) + { + Connection.Info oldConnectionInfo = (Connection.Info) oldTreeNode.Tag; + + Connection.Info newConnectionInfo = oldConnectionInfo.Copy(); + Connection.Info.Inheritance newInheritance = oldConnectionInfo.Inherit.Copy(); + newInheritance.Parent = newConnectionInfo; + newConnectionInfo.Inherit = newInheritance; + + Runtime.ConnectionList.Add(newConnectionInfo); + + TreeNode newTreeNode = new TreeNode(newConnectionInfo.Name); + newTreeNode.Tag = newConnectionInfo; + newTreeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed; + newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed; + + newConnectionInfo.TreeNode = newTreeNode; + + if (parentNode == null) + { + oldTreeNode.Parent.Nodes.Insert(oldTreeNode.Index + 1, newTreeNode); + TreeView.SelectedNode = newTreeNode; + } + else + { + Container.Info parentContainerInfo = parentNode.Tag as Container.Info; + if (parentContainerInfo != null) + { + newConnectionInfo.Parent = parentContainerInfo; + } + parentNode.Nodes.Add(newTreeNode); + } + } + else if (GetNodeType(oldTreeNode) == Type.Container) + { + Container.Info oldContainerInfo = (Container.Info) oldTreeNode.Tag; + + Container.Info newContainerInfo = oldContainerInfo.Copy(); + Connection.Info newConnectionInfo = oldContainerInfo.ConnectionInfo.Copy(); + newContainerInfo.ConnectionInfo = newConnectionInfo; + + TreeNode newTreeNode = new TreeNode(newContainerInfo.Name); + newTreeNode.Tag = newContainerInfo; + newTreeNode.ImageIndex = Images.Enums.TreeImage.Container; + newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.Container; + newContainerInfo.ConnectionInfo.Parent = newContainerInfo; + + Runtime.ContainerList.Add(newContainerInfo); + + if (parentNode == null) + { + oldTreeNode.Parent.Nodes.Insert(oldTreeNode.Index + 1, newTreeNode); + TreeView.SelectedNode = newTreeNode; + } + else + { + parentNode.Nodes.Add(newTreeNode); + } + + foreach (TreeNode childTreeNode in oldTreeNode.Nodes) + { + CloneNode(childTreeNode, newTreeNode); + } + + newTreeNode.Expand(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(My.Language.strErrorCloneNodeFailed, ex.Message)); + } + } + + public static void SetNodeImage(TreeNode treeNode, Images.Enums.TreeImage Img) + { + SetNodeImageIndex(treeNode, Img); + } + + private delegate void SetNodeImageIndexDelegate(TreeNode treeNode, int imageIndex); + private static void SetNodeImageIndex(TreeNode treeNode, int imageIndex) + { + if (treeNode == null || treeNode.TreeView == null) + { + return ; + } + if (treeNode.TreeView.InvokeRequired) + { + treeNode.TreeView.Invoke(new SetNodeImageIndexDelegate(SetNodeImageIndex), new object[] {treeNode, imageIndex}); + return ; + } + + treeNode.ImageIndex = imageIndex; + treeNode.SelectedImageIndex = imageIndex; + } + + // VBConversions Note: Former VB static variables moved to class level because they aren't supported in C#. + static TreeNode SetNodeToolTip_old_node = default(TreeNode); + public static void SetNodeToolTip(MouseEventArgs e, ToolTip tTip) + { + try + { + if (My.Settings.Default.ShowDescriptionTooltipsInTree) + { + //Find the node under the mouse. + // static TreeNode old_node = default(TreeNode); VBConversions Note: Static variable moved to class level and renamed SetNodeToolTip_old_node. Local static variables are not supported in C#. + TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); + if (new_node == SetNodeToolTip_old_node) + { + return; + } + SetNodeToolTip_old_node = new_node; + + //See if we have a node. + if (SetNodeToolTip_old_node == null) + { + tTip.SetToolTip(_TreeView, ""); + } + else + { + //Get this node's object data. + if (GetNodeType(SetNodeToolTip_old_node) == Type.Connection) + { + tTip.SetToolTip(_TreeView, (SetNodeToolTip_old_node.Tag as mRemoteNG.Connection.Info).Description); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SetNodeToolTip failed" + Constants.vbNewLine + ex.Message, true); + } + } + + + public static void DeleteSelectedNode() + { + try + { + if (SelectedNode == null) + { + return ; + } + + if (Tree.Node.GetNodeType(SelectedNode) == Type.Root) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "The root item cannot be deleted!"); + } + else if (Tree.Node.GetNodeType(SelectedNode) == Type.Container) + { + if (Tree.Node.IsEmpty(SelectedNode) == false) + { + if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeFolder, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + { + SelectedNode.Remove(); + } + } + else + { + if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + { + foreach (TreeNode tNode in SelectedNode.Nodes) + { + tNode.Remove(); + } + SelectedNode.Remove(); + } + } + } + else if (Tree.Node.GetNodeType(SelectedNode) == Type.Connection) + { + if (Interaction.MsgBox(string.Format(My.Language.strConfirmDeleteNodeConnection, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + { + SelectedNode.Remove(); + } + } + else + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Deleting selected node failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public static void StartRenameSelectedNode() + { + if (SelectedNode != null) + { + SelectedNode.BeginEdit(); + } + } + + public static void FinishRenameSelectedNode(string newName) + { + if (newName == null) + { + return ; + } + + if (newName.Length > 0) + { + SelectedNode.Tag.Name = newName; + + if (My.Settings.Default.SetHostnameLikeDisplayName) + { + Connection.Info connectionInfo = SelectedNode.Tag as Connection.Info; + if (connectionInfo != null) + { + connectionInfo.Hostname = newName; + } } } } -} + + public static void MoveNodeUp() + { + try + { + if (SelectedNode != null) + { + if (!(SelectedNode.PrevNode == null)) + { + TreeView.BeginUpdate(); + TreeView.Sorted = false; + + TreeNode newNode = (TreeNode)SelectedNode.Clone(); + SelectedNode.Parent.Nodes.Insert(SelectedNode.Index - 1, newNode); + SelectedNode.Remove(); + SelectedNode = newNode; + + TreeView.EndUpdate(); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeUp failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public static void MoveNodeDown() + { + try + { + if (SelectedNode != null) + { + if (!(SelectedNode.NextNode == null)) + { + TreeView.BeginUpdate(); + TreeView.Sorted = false; + + TreeNode newNode = (TreeNode)SelectedNode.Clone(); + SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 2, newNode); + SelectedNode.Remove(); + SelectedNode = newNode; + + TreeView.EndUpdate(); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeDown failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public static void ExpandAllNodes() + { + TreeView.BeginUpdate(); + TreeView.ExpandAll(); + TreeView.EndUpdate(); + } + + public static void CollapseAllNodes() + { + TreeView.BeginUpdate(); + foreach (TreeNode treeNode in TreeView.Nodes[0].Nodes) + { + treeNode.Collapse(false); + } + TreeView.EndUpdate(); + } + + public static void Sort(TreeNode treeNode, System.Windows.Forms.SortOrder sorting) + { + if (TreeView == null) + { + return ; + } + + TreeView.BeginUpdate(); + + if (treeNode == null) + { + if (TreeView.Nodes.Count > 0) + { + treeNode = TreeView.Nodes[0]; + } + else + { + return ; + } + } + else if (GetNodeType(treeNode) == Type.Connection) + { + treeNode = treeNode.Parent; + if (treeNode == null) + { + return ; + } + } + + Sort(treeNode, new Tools.Controls.TreeNodeSorter(sorting)); + + TreeView.EndUpdate(); + } + + // Adapted from http://www.codeproject.com/Tips/252234/ASP-NET-TreeView-Sort + private static void Sort(TreeNode treeNode, Tools.Controls.TreeNodeSorter nodeSorter) + { + foreach (TreeNode childNode in treeNode.Nodes) + { + Sort(childNode, nodeSorter); + } + + try + { + List sortedNodes = new List(); + TreeNode currentNode = null; + while (treeNode.Nodes.Count > 0) + { + foreach (TreeNode childNode in treeNode.Nodes) + { + if (currentNode == null || nodeSorter.Compare(childNode, currentNode) < 0) + { + currentNode = childNode; + } + } + treeNode.Nodes.Remove(currentNode); + sortedNodes.Add(currentNode); + currentNode = null; + } + + foreach (TreeNode childNode in sortedNodes) + { + treeNode.Nodes.Add(childNode); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Sort nodes failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private delegate void ResetTreeDelegate(); + public static void ResetTree() + { + if (TreeView.InvokeRequired) + { + ResetTreeDelegate resetTreeDelegate = new ResetTreeDelegate(ResetTree); + Windows.treeForm.Invoke(resetTreeDelegate); + } + else + { + TreeView.BeginUpdate(); + TreeView.Nodes.Clear(); + TreeView.Nodes.Add(My.Language.strConnections); + TreeView.EndUpdate(); + } + } + #endregion + } +} \ No newline at end of file diff --git a/mRemoteV1/CS/UI/UI.Window.About.cs b/mRemoteV1/CS/UI/UI.Window.About.cs index 01f305605..7ee98ff07 100644 --- a/mRemoteV1/CS/UI/UI.Window.About.cs +++ b/mRemoteV1/CS/UI/UI.Window.About.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,352 +8,349 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using WeifenLuo.WinFormsUI.Docking; using System.IO; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { - public class About : Base + public class About : Base + { + #region Form Init + internal System.Windows.Forms.Label lblCopyright; + internal System.Windows.Forms.Label lblTitle; + internal System.Windows.Forms.Label lblVersion; + internal System.Windows.Forms.Label lblLicense; + internal System.Windows.Forms.TextBox txtChangeLog; + internal System.Windows.Forms.Label lblChangeLog; + internal System.Windows.Forms.Panel pnlBottom; + internal System.Windows.Forms.PictureBox pbLogo; + internal System.Windows.Forms.Label lblEdition; + internal System.Windows.Forms.LinkLabel llblFAMFAMFAM; + internal System.Windows.Forms.LinkLabel llblMagicLibrary; + internal System.Windows.Forms.LinkLabel llblWeifenLuo; + internal System.Windows.Forms.Panel pnlTop; + + private void InitializeComponent() + { + this.pnlTop = new System.Windows.Forms.Panel(); + this.Load += new System.EventHandler(About_Load); + this.lblEdition = new System.Windows.Forms.Label(); + this.pbLogo = new System.Windows.Forms.PictureBox(); + this.pnlBottom = new System.Windows.Forms.Panel(); + this.llblWeifenLuo = new System.Windows.Forms.LinkLabel(); + this.llblWeifenLuo.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblWeifenLuo_LinkClicked); + this.llblMagicLibrary = new System.Windows.Forms.LinkLabel(); + this.llblMagicLibrary.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblMagicLibrary_LinkClicked); + this.llblFAMFAMFAM = new System.Windows.Forms.LinkLabel(); + this.llblFAMFAMFAM.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblFAMFAMFAM_LinkClicked); + this.txtChangeLog = new System.Windows.Forms.TextBox(); + this.lblTitle = new System.Windows.Forms.Label(); + this.lblVersion = new System.Windows.Forms.Label(); + this.lblChangeLog = new System.Windows.Forms.Label(); + this.lblLicense = new System.Windows.Forms.Label(); + this.lblCopyright = new System.Windows.Forms.Label(); + this.pnlTop.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbLogo).BeginInit(); + this.pnlBottom.SuspendLayout(); + this.SuspendLayout(); + // + //pnlTop + // + this.pnlTop.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlTop.BackColor = System.Drawing.Color.Black; + this.pnlTop.Controls.Add(this.lblEdition); + this.pnlTop.Controls.Add(this.pbLogo); + this.pnlTop.ForeColor = System.Drawing.Color.White; + this.pnlTop.Location = new System.Drawing.Point(-1, -1); + this.pnlTop.Name = "pnlTop"; + this.pnlTop.Size = new System.Drawing.Size(788, 145); + this.pnlTop.TabIndex = 0; + // + //lblEdition + // + this.lblEdition.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.lblEdition.BackColor = System.Drawing.Color.Black; + this.lblEdition.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (14.25F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblEdition.ForeColor = System.Drawing.Color.White; + this.lblEdition.Location = new System.Drawing.Point(512, 112); + this.lblEdition.Name = "lblEdition"; + this.lblEdition.Size = new System.Drawing.Size(264, 24); + this.lblEdition.TabIndex = 0; + this.lblEdition.Text = "Edition"; + this.lblEdition.TextAlign = System.Drawing.ContentAlignment.BottomRight; + this.lblEdition.Visible = false; + // + //pbLogo + // + this.pbLogo.Image = global::My.Resources.Resources.Logo; + this.pbLogo.Location = new System.Drawing.Point(8, 8); + this.pbLogo.Name = "pbLogo"; + this.pbLogo.Size = new System.Drawing.Size(492, 128); + this.pbLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pbLogo.TabIndex = 1; + this.pbLogo.TabStop = false; + // + //pnlBottom + // + this.pnlBottom.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlBottom.BackColor = System.Drawing.SystemColors.Control; + this.pnlBottom.Controls.Add(this.llblWeifenLuo); + this.pnlBottom.Controls.Add(this.llblMagicLibrary); + this.pnlBottom.Controls.Add(this.llblFAMFAMFAM); + this.pnlBottom.Controls.Add(this.txtChangeLog); + this.pnlBottom.Controls.Add(this.lblTitle); + this.pnlBottom.Controls.Add(this.lblVersion); + this.pnlBottom.Controls.Add(this.lblChangeLog); + this.pnlBottom.Controls.Add(this.lblLicense); + this.pnlBottom.Controls.Add(this.lblCopyright); + this.pnlBottom.ForeColor = System.Drawing.SystemColors.ControlText; + this.pnlBottom.Location = new System.Drawing.Point(-1, 144); + this.pnlBottom.Name = "pnlBottom"; + this.pnlBottom.Size = new System.Drawing.Size(788, 418); + this.pnlBottom.TabIndex = 1; + // + //llblWeifenLuo + // + this.llblWeifenLuo.AutoSize = true; + this.llblWeifenLuo.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.llblWeifenLuo.ForeColor = System.Drawing.SystemColors.ControlText; + this.llblWeifenLuo.LinkColor = System.Drawing.Color.Blue; + this.llblWeifenLuo.Location = new System.Drawing.Point(16, 158); + this.llblWeifenLuo.Name = "llblWeifenLuo"; + this.llblWeifenLuo.Size = new System.Drawing.Size(78, 22); + this.llblWeifenLuo.TabIndex = 9; + this.llblWeifenLuo.TabStop = true; + this.llblWeifenLuo.Text = "WeifenLuo"; + this.llblWeifenLuo.UseCompatibleTextRendering = true; + // + //llblMagicLibrary + // + this.llblMagicLibrary.AutoSize = true; + this.llblMagicLibrary.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.llblMagicLibrary.ForeColor = System.Drawing.SystemColors.ControlText; + this.llblMagicLibrary.LinkColor = System.Drawing.Color.Blue; + this.llblMagicLibrary.Location = new System.Drawing.Point(16, 136); + this.llblMagicLibrary.Name = "llblMagicLibrary"; + this.llblMagicLibrary.Size = new System.Drawing.Size(92, 22); + this.llblMagicLibrary.TabIndex = 8; + this.llblMagicLibrary.TabStop = true; + this.llblMagicLibrary.Text = "MagicLibrary"; + this.llblMagicLibrary.UseCompatibleTextRendering = true; + // + //llblFAMFAMFAM + // + this.llblFAMFAMFAM.AutoSize = true; + this.llblFAMFAMFAM.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.llblFAMFAMFAM.ForeColor = System.Drawing.SystemColors.ControlText; + this.llblFAMFAMFAM.LinkColor = System.Drawing.Color.Blue; + this.llblFAMFAMFAM.Location = new System.Drawing.Point(16, 116); + this.llblFAMFAMFAM.Name = "llblFAMFAMFAM"; + this.llblFAMFAMFAM.Size = new System.Drawing.Size(101, 22); + this.llblFAMFAMFAM.TabIndex = 4; + this.llblFAMFAMFAM.TabStop = true; + this.llblFAMFAMFAM.Text = "FAMFAMFAM"; + this.llblFAMFAMFAM.UseCompatibleTextRendering = true; + // + //txtChangeLog + // + this.txtChangeLog.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtChangeLog.BackColor = System.Drawing.SystemColors.Control; + this.txtChangeLog.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtChangeLog.Cursor = System.Windows.Forms.Cursors.Default; + this.txtChangeLog.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (9.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.txtChangeLog.ForeColor = System.Drawing.SystemColors.ControlText; + this.txtChangeLog.Location = new System.Drawing.Point(24, 224); + this.txtChangeLog.Multiline = true; + this.txtChangeLog.Name = "txtChangeLog"; + this.txtChangeLog.ReadOnly = true; + this.txtChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtChangeLog.Size = new System.Drawing.Size(760, 192); + this.txtChangeLog.TabIndex = 7; + this.txtChangeLog.TabStop = false; + // + //lblTitle + // + this.lblTitle.AutoSize = true; + this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (14.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblTitle.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblTitle.Location = new System.Drawing.Point(16, 16); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(122, 27); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "mRemoteNG"; + this.lblTitle.UseCompatibleTextRendering = true; + // + //lblVersion + // + this.lblVersion.AutoSize = true; + this.lblVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblVersion.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblVersion.Location = new System.Drawing.Point(16, 56); + this.lblVersion.Name = "lblVersion"; + this.lblVersion.Size = new System.Drawing.Size(57, 22); + this.lblVersion.TabIndex = 1; + this.lblVersion.Text = "Version"; + this.lblVersion.UseCompatibleTextRendering = true; + // + //lblChangeLog + // + this.lblChangeLog.AutoSize = true; + this.lblChangeLog.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblChangeLog.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblChangeLog.Location = new System.Drawing.Point(16, 199); + this.lblChangeLog.Name = "lblChangeLog"; + this.lblChangeLog.Size = new System.Drawing.Size(92, 22); + this.lblChangeLog.TabIndex = 6; + this.lblChangeLog.Text = "Change Log:"; + this.lblChangeLog.UseCompatibleTextRendering = true; + // + //lblLicense + // + this.lblLicense.AutoSize = true; + this.lblLicense.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblLicense.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblLicense.Location = new System.Drawing.Point(16, 96); + this.lblLicense.Name = "lblLicense"; + this.lblLicense.Size = new System.Drawing.Size(58, 22); + this.lblLicense.TabIndex = 5; + this.lblLicense.Text = "License"; + this.lblLicense.UseCompatibleTextRendering = true; + // + //lblCopyright + // + this.lblCopyright.AutoSize = true; + this.lblCopyright.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCopyright.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblCopyright.Location = new System.Drawing.Point(16, 76); + this.lblCopyright.Name = "lblCopyright"; + this.lblCopyright.Size = new System.Drawing.Size(70, 22); + this.lblCopyright.TabIndex = 2; + this.lblCopyright.Text = "Copyright"; + this.lblCopyright.UseCompatibleTextRendering = true; + // + //About + // + this.BackColor = System.Drawing.SystemColors.Control; + this.ClientSize = new System.Drawing.Size(784, 564); + this.Controls.Add(this.pnlTop); + this.Controls.Add(this.pnlBottom); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.ForeColor = System.Drawing.SystemColors.ControlText; + this.Icon = global::My.Resources.Resources.mRemote_Icon; + this.MaximumSize = new System.Drawing.Size(20000, 10000); + this.Name = "About"; + this.TabText = "About"; + this.Text = "About"; + this.pnlTop.ResumeLayout(false); + this.pnlTop.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbLogo).EndInit(); + this.pnlBottom.ResumeLayout(false); + this.pnlBottom.PerformLayout(); + this.ResumeLayout(false); + + } + #endregion + + #region Public Methods + public About(DockContent Panel) + { + this.WindowType = Type.About; + this.DockPnl = Panel; + this.InitializeComponent(); + App.Runtime.FontOverride(this); + } + #endregion + + #region Private Methods + private void ApplyLanguage() + { + lblLicense.Text = My.Language.strLabelReleasedUnderGPL; + lblChangeLog.Text = My.Language.strLabelChangeLog; + TabText = My.Language.strAbout; + Text = My.Language.strAbout; + } + + private void ApplyEditions() + { + #if PORTABLE + lblEdition.Text = My.Language.strLabelPortableEdition; + lblEdition.Visible = true; + #endif + } + + private void FillLinkLabel(LinkLabel llbl, string Text, string URL) + { + llbl.Links.Clear(); + + int Open = Text.IndexOf("["); + int Close = 0; + while (Open != -1) { - -#region Form Init - internal System.Windows.Forms.Label lblCopyright; - internal System.Windows.Forms.Label lblTitle; - internal System.Windows.Forms.Label lblVersion; - internal System.Windows.Forms.Label lblLicense; - internal System.Windows.Forms.TextBox txtChangeLog; - internal System.Windows.Forms.Label lblChangeLog; - internal System.Windows.Forms.Panel pnlBottom; - internal System.Windows.Forms.PictureBox pbLogo; - internal System.Windows.Forms.Label lblEdition; - internal System.Windows.Forms.LinkLabel llblFAMFAMFAM; - internal System.Windows.Forms.LinkLabel llblMagicLibrary; - internal System.Windows.Forms.LinkLabel llblWeifenLuo; - internal System.Windows.Forms.Panel pnlTop; - - private void InitializeComponent() + Text = Text.Remove(Open, 1); + Close = Text.IndexOf("]", Open); + if (Close == -1) { - this.pnlTop = new System.Windows.Forms.Panel(); - this.Load += new System.EventHandler(About_Load); - this.lblEdition = new System.Windows.Forms.Label(); - this.pbLogo = new System.Windows.Forms.PictureBox(); - this.pnlBottom = new System.Windows.Forms.Panel(); - this.llblWeifenLuo = new System.Windows.Forms.LinkLabel(); - this.llblWeifenLuo.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblWeifenLuo_LinkClicked); - this.llblMagicLibrary = new System.Windows.Forms.LinkLabel(); - this.llblMagicLibrary.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblMagicLibrary_LinkClicked); - this.llblFAMFAMFAM = new System.Windows.Forms.LinkLabel(); - this.llblFAMFAMFAM.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llblFAMFAMFAM_LinkClicked); - this.txtChangeLog = new System.Windows.Forms.TextBox(); - this.lblTitle = new System.Windows.Forms.Label(); - this.lblVersion = new System.Windows.Forms.Label(); - this.lblChangeLog = new System.Windows.Forms.Label(); - this.lblLicense = new System.Windows.Forms.Label(); - this.lblCopyright = new System.Windows.Forms.Label(); - this.pnlTop.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbLogo).BeginInit(); - this.pnlBottom.SuspendLayout(); - this.SuspendLayout(); - // - //pnlTop - // - this.pnlTop.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlTop.BackColor = System.Drawing.Color.Black; - this.pnlTop.Controls.Add(this.lblEdition); - this.pnlTop.Controls.Add(this.pbLogo); - this.pnlTop.ForeColor = System.Drawing.Color.White; - this.pnlTop.Location = new System.Drawing.Point(-1, -1); - this.pnlTop.Name = "pnlTop"; - this.pnlTop.Size = new System.Drawing.Size(788, 145); - this.pnlTop.TabIndex = 0; - // - //lblEdition - // - this.lblEdition.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.lblEdition.BackColor = System.Drawing.Color.Black; - this.lblEdition.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (14.25F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblEdition.ForeColor = System.Drawing.Color.White; - this.lblEdition.Location = new System.Drawing.Point(512, 112); - this.lblEdition.Name = "lblEdition"; - this.lblEdition.Size = new System.Drawing.Size(264, 24); - this.lblEdition.TabIndex = 0; - this.lblEdition.Text = "Edition"; - this.lblEdition.TextAlign = System.Drawing.ContentAlignment.BottomRight; - this.lblEdition.Visible = false; - // - //pbLogo - // - this.pbLogo.Image = global::My.Resources.Resources.Logo; - this.pbLogo.Location = new System.Drawing.Point(8, 8); - this.pbLogo.Name = "pbLogo"; - this.pbLogo.Size = new System.Drawing.Size(492, 128); - this.pbLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pbLogo.TabIndex = 1; - this.pbLogo.TabStop = false; - // - //pnlBottom - // - this.pnlBottom.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlBottom.BackColor = System.Drawing.SystemColors.Control; - this.pnlBottom.Controls.Add(this.llblWeifenLuo); - this.pnlBottom.Controls.Add(this.llblMagicLibrary); - this.pnlBottom.Controls.Add(this.llblFAMFAMFAM); - this.pnlBottom.Controls.Add(this.txtChangeLog); - this.pnlBottom.Controls.Add(this.lblTitle); - this.pnlBottom.Controls.Add(this.lblVersion); - this.pnlBottom.Controls.Add(this.lblChangeLog); - this.pnlBottom.Controls.Add(this.lblLicense); - this.pnlBottom.Controls.Add(this.lblCopyright); - this.pnlBottom.ForeColor = System.Drawing.SystemColors.ControlText; - this.pnlBottom.Location = new System.Drawing.Point(-1, 144); - this.pnlBottom.Name = "pnlBottom"; - this.pnlBottom.Size = new System.Drawing.Size(788, 418); - this.pnlBottom.TabIndex = 1; - // - //llblWeifenLuo - // - this.llblWeifenLuo.AutoSize = true; - this.llblWeifenLuo.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.llblWeifenLuo.ForeColor = System.Drawing.SystemColors.ControlText; - this.llblWeifenLuo.LinkColor = System.Drawing.Color.Blue; - this.llblWeifenLuo.Location = new System.Drawing.Point(16, 158); - this.llblWeifenLuo.Name = "llblWeifenLuo"; - this.llblWeifenLuo.Size = new System.Drawing.Size(78, 22); - this.llblWeifenLuo.TabIndex = 9; - this.llblWeifenLuo.TabStop = true; - this.llblWeifenLuo.Text = "WeifenLuo"; - this.llblWeifenLuo.UseCompatibleTextRendering = true; - // - //llblMagicLibrary - // - this.llblMagicLibrary.AutoSize = true; - this.llblMagicLibrary.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.llblMagicLibrary.ForeColor = System.Drawing.SystemColors.ControlText; - this.llblMagicLibrary.LinkColor = System.Drawing.Color.Blue; - this.llblMagicLibrary.Location = new System.Drawing.Point(16, 136); - this.llblMagicLibrary.Name = "llblMagicLibrary"; - this.llblMagicLibrary.Size = new System.Drawing.Size(92, 22); - this.llblMagicLibrary.TabIndex = 8; - this.llblMagicLibrary.TabStop = true; - this.llblMagicLibrary.Text = "MagicLibrary"; - this.llblMagicLibrary.UseCompatibleTextRendering = true; - // - //llblFAMFAMFAM - // - this.llblFAMFAMFAM.AutoSize = true; - this.llblFAMFAMFAM.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.llblFAMFAMFAM.ForeColor = System.Drawing.SystemColors.ControlText; - this.llblFAMFAMFAM.LinkColor = System.Drawing.Color.Blue; - this.llblFAMFAMFAM.Location = new System.Drawing.Point(16, 116); - this.llblFAMFAMFAM.Name = "llblFAMFAMFAM"; - this.llblFAMFAMFAM.Size = new System.Drawing.Size(101, 22); - this.llblFAMFAMFAM.TabIndex = 4; - this.llblFAMFAMFAM.TabStop = true; - this.llblFAMFAMFAM.Text = "FAMFAMFAM"; - this.llblFAMFAMFAM.UseCompatibleTextRendering = true; - // - //txtChangeLog - // - this.txtChangeLog.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtChangeLog.BackColor = System.Drawing.SystemColors.Control; - this.txtChangeLog.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtChangeLog.Cursor = System.Windows.Forms.Cursors.Default; - this.txtChangeLog.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (9.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.txtChangeLog.ForeColor = System.Drawing.SystemColors.ControlText; - this.txtChangeLog.Location = new System.Drawing.Point(24, 224); - this.txtChangeLog.Multiline = true; - this.txtChangeLog.Name = "txtChangeLog"; - this.txtChangeLog.ReadOnly = true; - this.txtChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtChangeLog.Size = new System.Drawing.Size(760, 192); - this.txtChangeLog.TabIndex = 7; - this.txtChangeLog.TabStop = false; - // - //lblTitle - // - this.lblTitle.AutoSize = true; - this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (14.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblTitle.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblTitle.Location = new System.Drawing.Point(16, 16); - this.lblTitle.Name = "lblTitle"; - this.lblTitle.Size = new System.Drawing.Size(122, 27); - this.lblTitle.TabIndex = 0; - this.lblTitle.Text = "mRemoteNG"; - this.lblTitle.UseCompatibleTextRendering = true; - // - //lblVersion - // - this.lblVersion.AutoSize = true; - this.lblVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblVersion.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblVersion.Location = new System.Drawing.Point(16, 56); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(57, 22); - this.lblVersion.TabIndex = 1; - this.lblVersion.Text = "Version"; - this.lblVersion.UseCompatibleTextRendering = true; - // - //lblChangeLog - // - this.lblChangeLog.AutoSize = true; - this.lblChangeLog.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblChangeLog.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblChangeLog.Location = new System.Drawing.Point(16, 199); - this.lblChangeLog.Name = "lblChangeLog"; - this.lblChangeLog.Size = new System.Drawing.Size(92, 22); - this.lblChangeLog.TabIndex = 6; - this.lblChangeLog.Text = "Change Log:"; - this.lblChangeLog.UseCompatibleTextRendering = true; - // - //lblLicense - // - this.lblLicense.AutoSize = true; - this.lblLicense.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblLicense.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblLicense.Location = new System.Drawing.Point(16, 96); - this.lblLicense.Name = "lblLicense"; - this.lblLicense.Size = new System.Drawing.Size(58, 22); - this.lblLicense.TabIndex = 5; - this.lblLicense.Text = "License"; - this.lblLicense.UseCompatibleTextRendering = true; - // - //lblCopyright - // - this.lblCopyright.AutoSize = true; - this.lblCopyright.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (11.0F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCopyright.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblCopyright.Location = new System.Drawing.Point(16, 76); - this.lblCopyright.Name = "lblCopyright"; - this.lblCopyright.Size = new System.Drawing.Size(70, 22); - this.lblCopyright.TabIndex = 2; - this.lblCopyright.Text = "Copyright"; - this.lblCopyright.UseCompatibleTextRendering = true; - // - //About - // - this.BackColor = System.Drawing.SystemColors.Control; - this.ClientSize = new System.Drawing.Size(784, 564); - this.Controls.Add(this.pnlTop); - this.Controls.Add(this.pnlBottom); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.ForeColor = System.Drawing.SystemColors.ControlText; - this.Icon = global::My.Resources.Resources.mRemote_Icon; - this.MaximumSize = new System.Drawing.Size(20000, 10000); - this.Name = "About"; - this.TabText = "About"; - this.Text = "About"; - this.pnlTop.ResumeLayout(false); - this.pnlTop.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbLogo).EndInit(); - this.pnlBottom.ResumeLayout(false); - this.pnlBottom.PerformLayout(); - this.ResumeLayout(false); - + break; } -#endregion - -#region Public Methods - public About(DockContent Panel) - { - this.WindowType = Type.About; - this.DockPnl = Panel; - this.InitializeComponent(); - App.Runtime.FontOverride(this); - } -#endregion - -#region Private Methods - private void ApplyLanguage() - { - lblLicense.Text = My.Language.strLabelReleasedUnderGPL; - lblChangeLog.Text = My.Language.strLabelChangeLog; - TabText = My.Language.strAbout; - Text = My.Language.strAbout; - } - - private void ApplyEditions() - { -#if PORTABLE - lblEdition.Text = My.Language.strLabelPortableEdition; - lblEdition.Visible = true; -#endif - } - - private void FillLinkLabel(LinkLabel llbl, string Text, string URL) - { - llbl.Links.Clear(); - - int Open = Text.IndexOf("["); - int Close = 0; - while (Open != -1) - { - Text = Text.Remove(Open, 1); - Close = Text.IndexOf("]", Open); - if (Close == -1) - { - break; - } - Text = Text.Remove(Close, 1); - llbl.Links.Add(Open, Close - Open, URL); - Open = Text.IndexOf("[", Open); - } - - llbl.Text = Text; - } -#endregion - -#region Form Stuff - private void About_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - ApplyEditions(); - - try - { - lblCopyright.Text = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Copyright; - - this.lblVersion.Text = "Version " + (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version.ToString(); - - FillLinkLabel(llblFAMFAMFAM, My.Language.strFAMFAMFAMAttribution, My.Language.strFAMFAMFAMAttributionURL); - FillLinkLabel(llblMagicLibrary, My.Language.strMagicLibraryAttribution, My.Language.strMagicLibraryAttributionURL); - FillLinkLabel(llblWeifenLuo, My.Language.strWeifenLuoAttribution, My.Language.strWeifenLuoAttributionURL); - - if (File.Exists((new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\CHANGELOG.TXT")) - { - StreamReader sR = new StreamReader((new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\CHANGELOG.TXT"); - this.txtChangeLog.Text = sR.ReadToEnd(); - sR.Close(); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Loading About failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void llblFAMFAMFAM_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) - { - App.Runtime.GoToURL(My.Language.strFAMFAMFAMAttributionURL); - } - - private void llblMagicLibrary_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) - { - App.Runtime.GoToURL(My.Language.strMagicLibraryAttributionURL); - } - - private void llblWeifenLuo_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) - { - App.Runtime.GoToURL(My.Language.strWeifenLuoAttributionURL); - } -#endregion + Text = Text.Remove(Close, 1); + llbl.Links.Add(Open, Close - Open, URL); + Open = Text.IndexOf("[", Open); } + + llbl.Text = Text; + } + #endregion + + #region Form Stuff + private void About_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + ApplyEditions(); + + try + { + lblCopyright.Text = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Copyright; + + this.lblVersion.Text = "Version " + (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version.ToString(); + + FillLinkLabel(llblFAMFAMFAM, My.Language.strFAMFAMFAMAttribution, My.Language.strFAMFAMFAMAttributionURL); + FillLinkLabel(llblMagicLibrary, My.Language.strMagicLibraryAttribution, My.Language.strMagicLibraryAttributionURL); + FillLinkLabel(llblWeifenLuo, My.Language.strWeifenLuoAttribution, My.Language.strWeifenLuoAttributionURL); + + if (File.Exists((new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\CHANGELOG.TXT")) + { + StreamReader sR = new StreamReader((new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\CHANGELOG.TXT"); + this.txtChangeLog.Text = sR.ReadToEnd(); + sR.Close(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Loading About failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void llblFAMFAMFAM_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) + { + App.Runtime.GoToURL(My.Language.strFAMFAMFAMAttributionURL); + } + + private void llblMagicLibrary_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) + { + App.Runtime.GoToURL(My.Language.strMagicLibraryAttributionURL); + } + + private void llblWeifenLuo_LinkClicked(System.Object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) + { + App.Runtime.GoToURL(My.Language.strWeifenLuoAttributionURL); + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Announcement.cs b/mRemoteV1/CS/UI/UI.Window.Announcement.cs index 448bac2a7..1802c5b99 100644 --- a/mRemoteV1/CS/UI/UI.Window.Announcement.cs +++ b/mRemoteV1/CS/UI/UI.Window.Announcement.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,99 +8,97 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.ComponentModel; using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public partial class Announcement : Base + { + #region Public Methods + public Announcement(DockContent panel) + { + WindowType = Type.Announcement; + DockPnl = panel; + InitializeComponent(); + } + #endregion + + #region Private Fields + private App.Update _appUpdate; + #endregion + + #region Private Methods + public void Announcement_Load(object sender, EventArgs e) + { + webBrowser.Navigated += webBrowser_Navigated; + + ApplyLanguage(); + CheckForAnnouncement(); + } + + private void ApplyLanguage() + { + + } + + private void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) + { + // This can only be set once the WebBrowser control is shown, it will throw a COM exception otherwise. + webBrowser.AllowWebBrowserDrop = false; + + webBrowser.Navigated -= webBrowser_Navigated; + } + + private void CheckForAnnouncement() + { + if (_appUpdate == null) { -#region Public Methods - public Announcement(DockContent panel) - { - WindowType = Type.Announcement; - DockPnl = panel; - InitializeComponent(); - } -#endregion - -#region Private Fields - private App.Update _appUpdate; -#endregion - -#region Private Methods - public void Announcement_Load(object sender, EventArgs e) - { - webBrowser.Navigated += webBrowser_Navigated; - - ApplyLanguage(); - CheckForAnnouncement(); - } - - private void ApplyLanguage() - { - - } - - private void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) - { - // This can only be set once the WebBrowser control is shown, it will throw a COM exception otherwise. - webBrowser.AllowWebBrowserDrop = false; - - webBrowser.Navigated -= webBrowser_Navigated; - } - - private void CheckForAnnouncement() - { - if (_appUpdate == null) - { - _appUpdate = new App.Update(); - _appUpdate.Load += _appUpdate.Update_Load; - } - else if (_appUpdate.IsGetAnnouncementInfoRunning) - { - return ; - } - - _appUpdate.GetAnnouncementInfoCompletedEvent += GetAnnouncementInfoCompleted; - - _appUpdate.GetAnnouncementInfoAsync(); - } - - private void GetAnnouncementInfoCompleted(object sender, AsyncCompletedEventArgs e) - { - if (InvokeRequired) - { - AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetAnnouncementInfoCompleted); - Invoke(myDelegate, new object[] {sender, e}); - return ; - } - - try - { - _appUpdate.GetAnnouncementInfoCompletedEvent -= GetAnnouncementInfoCompleted; - - if (e.Cancelled) - { - return ; - } - if (e.Error != null) - { - throw (e.Error); - } - - webBrowser.Navigate(_appUpdate.CurrentAnnouncementInfo.Address); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(Language.strUpdateGetAnnouncementInfoFailed, ex); - } - } -#endregion + _appUpdate = new App.Update(); + _appUpdate.Load += _appUpdate.Update_Load; } + else if (_appUpdate.IsGetAnnouncementInfoRunning) + { + return ; + } + + _appUpdate.GetAnnouncementInfoCompletedEvent += GetAnnouncementInfoCompleted; + + _appUpdate.GetAnnouncementInfoAsync(); + } + + private void GetAnnouncementInfoCompleted(object sender, AsyncCompletedEventArgs e) + { + if (InvokeRequired) + { + AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetAnnouncementInfoCompleted); + Invoke(myDelegate, new object[] {sender, e}); + return ; + } + + try + { + _appUpdate.GetAnnouncementInfoCompletedEvent -= GetAnnouncementInfoCompleted; + + if (e.Cancelled) + { + return ; + } + if (e.Error != null) + { + throw (e.Error); + } + + webBrowser.Navigate(_appUpdate.CurrentAnnouncementInfo.Address); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateGetAnnouncementInfoFailed, ex); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Base.cs b/mRemoteV1/CS/UI/UI.Window.Base.cs index 90a83ffad..8d60ed4cd 100644 --- a/mRemoteV1/CS/UI/UI.Window.Base.cs +++ b/mRemoteV1/CS/UI/UI.Window.Base.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,102 +8,98 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using WeifenLuo.WinFormsUI.Docking; namespace mRemoteNG.UI.Window { public class Base : DockContent - { - public Base() - { - InitializeComponent(); + { + public Base() + { + InitializeComponent(); - //Added to support default instance behavour in C# - if (defaultInstance == null) - defaultInstance = this; - } + //Added to support default instance behavour in C# + if (defaultInstance == null) + defaultInstance = this; + } -#region Default Instance + #region Default Instance + private static Base defaultInstance; - private static Base defaultInstance; - - /// - /// Added by the VB.Net to C# Converter to support default instance behavour in C# - /// -public static Base Default + /// + /// Added by the VB.Net to C# Converter to support default instance behavour in C# + /// + public static Base Default + { + get + { + if (defaultInstance == null) { - get - { - if (defaultInstance == null) - { - defaultInstance = new Base(); - defaultInstance.FormClosed += new FormClosedEventHandler(defaultInstance_FormClosed); - } + defaultInstance = new Base(); + defaultInstance.FormClosed += new FormClosedEventHandler(defaultInstance_FormClosed); + } - return defaultInstance; - } - set - { - defaultInstance = value; - } - } - - static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e) - { - defaultInstance = null; - } - -#endregion - -#region Public Properties - private Type _WindowType; -public Type WindowType - { - get - { - return this._WindowType; - } - set - { - this._WindowType = value; - } - } - - private DockContent _DockPnl; -public DockContent DockPnl - { - get - { - return this._DockPnl; - } - set - { - this._DockPnl = value; - } - } -#endregion - -#region Public Methods - public void SetFormText(string Text) - { - this.Text = Text; - this.TabText = Text; - } -#endregion - -#region Private Methods - private void Base_Load(System.Object sender, System.EventArgs e) - { - frmMain.Default.ShowHidePanelTabs(); - } - - private void Base_FormClosed(System.Object sender, System.Windows.Forms.FormClosedEventArgs e) - { - frmMain.Default.ShowHidePanelTabs(this); - } -#endregion + return defaultInstance; } + set + { + defaultInstance = value; + } + } + + static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e) + { + defaultInstance = null; + } + #endregion + + #region Public Properties + private Type _WindowType; + public Type WindowType + { + get + { + return this._WindowType; + } + set + { + this._WindowType = value; + } + } + + private DockContent _DockPnl; + public DockContent DockPnl + { + get + { + return this._DockPnl; + } + set + { + this._DockPnl = value; + } + } + #endregion + + #region Public Methods + public void SetFormText(string Text) + { + this.Text = Text; + this.TabText = Text; + } + #endregion + + #region Private Methods + private void Base_Load(System.Object sender, System.EventArgs e) + { + frmMain.Default.ShowHidePanelTabs(); + } + + private void Base_FormClosed(System.Object sender, System.Windows.Forms.FormClosedEventArgs e) + { + frmMain.Default.ShowHidePanelTabs(this); + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.ComponentsCheck.cs b/mRemoteV1/CS/UI/UI.Window.ComponentsCheck.cs index 13b9557ef..bf7b0ae15 100644 --- a/mRemoteV1/CS/UI/UI.Window.ComponentsCheck.cs +++ b/mRemoteV1/CS/UI/UI.Window.ComponentsCheck.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,710 +8,707 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using WeifenLuo.WinFormsUI.Docking; using System.IO; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.Threading; namespace mRemoteNG.UI.Window { public class ComponentsCheck : Base + { + #region Form Stuff + internal System.Windows.Forms.PictureBox pbCheck1; + internal System.Windows.Forms.Label lblCheck1; + internal System.Windows.Forms.Panel pnlCheck2; + internal System.Windows.Forms.Label lblCheck2; + internal System.Windows.Forms.PictureBox pbCheck2; + internal System.Windows.Forms.Panel pnlCheck3; + internal System.Windows.Forms.Label lblCheck3; + internal System.Windows.Forms.PictureBox pbCheck3; + internal System.Windows.Forms.Panel pnlCheck4; + internal System.Windows.Forms.Label lblCheck4; + internal System.Windows.Forms.PictureBox pbCheck4; + internal System.Windows.Forms.Panel pnlCheck5; + internal System.Windows.Forms.Label lblCheck5; + internal System.Windows.Forms.PictureBox pbCheck5; + internal System.Windows.Forms.Button btnCheckAgain; + internal System.Windows.Forms.TextBox txtCheck1; + internal System.Windows.Forms.TextBox txtCheck2; + internal System.Windows.Forms.TextBox txtCheck3; + internal System.Windows.Forms.TextBox txtCheck4; + internal System.Windows.Forms.TextBox txtCheck5; + internal System.Windows.Forms.CheckBox chkAlwaysShow; + internal System.Windows.Forms.Panel pnlChecks; + internal System.Windows.Forms.Panel pnlCheck6; + internal System.Windows.Forms.TextBox txtCheck6; + internal System.Windows.Forms.Label lblCheck6; + internal System.Windows.Forms.PictureBox pbCheck6; + internal System.Windows.Forms.Panel pnlCheck1; + + private void InitializeComponent() + { + this.pnlCheck1 = new System.Windows.Forms.Panel(); + this.Load += new System.EventHandler(ComponentsCheck_Load); + this.txtCheck1 = new System.Windows.Forms.TextBox(); + this.lblCheck1 = new System.Windows.Forms.Label(); + this.pbCheck1 = new System.Windows.Forms.PictureBox(); + this.pnlCheck2 = new System.Windows.Forms.Panel(); + this.txtCheck2 = new System.Windows.Forms.TextBox(); + this.lblCheck2 = new System.Windows.Forms.Label(); + this.pbCheck2 = new System.Windows.Forms.PictureBox(); + this.pnlCheck3 = new System.Windows.Forms.Panel(); + this.txtCheck3 = new System.Windows.Forms.TextBox(); + this.lblCheck3 = new System.Windows.Forms.Label(); + this.pbCheck3 = new System.Windows.Forms.PictureBox(); + this.pnlCheck4 = new System.Windows.Forms.Panel(); + this.txtCheck4 = new System.Windows.Forms.TextBox(); + this.lblCheck4 = new System.Windows.Forms.Label(); + this.pbCheck4 = new System.Windows.Forms.PictureBox(); + this.pnlCheck5 = new System.Windows.Forms.Panel(); + this.txtCheck5 = new System.Windows.Forms.TextBox(); + this.lblCheck5 = new System.Windows.Forms.Label(); + this.pbCheck5 = new System.Windows.Forms.PictureBox(); + this.btnCheckAgain = new System.Windows.Forms.Button(); + this.btnCheckAgain.Click += new System.EventHandler(this.btnCheckAgain_Click); + this.chkAlwaysShow = new System.Windows.Forms.CheckBox(); + this.chkAlwaysShow.CheckedChanged += new System.EventHandler(this.chkAlwaysShow_CheckedChanged); + this.pnlChecks = new System.Windows.Forms.Panel(); + this.pnlCheck6 = new System.Windows.Forms.Panel(); + this.txtCheck6 = new System.Windows.Forms.TextBox(); + this.lblCheck6 = new System.Windows.Forms.Label(); + this.pbCheck6 = new System.Windows.Forms.PictureBox(); + this.pnlCheck1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck1).BeginInit(); + this.pnlCheck2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck2).BeginInit(); + this.pnlCheck3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck3).BeginInit(); + this.pnlCheck4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck4).BeginInit(); + this.pnlCheck5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck5).BeginInit(); + this.pnlChecks.SuspendLayout(); + this.pnlCheck6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck6).BeginInit(); + this.SuspendLayout(); + // + //pnlCheck1 + // + this.pnlCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck1.Controls.Add(this.txtCheck1); + this.pnlCheck1.Controls.Add(this.lblCheck1); + this.pnlCheck1.Controls.Add(this.pbCheck1); + this.pnlCheck1.Location = new System.Drawing.Point(3, 3); + this.pnlCheck1.Name = "pnlCheck1"; + this.pnlCheck1.Size = new System.Drawing.Size(562, 130); + this.pnlCheck1.TabIndex = 10; + this.pnlCheck1.Visible = false; + // + //txtCheck1 + // + this.txtCheck1.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck1.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck1.Location = new System.Drawing.Point(129, 29); + this.txtCheck1.Multiline = true; + this.txtCheck1.Name = "txtCheck1"; + this.txtCheck1.ReadOnly = true; + this.txtCheck1.Size = new System.Drawing.Size(430, 97); + this.txtCheck1.TabIndex = 2; + // + //lblCheck1 + // + this.lblCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck1.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck1.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblCheck1.Location = new System.Drawing.Point(108, 3); + this.lblCheck1.Name = "lblCheck1"; + this.lblCheck1.Size = new System.Drawing.Size(451, 23); + this.lblCheck1.TabIndex = 1; + this.lblCheck1.Text = "RDP check succeeded!"; + // + //pbCheck1 + // + this.pbCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck1.Location = new System.Drawing.Point(3, 3); + this.pbCheck1.Name = "pbCheck1"; + this.pbCheck1.Size = new System.Drawing.Size(72, 123); + this.pbCheck1.TabIndex = 0; + this.pbCheck1.TabStop = false; + // + //pnlCheck2 + // + this.pnlCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck2.Controls.Add(this.txtCheck2); + this.pnlCheck2.Controls.Add(this.lblCheck2); + this.pnlCheck2.Controls.Add(this.pbCheck2); + this.pnlCheck2.Location = new System.Drawing.Point(3, 139); + this.pnlCheck2.Name = "pnlCheck2"; + this.pnlCheck2.Size = new System.Drawing.Size(562, 130); + this.pnlCheck2.TabIndex = 20; + this.pnlCheck2.Visible = false; + // + //txtCheck2 + // + this.txtCheck2.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck2.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck2.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck2.Location = new System.Drawing.Point(129, 29); + this.txtCheck2.Multiline = true; + this.txtCheck2.Name = "txtCheck2"; + this.txtCheck2.ReadOnly = true; + this.txtCheck2.Size = new System.Drawing.Size(430, 97); + this.txtCheck2.TabIndex = 2; + // + //lblCheck2 + // + this.lblCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck2.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck2.Location = new System.Drawing.Point(112, 3); + this.lblCheck2.Name = "lblCheck2"; + this.lblCheck2.Size = new System.Drawing.Size(447, 23); + this.lblCheck2.TabIndex = 1; + this.lblCheck2.Text = "RDP check succeeded!"; + // + //pbCheck2 + // + this.pbCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck2.Location = new System.Drawing.Point(3, 3); + this.pbCheck2.Name = "pbCheck2"; + this.pbCheck2.Size = new System.Drawing.Size(72, 123); + this.pbCheck2.TabIndex = 0; + this.pbCheck2.TabStop = false; + // + //pnlCheck3 + // + this.pnlCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck3.Controls.Add(this.txtCheck3); + this.pnlCheck3.Controls.Add(this.lblCheck3); + this.pnlCheck3.Controls.Add(this.pbCheck3); + this.pnlCheck3.Location = new System.Drawing.Point(3, 275); + this.pnlCheck3.Name = "pnlCheck3"; + this.pnlCheck3.Size = new System.Drawing.Size(562, 130); + this.pnlCheck3.TabIndex = 30; + this.pnlCheck3.Visible = false; + // + //txtCheck3 + // + this.txtCheck3.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck3.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck3.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck3.Location = new System.Drawing.Point(129, 29); + this.txtCheck3.Multiline = true; + this.txtCheck3.Name = "txtCheck3"; + this.txtCheck3.ReadOnly = true; + this.txtCheck3.Size = new System.Drawing.Size(430, 97); + this.txtCheck3.TabIndex = 2; + // + //lblCheck3 + // + this.lblCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck3.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck3.Location = new System.Drawing.Point(112, 3); + this.lblCheck3.Name = "lblCheck3"; + this.lblCheck3.Size = new System.Drawing.Size(447, 23); + this.lblCheck3.TabIndex = 1; + this.lblCheck3.Text = "RDP check succeeded!"; + // + //pbCheck3 + // + this.pbCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck3.Location = new System.Drawing.Point(3, 3); + this.pbCheck3.Name = "pbCheck3"; + this.pbCheck3.Size = new System.Drawing.Size(72, 123); + this.pbCheck3.TabIndex = 0; + this.pbCheck3.TabStop = false; + // + //pnlCheck4 + // + this.pnlCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck4.Controls.Add(this.txtCheck4); + this.pnlCheck4.Controls.Add(this.lblCheck4); + this.pnlCheck4.Controls.Add(this.pbCheck4); + this.pnlCheck4.Location = new System.Drawing.Point(3, 411); + this.pnlCheck4.Name = "pnlCheck4"; + this.pnlCheck4.Size = new System.Drawing.Size(562, 130); + this.pnlCheck4.TabIndex = 40; + this.pnlCheck4.Visible = false; + // + //txtCheck4 + // + this.txtCheck4.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck4.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck4.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck4.Location = new System.Drawing.Point(129, 30); + this.txtCheck4.Multiline = true; + this.txtCheck4.Name = "txtCheck4"; + this.txtCheck4.ReadOnly = true; + this.txtCheck4.Size = new System.Drawing.Size(430, 97); + this.txtCheck4.TabIndex = 2; + // + //lblCheck4 + // + this.lblCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck4.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck4.Location = new System.Drawing.Point(112, 3); + this.lblCheck4.Name = "lblCheck4"; + this.lblCheck4.Size = new System.Drawing.Size(447, 23); + this.lblCheck4.TabIndex = 1; + this.lblCheck4.Text = "RDP check succeeded!"; + // + //pbCheck4 + // + this.pbCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck4.Location = new System.Drawing.Point(3, 3); + this.pbCheck4.Name = "pbCheck4"; + this.pbCheck4.Size = new System.Drawing.Size(72, 123); + this.pbCheck4.TabIndex = 0; + this.pbCheck4.TabStop = false; + // + //pnlCheck5 + // + this.pnlCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck5.Controls.Add(this.txtCheck5); + this.pnlCheck5.Controls.Add(this.lblCheck5); + this.pnlCheck5.Controls.Add(this.pbCheck5); + this.pnlCheck5.Location = new System.Drawing.Point(3, 547); + this.pnlCheck5.Name = "pnlCheck5"; + this.pnlCheck5.Size = new System.Drawing.Size(562, 130); + this.pnlCheck5.TabIndex = 50; + this.pnlCheck5.Visible = false; + // + //txtCheck5 + // + this.txtCheck5.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck5.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck5.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck5.Location = new System.Drawing.Point(129, 29); + this.txtCheck5.Multiline = true; + this.txtCheck5.Name = "txtCheck5"; + this.txtCheck5.ReadOnly = true; + this.txtCheck5.Size = new System.Drawing.Size(430, 97); + this.txtCheck5.TabIndex = 2; + // + //lblCheck5 + // + this.lblCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck5.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck5.Location = new System.Drawing.Point(112, 3); + this.lblCheck5.Name = "lblCheck5"; + this.lblCheck5.Size = new System.Drawing.Size(447, 23); + this.lblCheck5.TabIndex = 1; + this.lblCheck5.Text = "RDP check succeeded!"; + // + //pbCheck5 + // + this.pbCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck5.Location = new System.Drawing.Point(3, 3); + this.pbCheck5.Name = "pbCheck5"; + this.pbCheck5.Size = new System.Drawing.Size(72, 123); + this.pbCheck5.TabIndex = 0; + this.pbCheck5.TabStop = false; + // + //btnCheckAgain + // + this.btnCheckAgain.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnCheckAgain.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnCheckAgain.Location = new System.Drawing.Point(476, 842); + this.btnCheckAgain.Name = "btnCheckAgain"; + this.btnCheckAgain.Size = new System.Drawing.Size(104, 23); + this.btnCheckAgain.TabIndex = 0; + this.btnCheckAgain.Text = "Check again"; + this.btnCheckAgain.UseVisualStyleBackColor = true; + // + //chkAlwaysShow + // + this.chkAlwaysShow.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left); + this.chkAlwaysShow.AutoSize = true; + this.chkAlwaysShow.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.chkAlwaysShow.Location = new System.Drawing.Point(12, 846); + this.chkAlwaysShow.Name = "chkAlwaysShow"; + this.chkAlwaysShow.Size = new System.Drawing.Size(185, 17); + this.chkAlwaysShow.TabIndex = 51; + this.chkAlwaysShow.Text = "Always show this screen at startup"; + this.chkAlwaysShow.UseVisualStyleBackColor = true; + // + //pnlChecks + // + this.pnlChecks.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlChecks.AutoScroll = true; + this.pnlChecks.Controls.Add(this.pnlCheck1); + this.pnlChecks.Controls.Add(this.pnlCheck2); + this.pnlChecks.Controls.Add(this.pnlCheck3); + this.pnlChecks.Controls.Add(this.pnlCheck6); + this.pnlChecks.Controls.Add(this.pnlCheck5); + this.pnlChecks.Controls.Add(this.pnlCheck4); + this.pnlChecks.Location = new System.Drawing.Point(12, 12); + this.pnlChecks.Name = "pnlChecks"; + this.pnlChecks.Size = new System.Drawing.Size(568, 824); + this.pnlChecks.TabIndex = 52; + // + //pnlCheck6 + // + this.pnlCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlCheck6.Controls.Add(this.txtCheck6); + this.pnlCheck6.Controls.Add(this.lblCheck6); + this.pnlCheck6.Controls.Add(this.pbCheck6); + this.pnlCheck6.Location = new System.Drawing.Point(3, 683); + this.pnlCheck6.Name = "pnlCheck6"; + this.pnlCheck6.Size = new System.Drawing.Size(562, 130); + this.pnlCheck6.TabIndex = 50; + this.pnlCheck6.Visible = false; + // + //txtCheck6 + // + this.txtCheck6.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtCheck6.BackColor = System.Drawing.SystemColors.Control; + this.txtCheck6.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCheck6.Location = new System.Drawing.Point(129, 29); + this.txtCheck6.Multiline = true; + this.txtCheck6.Name = "txtCheck6"; + this.txtCheck6.ReadOnly = true; + this.txtCheck6.Size = new System.Drawing.Size(430, 97); + this.txtCheck6.TabIndex = 2; + // + //lblCheck6 + // + this.lblCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblCheck6.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblCheck6.Location = new System.Drawing.Point(112, 3); + this.lblCheck6.Name = "lblCheck6"; + this.lblCheck6.Size = new System.Drawing.Size(447, 23); + this.lblCheck6.TabIndex = 1; + this.lblCheck6.Text = "RDP check succeeded!"; + // + //pbCheck6 + // + this.pbCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left); + this.pbCheck6.Location = new System.Drawing.Point(3, 3); + this.pbCheck6.Name = "pbCheck6"; + this.pbCheck6.Size = new System.Drawing.Size(72, 123); + this.pbCheck6.TabIndex = 0; + this.pbCheck6.TabStop = false; + // + //ComponentsCheck + // + this.ClientSize = new System.Drawing.Size(592, 877); + this.Controls.Add(this.pnlChecks); + this.Controls.Add(this.chkAlwaysShow); + this.Controls.Add(this.btnCheckAgain); + this.Icon = global::My.Resources.Resources.ComponentsCheck_Icon; + this.Name = "ComponentsCheck"; + this.TabText = "Components Check"; + this.Text = "Components Check"; + this.pnlCheck1.ResumeLayout(false); + this.pnlCheck1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck1).EndInit(); + this.pnlCheck2.ResumeLayout(false); + this.pnlCheck2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck2).EndInit(); + this.pnlCheck3.ResumeLayout(false); + this.pnlCheck3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck3).EndInit(); + this.pnlCheck4.ResumeLayout(false); + this.pnlCheck4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck4).EndInit(); + this.pnlCheck5.ResumeLayout(false); + this.pnlCheck5.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck5).EndInit(); + this.pnlChecks.ResumeLayout(false); + this.pnlCheck6.ResumeLayout(false); + this.pnlCheck6.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbCheck6).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + #region Public Methods + public ComponentsCheck(DockContent Panel) + { + this.WindowType = Type.ComponentsCheck; + this.DockPnl = Panel; + this.InitializeComponent(); + } + #endregion + + #region Form Stuff + private void ComponentsCheck_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + + chkAlwaysShow.Checked = System.Convert.ToBoolean(My.Settings.Default.StartupComponentsCheck); + CheckComponents(); + } + + private void ApplyLanguage() + { + TabText = My.Language.strComponentsCheck; + Text = My.Language.strComponentsCheck; + chkAlwaysShow.Text = My.Language.strCcAlwaysShowScreen; + btnCheckAgain.Text = My.Language.strCcCheckAgain; + } + + private void btnCheckAgain_Click(System.Object sender, System.EventArgs e) + { + CheckComponents(); + } + + private void chkAlwaysShow_CheckedChanged(System.Object sender, System.EventArgs e) + { + My.Settings.Default.StartupComponentsCheck = chkAlwaysShow.Checked; + My.Settings.Default.Save(); + } + #endregion + + #region Private Methods + private void CheckComponents() + { + string errorMsg = My.Language.strCcNotInstalledProperly; + + pnlCheck1.Visible = true; + pnlCheck2.Visible = true; + pnlCheck3.Visible = true; + pnlCheck4.Visible = true; + pnlCheck5.Visible = true; + pnlCheck6.Visible = true; + + + AxMSTSCLib.AxMsRdpClient5NotSafeForScripting rdpClient = null; + + try { - -#region Form Stuff - internal System.Windows.Forms.PictureBox pbCheck1; - internal System.Windows.Forms.Label lblCheck1; - internal System.Windows.Forms.Panel pnlCheck2; - internal System.Windows.Forms.Label lblCheck2; - internal System.Windows.Forms.PictureBox pbCheck2; - internal System.Windows.Forms.Panel pnlCheck3; - internal System.Windows.Forms.Label lblCheck3; - internal System.Windows.Forms.PictureBox pbCheck3; - internal System.Windows.Forms.Panel pnlCheck4; - internal System.Windows.Forms.Label lblCheck4; - internal System.Windows.Forms.PictureBox pbCheck4; - internal System.Windows.Forms.Panel pnlCheck5; - internal System.Windows.Forms.Label lblCheck5; - internal System.Windows.Forms.PictureBox pbCheck5; - internal System.Windows.Forms.Button btnCheckAgain; - internal System.Windows.Forms.TextBox txtCheck1; - internal System.Windows.Forms.TextBox txtCheck2; - internal System.Windows.Forms.TextBox txtCheck3; - internal System.Windows.Forms.TextBox txtCheck4; - internal System.Windows.Forms.TextBox txtCheck5; - internal System.Windows.Forms.CheckBox chkAlwaysShow; - internal System.Windows.Forms.Panel pnlChecks; - internal System.Windows.Forms.Panel pnlCheck6; - internal System.Windows.Forms.TextBox txtCheck6; - internal System.Windows.Forms.Label lblCheck6; - internal System.Windows.Forms.PictureBox pbCheck6; - internal System.Windows.Forms.Panel pnlCheck1; - - private void InitializeComponent() + rdpClient = new AxMSTSCLib.AxMsRdpClient5NotSafeForScripting(); + rdpClient.CreateControl(); + + while (!rdpClient.Created) { - this.pnlCheck1 = new System.Windows.Forms.Panel(); - this.Load += new System.EventHandler(ComponentsCheck_Load); - this.txtCheck1 = new System.Windows.Forms.TextBox(); - this.lblCheck1 = new System.Windows.Forms.Label(); - this.pbCheck1 = new System.Windows.Forms.PictureBox(); - this.pnlCheck2 = new System.Windows.Forms.Panel(); - this.txtCheck2 = new System.Windows.Forms.TextBox(); - this.lblCheck2 = new System.Windows.Forms.Label(); - this.pbCheck2 = new System.Windows.Forms.PictureBox(); - this.pnlCheck3 = new System.Windows.Forms.Panel(); - this.txtCheck3 = new System.Windows.Forms.TextBox(); - this.lblCheck3 = new System.Windows.Forms.Label(); - this.pbCheck3 = new System.Windows.Forms.PictureBox(); - this.pnlCheck4 = new System.Windows.Forms.Panel(); - this.txtCheck4 = new System.Windows.Forms.TextBox(); - this.lblCheck4 = new System.Windows.Forms.Label(); - this.pbCheck4 = new System.Windows.Forms.PictureBox(); - this.pnlCheck5 = new System.Windows.Forms.Panel(); - this.txtCheck5 = new System.Windows.Forms.TextBox(); - this.lblCheck5 = new System.Windows.Forms.Label(); - this.pbCheck5 = new System.Windows.Forms.PictureBox(); - this.btnCheckAgain = new System.Windows.Forms.Button(); - this.btnCheckAgain.Click += new System.EventHandler(this.btnCheckAgain_Click); - this.chkAlwaysShow = new System.Windows.Forms.CheckBox(); - this.chkAlwaysShow.CheckedChanged += new System.EventHandler(this.chkAlwaysShow_CheckedChanged); - this.pnlChecks = new System.Windows.Forms.Panel(); - this.pnlCheck6 = new System.Windows.Forms.Panel(); - this.txtCheck6 = new System.Windows.Forms.TextBox(); - this.lblCheck6 = new System.Windows.Forms.Label(); - this.pbCheck6 = new System.Windows.Forms.PictureBox(); - this.pnlCheck1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck1).BeginInit(); - this.pnlCheck2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck2).BeginInit(); - this.pnlCheck3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck3).BeginInit(); - this.pnlCheck4.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck4).BeginInit(); - this.pnlCheck5.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck5).BeginInit(); - this.pnlChecks.SuspendLayout(); - this.pnlCheck6.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck6).BeginInit(); - this.SuspendLayout(); - // - //pnlCheck1 - // - this.pnlCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck1.Controls.Add(this.txtCheck1); - this.pnlCheck1.Controls.Add(this.lblCheck1); - this.pnlCheck1.Controls.Add(this.pbCheck1); - this.pnlCheck1.Location = new System.Drawing.Point(3, 3); - this.pnlCheck1.Name = "pnlCheck1"; - this.pnlCheck1.Size = new System.Drawing.Size(562, 130); - this.pnlCheck1.TabIndex = 10; - this.pnlCheck1.Visible = false; - // - //txtCheck1 - // - this.txtCheck1.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck1.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck1.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck1.Location = new System.Drawing.Point(129, 29); - this.txtCheck1.Multiline = true; - this.txtCheck1.Name = "txtCheck1"; - this.txtCheck1.ReadOnly = true; - this.txtCheck1.Size = new System.Drawing.Size(430, 97); - this.txtCheck1.TabIndex = 2; - // - //lblCheck1 - // - this.lblCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck1.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck1.ForeColor = System.Drawing.SystemColors.ControlText; - this.lblCheck1.Location = new System.Drawing.Point(108, 3); - this.lblCheck1.Name = "lblCheck1"; - this.lblCheck1.Size = new System.Drawing.Size(451, 23); - this.lblCheck1.TabIndex = 1; - this.lblCheck1.Text = "RDP check succeeded!"; - // - //pbCheck1 - // - this.pbCheck1.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck1.Location = new System.Drawing.Point(3, 3); - this.pbCheck1.Name = "pbCheck1"; - this.pbCheck1.Size = new System.Drawing.Size(72, 123); - this.pbCheck1.TabIndex = 0; - this.pbCheck1.TabStop = false; - // - //pnlCheck2 - // - this.pnlCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck2.Controls.Add(this.txtCheck2); - this.pnlCheck2.Controls.Add(this.lblCheck2); - this.pnlCheck2.Controls.Add(this.pbCheck2); - this.pnlCheck2.Location = new System.Drawing.Point(3, 139); - this.pnlCheck2.Name = "pnlCheck2"; - this.pnlCheck2.Size = new System.Drawing.Size(562, 130); - this.pnlCheck2.TabIndex = 20; - this.pnlCheck2.Visible = false; - // - //txtCheck2 - // - this.txtCheck2.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck2.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck2.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck2.Location = new System.Drawing.Point(129, 29); - this.txtCheck2.Multiline = true; - this.txtCheck2.Name = "txtCheck2"; - this.txtCheck2.ReadOnly = true; - this.txtCheck2.Size = new System.Drawing.Size(430, 97); - this.txtCheck2.TabIndex = 2; - // - //lblCheck2 - // - this.lblCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck2.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck2.Location = new System.Drawing.Point(112, 3); - this.lblCheck2.Name = "lblCheck2"; - this.lblCheck2.Size = new System.Drawing.Size(447, 23); - this.lblCheck2.TabIndex = 1; - this.lblCheck2.Text = "RDP check succeeded!"; - // - //pbCheck2 - // - this.pbCheck2.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck2.Location = new System.Drawing.Point(3, 3); - this.pbCheck2.Name = "pbCheck2"; - this.pbCheck2.Size = new System.Drawing.Size(72, 123); - this.pbCheck2.TabIndex = 0; - this.pbCheck2.TabStop = false; - // - //pnlCheck3 - // - this.pnlCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck3.Controls.Add(this.txtCheck3); - this.pnlCheck3.Controls.Add(this.lblCheck3); - this.pnlCheck3.Controls.Add(this.pbCheck3); - this.pnlCheck3.Location = new System.Drawing.Point(3, 275); - this.pnlCheck3.Name = "pnlCheck3"; - this.pnlCheck3.Size = new System.Drawing.Size(562, 130); - this.pnlCheck3.TabIndex = 30; - this.pnlCheck3.Visible = false; - // - //txtCheck3 - // - this.txtCheck3.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck3.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck3.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck3.Location = new System.Drawing.Point(129, 29); - this.txtCheck3.Multiline = true; - this.txtCheck3.Name = "txtCheck3"; - this.txtCheck3.ReadOnly = true; - this.txtCheck3.Size = new System.Drawing.Size(430, 97); - this.txtCheck3.TabIndex = 2; - // - //lblCheck3 - // - this.lblCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck3.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck3.Location = new System.Drawing.Point(112, 3); - this.lblCheck3.Name = "lblCheck3"; - this.lblCheck3.Size = new System.Drawing.Size(447, 23); - this.lblCheck3.TabIndex = 1; - this.lblCheck3.Text = "RDP check succeeded!"; - // - //pbCheck3 - // - this.pbCheck3.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck3.Location = new System.Drawing.Point(3, 3); - this.pbCheck3.Name = "pbCheck3"; - this.pbCheck3.Size = new System.Drawing.Size(72, 123); - this.pbCheck3.TabIndex = 0; - this.pbCheck3.TabStop = false; - // - //pnlCheck4 - // - this.pnlCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck4.Controls.Add(this.txtCheck4); - this.pnlCheck4.Controls.Add(this.lblCheck4); - this.pnlCheck4.Controls.Add(this.pbCheck4); - this.pnlCheck4.Location = new System.Drawing.Point(3, 411); - this.pnlCheck4.Name = "pnlCheck4"; - this.pnlCheck4.Size = new System.Drawing.Size(562, 130); - this.pnlCheck4.TabIndex = 40; - this.pnlCheck4.Visible = false; - // - //txtCheck4 - // - this.txtCheck4.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck4.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck4.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck4.Location = new System.Drawing.Point(129, 30); - this.txtCheck4.Multiline = true; - this.txtCheck4.Name = "txtCheck4"; - this.txtCheck4.ReadOnly = true; - this.txtCheck4.Size = new System.Drawing.Size(430, 97); - this.txtCheck4.TabIndex = 2; - // - //lblCheck4 - // - this.lblCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck4.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck4.Location = new System.Drawing.Point(112, 3); - this.lblCheck4.Name = "lblCheck4"; - this.lblCheck4.Size = new System.Drawing.Size(447, 23); - this.lblCheck4.TabIndex = 1; - this.lblCheck4.Text = "RDP check succeeded!"; - // - //pbCheck4 - // - this.pbCheck4.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck4.Location = new System.Drawing.Point(3, 3); - this.pbCheck4.Name = "pbCheck4"; - this.pbCheck4.Size = new System.Drawing.Size(72, 123); - this.pbCheck4.TabIndex = 0; - this.pbCheck4.TabStop = false; - // - //pnlCheck5 - // - this.pnlCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck5.Controls.Add(this.txtCheck5); - this.pnlCheck5.Controls.Add(this.lblCheck5); - this.pnlCheck5.Controls.Add(this.pbCheck5); - this.pnlCheck5.Location = new System.Drawing.Point(3, 547); - this.pnlCheck5.Name = "pnlCheck5"; - this.pnlCheck5.Size = new System.Drawing.Size(562, 130); - this.pnlCheck5.TabIndex = 50; - this.pnlCheck5.Visible = false; - // - //txtCheck5 - // - this.txtCheck5.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck5.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck5.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck5.Location = new System.Drawing.Point(129, 29); - this.txtCheck5.Multiline = true; - this.txtCheck5.Name = "txtCheck5"; - this.txtCheck5.ReadOnly = true; - this.txtCheck5.Size = new System.Drawing.Size(430, 97); - this.txtCheck5.TabIndex = 2; - // - //lblCheck5 - // - this.lblCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck5.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck5.Location = new System.Drawing.Point(112, 3); - this.lblCheck5.Name = "lblCheck5"; - this.lblCheck5.Size = new System.Drawing.Size(447, 23); - this.lblCheck5.TabIndex = 1; - this.lblCheck5.Text = "RDP check succeeded!"; - // - //pbCheck5 - // - this.pbCheck5.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck5.Location = new System.Drawing.Point(3, 3); - this.pbCheck5.Name = "pbCheck5"; - this.pbCheck5.Size = new System.Drawing.Size(72, 123); - this.pbCheck5.TabIndex = 0; - this.pbCheck5.TabStop = false; - // - //btnCheckAgain - // - this.btnCheckAgain.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - this.btnCheckAgain.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnCheckAgain.Location = new System.Drawing.Point(476, 842); - this.btnCheckAgain.Name = "btnCheckAgain"; - this.btnCheckAgain.Size = new System.Drawing.Size(104, 23); - this.btnCheckAgain.TabIndex = 0; - this.btnCheckAgain.Text = "Check again"; - this.btnCheckAgain.UseVisualStyleBackColor = true; - // - //chkAlwaysShow - // - this.chkAlwaysShow.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left); - this.chkAlwaysShow.AutoSize = true; - this.chkAlwaysShow.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkAlwaysShow.Location = new System.Drawing.Point(12, 846); - this.chkAlwaysShow.Name = "chkAlwaysShow"; - this.chkAlwaysShow.Size = new System.Drawing.Size(185, 17); - this.chkAlwaysShow.TabIndex = 51; - this.chkAlwaysShow.Text = "Always show this screen at startup"; - this.chkAlwaysShow.UseVisualStyleBackColor = true; - // - //pnlChecks - // - this.pnlChecks.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlChecks.AutoScroll = true; - this.pnlChecks.Controls.Add(this.pnlCheck1); - this.pnlChecks.Controls.Add(this.pnlCheck2); - this.pnlChecks.Controls.Add(this.pnlCheck3); - this.pnlChecks.Controls.Add(this.pnlCheck6); - this.pnlChecks.Controls.Add(this.pnlCheck5); - this.pnlChecks.Controls.Add(this.pnlCheck4); - this.pnlChecks.Location = new System.Drawing.Point(12, 12); - this.pnlChecks.Name = "pnlChecks"; - this.pnlChecks.Size = new System.Drawing.Size(568, 824); - this.pnlChecks.TabIndex = 52; - // - //pnlCheck6 - // - this.pnlCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlCheck6.Controls.Add(this.txtCheck6); - this.pnlCheck6.Controls.Add(this.lblCheck6); - this.pnlCheck6.Controls.Add(this.pbCheck6); - this.pnlCheck6.Location = new System.Drawing.Point(3, 683); - this.pnlCheck6.Name = "pnlCheck6"; - this.pnlCheck6.Size = new System.Drawing.Size(562, 130); - this.pnlCheck6.TabIndex = 50; - this.pnlCheck6.Visible = false; - // - //txtCheck6 - // - this.txtCheck6.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtCheck6.BackColor = System.Drawing.SystemColors.Control; - this.txtCheck6.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCheck6.Location = new System.Drawing.Point(129, 29); - this.txtCheck6.Multiline = true; - this.txtCheck6.Name = "txtCheck6"; - this.txtCheck6.ReadOnly = true; - this.txtCheck6.Size = new System.Drawing.Size(430, 97); - this.txtCheck6.TabIndex = 2; - // - //lblCheck6 - // - this.lblCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblCheck6.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (12.0F), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblCheck6.Location = new System.Drawing.Point(112, 3); - this.lblCheck6.Name = "lblCheck6"; - this.lblCheck6.Size = new System.Drawing.Size(447, 23); - this.lblCheck6.TabIndex = 1; - this.lblCheck6.Text = "RDP check succeeded!"; - // - //pbCheck6 - // - this.pbCheck6.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left); - this.pbCheck6.Location = new System.Drawing.Point(3, 3); - this.pbCheck6.Name = "pbCheck6"; - this.pbCheck6.Size = new System.Drawing.Size(72, 123); - this.pbCheck6.TabIndex = 0; - this.pbCheck6.TabStop = false; - // - //ComponentsCheck - // - this.ClientSize = new System.Drawing.Size(592, 877); - this.Controls.Add(this.pnlChecks); - this.Controls.Add(this.chkAlwaysShow); - this.Controls.Add(this.btnCheckAgain); - this.Icon = global::My.Resources.Resources.ComponentsCheck_Icon; - this.Name = "ComponentsCheck"; - this.TabText = "Components Check"; - this.Text = "Components Check"; - this.pnlCheck1.ResumeLayout(false); - this.pnlCheck1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck1).EndInit(); - this.pnlCheck2.ResumeLayout(false); - this.pnlCheck2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck2).EndInit(); - this.pnlCheck3.ResumeLayout(false); - this.pnlCheck3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck3).EndInit(); - this.pnlCheck4.ResumeLayout(false); - this.pnlCheck4.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck4).EndInit(); - this.pnlCheck5.ResumeLayout(false); - this.pnlCheck5.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck5).EndInit(); - this.pnlChecks.ResumeLayout(false); - this.pnlCheck6.ResumeLayout(false); - this.pnlCheck6.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbCheck6).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + Thread.Sleep(0); + System.Windows.Forms.Application.DoEvents(); } -#endregion - -#region Public Methods - public ComponentsCheck(DockContent Panel) + + if (!(new Version(System.Convert.ToString(rdpClient.Version)) >= mRemoteNG.Connection.Protocol.RDP.Versions.RDC60)) { - this.WindowType = Type.ComponentsCheck; - this.DockPnl = Panel; - this.InitializeComponent(); + throw (new Exception(string.Format("Found RDC Client version {0} but version {1} or higher is required.", rdpClient.Version, mRemoteNG.Connection.Protocol.RDP.Versions.RDC60))); } -#endregion - -#region Form Stuff - private void ComponentsCheck_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - - chkAlwaysShow.Checked = System.Convert.ToBoolean(My.Settings.Default.StartupComponentsCheck); - CheckComponents(); - } - - private void ApplyLanguage() - { - TabText = My.Language.strComponentsCheck; - Text = My.Language.strComponentsCheck; - chkAlwaysShow.Text = My.Language.strCcAlwaysShowScreen; - btnCheckAgain.Text = My.Language.strCcCheckAgain; - } - - private void btnCheckAgain_Click(System.Object sender, System.EventArgs e) - { - CheckComponents(); - } - - private void chkAlwaysShow_CheckedChanged(System.Object sender, System.EventArgs e) - { - My.Settings.Default.StartupComponentsCheck = chkAlwaysShow.Checked; - My.Settings.Default.Save(); - } -#endregion - -#region Private Methods - private void CheckComponents() - { - string errorMsg = My.Language.strCcNotInstalledProperly; - - pnlCheck1.Visible = true; - pnlCheck2.Visible = true; - pnlCheck3.Visible = true; - pnlCheck4.Visible = true; - pnlCheck5.Visible = true; - pnlCheck6.Visible = true; - - - AxMSTSCLib.AxMsRdpClient5NotSafeForScripting rdpClient = null; - - try - { - rdpClient = new AxMSTSCLib.AxMsRdpClient5NotSafeForScripting(); - rdpClient.CreateControl(); - while (!rdpClient.Created) - { - Thread.Sleep(0); - System.Windows.Forms.Application.DoEvents(); - } - - if (!(new Version(System.Convert.ToString(rdpClient.Version)) >= mRemoteNG.Connection.Protocol.RDP.Versions.RDC60)) - { - throw (new Exception(string.Format("Found RDC Client version {0} but version {1} or higher is required.", rdpClient.Version, mRemoteNG.Connection.Protocol.RDP.Versions.RDC60))); - } - - pbCheck1.Image = global::My.Resources.Good_Symbol; - lblCheck1.ForeColor = Color.DarkOliveGreen; - lblCheck1.Text = "RDP (Remote Desktop) " + My.Language.strCcCheckSucceeded; - txtCheck1.Text = string.Format(My.Language.strCcRDPOK, rdpClient.Version); - } - catch (Exception ex) - { - pbCheck1.Image = global::My.Resources.Bad_Symbol; - lblCheck1.ForeColor = Color.Firebrick; - lblCheck1.Text = "RDP (Remote Desktop) " + My.Language.strCcCheckFailed; - txtCheck1.Text = My.Language.strCcRDPFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "RDP " + errorMsg, true); - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); - } - - if (rdpClient != null) - { - rdpClient.Dispose(); - } - - - VncSharp.RemoteDesktop VNC = null; - - try - { - VNC = new VncSharp.RemoteDesktop(); - VNC.CreateControl(); - - while (!VNC.Created) - { - Thread.Sleep(10); - System.Windows.Forms.Application.DoEvents(); - } - - pbCheck2.Image = global::My.Resources.Good_Symbol; - lblCheck2.ForeColor = Color.DarkOliveGreen; - lblCheck2.Text = "VNC (Virtual Network Computing) " + My.Language.strCcCheckSucceeded; - txtCheck2.Text = string.Format(My.Language.strCcVNCOK, VNC.ProductVersion); - } - catch (Exception) - { - pbCheck2.Image = global::My.Resources.Bad_Symbol; - lblCheck2.ForeColor = Color.Firebrick; - lblCheck2.Text = "VNC (Virtual Network Computing) " + My.Language.strCcCheckFailed; - txtCheck2.Text = My.Language.strCcVNCFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "VNC " + errorMsg, true); - } - - if (VNC != null) - { - VNC.Dispose(); - } - - - string pPath = ""; - if (My.Settings.Default.UseCustomPuttyPath == false) - { - pPath = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\PuTTYNG.exe"; - } - else - { - pPath = System.Convert.ToString(My.Settings.Default.CustomPuttyPath); - } - - if (File.Exists(pPath)) - { - pbCheck3.Image = global::My.Resources.Good_Symbol; - lblCheck3.ForeColor = Color.DarkOliveGreen; - lblCheck3.Text = "PuTTY (SSH/Telnet/Rlogin/RAW) " + My.Language.strCcCheckSucceeded; - txtCheck3.Text = My.Language.strCcPuttyOK; - } - else - { - pbCheck3.Image = global::My.Resources.Bad_Symbol; - lblCheck3.ForeColor = Color.Firebrick; - lblCheck3.Text = "PuTTY (SSH/Telnet/Rlogin/RAW) " + My.Language.strCcCheckFailed; - txtCheck3.Text = My.Language.strCcPuttyFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "PuTTY " + errorMsg, true); - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "File " + pPath + " does not exist.", true); - } - - - AxWFICALib.AxICAClient ICA = null; - - try - { - ICA = new AxWFICALib.AxICAClient(); - ICA.Parent = this; - ICA.CreateControl(); - - while (!ICA.Created) - { - Thread.Sleep(10); - System.Windows.Forms.Application.DoEvents(); - } - - pbCheck4.Image = global::My.Resources.Good_Symbol; - lblCheck4.ForeColor = Color.DarkOliveGreen; - lblCheck4.Text = "ICA (Citrix ICA) " + My.Language.strCcCheckSucceeded; - txtCheck4.Text = string.Format(My.Language.strCcICAOK, ICA.Version); - } - catch (Exception ex) - { - pbCheck4.Image = global::My.Resources.Bad_Symbol; - lblCheck4.ForeColor = Color.Firebrick; - lblCheck4.Text = "ICA (Citrix ICA) " + My.Language.strCcCheckFailed; - txtCheck4.Text = My.Language.strCcICAFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "ICA " + errorMsg, true); - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); - } - - if (ICA != null) - { - ICA.Dispose(); - } - - - bool GeckoBad = false; - - if (My.Settings.Default.XULRunnerPath == "") - { - GeckoBad = true; - } - - if (Directory.Exists(System.Convert.ToString(My.Settings.Default.XULRunnerPath))) - { - if (File.Exists(Path.Combine(System.Convert.ToString(My.Settings.Default.XULRunnerPath), "xpcom.dll")) == false) - { - GeckoBad = true; - } - } - else - { - GeckoBad = true; - } - - if (GeckoBad == false) - { - pbCheck5.Image = global::My.Resources.Good_Symbol; - lblCheck5.ForeColor = Color.DarkOliveGreen; - lblCheck5.Text = "Gecko (Firefox) Rendering Engine (HTTP/S) " + My.Language.strCcCheckSucceeded; - txtCheck5.Text = My.Language.strCcGeckoOK; - } - else - { - pbCheck5.Image = global::My.Resources.Bad_Symbol; - lblCheck5.ForeColor = Color.Firebrick; - lblCheck5.Text = "Gecko (Firefox) Rendering Engine (HTTP/S) " + My.Language.strCcCheckFailed; - txtCheck5.Text = My.Language.strCcGeckoFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Gecko " + errorMsg, true); - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "XULrunner was not found in " + My.Settings.Default.XULRunnerPath, true); - } - - - EOLWTSCOM.WTSCOM eol = null; - - try - { - eol = new EOLWTSCOM.WTSCOM(); - - pbCheck6.Image = global::My.Resources.Good_Symbol; - lblCheck6.ForeColor = Color.DarkOliveGreen; - lblCheck6.Text = "(RDP) Sessions " + My.Language.strCcCheckSucceeded; - txtCheck6.Text = My.Language.strCcEOLOK; - } - catch (Exception ex) - { - pbCheck6.Image = global::My.Resources.Bad_Symbol; - lblCheck6.ForeColor = Color.Firebrick; - lblCheck6.Text = "(RDP) Sessions " + My.Language.strCcCheckFailed; - txtCheck6.Text = My.Language.strCcEOLFailed; - - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "EOLWTSCOM " + errorMsg, true); - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); - } - } -#endregion - + pbCheck1.Image = global::My.Resources.Good_Symbol; + lblCheck1.ForeColor = Color.DarkOliveGreen; + lblCheck1.Text = "RDP (Remote Desktop) " + My.Language.strCcCheckSucceeded; + txtCheck1.Text = string.Format(My.Language.strCcRDPOK, rdpClient.Version); } + catch (Exception ex) + { + pbCheck1.Image = global::My.Resources.Bad_Symbol; + lblCheck1.ForeColor = Color.Firebrick; + lblCheck1.Text = "RDP (Remote Desktop) " + My.Language.strCcCheckFailed; + txtCheck1.Text = My.Language.strCcRDPFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "RDP " + errorMsg, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); + } + + if (rdpClient != null) + { + rdpClient.Dispose(); + } + + + VncSharp.RemoteDesktop VNC = null; + + try + { + VNC = new VncSharp.RemoteDesktop(); + VNC.CreateControl(); + + while (!VNC.Created) + { + Thread.Sleep(10); + System.Windows.Forms.Application.DoEvents(); + } + + pbCheck2.Image = global::My.Resources.Good_Symbol; + lblCheck2.ForeColor = Color.DarkOliveGreen; + lblCheck2.Text = "VNC (Virtual Network Computing) " + My.Language.strCcCheckSucceeded; + txtCheck2.Text = string.Format(My.Language.strCcVNCOK, VNC.ProductVersion); + } + catch (Exception) + { + pbCheck2.Image = global::My.Resources.Bad_Symbol; + lblCheck2.ForeColor = Color.Firebrick; + lblCheck2.Text = "VNC (Virtual Network Computing) " + My.Language.strCcCheckFailed; + txtCheck2.Text = My.Language.strCcVNCFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "VNC " + errorMsg, true); + } + + if (VNC != null) + { + VNC.Dispose(); + } + + + string pPath = ""; + if (My.Settings.Default.UseCustomPuttyPath == false) + { + pPath = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\PuTTYNG.exe"; + } + else + { + pPath = System.Convert.ToString(My.Settings.Default.CustomPuttyPath); + } + + if (File.Exists(pPath)) + { + pbCheck3.Image = global::My.Resources.Good_Symbol; + lblCheck3.ForeColor = Color.DarkOliveGreen; + lblCheck3.Text = "PuTTY (SSH/Telnet/Rlogin/RAW) " + My.Language.strCcCheckSucceeded; + txtCheck3.Text = My.Language.strCcPuttyOK; + } + else + { + pbCheck3.Image = global::My.Resources.Bad_Symbol; + lblCheck3.ForeColor = Color.Firebrick; + lblCheck3.Text = "PuTTY (SSH/Telnet/Rlogin/RAW) " + My.Language.strCcCheckFailed; + txtCheck3.Text = My.Language.strCcPuttyFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "PuTTY " + errorMsg, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "File " + pPath + " does not exist.", true); + } + + + AxWFICALib.AxICAClient ICA = null; + + try + { + ICA = new AxWFICALib.AxICAClient(); + ICA.Parent = this; + ICA.CreateControl(); + + while (!ICA.Created) + { + Thread.Sleep(10); + System.Windows.Forms.Application.DoEvents(); + } + + pbCheck4.Image = global::My.Resources.Good_Symbol; + lblCheck4.ForeColor = Color.DarkOliveGreen; + lblCheck4.Text = "ICA (Citrix ICA) " + My.Language.strCcCheckSucceeded; + txtCheck4.Text = string.Format(My.Language.strCcICAOK, ICA.Version); + } + catch (Exception ex) + { + pbCheck4.Image = global::My.Resources.Bad_Symbol; + lblCheck4.ForeColor = Color.Firebrick; + lblCheck4.Text = "ICA (Citrix ICA) " + My.Language.strCcCheckFailed; + txtCheck4.Text = My.Language.strCcICAFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "ICA " + errorMsg, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); + } + + if (ICA != null) + { + ICA.Dispose(); + } + + + bool GeckoBad = false; + + if (My.Settings.Default.XULRunnerPath == "") + { + GeckoBad = true; + } + + if (Directory.Exists(System.Convert.ToString(My.Settings.Default.XULRunnerPath))) + { + if (File.Exists(Path.Combine(System.Convert.ToString(My.Settings.Default.XULRunnerPath), "xpcom.dll")) == false) + { + GeckoBad = true; + } + } + else + { + GeckoBad = true; + } + + if (GeckoBad == false) + { + pbCheck5.Image = global::My.Resources.Good_Symbol; + lblCheck5.ForeColor = Color.DarkOliveGreen; + lblCheck5.Text = "Gecko (Firefox) Rendering Engine (HTTP/S) " + My.Language.strCcCheckSucceeded; + txtCheck5.Text = My.Language.strCcGeckoOK; + } + else + { + pbCheck5.Image = global::My.Resources.Bad_Symbol; + lblCheck5.ForeColor = Color.Firebrick; + lblCheck5.Text = "Gecko (Firefox) Rendering Engine (HTTP/S) " + My.Language.strCcCheckFailed; + txtCheck5.Text = My.Language.strCcGeckoFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Gecko " + errorMsg, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "XULrunner was not found in " + My.Settings.Default.XULRunnerPath, true); + } + + + EOLWTSCOM.WTSCOM eol = null; + + try + { + eol = new EOLWTSCOM.WTSCOM(); + + pbCheck6.Image = global::My.Resources.Good_Symbol; + lblCheck6.ForeColor = Color.DarkOliveGreen; + lblCheck6.Text = "(RDP) Sessions " + My.Language.strCcCheckSucceeded; + txtCheck6.Text = My.Language.strCcEOLOK; + } + catch (Exception ex) + { + pbCheck6.Image = global::My.Resources.Bad_Symbol; + lblCheck6.ForeColor = Color.Firebrick; + lblCheck6.Text = "(RDP) Sessions " + My.Language.strCcCheckFailed; + txtCheck6.Text = My.Language.strCcEOLFailed; + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "EOLWTSCOM " + errorMsg, true); + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true); + } + } + #endregion + + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Config.cs b/mRemoteV1/CS/UI/UI.Window.Config.cs index 57d739b9a..e93b85f7d 100644 --- a/mRemoteV1/CS/UI/UI.Window.Config.cs +++ b/mRemoteV1/CS/UI/UI.Window.Config.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,8 +8,6 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.IO; using mRemoteNG.Messages; using mRemoteNG.My; @@ -18,1900 +15,1898 @@ using mRemoteNG.Connection.Protocol; using mRemoteNG.Root; using WeifenLuo.WinFormsUI.Docking; using System.Net.NetworkInformation; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public class Config : Base + { + #region Form Init + internal System.Windows.Forms.ToolStripButton btnShowProperties; + internal System.Windows.Forms.ToolStripButton btnShowDefaultProperties; + internal System.Windows.Forms.ToolStripButton btnShowInheritance; + internal System.Windows.Forms.ToolStripButton btnShowDefaultInheritance; + internal System.Windows.Forms.ToolStripButton btnIcon; + internal System.Windows.Forms.ToolStripButton btnHostStatus; + internal System.Windows.Forms.ContextMenuStrip cMenIcons; + private System.ComponentModel.Container components = null; + internal System.Windows.Forms.ContextMenuStrip propertyGridContextMenu; + internal System.Windows.Forms.ToolStripMenuItem propertyGridContextMenuShowHelpText; + internal System.Windows.Forms.ToolStripMenuItem propertyGridContextMenuReset; + internal System.Windows.Forms.ToolStripSeparator ToolStripSeparator1; + internal Azuria.Common.Controls.FilteredPropertyGrid pGrid; + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Load += new System.EventHandler(Config_Load); + base.SystemColorsChanged += new System.EventHandler(Config_SystemColorsChanged); + this.pGrid = new Azuria.Common.Controls.FilteredPropertyGrid(); + this.pGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.pGrid_PropertyValueChanged); + this.pGrid.PropertySortChanged += new System.EventHandler(this.pGrid_PropertySortChanged); + this.propertyGridContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.propertyGridContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.propertyGridContextMenu_Opening); + this.propertyGridContextMenuReset = new System.Windows.Forms.ToolStripMenuItem(); + this.propertyGridContextMenuReset.Click += new System.EventHandler(this.propertyGridContextMenuReset_Click); + this.ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.propertyGridContextMenuShowHelpText = new System.Windows.Forms.ToolStripMenuItem(); + this.propertyGridContextMenuShowHelpText.Click += new System.EventHandler(this.propertyGridContextMenuShowHelpText_Click); + this.propertyGridContextMenuShowHelpText.CheckedChanged += new System.EventHandler(this.propertyGridContextMenuShowHelpText_CheckedChanged); + this.btnShowInheritance = new System.Windows.Forms.ToolStripButton(); + this.btnShowInheritance.Click += new System.EventHandler(this.btnShowInheritance_Click); + this.btnShowDefaultInheritance = new System.Windows.Forms.ToolStripButton(); + this.btnShowDefaultInheritance.Click += new System.EventHandler(this.btnShowDefaultInheritance_Click); + this.btnShowProperties = new System.Windows.Forms.ToolStripButton(); + this.btnShowProperties.Click += new System.EventHandler(this.btnShowProperties_Click); + this.btnShowDefaultProperties = new System.Windows.Forms.ToolStripButton(); + this.btnShowDefaultProperties.Click += new System.EventHandler(this.btnShowDefaultProperties_Click); + this.btnIcon = new System.Windows.Forms.ToolStripButton(); + this.btnIcon.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnIcon_Click); + this.btnHostStatus = new System.Windows.Forms.ToolStripButton(); + this.btnHostStatus.Click += new System.EventHandler(this.btnHostStatus_Click); + this.cMenIcons = new System.Windows.Forms.ContextMenuStrip(this.components); + this.propertyGridContextMenu.SuspendLayout(); + this.SuspendLayout(); + // + //pGrid + // + this.pGrid.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pGrid.BrowsableProperties = null; + this.pGrid.ContextMenuStrip = this.propertyGridContextMenu; + this.pGrid.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.pGrid.HiddenAttributes = null; + this.pGrid.HiddenProperties = null; + this.pGrid.Location = new System.Drawing.Point(0, 0); + this.pGrid.Name = "pGrid"; + this.pGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized; + this.pGrid.Size = new System.Drawing.Size(226, 530); + this.pGrid.TabIndex = 0; + this.pGrid.UseCompatibleTextRendering = true; + // + //propertyGridContextMenu + // + this.propertyGridContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.propertyGridContextMenuReset, this.ToolStripSeparator1, this.propertyGridContextMenuShowHelpText}); + this.propertyGridContextMenu.Name = "propertyGridContextMenu"; + this.propertyGridContextMenu.Size = new System.Drawing.Size(157, 76); + // + //propertyGridContextMenuReset + // + this.propertyGridContextMenuReset.Name = "propertyGridContextMenuReset"; + this.propertyGridContextMenuReset.Size = new System.Drawing.Size(156, 22); + this.propertyGridContextMenuReset.Text = "&Reset"; + // + //ToolStripSeparator1 + // + this.ToolStripSeparator1.Name = "ToolStripSeparator1"; + this.ToolStripSeparator1.Size = new System.Drawing.Size(153, 6); + // + //propertyGridContextMenuShowHelpText + // + this.propertyGridContextMenuShowHelpText.Name = "propertyGridContextMenuShowHelpText"; + this.propertyGridContextMenuShowHelpText.Size = new System.Drawing.Size(156, 22); + this.propertyGridContextMenuShowHelpText.Text = "&Show Help Text"; + // + //btnShowInheritance + // + this.btnShowInheritance.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnShowInheritance.Image = global::My.Resources.Resources.Inheritance; + this.btnShowInheritance.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnShowInheritance.Name = "btnShowInheritance"; + this.btnShowInheritance.Size = new System.Drawing.Size(23, 22); + this.btnShowInheritance.Text = "Inheritance"; + // + //btnShowDefaultInheritance + // + this.btnShowDefaultInheritance.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnShowDefaultInheritance.Image = global::My.Resources.Resources.Inheritance_Default; + this.btnShowDefaultInheritance.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnShowDefaultInheritance.Name = "btnShowDefaultInheritance"; + this.btnShowDefaultInheritance.Size = new System.Drawing.Size(23, 22); + this.btnShowDefaultInheritance.Text = "Default Inheritance"; + // + //btnShowProperties + // + this.btnShowProperties.Checked = true; + this.btnShowProperties.CheckState = System.Windows.Forms.CheckState.Checked; + this.btnShowProperties.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnShowProperties.Image = global::My.Resources.Resources.Properties; + this.btnShowProperties.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnShowProperties.Name = "btnShowProperties"; + this.btnShowProperties.Size = new System.Drawing.Size(23, 22); + this.btnShowProperties.Text = "Properties"; + // + //btnShowDefaultProperties + // + this.btnShowDefaultProperties.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnShowDefaultProperties.Image = global::My.Resources.Resources.Properties_Default; + this.btnShowDefaultProperties.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnShowDefaultProperties.Name = "btnShowDefaultProperties"; + this.btnShowDefaultProperties.Size = new System.Drawing.Size(23, 22); + this.btnShowDefaultProperties.Text = "Default Properties"; + // + //btnIcon + // + this.btnIcon.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.btnIcon.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnIcon.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnIcon.Name = "btnIcon"; + this.btnIcon.Size = new System.Drawing.Size(23, 22); + this.btnIcon.Text = "Icon"; + // + //btnHostStatus + // + this.btnHostStatus.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.btnHostStatus.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnHostStatus.Image = global::My.Resources.Resources.HostStatus_Check; + this.btnHostStatus.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnHostStatus.Name = "btnHostStatus"; + this.btnHostStatus.Size = new System.Drawing.Size(23, 22); + this.btnHostStatus.Tag = "checking"; + this.btnHostStatus.Text = "Status"; + // + //cMenIcons + // + this.cMenIcons.Name = "cMenIcons"; + this.cMenIcons.Size = new System.Drawing.Size(61, 4); + // + //Config + // + this.ClientSize = new System.Drawing.Size(226, 530); + this.Controls.Add(this.pGrid); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.HideOnClose = true; + this.Icon = global::My.Resources.Resources.Config_Icon; + this.Name = "Config"; + this.TabText = "Config"; + this.Text = "Config"; + this.propertyGridContextMenu.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + #region Private Properties + private bool ConfigLoading = false; + #endregion + + #region Public Properties + public bool PropertiesVisible + { + get { - - -#region Form Init - internal System.Windows.Forms.ToolStripButton btnShowProperties; - internal System.Windows.Forms.ToolStripButton btnShowDefaultProperties; - internal System.Windows.Forms.ToolStripButton btnShowInheritance; - internal System.Windows.Forms.ToolStripButton btnShowDefaultInheritance; - internal System.Windows.Forms.ToolStripButton btnIcon; - internal System.Windows.Forms.ToolStripButton btnHostStatus; - internal System.Windows.Forms.ContextMenuStrip cMenIcons; - private System.ComponentModel.Container components = null; - internal System.Windows.Forms.ContextMenuStrip propertyGridContextMenu; - internal System.Windows.Forms.ToolStripMenuItem propertyGridContextMenuShowHelpText; - internal System.Windows.Forms.ToolStripMenuItem propertyGridContextMenuReset; - internal System.Windows.Forms.ToolStripSeparator ToolStripSeparator1; - internal Azuria.Common.Controls.FilteredPropertyGrid pGrid; - private void InitializeComponent() + if (this.btnShowProperties.Checked) { - this.components = new System.ComponentModel.Container(); - this.Load += new System.EventHandler(Config_Load); - base.SystemColorsChanged += new System.EventHandler(Config_SystemColorsChanged); - this.pGrid = new Azuria.Common.Controls.FilteredPropertyGrid(); - this.pGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.pGrid_PropertyValueChanged); - this.pGrid.PropertySortChanged += new System.EventHandler(this.pGrid_PropertySortChanged); - this.propertyGridContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.propertyGridContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.propertyGridContextMenu_Opening); - this.propertyGridContextMenuReset = new System.Windows.Forms.ToolStripMenuItem(); - this.propertyGridContextMenuReset.Click += new System.EventHandler(this.propertyGridContextMenuReset_Click); - this.ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.propertyGridContextMenuShowHelpText = new System.Windows.Forms.ToolStripMenuItem(); - this.propertyGridContextMenuShowHelpText.Click += new System.EventHandler(this.propertyGridContextMenuShowHelpText_Click); - this.propertyGridContextMenuShowHelpText.CheckedChanged += new System.EventHandler(this.propertyGridContextMenuShowHelpText_CheckedChanged); - this.btnShowInheritance = new System.Windows.Forms.ToolStripButton(); - this.btnShowInheritance.Click += new System.EventHandler(this.btnShowInheritance_Click); - this.btnShowDefaultInheritance = new System.Windows.Forms.ToolStripButton(); - this.btnShowDefaultInheritance.Click += new System.EventHandler(this.btnShowDefaultInheritance_Click); - this.btnShowProperties = new System.Windows.Forms.ToolStripButton(); - this.btnShowProperties.Click += new System.EventHandler(this.btnShowProperties_Click); - this.btnShowDefaultProperties = new System.Windows.Forms.ToolStripButton(); - this.btnShowDefaultProperties.Click += new System.EventHandler(this.btnShowDefaultProperties_Click); - this.btnIcon = new System.Windows.Forms.ToolStripButton(); - this.btnIcon.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnIcon_Click); - this.btnHostStatus = new System.Windows.Forms.ToolStripButton(); - this.btnHostStatus.Click += new System.EventHandler(this.btnHostStatus_Click); - this.cMenIcons = new System.Windows.Forms.ContextMenuStrip(this.components); - this.propertyGridContextMenu.SuspendLayout(); - this.SuspendLayout(); - // - //pGrid - // - this.pGrid.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pGrid.BrowsableProperties = null; - this.pGrid.ContextMenuStrip = this.propertyGridContextMenu; - this.pGrid.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.pGrid.HiddenAttributes = null; - this.pGrid.HiddenProperties = null; - this.pGrid.Location = new System.Drawing.Point(0, 0); - this.pGrid.Name = "pGrid"; - this.pGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized; - this.pGrid.Size = new System.Drawing.Size(226, 530); - this.pGrid.TabIndex = 0; - this.pGrid.UseCompatibleTextRendering = true; - // - //propertyGridContextMenu - // - this.propertyGridContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.propertyGridContextMenuReset, this.ToolStripSeparator1, this.propertyGridContextMenuShowHelpText}); - this.propertyGridContextMenu.Name = "propertyGridContextMenu"; - this.propertyGridContextMenu.Size = new System.Drawing.Size(157, 76); - // - //propertyGridContextMenuReset - // - this.propertyGridContextMenuReset.Name = "propertyGridContextMenuReset"; - this.propertyGridContextMenuReset.Size = new System.Drawing.Size(156, 22); - this.propertyGridContextMenuReset.Text = "&Reset"; - // - //ToolStripSeparator1 - // - this.ToolStripSeparator1.Name = "ToolStripSeparator1"; - this.ToolStripSeparator1.Size = new System.Drawing.Size(153, 6); - // - //propertyGridContextMenuShowHelpText - // - this.propertyGridContextMenuShowHelpText.Name = "propertyGridContextMenuShowHelpText"; - this.propertyGridContextMenuShowHelpText.Size = new System.Drawing.Size(156, 22); - this.propertyGridContextMenuShowHelpText.Text = "&Show Help Text"; - // - //btnShowInheritance - // - this.btnShowInheritance.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnShowInheritance.Image = global::My.Resources.Resources.Inheritance; - this.btnShowInheritance.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnShowInheritance.Name = "btnShowInheritance"; - this.btnShowInheritance.Size = new System.Drawing.Size(23, 22); - this.btnShowInheritance.Text = "Inheritance"; - // - //btnShowDefaultInheritance - // - this.btnShowDefaultInheritance.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnShowDefaultInheritance.Image = global::My.Resources.Resources.Inheritance_Default; - this.btnShowDefaultInheritance.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnShowDefaultInheritance.Name = "btnShowDefaultInheritance"; - this.btnShowDefaultInheritance.Size = new System.Drawing.Size(23, 22); - this.btnShowDefaultInheritance.Text = "Default Inheritance"; - // - //btnShowProperties - // - this.btnShowProperties.Checked = true; - this.btnShowProperties.CheckState = System.Windows.Forms.CheckState.Checked; - this.btnShowProperties.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnShowProperties.Image = global::My.Resources.Resources.Properties; - this.btnShowProperties.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnShowProperties.Name = "btnShowProperties"; - this.btnShowProperties.Size = new System.Drawing.Size(23, 22); - this.btnShowProperties.Text = "Properties"; - // - //btnShowDefaultProperties - // - this.btnShowDefaultProperties.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnShowDefaultProperties.Image = global::My.Resources.Resources.Properties_Default; - this.btnShowDefaultProperties.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnShowDefaultProperties.Name = "btnShowDefaultProperties"; - this.btnShowDefaultProperties.Size = new System.Drawing.Size(23, 22); - this.btnShowDefaultProperties.Text = "Default Properties"; - // - //btnIcon - // - this.btnIcon.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.btnIcon.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnIcon.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnIcon.Name = "btnIcon"; - this.btnIcon.Size = new System.Drawing.Size(23, 22); - this.btnIcon.Text = "Icon"; - // - //btnHostStatus - // - this.btnHostStatus.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.btnHostStatus.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnHostStatus.Image = global::My.Resources.Resources.HostStatus_Check; - this.btnHostStatus.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnHostStatus.Name = "btnHostStatus"; - this.btnHostStatus.Size = new System.Drawing.Size(23, 22); - this.btnHostStatus.Tag = "checking"; - this.btnHostStatus.Text = "Status"; - // - //cMenIcons - // - this.cMenIcons.Name = "cMenIcons"; - this.cMenIcons.Size = new System.Drawing.Size(61, 4); - // - //Config - // - this.ClientSize = new System.Drawing.Size(226, 530); - this.Controls.Add(this.pGrid); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.HideOnClose = true; - this.Icon = global::My.Resources.Resources.Config_Icon; - this.Name = "Config"; - this.TabText = "Config"; - this.Text = "Config"; - this.propertyGridContextMenu.ResumeLayout(false); - this.ResumeLayout(false); - + return true; } -#endregion - -#region Private Properties - private bool ConfigLoading = false; -#endregion - -#region Public Properties -public bool PropertiesVisible + else { - get - { - if (this.btnShowProperties.Checked) - { - return true; - } - else - { - return false; - } - } - set - { - this.btnShowProperties.Checked = value; - - if (value == true) - { - this.btnShowInheritance.Checked = false; - this.btnShowDefaultInheritance.Checked = false; - this.btnShowDefaultProperties.Checked = false; - } - } - } - -public bool InheritanceVisible - { - get - { - if (this.btnShowInheritance.Checked) - { - return true; - } - else - { - return false; - } - } - set - { - this.btnShowInheritance.Checked = value; - - if (value == true) - { - this.btnShowProperties.Checked = false; - this.btnShowDefaultInheritance.Checked = false; - this.btnShowDefaultProperties.Checked = false; - } - } - } - -public bool DefaultPropertiesVisible - { - get - { - if (this.btnShowDefaultProperties.Checked) - { - return true; - } - else - { - return false; - } - } - set - { - this.btnShowDefaultProperties.Checked = value; - - if (value == true) - { - this.btnShowProperties.Checked = false; - this.btnShowDefaultInheritance.Checked = false; - this.btnShowInheritance.Checked = false; - } - } - } - -public bool DefaultInheritanceVisible - { - get - { - if (this.btnShowDefaultInheritance.Checked) - { - return true; - } - else - { - return false; - } - } - set - { - this.btnShowDefaultInheritance.Checked = value; - - if (value == true) - { - this.btnShowProperties.Checked = false; - this.btnShowDefaultProperties.Checked = false; - this.btnShowInheritance.Checked = false; - } - } - } -#endregion - -#region Public Methods - public Config(DockContent Panel) - { - this.WindowType = Type.Config; - this.DockPnl = Panel; - this.InitializeComponent(); - } - - // Main form handle command key events - // Adapted from http://kiwigis.blogspot.com/2009/05/adding-tab-key-support-to-propertygrid.html - protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData) - { - if ((keyData & Keys.KeyCode) == Keys.Tab) - { - GridItem selectedItem = pGrid.SelectedGridItem; - GridItem gridRoot = selectedItem; - while (gridRoot.GridItemType != GridItemType.Root) - { - gridRoot = gridRoot.Parent; - } - - List gridItems = new List(); - FindChildGridItems(gridRoot, ref gridItems); - - if (!ContainsGridItemProperty(gridItems)) - { - return true; - } - - GridItem newItem = selectedItem; - - if (keyData == (Keys.Tab | Keys.Shift)) - { - newItem = FindPreviousGridItemProperty(gridItems, selectedItem); - } - else if (keyData == Keys.Tab) - { - newItem = FindNextGridItemProperty(gridItems, selectedItem); - } - - pGrid.SelectedGridItem = newItem; - - return true; // Handled - } - else - { - return base.ProcessCmdKey(ref msg, keyData); - } - } - - private void FindChildGridItems(GridItem item, ref List gridItems) - { - gridItems.Add(item); - - if (!item.Expandable || item.Expanded) - { - foreach (GridItem child in item.GridItems) - { - FindChildGridItems(child, ref gridItems); - } - } - } - - private bool ContainsGridItemProperty(List gridItems) - { - foreach (GridItem item in gridItems) - { - if (item.GridItemType == GridItemType.Property) - { - return true; - } - } return false; } - - private GridItem FindPreviousGridItemProperty(System.Collections.Generic.List gridItems, GridItem startItem) - { - if (gridItems.Count == 0) - { - return null; - } - if (startItem == null) - { - return null; - } - - int startIndex = gridItems.IndexOf(startItem); - - if (startItem.GridItemType == GridItemType.Property) - { - startIndex--; - if (startIndex < 0) - { - startIndex = gridItems.Count - 1; - } - } - - int previousIndex = 0; - bool previousIndexValid = false; - for (int index = startIndex; index >= 0; index--) - { - if (gridItems[index].GridItemType == GridItemType.Property) - { - previousIndex = index; - previousIndexValid = true; - break; - } - } - - if (previousIndexValid) - { - return gridItems[previousIndex]; - } - - for (int index = gridItems.Count - 1; index >= startIndex + 1; index--) - { - if (gridItems[index].GridItemType == GridItemType.Property) - { - previousIndex = index; - previousIndexValid = true; - break; - } - } - - if (!previousIndexValid) - { - return null; - } - - return gridItems[previousIndex]; - } - - private GridItem FindNextGridItemProperty(System.Collections.Generic.List gridItems, GridItem startItem) - { - if (gridItems.Count == 0) - { - return null; - } - if (startItem == null) - { - return null; - } - - int startIndex = gridItems.IndexOf(startItem); - - if (startItem.GridItemType == GridItemType.Property) - { - startIndex++; - if (startIndex >= gridItems.Count) - { - startIndex = 0; - } - } - - int nextIndex = 0; - bool nextIndexValid = false; - for (int index = startIndex; index <= gridItems.Count - 1; index++) - { - if (gridItems[index].GridItemType == GridItemType.Property) - { - nextIndex = index; - nextIndexValid = true; - break; - } - } - - if (nextIndexValid) - { - return gridItems[nextIndex]; - } - - for (int index = 0; index <= startIndex - 1; index++) - { - if (gridItems[index].GridItemType == GridItemType.Property) - { - nextIndex = index; - nextIndexValid = true; - break; - } - } - - if (!nextIndexValid) - { - return null; - } - - return gridItems[nextIndex]; - } - - public void SetPropertyGridObject(object Obj) - { - try - { - this.btnShowProperties.Enabled = false; - this.btnShowInheritance.Enabled = false; - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = false; - this.btnHostStatus.Enabled = false; + } + set + { + this.btnShowProperties.Checked = value; - this.btnIcon.Image = null; + if (value == true) + { + this.btnShowInheritance.Checked = false; + this.btnShowDefaultInheritance.Checked = false; + this.btnShowDefaultProperties.Checked = false; + } + } + } + + public bool InheritanceVisible + { + get + { + if (this.btnShowInheritance.Checked) + { + return true; + } + else + { + return false; + } + } + set + { + this.btnShowInheritance.Checked = value; - if (Obj is mRemoteNG.Connection.Info) //CONNECTION INFO - { - if ((Obj as mRemoteNG.Connection.Info).IsContainer == false) //NO CONTAINER - { - if (this.PropertiesVisible) //Properties selected - { - this.pGrid.SelectedObject = Obj; - - this.btnShowProperties.Enabled = true; - if ((Obj as mRemoteNG.Connection.Info).Parent != null) - { - this.btnShowInheritance.Enabled = true; - } - else - { - this.btnShowInheritance.Enabled = false; - } - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - btnIcon.Enabled = true; - this.btnHostStatus.Enabled = true; - } - else if (this.DefaultPropertiesVisible) //Defaults selected - { - this.pGrid.SelectedObject = Obj; - - if ((Obj as mRemoteNG.Connection.Info).IsDefault) //Is the default connection - { - this.btnShowProperties.Enabled = true; - this.btnShowInheritance.Enabled = false; - this.btnShowDefaultProperties.Enabled = true; - this.btnShowDefaultInheritance.Enabled = true; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = false; - } - else //is not the default connection - { - this.btnShowProperties.Enabled = true; - this.btnShowInheritance.Enabled = true; - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = true; - - this.PropertiesVisible = true; - } - } - else if (this.InheritanceVisible) //Inheritance selected - { - this.pGrid.SelectedObject = (Obj as mRemoteNG.Connection.Info).Inherit; - - this.btnShowProperties.Enabled = true; - this.btnShowInheritance.Enabled = true; - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = true; - } - else if (this.DefaultInheritanceVisible) //Default Inhertiance selected - { - pGrid.SelectedObject = Obj; - - this.btnShowProperties.Enabled = true; - this.btnShowInheritance.Enabled = true; - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = true; - - this.PropertiesVisible = true; - } - } - else if ((Obj as mRemoteNG.Connection.Info).IsContainer) //CONTAINER - { - this.pGrid.SelectedObject = Obj; - - this.btnShowProperties.Enabled = true; - if (((Obj as mRemoteNG.Connection.Info).Parent as mRemoteNG.Container.Info).Parent != null) - { - this.btnShowInheritance.Enabled = true; - } - else - { - this.btnShowInheritance.Enabled = false; - } - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = false; - - this.PropertiesVisible = true; - } - - Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString((Obj as mRemoteNG.Connection.Info).Icon)); - if (conIcon != null) - { - this.btnIcon.Image = conIcon.ToBitmap(); - } - } - else if (Obj is Root.Info) //ROOT - { - Root.Info rootInfo = (Root.Info) Obj; - switch (rootInfo.Type) - { - case Root.Info.RootType.Connection: - PropertiesVisible = true; - DefaultPropertiesVisible = false; - btnShowProperties.Enabled = true; - btnShowInheritance.Enabled = false; - btnShowDefaultProperties.Enabled = true; - btnShowDefaultInheritance.Enabled = true; - btnIcon.Enabled = false; - btnHostStatus.Enabled = false; - break; - case Root.Info.RootType.Credential: - throw (new NotImplementedException()); - break; - case Root.Info.RootType.PuttySessions: - PropertiesVisible = true; - DefaultPropertiesVisible = false; - btnShowProperties.Enabled = true; - btnShowInheritance.Enabled = false; - btnShowDefaultProperties.Enabled = false; - btnShowDefaultInheritance.Enabled = false; - btnIcon.Enabled = false; - btnHostStatus.Enabled = false; - break; - } - pGrid.SelectedObject = Obj; - } - else if (Obj is mRemoteNG.Connection.Info.Inheritance) //INHERITANCE + if (value == true) + { + this.btnShowProperties.Checked = false; + this.btnShowDefaultInheritance.Checked = false; + this.btnShowDefaultProperties.Checked = false; + } + } + } + + public bool DefaultPropertiesVisible + { + get + { + if (this.btnShowDefaultProperties.Checked) + { + return true; + } + else + { + return false; + } + } + set + { + this.btnShowDefaultProperties.Checked = value; + + if (value == true) + { + this.btnShowProperties.Checked = false; + this.btnShowDefaultInheritance.Checked = false; + this.btnShowInheritance.Checked = false; + } + } + } + + public bool DefaultInheritanceVisible + { + get + { + if (this.btnShowDefaultInheritance.Checked) + { + return true; + } + else + { + return false; + } + } + set + { + this.btnShowDefaultInheritance.Checked = value; + + if (value == true) + { + this.btnShowProperties.Checked = false; + this.btnShowDefaultProperties.Checked = false; + this.btnShowInheritance.Checked = false; + } + } + } + #endregion + + #region Public Methods + public Config(DockContent Panel) + { + this.WindowType = Type.Config; + this.DockPnl = Panel; + this.InitializeComponent(); + } + + // Main form handle command key events + // Adapted from http://kiwigis.blogspot.com/2009/05/adding-tab-key-support-to-propertygrid.html + protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData) + { + if ((keyData & Keys.KeyCode) == Keys.Tab) + { + GridItem selectedItem = pGrid.SelectedGridItem; + GridItem gridRoot = selectedItem; + while (gridRoot.GridItemType != GridItemType.Root) + { + gridRoot = gridRoot.Parent; + } + + List gridItems = new List(); + FindChildGridItems(gridRoot, ref gridItems); + + if (!ContainsGridItemProperty(gridItems)) + { + return true; + } + + GridItem newItem = selectedItem; + + if (keyData == (Keys.Tab | Keys.Shift)) + { + newItem = FindPreviousGridItemProperty(gridItems, selectedItem); + } + else if (keyData == Keys.Tab) + { + newItem = FindNextGridItemProperty(gridItems, selectedItem); + } + + pGrid.SelectedGridItem = newItem; + + return true; // Handled + } + else + { + return base.ProcessCmdKey(ref msg, keyData); + } + } + + private void FindChildGridItems(GridItem item, ref List gridItems) + { + gridItems.Add(item); + + if (!item.Expandable || item.Expanded) + { + foreach (GridItem child in item.GridItems) + { + FindChildGridItems(child, ref gridItems); + } + } + } + + private bool ContainsGridItemProperty(List gridItems) + { + foreach (GridItem item in gridItems) + { + if (item.GridItemType == GridItemType.Property) + { + return true; + } + } + return false; + } + + private GridItem FindPreviousGridItemProperty(System.Collections.Generic.List gridItems, GridItem startItem) + { + if (gridItems.Count == 0) + { + return null; + } + if (startItem == null) + { + return null; + } + + int startIndex = gridItems.IndexOf(startItem); + + if (startItem.GridItemType == GridItemType.Property) + { + startIndex--; + if (startIndex < 0) + { + startIndex = gridItems.Count - 1; + } + } + + int previousIndex = 0; + bool previousIndexValid = false; + for (int index = startIndex; index >= 0; index--) + { + if (gridItems[index].GridItemType == GridItemType.Property) + { + previousIndex = index; + previousIndexValid = true; + break; + } + } + + if (previousIndexValid) + { + return gridItems[previousIndex]; + } + + for (int index = gridItems.Count - 1; index >= startIndex + 1; index--) + { + if (gridItems[index].GridItemType == GridItemType.Property) + { + previousIndex = index; + previousIndexValid = true; + break; + } + } + + if (!previousIndexValid) + { + return null; + } + + return gridItems[previousIndex]; + } + + private GridItem FindNextGridItemProperty(System.Collections.Generic.List gridItems, GridItem startItem) + { + if (gridItems.Count == 0) + { + return null; + } + if (startItem == null) + { + return null; + } + + int startIndex = gridItems.IndexOf(startItem); + + if (startItem.GridItemType == GridItemType.Property) + { + startIndex++; + if (startIndex >= gridItems.Count) + { + startIndex = 0; + } + } + + int nextIndex = 0; + bool nextIndexValid = false; + for (int index = startIndex; index <= gridItems.Count - 1; index++) + { + if (gridItems[index].GridItemType == GridItemType.Property) + { + nextIndex = index; + nextIndexValid = true; + break; + } + } + + if (nextIndexValid) + { + return gridItems[nextIndex]; + } + + for (int index = 0; index <= startIndex - 1; index++) + { + if (gridItems[index].GridItemType == GridItemType.Property) + { + nextIndex = index; + nextIndexValid = true; + break; + } + } + + if (!nextIndexValid) + { + return null; + } + + return gridItems[nextIndex]; + } + + public void SetPropertyGridObject(object Obj) + { + try + { + this.btnShowProperties.Enabled = false; + this.btnShowInheritance.Enabled = false; + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = false; + this.btnHostStatus.Enabled = false; + + this.btnIcon.Image = null; + + if (Obj is mRemoteNG.Connection.Info) //CONNECTION INFO + { + if ((Obj as mRemoteNG.Connection.Info).IsContainer == false) //NO CONTAINER + { + if (this.PropertiesVisible) //Properties selected { this.pGrid.SelectedObject = Obj; - - if (this.InheritanceVisible) + + this.btnShowProperties.Enabled = true; + if ((Obj as mRemoteNG.Connection.Info).Parent != null) { - this.InheritanceVisible = true; - this.btnShowProperties.Enabled = true; this.btnShowInheritance.Enabled = true; - this.btnShowDefaultProperties.Enabled = false; - this.btnShowDefaultInheritance.Enabled = false; - this.btnIcon.Enabled = true; - this.btnHostStatus.Enabled = !((Obj as mRemoteNG.Connection.Info.Inheritance).Parent as mRemoteNG.Connection.Info).IsContainer; - - this.InheritanceVisible = true; - - Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString(((Obj as mRemoteNG.Connection.Info.Inheritance).Parent as mRemoteNG.Connection.Info).Icon)); - if (conIcon != null) - { - this.btnIcon.Image = conIcon.ToBitmap(); - } } - else if (this.DefaultInheritanceVisible) + else + { + this.btnShowInheritance.Enabled = false; + } + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + btnIcon.Enabled = true; + this.btnHostStatus.Enabled = true; + } + else if (this.DefaultPropertiesVisible) //Defaults selected + { + this.pGrid.SelectedObject = Obj; + + if ((Obj as mRemoteNG.Connection.Info).IsDefault) //Is the default connection { this.btnShowProperties.Enabled = true; this.btnShowInheritance.Enabled = false; this.btnShowDefaultProperties.Enabled = true; this.btnShowDefaultInheritance.Enabled = true; - this.btnIcon.Enabled = false; + this.btnIcon.Enabled = true; this.btnHostStatus.Enabled = false; - - this.DefaultInheritanceVisible = true; } - - } - - this.ShowHideGridItems(); - this.SetHostStatus(Obj); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridObjectFailed + Constants.vbNewLine + ex.Message, true); - } - } - - public void pGrid_SelectedObjectChanged() - { - this.ShowHideGridItems(); - } -#endregion - -#region Private Methods - private void ApplyLanguage() - { - btnShowInheritance.Text = My.Language.strButtonInheritance; - btnShowDefaultInheritance.Text = My.Language.strButtonDefaultInheritance; - btnShowProperties.Text = My.Language.strButtonProperties; - btnShowDefaultProperties.Text = My.Language.strButtonDefaultProperties; - btnIcon.Text = My.Language.strButtonIcon; - btnHostStatus.Text = My.Language.strStatus; - Text = My.Language.strMenuConfig; - TabText = My.Language.strMenuConfig; - propertyGridContextMenuShowHelpText.Text = Language.strMenuShowHelpText; - } - - private void ApplyTheme() - { - pGrid.BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; - pGrid.ForeColor = Themes.ThemeManager.ActiveTheme.ToolbarTextColor; - pGrid.ViewBackColor = Themes.ThemeManager.ActiveTheme.ConfigPanelBackgroundColor; - pGrid.ViewForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelTextColor; - pGrid.LineColor = Themes.ThemeManager.ActiveTheme.ConfigPanelGridLineColor; - pGrid.HelpBackColor = Themes.ThemeManager.ActiveTheme.ConfigPanelHelpBackgroundColor; - pGrid.HelpForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelHelpTextColor; - pGrid.CategoryForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelCategoryTextColor; - } - - private bool _originalPropertyGridToolStripItemCountValid; - private int _originalPropertyGridToolStripItemCount; - - private void AddToolStripItems() - { - try - { - ToolStrip customToolStrip = new ToolStrip(); - customToolStrip.Items.Add(btnShowProperties); - customToolStrip.Items.Add(btnShowInheritance); - customToolStrip.Items.Add(btnShowDefaultProperties); - customToolStrip.Items.Add(btnShowDefaultInheritance); - customToolStrip.Items.Add(btnHostStatus); - customToolStrip.Items.Add(btnIcon); - customToolStrip.Show(); - - ToolStrip propertyGridToolStrip = new ToolStrip(); - - ToolStrip toolStrip = null; - foreach (System.Windows.Forms.Control control in pGrid.Controls) - { - toolStrip = control as ToolStrip; - - if (toolStrip != null) + else //is not the default connection { - propertyGridToolStrip = toolStrip; - break; - } - } - - if (toolStrip == null) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strCouldNotFindToolStripInFilteredPropertyGrid, true); - return ; - } - - if (!_originalPropertyGridToolStripItemCountValid) - { - _originalPropertyGridToolStripItemCount = propertyGridToolStrip.Items.Count; - _originalPropertyGridToolStripItemCountValid = true; - } - Debug.Assert(_originalPropertyGridToolStripItemCount == 5); - - // Hide the "Property Pages" button - propertyGridToolStrip.Items[_originalPropertyGridToolStripItemCount - 1].Visible = false; - - int expectedToolStripItemCount = _originalPropertyGridToolStripItemCount + customToolStrip.Items.Count; - if (propertyGridToolStrip.Items.Count != expectedToolStripItemCount) - { - propertyGridToolStrip.AllowMerge = true; - ToolStripManager.Merge(customToolStrip, propertyGridToolStrip); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strConfigUiLoadFailed + Constants.vbNewLine + ex.Message, true); - } - } - - private void Config_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - - Themes.ThemeManager.ThemeChanged += ApplyTheme; - ApplyTheme(); - - AddToolStripItems(); - - pGrid.HelpVisible = Settings.ShowConfigHelpText; - } - - private void Config_SystemColorsChanged(System.Object sender, System.EventArgs e) - { - AddToolStripItems(); - } - - private void pGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e) - { - try - { - if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) - { - if (e.ChangedItem.Label == My.Language.strPropertyNameProtocol) - { - (this.pGrid.SelectedObject as mRemoteNG.Connection.Info).SetDefaultPort(); - } - else if (e.ChangedItem.Label == My.Language.strPropertyNameName) - { - App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Text = System.Convert.ToString(this.pGrid.SelectedObject.Name); - if (My.Settings.Default.SetHostnameLikeDisplayName && this.pGrid.SelectedObject is mRemoteNG.Connection.Info) - { - mRemoteNG.Connection.Info connectionInfo = (mRemoteNG.Connection.Info) this.pGrid.SelectedObject; - if (!string.IsNullOrEmpty(connectionInfo.Name)) - { - connectionInfo.Hostname = connectionInfo.Name; - } - } - } - else if (e.ChangedItem.Label == My.Language.strPropertyNameIcon) - { - Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).Icon)); - if (conIcon != null) - { - this.btnIcon.Image = conIcon.ToBitmap(); - } - } - else if (e.ChangedItem.Label == My.Language.strPropertyNameAddress) - { - this.SetHostStatus(this.pGrid.SelectedObject); - } - - if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).IsDefault) - { - App.Runtime.DefaultConnectionToSettings(); - } - } - - Info rootInfo = pGrid.SelectedObject as Info; - if (rootInfo != null) - { - switch (e.ChangedItem.PropertyDescriptor.Name) - { - case "Password": - if (rootInfo.Password == true) - { - string passwordName = ""; - if (Settings.UseSQLServer) - { - passwordName = Language.strSQLServer.TrimEnd(':'); - } - else - { - passwordName = Path.GetFileName(GetStartupConnectionFileName()); - } + this.btnShowProperties.Enabled = true; + this.btnShowInheritance.Enabled = true; + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = true; + this.btnHostStatus.Enabled = true; - string password = Tools.Misc.PasswordDialog(passwordName); - - if (string.IsNullOrEmpty(password)) - { - rootInfo.Password = System.Convert.ToString(false); - } - else - { - rootInfo.PasswordString = password; - } - } - break; - case "Name": - break; - //Windows.treeForm.tvConnections.SelectedNode.Text = pGrid.SelectedObject.Name + this.PropertiesVisible = true; } } - - if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) + else if (this.InheritanceVisible) //Inheritance selected { - if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).IsDefault) - { - App.Runtime.DefaultInheritanceToSettings(); - } + this.pGrid.SelectedObject = (Obj as mRemoteNG.Connection.Info).Inherit; + + this.btnShowProperties.Enabled = true; + this.btnShowInheritance.Enabled = true; + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = true; + this.btnHostStatus.Enabled = true; } - - this.ShowHideGridItems(); - App.Runtime.SaveConnectionsBG(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridValueFailed + Constants.vbNewLine + ex.Message, true); - } - } - - private void pGrid_PropertySortChanged(object sender, EventArgs e) - { - if (pGrid.PropertySort == PropertySort.CategorizedAlphabetical) - { - pGrid.PropertySort = PropertySort.Categorized; - } - } - - private void ShowHideGridItems() - { - try - { - System.Collections.Generic.List strHide = new System.Collections.Generic.List(); - - if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) - { - mRemoteNG.Connection.Info conI = pGrid.SelectedObject; - - switch (conI.Protocol) - { - case mRemoteNG.Connection.Protocol.Protocols.RDP: - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("PuttySession"); - strHide.Add("RenderingEngine"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - if (conI.RDGatewayUsageMethod == mRemoteNG.Connection.Protocol.RDP.RDGatewayUsageMethod.Never) - { - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - } - else if (conI.RDGatewayUseConnectionCredentials) - { - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsername"); - } - if (!(conI.Resolution == RDP.RDPResolutions.FitToWindow || conI.Resolution == RDP.RDPResolutions.Fullscreen)) - { - strHide.Add("AutomaticResize"); - } - break; - case mRemoteNG.Connection.Protocol.Protocols.VNC: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("PuttySession"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - if (conI.VNCAuthMode == mRemoteNG.Connection.Protocol.VNC.AuthMode.AuthVNC) - { - strHide.Add("Username"); - strHide.Add("Domain"); - } - if (conI.VNCProxyType == mRemoteNG.Connection.Protocol.VNC.ProxyType.ProxyNone) - { - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyUsername"); - } - break; - case mRemoteNG.Connection.Protocol.Protocols.SSH1: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.SSH2: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.Telnet: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("Password"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("Username"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.Rlogin: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("Password"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("Username"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.RAW: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("Password"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("Username"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.HTTP: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("PuttySession"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.HTTPS: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ExtApp"); - strHide.Add("ICAEncryption"); - strHide.Add("PuttySession"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound;Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.ICA: - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("ExtApp"); - strHide.Add("Port"); - strHide.Add("PuttySession"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - case mRemoteNG.Connection.Protocol.Protocols.IntApp: - strHide.Add("CacheBitmaps"); - strHide.Add("Colors"); - strHide.Add("DisplayThemes"); - strHide.Add("DisplayWallpaper"); - strHide.Add("EnableFontSmoothing"); - strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); - strHide.Add("ICAEncryption"); - strHide.Add("PuttySession"); - strHide.Add("RDGatewayDomain"); - strHide.Add("RDGatewayHostname"); - strHide.Add("RDGatewayPassword"); - strHide.Add("RDGatewayUsageMethod"); - strHide.Add("RDGatewayUseConnectionCredentials"); - strHide.Add("RDGatewayUsername"); - strHide.Add("RDPAuthenticationLevel"); - strHide.Add("LoadBalanceInfo"); - strHide.Add("RedirectDiskDrives"); - strHide.Add("RedirectKeys"); - strHide.Add("RedirectPorts"); - strHide.Add("RedirectPrinters"); - strHide.Add("RedirectSmartCards"); - strHide.Add("RedirectSound"); - strHide.Add("RenderingEngine"); - strHide.Add("Resolution"); - strHide.Add("AutomaticResize"); - strHide.Add("UseConsoleSession"); - strHide.Add("UseCredSsp"); - strHide.Add("VNCAuthMode"); - strHide.Add("VNCColors"); - strHide.Add("VNCCompression"); - strHide.Add("VNCEncoding"); - strHide.Add("VNCProxyIP"); - strHide.Add("VNCProxyPassword"); - strHide.Add("VNCProxyPort"); - strHide.Add("VNCProxyType"); - strHide.Add("VNCProxyUsername"); - strHide.Add("VNCSmartSizeMode"); - strHide.Add("VNCViewOnly"); - break; - } - - if (conI.IsDefault == false) - { - if (conI.Inherit.CacheBitmaps) - { - strHide.Add("CacheBitmaps"); - } - - if (conI.Inherit.Colors) - { - strHide.Add("Colors"); - } - - if (conI.Inherit.Description) - { - strHide.Add("Description"); - } - - if (conI.Inherit.DisplayThemes) - { - strHide.Add("DisplayThemes"); - } - - if (conI.Inherit.DisplayWallpaper) - { - strHide.Add("DisplayWallpaper"); - } - - if (conI.Inherit.EnableFontSmoothing) - { - strHide.Add("EnableFontSmoothing"); - } - - if (conI.Inherit.EnableDesktopComposition) - { - strHide.Add("EnableDesktopComposition"); - } - - if (conI.Inherit.Domain) - { - strHide.Add("Domain"); - } - - if (conI.Inherit.Icon) - { - strHide.Add("Icon"); - } - - if (conI.Inherit.Password) - { - strHide.Add("Password"); - } - - if (conI.Inherit.Port) - { - strHide.Add("Port"); - } - - if (conI.Inherit.Protocol) - { - strHide.Add("Protocol"); - } - - if (conI.Inherit.PuttySession) - { - strHide.Add("PuttySession"); - } - - if (conI.Inherit.RedirectDiskDrives) - { - strHide.Add("RedirectDiskDrives"); - } - - if (conI.Inherit.RedirectKeys) - { - strHide.Add("RedirectKeys"); - } - - if (conI.Inherit.RedirectPorts) - { - strHide.Add("RedirectPorts"); - } - - if (conI.Inherit.RedirectPrinters) - { - strHide.Add("RedirectPrinters"); - } - - if (conI.Inherit.RedirectSmartCards) - { - strHide.Add("RedirectSmartCards"); - } - - if (conI.Inherit.RedirectSound) - { - strHide.Add("RedirectSound"); - } - - if (conI.Inherit.Resolution) - { - strHide.Add("Resolution"); - } - - if (conI.Inherit.AutomaticResize) - { - strHide.Add("AutomaticResize"); - } - - if (conI.Inherit.UseConsoleSession) - { - strHide.Add("UseConsoleSession"); - } - - if (conI.Inherit.UseCredSsp) - { - strHide.Add("UseCredSsp"); - } - - if (conI.Inherit.RenderingEngine) - { - strHide.Add("RenderingEngine"); - } - - if (conI.Inherit.ICAEncryption) - { - strHide.Add("ICAEncryption"); - } - - if (conI.Inherit.RDPAuthenticationLevel) - { - strHide.Add("RDPAuthenticationLevel"); - } - - if (conI.Inherit.LoadBalanceInfo) - { - strHide.Add("LoadBalanceInfo"); - } - - if (conI.Inherit.Username) - { - strHide.Add("Username"); - } - - if (conI.Inherit.Panel) - { - strHide.Add("Panel"); - } - - if (conI.IsContainer) - { - strHide.Add("Hostname"); - } - - if (conI.Inherit.PreExtApp) - { - strHide.Add("PreExtApp"); - } - - if (conI.Inherit.PostExtApp) - { - strHide.Add("PostExtApp"); - } - - if (conI.Inherit.MacAddress) - { - strHide.Add("MacAddress"); - } - - if (conI.Inherit.UserField) - { - strHide.Add("UserField"); - } - - if (conI.Inherit.VNCAuthMode) - { - strHide.Add("VNCAuthMode"); - } - - if (conI.Inherit.VNCColors) - { - strHide.Add("VNCColors"); - } - - if (conI.Inherit.VNCCompression) - { - strHide.Add("VNCCompression"); - } - - if (conI.Inherit.VNCEncoding) - { - strHide.Add("VNCEncoding"); - } - - if (conI.Inherit.VNCProxyIP) - { - strHide.Add("VNCProxyIP"); - } - - if (conI.Inherit.VNCProxyPassword) - { - strHide.Add("VNCProxyPassword"); - } - - if (conI.Inherit.VNCProxyPort) - { - strHide.Add("VNCProxyPort"); - } - - if (conI.Inherit.VNCProxyType) - { - strHide.Add("VNCProxyType"); - } - - if (conI.Inherit.VNCProxyUsername) - { - strHide.Add("VNCProxyUsername"); - } - - if (conI.Inherit.VNCViewOnly) - { - strHide.Add("VNCViewOnly"); - } - - if (conI.Inherit.VNCSmartSizeMode) - { - strHide.Add("VNCSmartSizeMode"); - } - - if (conI.Inherit.ExtApp) - { - strHide.Add("ExtApp"); - } - - if (conI.Inherit.RDGatewayUsageMethod) - { - strHide.Add("RDGatewayUsageMethod"); - } - - if (conI.Inherit.RDGatewayHostname) - { - strHide.Add("RDGatewayHostname"); - } - - if (conI.Inherit.RDGatewayUsername) - { - strHide.Add("RDGatewayUsername"); - } - - if (conI.Inherit.RDGatewayPassword) - { - strHide.Add("RDGatewayPassword"); - } - - if (conI.Inherit.RDGatewayDomain) - { - strHide.Add("RDGatewayDomain"); - } - - if (conI.Inherit.RDGatewayUseConnectionCredentials) - { - strHide.Add("RDGatewayUseConnectionCredentials"); - } - - if (conI.Inherit.RDGatewayHostname) - { - strHide.Add("RDGatewayHostname"); - } - } - else - { - strHide.Add("Hostname"); - strHide.Add("Name"); - } - } - else if (pGrid.SelectedObject is Root.Info) - { - Root.Info rootInfo = (Root.Info) pGrid.SelectedObject; - if (rootInfo.Type == Root.Info.RootType.PuttySessions) - { - strHide.Add("Password"); - } - } - - this.pGrid.HiddenProperties = strHide.ToArray(); - - this.pGrid.Refresh(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridHideItemsFailed + Constants.vbNewLine + ex.Message, true); - } - } - - private void btnShowProperties_Click(object sender, System.EventArgs e) - { - if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) - { - if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).IsDefault) + else if (this.DefaultInheritanceVisible) //Default Inhertiance selected { + pGrid.SelectedObject = Obj; + + this.btnShowProperties.Enabled = true; + this.btnShowInheritance.Enabled = true; + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = true; + this.btnHostStatus.Enabled = true; + this.PropertiesVisible = true; - this.InheritanceVisible = false; - this.DefaultPropertiesVisible = false; - this.DefaultInheritanceVisible = false; - this.SetPropertyGridObject(App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Tag as mRemoteNG.Root.Info); + } + } + else if ((Obj as mRemoteNG.Connection.Info).IsContainer) //CONTAINER + { + this.pGrid.SelectedObject = Obj; + + this.btnShowProperties.Enabled = true; + if (((Obj as mRemoteNG.Connection.Info).Parent as mRemoteNG.Container.Info).Parent != null) + { + this.btnShowInheritance.Enabled = true; } else { - this.PropertiesVisible = true; - this.InheritanceVisible = false; - this.DefaultPropertiesVisible = false; - this.DefaultInheritanceVisible = false; - this.SetPropertyGridObject((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).Parent); + this.btnShowInheritance.Enabled = false; } + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = true; + this.btnHostStatus.Enabled = false; + + this.PropertiesVisible = true; } - else if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + + Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString((Obj as mRemoteNG.Connection.Info).Icon)); + if (conIcon != null) { - if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).IsDefault) - { - this.PropertiesVisible = true; - this.InheritanceVisible = false; - this.DefaultPropertiesVisible = false; - this.DefaultInheritanceVisible = false; - this.SetPropertyGridObject(App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Tag as mRemoteNG.Root.Info); - } + this.btnIcon.Image = conIcon.ToBitmap(); } } - - private void btnShowDefaultProperties_Click(object sender, System.EventArgs e) + else if (Obj is Root.Info) //ROOT { - if (this.pGrid.SelectedObject is mRemoteNG.Root.Info|| this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) + Root.Info rootInfo = (Root.Info) Obj; + switch (rootInfo.Type) { - this.PropertiesVisible = false; - this.InheritanceVisible = false; - this.DefaultPropertiesVisible = true; - this.DefaultInheritanceVisible = false; - this.SetPropertyGridObject(App.Runtime.DefaultConnectionFromSettings()); + case Root.Info.RootType.Connection: + PropertiesVisible = true; + DefaultPropertiesVisible = false; + btnShowProperties.Enabled = true; + btnShowInheritance.Enabled = false; + btnShowDefaultProperties.Enabled = true; + btnShowDefaultInheritance.Enabled = true; + btnIcon.Enabled = false; + btnHostStatus.Enabled = false; + break; + case Root.Info.RootType.Credential: + throw (new NotImplementedException()); + break; + case Root.Info.RootType.PuttySessions: + PropertiesVisible = true; + DefaultPropertiesVisible = false; + btnShowProperties.Enabled = true; + btnShowInheritance.Enabled = false; + btnShowDefaultProperties.Enabled = false; + btnShowDefaultInheritance.Enabled = false; + btnIcon.Enabled = false; + btnHostStatus.Enabled = false; + break; } + pGrid.SelectedObject = Obj; } - - private void btnShowInheritance_Click(object sender, System.EventArgs e) + else if (Obj is mRemoteNG.Connection.Info.Inheritance) //INHERITANCE { - if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + this.pGrid.SelectedObject = Obj; + + if (this.InheritanceVisible) { - this.PropertiesVisible = false; this.InheritanceVisible = true; - this.DefaultPropertiesVisible = false; - this.DefaultInheritanceVisible = false; - this.SetPropertyGridObject((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).Inherit); - } - } - - private void btnShowDefaultInheritance_Click(object sender, System.EventArgs e) - { - if (this.pGrid.SelectedObject is mRemoteNG.Root.Info|| this.pGrid.SelectedObject is mRemoteNG.Connection.Info) - { - this.PropertiesVisible = false; - this.InheritanceVisible = false; - this.DefaultPropertiesVisible = false; - this.DefaultInheritanceVisible = true; - this.SetPropertyGridObject(App.Runtime.DefaultInheritanceFromSettings()); - } - } - - private void btnHostStatus_Click(object sender, System.EventArgs e) - { - SetHostStatus(this.pGrid.SelectedObject); - } - - private void btnIcon_Click(object sender, System.Windows.Forms.MouseEventArgs e) - { - try - { - if (pGrid.SelectedObject is mRemoteNG.Connection.Info&& !(pGrid.SelectedObject is mRemoteNG.Connection.PuttySession.Info)) - { - this.cMenIcons.Items.Clear(); - - foreach (string iStr in mRemoteNG.Connection.Icon.Icons) - { - ToolStripMenuItem tI = new ToolStripMenuItem(); - tI.Text = iStr; - tI.Image = mRemoteNG.Connection.Icon.FromString(iStr).ToBitmap(); - tI.Click += IconMenu_Click; + this.btnShowProperties.Enabled = true; + this.btnShowInheritance.Enabled = true; + this.btnShowDefaultProperties.Enabled = false; + this.btnShowDefaultInheritance.Enabled = false; + this.btnIcon.Enabled = true; + this.btnHostStatus.Enabled = !((Obj as mRemoteNG.Connection.Info.Inheritance).Parent as mRemoteNG.Connection.Info).IsContainer; - this.cMenIcons.Items.Add(tI); - } + this.InheritanceVisible = true; + + Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString(((Obj as mRemoteNG.Connection.Info.Inheritance).Parent as mRemoteNG.Connection.Info).Icon)); + if (conIcon != null) + { + this.btnIcon.Image = conIcon.ToBitmap(); + } + } + else if (this.DefaultInheritanceVisible) + { + this.btnShowProperties.Enabled = true; + this.btnShowInheritance.Enabled = false; + this.btnShowDefaultProperties.Enabled = true; + this.btnShowDefaultInheritance.Enabled = true; + this.btnIcon.Enabled = false; + this.btnHostStatus.Enabled = false; + + this.DefaultInheritanceVisible = true; + } - Point mPos = new Point(PointToScreen(new Point(e.Location.X + this.pGrid.Width - 100, e.Location.Y))); - this.cMenIcons.Show(mPos); - } - } - catch (Exception ex) + } + + this.ShowHideGridItems(); + this.SetHostStatus(Obj); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridObjectFailed + Constants.vbNewLine + ex.Message, true); + } + } + + public void pGrid_SelectedObjectChanged() + { + this.ShowHideGridItems(); + } + #endregion + + #region Private Methods + private void ApplyLanguage() + { + btnShowInheritance.Text = My.Language.strButtonInheritance; + btnShowDefaultInheritance.Text = My.Language.strButtonDefaultInheritance; + btnShowProperties.Text = My.Language.strButtonProperties; + btnShowDefaultProperties.Text = My.Language.strButtonDefaultProperties; + btnIcon.Text = My.Language.strButtonIcon; + btnHostStatus.Text = My.Language.strStatus; + Text = My.Language.strMenuConfig; + TabText = My.Language.strMenuConfig; + propertyGridContextMenuShowHelpText.Text = Language.strMenuShowHelpText; + } + + private void ApplyTheme() + { + pGrid.BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; + pGrid.ForeColor = Themes.ThemeManager.ActiveTheme.ToolbarTextColor; + pGrid.ViewBackColor = Themes.ThemeManager.ActiveTheme.ConfigPanelBackgroundColor; + pGrid.ViewForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelTextColor; + pGrid.LineColor = Themes.ThemeManager.ActiveTheme.ConfigPanelGridLineColor; + pGrid.HelpBackColor = Themes.ThemeManager.ActiveTheme.ConfigPanelHelpBackgroundColor; + pGrid.HelpForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelHelpTextColor; + pGrid.CategoryForeColor = Themes.ThemeManager.ActiveTheme.ConfigPanelCategoryTextColor; + } + + private bool _originalPropertyGridToolStripItemCountValid; + private int _originalPropertyGridToolStripItemCount; + + private void AddToolStripItems() + { + try + { + ToolStrip customToolStrip = new ToolStrip(); + customToolStrip.Items.Add(btnShowProperties); + customToolStrip.Items.Add(btnShowInheritance); + customToolStrip.Items.Add(btnShowDefaultProperties); + customToolStrip.Items.Add(btnShowDefaultInheritance); + customToolStrip.Items.Add(btnHostStatus); + customToolStrip.Items.Add(btnIcon); + customToolStrip.Show(); + + ToolStrip propertyGridToolStrip = new ToolStrip(); + + ToolStrip toolStrip = null; + foreach (System.Windows.Forms.Control control in pGrid.Controls) + { + toolStrip = control as ToolStrip; + + if (toolStrip != null) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridButtonIconClickFailed + Constants.vbNewLine + ex.Message, true); + propertyGridToolStrip = toolStrip; + break; } } - - private void IconMenu_Click(object sender, EventArgs e) + + if (toolStrip == null) { - try - { - mRemoteNG.Connection.Info connectionInfo = pGrid.SelectedObject as mRemoteNG.Connection.Info; - if (connectionInfo == null) - { - return ; - } - - ToolStripMenuItem selectedMenuItem = sender as ToolStripMenuItem; - if (selectedMenuItem == null) - { - return ; - } - - string iconName = selectedMenuItem.Text; - if (string.IsNullOrEmpty(iconName)) - { - return ; - } - - Icon connectionIcon = mRemoteNG.Connection.Icon.FromString(iconName); - if (connectionIcon == null) - { - return ; - } - - btnIcon.Image = connectionIcon.ToBitmap(); - - connectionInfo.Icon = iconName; - pGrid.Refresh(); - - SaveConnectionsBG(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strConfigPropertyGridMenuClickFailed + Constants.vbNewLine + ex.Message, true); - } + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strCouldNotFindToolStripInFilteredPropertyGrid, true); + return ; } -#endregion - -#region Host Status (Ping) - private string HostName; - private System.Threading.Thread pThread; - - private void CheckHostAlive() + + if (!_originalPropertyGridToolStripItemCountValid) { - Ping pingSender = new Ping(); - PingReply pReply; + _originalPropertyGridToolStripItemCount = propertyGridToolStrip.Items.Count; + _originalPropertyGridToolStripItemCountValid = true; + } + Debug.Assert(_originalPropertyGridToolStripItemCount == 5); + + // Hide the "Property Pages" button + propertyGridToolStrip.Items[_originalPropertyGridToolStripItemCount - 1].Visible = false; + + int expectedToolStripItemCount = _originalPropertyGridToolStripItemCount + customToolStrip.Items.Count; + if (propertyGridToolStrip.Items.Count != expectedToolStripItemCount) + { + propertyGridToolStrip.AllowMerge = true; + ToolStripManager.Merge(customToolStrip, propertyGridToolStrip); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strConfigUiLoadFailed + Constants.vbNewLine + ex.Message, true); + } + } + + private void Config_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); - try + Themes.ThemeManager.ThemeChanged += ApplyTheme; + ApplyTheme(); + + AddToolStripItems(); + + pGrid.HelpVisible = Settings.ShowConfigHelpText; + } + + private void Config_SystemColorsChanged(System.Object sender, System.EventArgs e) + { + AddToolStripItems(); + } + + private void pGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e) + { + try + { + if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + { + if (e.ChangedItem.Label == My.Language.strPropertyNameProtocol) { - pReply = pingSender.Send(HostName); - - if (pReply.Status == IPStatus.Success) + (this.pGrid.SelectedObject as mRemoteNG.Connection.Info).SetDefaultPort(); + } + else if (e.ChangedItem.Label == My.Language.strPropertyNameName) + { + App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Text = System.Convert.ToString(this.pGrid.SelectedObject.Name); + if (My.Settings.Default.SetHostnameLikeDisplayName && this.pGrid.SelectedObject is mRemoteNG.Connection.Info) { - if ((string) this.btnHostStatus.Tag == "checking") + mRemoteNG.Connection.Info connectionInfo = (mRemoteNG.Connection.Info) this.pGrid.SelectedObject; + if (!string.IsNullOrEmpty(connectionInfo.Name)) { - ShowStatusImage(global::My.Resources.HostStatus_On); - } - } - else - { - if ((string) this.btnHostStatus.Tag == "checking") - { - ShowStatusImage(global::My.Resources.HostStatus_Off); + connectionInfo.Hostname = connectionInfo.Name; } } } - catch (Exception) + else if (e.ChangedItem.Label == My.Language.strPropertyNameIcon) { - if ((string) this.btnHostStatus.Tag == "checking") + Icon conIcon = mRemoteNG.Connection.Icon.FromString(System.Convert.ToString((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).Icon)); + if (conIcon != null) { - ShowStatusImage(global::My.Resources.HostStatus_Off); + this.btnIcon.Image = conIcon.ToBitmap(); } } + else if (e.ChangedItem.Label == My.Language.strPropertyNameAddress) + { + this.SetHostStatus(this.pGrid.SelectedObject); + } + + if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).IsDefault) + { + App.Runtime.DefaultConnectionToSettings(); + } } - - delegate void ShowStatusImageCB(Image Image); - private void ShowStatusImage(Image Image) + + Info rootInfo = pGrid.SelectedObject as Info; + if (rootInfo != null) { - if (this.pGrid.InvokeRequired) + switch (e.ChangedItem.PropertyDescriptor.Name) { - ShowStatusImageCB d = new ShowStatusImageCB(ShowStatusImage); - this.pGrid.Invoke(d, new object[] {Image}); + case "Password": + if (rootInfo.Password == true) + { + string passwordName = ""; + if (Settings.UseSQLServer) + { + passwordName = Language.strSQLServer.TrimEnd(':'); + } + else + { + passwordName = Path.GetFileName(GetStartupConnectionFileName()); + } + + string password = Tools.Misc.PasswordDialog(passwordName); + + if (string.IsNullOrEmpty(password)) + { + rootInfo.Password = System.Convert.ToString(false); + } + else + { + rootInfo.PasswordString = password; + } + } + break; + case "Name": + break; + //Windows.treeForm.tvConnections.SelectedNode.Text = pGrid.SelectedObject.Name + } + } + + if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) + { + if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).IsDefault) + { + App.Runtime.DefaultInheritanceToSettings(); + } + } + + this.ShowHideGridItems(); + App.Runtime.SaveConnectionsBG(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridValueFailed + Constants.vbNewLine + ex.Message, true); + } + } + + private void pGrid_PropertySortChanged(object sender, EventArgs e) + { + if (pGrid.PropertySort == PropertySort.CategorizedAlphabetical) + { + pGrid.PropertySort = PropertySort.Categorized; + } + } + + private void ShowHideGridItems() + { + try + { + System.Collections.Generic.List strHide = new System.Collections.Generic.List(); + + if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + { + mRemoteNG.Connection.Info conI = pGrid.SelectedObject; + + switch (conI.Protocol) + { + case mRemoteNG.Connection.Protocol.Protocols.RDP: + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("PuttySession"); + strHide.Add("RenderingEngine"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + if (conI.RDGatewayUsageMethod == mRemoteNG.Connection.Protocol.RDP.RDGatewayUsageMethod.Never) + { + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + } + else if (conI.RDGatewayUseConnectionCredentials) + { + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsername"); + } + if (!(conI.Resolution == RDP.RDPResolutions.FitToWindow || conI.Resolution == RDP.RDPResolutions.Fullscreen)) + { + strHide.Add("AutomaticResize"); + } + break; + case mRemoteNG.Connection.Protocol.Protocols.VNC: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("PuttySession"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + if (conI.VNCAuthMode == mRemoteNG.Connection.Protocol.VNC.AuthMode.AuthVNC) + { + strHide.Add("Username"); + strHide.Add("Domain"); + } + if (conI.VNCProxyType == mRemoteNG.Connection.Protocol.VNC.ProxyType.ProxyNone) + { + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyUsername"); + } + break; + case mRemoteNG.Connection.Protocol.Protocols.SSH1: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.SSH2: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.Telnet: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("Password"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("Username"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.Rlogin: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("Password"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("Username"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.RAW: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("Password"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("Username"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.HTTP: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("PuttySession"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.HTTPS: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ExtApp"); + strHide.Add("ICAEncryption"); + strHide.Add("PuttySession"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound;Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.ICA: + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("ExtApp"); + strHide.Add("Port"); + strHide.Add("PuttySession"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + case mRemoteNG.Connection.Protocol.Protocols.IntApp: + strHide.Add("CacheBitmaps"); + strHide.Add("Colors"); + strHide.Add("DisplayThemes"); + strHide.Add("DisplayWallpaper"); + strHide.Add("EnableFontSmoothing"); + strHide.Add("EnableDesktopComposition"); + strHide.Add("Domain"); + strHide.Add("ICAEncryption"); + strHide.Add("PuttySession"); + strHide.Add("RDGatewayDomain"); + strHide.Add("RDGatewayHostname"); + strHide.Add("RDGatewayPassword"); + strHide.Add("RDGatewayUsageMethod"); + strHide.Add("RDGatewayUseConnectionCredentials"); + strHide.Add("RDGatewayUsername"); + strHide.Add("RDPAuthenticationLevel"); + strHide.Add("LoadBalanceInfo"); + strHide.Add("RedirectDiskDrives"); + strHide.Add("RedirectKeys"); + strHide.Add("RedirectPorts"); + strHide.Add("RedirectPrinters"); + strHide.Add("RedirectSmartCards"); + strHide.Add("RedirectSound"); + strHide.Add("RenderingEngine"); + strHide.Add("Resolution"); + strHide.Add("AutomaticResize"); + strHide.Add("UseConsoleSession"); + strHide.Add("UseCredSsp"); + strHide.Add("VNCAuthMode"); + strHide.Add("VNCColors"); + strHide.Add("VNCCompression"); + strHide.Add("VNCEncoding"); + strHide.Add("VNCProxyIP"); + strHide.Add("VNCProxyPassword"); + strHide.Add("VNCProxyPort"); + strHide.Add("VNCProxyType"); + strHide.Add("VNCProxyUsername"); + strHide.Add("VNCSmartSizeMode"); + strHide.Add("VNCViewOnly"); + break; + } + + if (conI.IsDefault == false) + { + if (conI.Inherit.CacheBitmaps) + { + strHide.Add("CacheBitmaps"); + } + + if (conI.Inherit.Colors) + { + strHide.Add("Colors"); + } + + if (conI.Inherit.Description) + { + strHide.Add("Description"); + } + + if (conI.Inherit.DisplayThemes) + { + strHide.Add("DisplayThemes"); + } + + if (conI.Inherit.DisplayWallpaper) + { + strHide.Add("DisplayWallpaper"); + } + + if (conI.Inherit.EnableFontSmoothing) + { + strHide.Add("EnableFontSmoothing"); + } + + if (conI.Inherit.EnableDesktopComposition) + { + strHide.Add("EnableDesktopComposition"); + } + + if (conI.Inherit.Domain) + { + strHide.Add("Domain"); + } + + if (conI.Inherit.Icon) + { + strHide.Add("Icon"); + } + + if (conI.Inherit.Password) + { + strHide.Add("Password"); + } + + if (conI.Inherit.Port) + { + strHide.Add("Port"); + } + + if (conI.Inherit.Protocol) + { + strHide.Add("Protocol"); + } + + if (conI.Inherit.PuttySession) + { + strHide.Add("PuttySession"); + } + + if (conI.Inherit.RedirectDiskDrives) + { + strHide.Add("RedirectDiskDrives"); + } + + if (conI.Inherit.RedirectKeys) + { + strHide.Add("RedirectKeys"); + } + + if (conI.Inherit.RedirectPorts) + { + strHide.Add("RedirectPorts"); + } + + if (conI.Inherit.RedirectPrinters) + { + strHide.Add("RedirectPrinters"); + } + + if (conI.Inherit.RedirectSmartCards) + { + strHide.Add("RedirectSmartCards"); + } + + if (conI.Inherit.RedirectSound) + { + strHide.Add("RedirectSound"); + } + + if (conI.Inherit.Resolution) + { + strHide.Add("Resolution"); + } + + if (conI.Inherit.AutomaticResize) + { + strHide.Add("AutomaticResize"); + } + + if (conI.Inherit.UseConsoleSession) + { + strHide.Add("UseConsoleSession"); + } + + if (conI.Inherit.UseCredSsp) + { + strHide.Add("UseCredSsp"); + } + + if (conI.Inherit.RenderingEngine) + { + strHide.Add("RenderingEngine"); + } + + if (conI.Inherit.ICAEncryption) + { + strHide.Add("ICAEncryption"); + } + + if (conI.Inherit.RDPAuthenticationLevel) + { + strHide.Add("RDPAuthenticationLevel"); + } + + if (conI.Inherit.LoadBalanceInfo) + { + strHide.Add("LoadBalanceInfo"); + } + + if (conI.Inherit.Username) + { + strHide.Add("Username"); + } + + if (conI.Inherit.Panel) + { + strHide.Add("Panel"); + } + + if (conI.IsContainer) + { + strHide.Add("Hostname"); + } + + if (conI.Inherit.PreExtApp) + { + strHide.Add("PreExtApp"); + } + + if (conI.Inherit.PostExtApp) + { + strHide.Add("PostExtApp"); + } + + if (conI.Inherit.MacAddress) + { + strHide.Add("MacAddress"); + } + + if (conI.Inherit.UserField) + { + strHide.Add("UserField"); + } + + if (conI.Inherit.VNCAuthMode) + { + strHide.Add("VNCAuthMode"); + } + + if (conI.Inherit.VNCColors) + { + strHide.Add("VNCColors"); + } + + if (conI.Inherit.VNCCompression) + { + strHide.Add("VNCCompression"); + } + + if (conI.Inherit.VNCEncoding) + { + strHide.Add("VNCEncoding"); + } + + if (conI.Inherit.VNCProxyIP) + { + strHide.Add("VNCProxyIP"); + } + + if (conI.Inherit.VNCProxyPassword) + { + strHide.Add("VNCProxyPassword"); + } + + if (conI.Inherit.VNCProxyPort) + { + strHide.Add("VNCProxyPort"); + } + + if (conI.Inherit.VNCProxyType) + { + strHide.Add("VNCProxyType"); + } + + if (conI.Inherit.VNCProxyUsername) + { + strHide.Add("VNCProxyUsername"); + } + + if (conI.Inherit.VNCViewOnly) + { + strHide.Add("VNCViewOnly"); + } + + if (conI.Inherit.VNCSmartSizeMode) + { + strHide.Add("VNCSmartSizeMode"); + } + + if (conI.Inherit.ExtApp) + { + strHide.Add("ExtApp"); + } + + if (conI.Inherit.RDGatewayUsageMethod) + { + strHide.Add("RDGatewayUsageMethod"); + } + + if (conI.Inherit.RDGatewayHostname) + { + strHide.Add("RDGatewayHostname"); + } + + if (conI.Inherit.RDGatewayUsername) + { + strHide.Add("RDGatewayUsername"); + } + + if (conI.Inherit.RDGatewayPassword) + { + strHide.Add("RDGatewayPassword"); + } + + if (conI.Inherit.RDGatewayDomain) + { + strHide.Add("RDGatewayDomain"); + } + + if (conI.Inherit.RDGatewayUseConnectionCredentials) + { + strHide.Add("RDGatewayUseConnectionCredentials"); + } + + if (conI.Inherit.RDGatewayHostname) + { + strHide.Add("RDGatewayHostname"); + } } else { - this.btnHostStatus.Image = Image; - this.btnHostStatus.Tag = "checkfinished"; + strHide.Add("Hostname"); + strHide.Add("Name"); } } - - public void SetHostStatus(object ConnectionInfo) + else if (pGrid.SelectedObject is Root.Info) { - try + Root.Info rootInfo = (Root.Info) pGrid.SelectedObject; + if (rootInfo.Type == Root.Info.RootType.PuttySessions) { - this.btnHostStatus.Image = global::My.Resources.HostStatus_Check; + strHide.Add("Password"); + } + } - // To check status, ConnectionInfo must be an mRemoteNG.Connection.Info that is not a container - if (ConnectionInfo is mRemoteNG.Connection.Info) - { - if ((ConnectionInfo as mRemoteNG.Connection.Info).IsContainer) - { - return ; - } - } - else - { - return ; - } + this.pGrid.HiddenProperties = strHide.ToArray(); - this.btnHostStatus.Tag = "checking"; - HostName = (ConnectionInfo as mRemoteNG.Connection.Info).Hostname; - pThread = new System.Threading.Thread(new System.Threading.ThreadStart(CheckHostAlive)); - pThread.SetApartmentState(System.Threading.ApartmentState.STA); - pThread.IsBackground = true; - pThread.Start(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridSetHostStatusFailed + Constants.vbNewLine + ex.Message, true); - } - } -#endregion + this.pGrid.Refresh(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridHideItemsFailed + Constants.vbNewLine + ex.Message, true); + } + } - private void propertyGridContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e) + private void btnShowProperties_Click(object sender, System.EventArgs e) + { + if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) + { + if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).IsDefault) { - try - { - propertyGridContextMenuShowHelpText.Checked = Settings.ShowConfigHelpText; - GridItem gridItem = pGrid.SelectedGridItem; - propertyGridContextMenuReset.Enabled = System.Convert.ToBoolean(pGrid.SelectedObject != null && gridItem != null && gridItem.PropertyDescriptor != null && gridItem.PropertyDescriptor.CanResetValue(pGrid.SelectedObject)); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage("UI.Window.Config.propertyGridContextMenu_Opening() failed.", ex, MessageClass.ErrorMsg, true); - } + this.PropertiesVisible = true; + this.InheritanceVisible = false; + this.DefaultPropertiesVisible = false; + this.DefaultInheritanceVisible = false; + this.SetPropertyGridObject(App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Tag as mRemoteNG.Root.Info); } - - private void propertyGridContextMenuReset_Click(System.Object sender, EventArgs e) + else { - try - { - GridItem gridItem = pGrid.SelectedGridItem; - if (pGrid.SelectedObject != null && gridItem != null && gridItem.PropertyDescriptor != null && gridItem.PropertyDescriptor.CanResetValue(pGrid.SelectedObject)) - { - pGrid.ResetSelectedProperty(); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage("UI.Window.Config.propertyGridContextMenuReset_Click() failed.", ex, MessageClass.ErrorMsg, true); - } - } - - private void propertyGridContextMenuShowHelpText_Click(object sender, EventArgs e) - { - propertyGridContextMenuShowHelpText.Checked = !propertyGridContextMenuShowHelpText.Checked; - } - - private void propertyGridContextMenuShowHelpText_CheckedChanged(object sender, EventArgs e) - { - Settings.ShowConfigHelpText = propertyGridContextMenuShowHelpText.Checked; - pGrid.HelpVisible = propertyGridContextMenuShowHelpText.Checked; + this.PropertiesVisible = true; + this.InheritanceVisible = false; + this.DefaultPropertiesVisible = false; + this.DefaultInheritanceVisible = false; + this.SetPropertyGridObject((this.pGrid.SelectedObject as mRemoteNG.Connection.Info.Inheritance).Parent); } } + else if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + { + if ((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).IsDefault) + { + this.PropertiesVisible = true; + this.InheritanceVisible = false; + this.DefaultPropertiesVisible = false; + this.DefaultInheritanceVisible = false; + this.SetPropertyGridObject(App.Runtime.Windows.treeForm.tvConnections.SelectedNode.Tag as mRemoteNG.Root.Info); + } + } + } + + private void btnShowDefaultProperties_Click(object sender, System.EventArgs e) + { + if (this.pGrid.SelectedObject is mRemoteNG.Root.Info|| this.pGrid.SelectedObject is mRemoteNG.Connection.Info.Inheritance) + { + this.PropertiesVisible = false; + this.InheritanceVisible = false; + this.DefaultPropertiesVisible = true; + this.DefaultInheritanceVisible = false; + this.SetPropertyGridObject(App.Runtime.DefaultConnectionFromSettings()); + } + } + + private void btnShowInheritance_Click(object sender, System.EventArgs e) + { + if (this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + { + this.PropertiesVisible = false; + this.InheritanceVisible = true; + this.DefaultPropertiesVisible = false; + this.DefaultInheritanceVisible = false; + this.SetPropertyGridObject((this.pGrid.SelectedObject as mRemoteNG.Connection.Info).Inherit); + } + } + + private void btnShowDefaultInheritance_Click(object sender, System.EventArgs e) + { + if (this.pGrid.SelectedObject is mRemoteNG.Root.Info|| this.pGrid.SelectedObject is mRemoteNG.Connection.Info) + { + this.PropertiesVisible = false; + this.InheritanceVisible = false; + this.DefaultPropertiesVisible = false; + this.DefaultInheritanceVisible = true; + this.SetPropertyGridObject(App.Runtime.DefaultInheritanceFromSettings()); + } + } + + private void btnHostStatus_Click(object sender, System.EventArgs e) + { + SetHostStatus(this.pGrid.SelectedObject); + } + + private void btnIcon_Click(object sender, System.Windows.Forms.MouseEventArgs e) + { + try + { + if (pGrid.SelectedObject is mRemoteNG.Connection.Info&& !(pGrid.SelectedObject is mRemoteNG.Connection.PuttySession.Info)) + { + this.cMenIcons.Items.Clear(); + + foreach (string iStr in mRemoteNG.Connection.Icon.Icons) + { + ToolStripMenuItem tI = new ToolStripMenuItem(); + tI.Text = iStr; + tI.Image = mRemoteNG.Connection.Icon.FromString(iStr).ToBitmap(); + tI.Click += IconMenu_Click; + + this.cMenIcons.Items.Add(tI); + } + + Point mPos = new Point(PointToScreen(new Point(e.Location.X + this.pGrid.Width - 100, e.Location.Y))); + this.cMenIcons.Show(mPos); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridButtonIconClickFailed + Constants.vbNewLine + ex.Message, true); + } + } + + private void IconMenu_Click(object sender, EventArgs e) + { + try + { + mRemoteNG.Connection.Info connectionInfo = pGrid.SelectedObject as mRemoteNG.Connection.Info; + if (connectionInfo == null) + { + return ; + } + + ToolStripMenuItem selectedMenuItem = sender as ToolStripMenuItem; + if (selectedMenuItem == null) + { + return ; + } + + string iconName = selectedMenuItem.Text; + if (string.IsNullOrEmpty(iconName)) + { + return ; + } + + Icon connectionIcon = mRemoteNG.Connection.Icon.FromString(iconName); + if (connectionIcon == null) + { + return ; + } + + btnIcon.Image = connectionIcon.ToBitmap(); + + connectionInfo.Icon = iconName; + pGrid.Refresh(); + + SaveConnectionsBG(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strConfigPropertyGridMenuClickFailed + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Host Status (Ping) + private string HostName; + private System.Threading.Thread pThread; + + private void CheckHostAlive() + { + Ping pingSender = new Ping(); + PingReply pReply; + + try + { + pReply = pingSender.Send(HostName); + + if (pReply.Status == IPStatus.Success) + { + if ((string) this.btnHostStatus.Tag == "checking") + { + ShowStatusImage(global::My.Resources.HostStatus_On); + } + } + else + { + if ((string) this.btnHostStatus.Tag == "checking") + { + ShowStatusImage(global::My.Resources.HostStatus_Off); + } + } + } + catch (Exception) + { + if ((string) this.btnHostStatus.Tag == "checking") + { + ShowStatusImage(global::My.Resources.HostStatus_Off); + } + } + } + + delegate void ShowStatusImageCB(Image Image); + private void ShowStatusImage(Image Image) + { + if (this.pGrid.InvokeRequired) + { + ShowStatusImageCB d = new ShowStatusImageCB(ShowStatusImage); + this.pGrid.Invoke(d, new object[] {Image}); + } + else + { + this.btnHostStatus.Image = Image; + this.btnHostStatus.Tag = "checkfinished"; + } + } + + public void SetHostStatus(object ConnectionInfo) + { + try + { + this.btnHostStatus.Image = global::My.Resources.HostStatus_Check; + + // To check status, ConnectionInfo must be an mRemoteNG.Connection.Info that is not a container + if (ConnectionInfo is mRemoteNG.Connection.Info) + { + if ((ConnectionInfo as mRemoteNG.Connection.Info).IsContainer) + { + return ; + } + } + else + { + return ; + } + + this.btnHostStatus.Tag = "checking"; + HostName = (ConnectionInfo as mRemoteNG.Connection.Info).Hostname; + pThread = new System.Threading.Thread(new System.Threading.ThreadStart(CheckHostAlive)); + pThread.SetApartmentState(System.Threading.ApartmentState.STA); + pThread.IsBackground = true; + pThread.Start(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConfigPropertyGridSetHostStatusFailed + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + private void propertyGridContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + try + { + propertyGridContextMenuShowHelpText.Checked = Settings.ShowConfigHelpText; + GridItem gridItem = pGrid.SelectedGridItem; + propertyGridContextMenuReset.Enabled = System.Convert.ToBoolean(pGrid.SelectedObject != null && gridItem != null && gridItem.PropertyDescriptor != null && gridItem.PropertyDescriptor.CanResetValue(pGrid.SelectedObject)); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage("UI.Window.Config.propertyGridContextMenu_Opening() failed.", ex, MessageClass.ErrorMsg, true); + } + } + + private void propertyGridContextMenuReset_Click(System.Object sender, EventArgs e) + { + try + { + GridItem gridItem = pGrid.SelectedGridItem; + if (pGrid.SelectedObject != null && gridItem != null && gridItem.PropertyDescriptor != null && gridItem.PropertyDescriptor.CanResetValue(pGrid.SelectedObject)) + { + pGrid.ResetSelectedProperty(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage("UI.Window.Config.propertyGridContextMenuReset_Click() failed.", ex, MessageClass.ErrorMsg, true); + } + } + + private void propertyGridContextMenuShowHelpText_Click(object sender, EventArgs e) + { + propertyGridContextMenuShowHelpText.Checked = !propertyGridContextMenuShowHelpText.Checked; + } + + private void propertyGridContextMenuShowHelpText_CheckedChanged(object sender, EventArgs e) + { + Settings.ShowConfigHelpText = propertyGridContextMenuShowHelpText.Checked; + pGrid.HelpVisible = propertyGridContextMenuShowHelpText.Checked; + } + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Connection.cs b/mRemoteV1/CS/UI/UI.Window.Connection.cs index eda2a6808..b277c1a0d 100644 --- a/mRemoteV1/CS/UI/UI.Window.Connection.cs +++ b/mRemoteV1/CS/UI/UI.Window.Connection.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,1340 +8,1336 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Windows; using mRemoteNG.Connection; using mRemoteNG.App; using Crownwood; using WeifenLuo.WinFormsUI.Docking; using PSTaskDialog; -//using mRemoteNG.App.Runtime; using mRemoteNG.Config; namespace mRemoteNG.UI.Window { public class Connection : UI.Window.Base + { + #region Form Init + internal System.Windows.Forms.ContextMenuStrip cmenTab; + private System.ComponentModel.Container components = null; + internal System.Windows.Forms.ToolStripMenuItem cmenTabFullscreen; + internal System.Windows.Forms.ToolStripMenuItem cmenTabScreenshot; + internal System.Windows.Forms.ToolStripMenuItem cmenTabTransferFile; + internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeys; + internal System.Windows.Forms.ToolStripSeparator cmenTabSep1; + internal System.Windows.Forms.ToolStripMenuItem cmenTabRenameTab; + internal System.Windows.Forms.ToolStripMenuItem cmenTabDuplicateTab; + internal System.Windows.Forms.ToolStripMenuItem cmenTabDisconnect; + internal System.Windows.Forms.ToolStripMenuItem cmenTabSmartSize; + internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeysCtrlAltDel; + internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeysCtrlEsc; + internal System.Windows.Forms.ToolStripMenuItem cmenTabViewOnly; + internal System.Windows.Forms.ToolStripMenuItem cmenTabReconnect; + internal System.Windows.Forms.ToolStripMenuItem cmenTabExternalApps; + internal System.Windows.Forms.ToolStripMenuItem cmenTabStartChat; + internal System.Windows.Forms.ToolStripMenuItem cmenTabRefreshScreen; + internal System.Windows.Forms.ToolStripSeparator ToolStripSeparator1; + internal System.Windows.Forms.ToolStripMenuItem cmenTabPuttySettings; + + public Crownwood.Magic.Controls.TabControl TabController; + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Load += new System.EventHandler(Connection_Load); + this.DockStateChanged += new System.EventHandler(Connection_DockStateChanged); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(Connection_FormClosing); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Connection)); + this.TabController = new Crownwood.Magic.Controls.TabControl(); + this.TabController.ClosePressed += new System.EventHandler(this.TabController_ClosePressed); + this.TabController.DoubleClickTab += new Crownwood.Magic.Controls.TabControl.DoubleClickTabHandler(this.TabController_DoubleClickTab); + this.TabController.DragDrop += new System.Windows.Forms.DragEventHandler(this.TabController_DragDrop); + this.TabController.DragEnter += new System.Windows.Forms.DragEventHandler(this.TabController_DragEnter); + this.TabController.DragOver += new System.Windows.Forms.DragEventHandler(this.TabController_DragOver); + this.TabController.SelectionChanged += new System.EventHandler(this.TabController_SelectionChanged); + this.TabController.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TabController_MouseUp); + this.TabController.PageDragEnd += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragStart); + this.TabController.PageDragStart += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragStart); + this.TabController.PageDragMove += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragMove); + this.TabController.PageDragEnd += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragEnd); + this.TabController.PageDragQuit += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragEnd); + this.cmenTab = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cmenTabFullscreen = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabFullscreen.Click += new System.EventHandler(this.cmenTabFullscreen_Click); + this.cmenTabSmartSize = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabSmartSize.Click += new System.EventHandler(this.cmenTabSmartSize_Click); + this.cmenTabViewOnly = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabViewOnly.Click += new System.EventHandler(this.cmenTabViewOnly_Click); + this.ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.cmenTabScreenshot = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabScreenshot.Click += new System.EventHandler(this.cmenTabScreenshot_Click); + this.cmenTabStartChat = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabStartChat.Click += new System.EventHandler(this.cmenTabStartChat_Click); + this.cmenTabTransferFile = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabTransferFile.Click += new System.EventHandler(this.cmenTabTransferFile_Click); + this.cmenTabRefreshScreen = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabRefreshScreen.Click += new System.EventHandler(this.cmenTabRefreshScreen_Click); + this.cmenTabSendSpecialKeys = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabSendSpecialKeysCtrlAltDel = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabSendSpecialKeysCtrlAltDel.Click += new System.EventHandler(this.cmenTabSendSpecialKeysCtrlAltDel_Click); + this.cmenTabSendSpecialKeysCtrlEsc = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabSendSpecialKeysCtrlEsc.Click += new System.EventHandler(this.cmenTabSendSpecialKeysCtrlEsc_Click); + this.cmenTabExternalApps = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabSep1 = new System.Windows.Forms.ToolStripSeparator(); + this.cmenTabRenameTab = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabRenameTab.Click += new System.EventHandler(this.cmenTabRenameTab_Click); + this.cmenTabDuplicateTab = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabDuplicateTab.Click += new System.EventHandler(this.cmenTabDuplicateTab_Click); + this.cmenTabReconnect = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabReconnect.Click += new System.EventHandler(this.cmenTabReconnect_Click); + this.cmenTabDisconnect = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabDisconnect.Click += new System.EventHandler(this.cmenTabDisconnect_Click); + this.cmenTabPuttySettings = new System.Windows.Forms.ToolStripMenuItem(); + this.cmenTabPuttySettings.Click += new System.EventHandler(this.cmenTabPuttySettings_Click); + this.cmenTab.SuspendLayout(); + this.SuspendLayout(); + // + //TabController + // + this.TabController.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.TabController.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument; + this.TabController.Cursor = System.Windows.Forms.Cursors.Hand; + this.TabController.DragFromControl = false; + this.TabController.IDEPixelArea = true; + this.TabController.IDEPixelBorder = false; + this.TabController.Location = new System.Drawing.Point(0, -1); + this.TabController.Name = "TabController"; + this.TabController.Size = new System.Drawing.Size(632, 454); + this.TabController.TabIndex = 0; + // + //cmenTab + // + this.cmenTab.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cmenTabFullscreen, this.cmenTabSmartSize, this.cmenTabViewOnly, this.ToolStripSeparator1, this.cmenTabScreenshot, this.cmenTabStartChat, this.cmenTabTransferFile, this.cmenTabRefreshScreen, this.cmenTabSendSpecialKeys, this.cmenTabPuttySettings, this.cmenTabExternalApps, this.cmenTabSep1, this.cmenTabRenameTab, this.cmenTabDuplicateTab, this.cmenTabReconnect, this.cmenTabDisconnect}); + this.cmenTab.Name = "cmenTab"; + this.cmenTab.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.cmenTab.Size = new System.Drawing.Size(202, 346); + // + //cmenTabFullscreen + // + this.cmenTabFullscreen.Image = global::My.Resources.Resources.arrow_out; + this.cmenTabFullscreen.Name = "cmenTabFullscreen"; + this.cmenTabFullscreen.Size = new System.Drawing.Size(201, 22); + this.cmenTabFullscreen.Text = "Fullscreen (RDP)"; + // + //cmenTabSmartSize + // + this.cmenTabSmartSize.Image = global::My.Resources.Resources.SmartSize; + this.cmenTabSmartSize.Name = "cmenTabSmartSize"; + this.cmenTabSmartSize.Size = new System.Drawing.Size(201, 22); + this.cmenTabSmartSize.Text = "SmartSize (RDP/VNC)"; + // + //cmenTabViewOnly + // + this.cmenTabViewOnly.Name = "cmenTabViewOnly"; + this.cmenTabViewOnly.Size = new System.Drawing.Size(201, 22); + this.cmenTabViewOnly.Text = "View Only (VNC)"; + // + //ToolStripSeparator1 + // + this.ToolStripSeparator1.Name = "ToolStripSeparator1"; + this.ToolStripSeparator1.Size = new System.Drawing.Size(198, 6); + // + //cmenTabScreenshot + // + this.cmenTabScreenshot.Image = global::My.Resources.Resources.Screenshot_Add; + this.cmenTabScreenshot.Name = "cmenTabScreenshot"; + this.cmenTabScreenshot.Size = new System.Drawing.Size(201, 22); + this.cmenTabScreenshot.Text = "Screenshot"; + // + //cmenTabStartChat + // + this.cmenTabStartChat.Image = global::My.Resources.Resources.Chat; + this.cmenTabStartChat.Name = "cmenTabStartChat"; + this.cmenTabStartChat.Size = new System.Drawing.Size(201, 22); + this.cmenTabStartChat.Text = "Start Chat (VNC)"; + this.cmenTabStartChat.Visible = false; + // + //cmenTabTransferFile + // + this.cmenTabTransferFile.Image = global::My.Resources.Resources.SSHTransfer; + this.cmenTabTransferFile.Name = "cmenTabTransferFile"; + this.cmenTabTransferFile.Size = new System.Drawing.Size(201, 22); + this.cmenTabTransferFile.Text = "Transfer File (SSH)"; + // + //cmenTabRefreshScreen + // + this.cmenTabRefreshScreen.Image = global::My.Resources.Resources.Refresh; + this.cmenTabRefreshScreen.Name = "cmenTabRefreshScreen"; + this.cmenTabRefreshScreen.Size = new System.Drawing.Size(201, 22); + this.cmenTabRefreshScreen.Text = "Refresh Screen (VNC)"; + // + //cmenTabSendSpecialKeys + // + this.cmenTabSendSpecialKeys.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cmenTabSendSpecialKeysCtrlAltDel, this.cmenTabSendSpecialKeysCtrlEsc}); + this.cmenTabSendSpecialKeys.Image = global::My.Resources.Resources.Keyboard; + this.cmenTabSendSpecialKeys.Name = "cmenTabSendSpecialKeys"; + this.cmenTabSendSpecialKeys.Size = new System.Drawing.Size(201, 22); + this.cmenTabSendSpecialKeys.Text = "Send special Keys (VNC)"; + // + //cmenTabSendSpecialKeysCtrlAltDel + // + this.cmenTabSendSpecialKeysCtrlAltDel.Name = "cmenTabSendSpecialKeysCtrlAltDel"; + this.cmenTabSendSpecialKeysCtrlAltDel.Size = new System.Drawing.Size(141, 22); + this.cmenTabSendSpecialKeysCtrlAltDel.Text = "Ctrl+Alt+Del"; + // + //cmenTabSendSpecialKeysCtrlEsc + // + this.cmenTabSendSpecialKeysCtrlEsc.Name = "cmenTabSendSpecialKeysCtrlEsc"; + this.cmenTabSendSpecialKeysCtrlEsc.Size = new System.Drawing.Size(141, 22); + this.cmenTabSendSpecialKeysCtrlEsc.Text = "Ctrl+Esc"; + // + //cmenTabExternalApps + // + this.cmenTabExternalApps.Image = (System.Drawing.Image) (resources.GetObject("cmenTabExternalApps.Image")); + this.cmenTabExternalApps.Name = "cmenTabExternalApps"; + this.cmenTabExternalApps.Size = new System.Drawing.Size(201, 22); + this.cmenTabExternalApps.Text = "External Applications"; + // + //cmenTabSep1 + // + this.cmenTabSep1.Name = "cmenTabSep1"; + this.cmenTabSep1.Size = new System.Drawing.Size(198, 6); + // + //cmenTabRenameTab + // + this.cmenTabRenameTab.Image = global::My.Resources.Resources.Rename; + this.cmenTabRenameTab.Name = "cmenTabRenameTab"; + this.cmenTabRenameTab.Size = new System.Drawing.Size(201, 22); + this.cmenTabRenameTab.Text = "Rename Tab"; + // + //cmenTabDuplicateTab + // + this.cmenTabDuplicateTab.Name = "cmenTabDuplicateTab"; + this.cmenTabDuplicateTab.Size = new System.Drawing.Size(201, 22); + this.cmenTabDuplicateTab.Text = "Duplicate Tab"; + // + //cmenTabReconnect + // + this.cmenTabReconnect.Image = (System.Drawing.Image) (resources.GetObject("cmenTabReconnect.Image")); + this.cmenTabReconnect.Name = "cmenTabReconnect"; + this.cmenTabReconnect.Size = new System.Drawing.Size(201, 22); + this.cmenTabReconnect.Text = "Reconnect"; + // + //cmenTabDisconnect + // + this.cmenTabDisconnect.Image = global::My.Resources.Resources.Pause; + this.cmenTabDisconnect.Name = "cmenTabDisconnect"; + this.cmenTabDisconnect.Size = new System.Drawing.Size(201, 22); + this.cmenTabDisconnect.Text = "Disconnect"; + // + //cmenTabPuttySettings + // + this.cmenTabPuttySettings.Name = "cmenTabPuttySettings"; + this.cmenTabPuttySettings.Size = new System.Drawing.Size(201, 22); + this.cmenTabPuttySettings.Text = "PuTTY Settings"; + // + //Connection + // + this.ClientSize = new System.Drawing.Size(632, 453); + this.Controls.Add(this.TabController); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.Icon = global::My.Resources.Resources.mRemote_Icon; + this.Name = "Connection"; + this.TabText = "UI.Window.Connection"; + this.Text = "UI.Window.Connection"; + this.cmenTab.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + #region Public Methods + public Connection(DockContent Panel, string FormText = "") + { + + if (FormText == "") { - -#region Form Init - internal System.Windows.Forms.ContextMenuStrip cmenTab; - private System.ComponentModel.Container components = null; - internal System.Windows.Forms.ToolStripMenuItem cmenTabFullscreen; - internal System.Windows.Forms.ToolStripMenuItem cmenTabScreenshot; - internal System.Windows.Forms.ToolStripMenuItem cmenTabTransferFile; - internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeys; - internal System.Windows.Forms.ToolStripSeparator cmenTabSep1; - internal System.Windows.Forms.ToolStripMenuItem cmenTabRenameTab; - internal System.Windows.Forms.ToolStripMenuItem cmenTabDuplicateTab; - internal System.Windows.Forms.ToolStripMenuItem cmenTabDisconnect; - internal System.Windows.Forms.ToolStripMenuItem cmenTabSmartSize; - internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeysCtrlAltDel; - internal System.Windows.Forms.ToolStripMenuItem cmenTabSendSpecialKeysCtrlEsc; - internal System.Windows.Forms.ToolStripMenuItem cmenTabViewOnly; - internal System.Windows.Forms.ToolStripMenuItem cmenTabReconnect; - internal System.Windows.Forms.ToolStripMenuItem cmenTabExternalApps; - internal System.Windows.Forms.ToolStripMenuItem cmenTabStartChat; - internal System.Windows.Forms.ToolStripMenuItem cmenTabRefreshScreen; - internal System.Windows.Forms.ToolStripSeparator ToolStripSeparator1; - internal System.Windows.Forms.ToolStripMenuItem cmenTabPuttySettings; - - public Crownwood.Magic.Controls.TabControl TabController; - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.Load += new System.EventHandler(Connection_Load); - this.DockStateChanged += new System.EventHandler(Connection_DockStateChanged); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(Connection_FormClosing); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Connection)); - this.TabController = new Crownwood.Magic.Controls.TabControl(); - this.TabController.ClosePressed += new System.EventHandler(this.TabController_ClosePressed); - this.TabController.DoubleClickTab += new Crownwood.Magic.Controls.TabControl.DoubleClickTabHandler(this.TabController_DoubleClickTab); - this.TabController.DragDrop += new System.Windows.Forms.DragEventHandler(this.TabController_DragDrop); - this.TabController.DragEnter += new System.Windows.Forms.DragEventHandler(this.TabController_DragEnter); - this.TabController.DragOver += new System.Windows.Forms.DragEventHandler(this.TabController_DragOver); - this.TabController.SelectionChanged += new System.EventHandler(this.TabController_SelectionChanged); - this.TabController.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TabController_MouseUp); - this.TabController.PageDragEnd += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragStart); - this.TabController.PageDragStart += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragStart); - this.TabController.PageDragMove += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragMove); - this.TabController.PageDragEnd += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragEnd); - this.TabController.PageDragQuit += new System.Windows.Forms.MouseEventHandler(this.TabController_PageDragEnd); - this.cmenTab = new System.Windows.Forms.ContextMenuStrip(this.components); - this.cmenTabFullscreen = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabFullscreen.Click += new System.EventHandler(this.cmenTabFullscreen_Click); - this.cmenTabSmartSize = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabSmartSize.Click += new System.EventHandler(this.cmenTabSmartSize_Click); - this.cmenTabViewOnly = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabViewOnly.Click += new System.EventHandler(this.cmenTabViewOnly_Click); - this.ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.cmenTabScreenshot = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabScreenshot.Click += new System.EventHandler(this.cmenTabScreenshot_Click); - this.cmenTabStartChat = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabStartChat.Click += new System.EventHandler(this.cmenTabStartChat_Click); - this.cmenTabTransferFile = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabTransferFile.Click += new System.EventHandler(this.cmenTabTransferFile_Click); - this.cmenTabRefreshScreen = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabRefreshScreen.Click += new System.EventHandler(this.cmenTabRefreshScreen_Click); - this.cmenTabSendSpecialKeys = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabSendSpecialKeysCtrlAltDel = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabSendSpecialKeysCtrlAltDel.Click += new System.EventHandler(this.cmenTabSendSpecialKeysCtrlAltDel_Click); - this.cmenTabSendSpecialKeysCtrlEsc = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabSendSpecialKeysCtrlEsc.Click += new System.EventHandler(this.cmenTabSendSpecialKeysCtrlEsc_Click); - this.cmenTabExternalApps = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabSep1 = new System.Windows.Forms.ToolStripSeparator(); - this.cmenTabRenameTab = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabRenameTab.Click += new System.EventHandler(this.cmenTabRenameTab_Click); - this.cmenTabDuplicateTab = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabDuplicateTab.Click += new System.EventHandler(this.cmenTabDuplicateTab_Click); - this.cmenTabReconnect = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabReconnect.Click += new System.EventHandler(this.cmenTabReconnect_Click); - this.cmenTabDisconnect = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabDisconnect.Click += new System.EventHandler(this.cmenTabDisconnect_Click); - this.cmenTabPuttySettings = new System.Windows.Forms.ToolStripMenuItem(); - this.cmenTabPuttySettings.Click += new System.EventHandler(this.cmenTabPuttySettings_Click); - this.cmenTab.SuspendLayout(); - this.SuspendLayout(); - // - //TabController - // - this.TabController.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.TabController.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument; - this.TabController.Cursor = System.Windows.Forms.Cursors.Hand; - this.TabController.DragFromControl = false; - this.TabController.IDEPixelArea = true; - this.TabController.IDEPixelBorder = false; - this.TabController.Location = new System.Drawing.Point(0, -1); - this.TabController.Name = "TabController"; - this.TabController.Size = new System.Drawing.Size(632, 454); - this.TabController.TabIndex = 0; - // - //cmenTab - // - this.cmenTab.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cmenTabFullscreen, this.cmenTabSmartSize, this.cmenTabViewOnly, this.ToolStripSeparator1, this.cmenTabScreenshot, this.cmenTabStartChat, this.cmenTabTransferFile, this.cmenTabRefreshScreen, this.cmenTabSendSpecialKeys, this.cmenTabPuttySettings, this.cmenTabExternalApps, this.cmenTabSep1, this.cmenTabRenameTab, this.cmenTabDuplicateTab, this.cmenTabReconnect, this.cmenTabDisconnect}); - this.cmenTab.Name = "cmenTab"; - this.cmenTab.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.cmenTab.Size = new System.Drawing.Size(202, 346); - // - //cmenTabFullscreen - // - this.cmenTabFullscreen.Image = global::My.Resources.Resources.arrow_out; - this.cmenTabFullscreen.Name = "cmenTabFullscreen"; - this.cmenTabFullscreen.Size = new System.Drawing.Size(201, 22); - this.cmenTabFullscreen.Text = "Fullscreen (RDP)"; - // - //cmenTabSmartSize - // - this.cmenTabSmartSize.Image = global::My.Resources.Resources.SmartSize; - this.cmenTabSmartSize.Name = "cmenTabSmartSize"; - this.cmenTabSmartSize.Size = new System.Drawing.Size(201, 22); - this.cmenTabSmartSize.Text = "SmartSize (RDP/VNC)"; - // - //cmenTabViewOnly - // - this.cmenTabViewOnly.Name = "cmenTabViewOnly"; - this.cmenTabViewOnly.Size = new System.Drawing.Size(201, 22); - this.cmenTabViewOnly.Text = "View Only (VNC)"; - // - //ToolStripSeparator1 - // - this.ToolStripSeparator1.Name = "ToolStripSeparator1"; - this.ToolStripSeparator1.Size = new System.Drawing.Size(198, 6); - // - //cmenTabScreenshot - // - this.cmenTabScreenshot.Image = global::My.Resources.Resources.Screenshot_Add; - this.cmenTabScreenshot.Name = "cmenTabScreenshot"; - this.cmenTabScreenshot.Size = new System.Drawing.Size(201, 22); - this.cmenTabScreenshot.Text = "Screenshot"; - // - //cmenTabStartChat - // - this.cmenTabStartChat.Image = global::My.Resources.Resources.Chat; - this.cmenTabStartChat.Name = "cmenTabStartChat"; - this.cmenTabStartChat.Size = new System.Drawing.Size(201, 22); - this.cmenTabStartChat.Text = "Start Chat (VNC)"; - this.cmenTabStartChat.Visible = false; - // - //cmenTabTransferFile - // - this.cmenTabTransferFile.Image = global::My.Resources.Resources.SSHTransfer; - this.cmenTabTransferFile.Name = "cmenTabTransferFile"; - this.cmenTabTransferFile.Size = new System.Drawing.Size(201, 22); - this.cmenTabTransferFile.Text = "Transfer File (SSH)"; - // - //cmenTabRefreshScreen - // - this.cmenTabRefreshScreen.Image = global::My.Resources.Resources.Refresh; - this.cmenTabRefreshScreen.Name = "cmenTabRefreshScreen"; - this.cmenTabRefreshScreen.Size = new System.Drawing.Size(201, 22); - this.cmenTabRefreshScreen.Text = "Refresh Screen (VNC)"; - // - //cmenTabSendSpecialKeys - // - this.cmenTabSendSpecialKeys.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cmenTabSendSpecialKeysCtrlAltDel, this.cmenTabSendSpecialKeysCtrlEsc}); - this.cmenTabSendSpecialKeys.Image = global::My.Resources.Resources.Keyboard; - this.cmenTabSendSpecialKeys.Name = "cmenTabSendSpecialKeys"; - this.cmenTabSendSpecialKeys.Size = new System.Drawing.Size(201, 22); - this.cmenTabSendSpecialKeys.Text = "Send special Keys (VNC)"; - // - //cmenTabSendSpecialKeysCtrlAltDel - // - this.cmenTabSendSpecialKeysCtrlAltDel.Name = "cmenTabSendSpecialKeysCtrlAltDel"; - this.cmenTabSendSpecialKeysCtrlAltDel.Size = new System.Drawing.Size(141, 22); - this.cmenTabSendSpecialKeysCtrlAltDel.Text = "Ctrl+Alt+Del"; - // - //cmenTabSendSpecialKeysCtrlEsc - // - this.cmenTabSendSpecialKeysCtrlEsc.Name = "cmenTabSendSpecialKeysCtrlEsc"; - this.cmenTabSendSpecialKeysCtrlEsc.Size = new System.Drawing.Size(141, 22); - this.cmenTabSendSpecialKeysCtrlEsc.Text = "Ctrl+Esc"; - // - //cmenTabExternalApps - // - this.cmenTabExternalApps.Image = (System.Drawing.Image) (resources.GetObject("cmenTabExternalApps.Image")); - this.cmenTabExternalApps.Name = "cmenTabExternalApps"; - this.cmenTabExternalApps.Size = new System.Drawing.Size(201, 22); - this.cmenTabExternalApps.Text = "External Applications"; - // - //cmenTabSep1 - // - this.cmenTabSep1.Name = "cmenTabSep1"; - this.cmenTabSep1.Size = new System.Drawing.Size(198, 6); - // - //cmenTabRenameTab - // - this.cmenTabRenameTab.Image = global::My.Resources.Resources.Rename; - this.cmenTabRenameTab.Name = "cmenTabRenameTab"; - this.cmenTabRenameTab.Size = new System.Drawing.Size(201, 22); - this.cmenTabRenameTab.Text = "Rename Tab"; - // - //cmenTabDuplicateTab - // - this.cmenTabDuplicateTab.Name = "cmenTabDuplicateTab"; - this.cmenTabDuplicateTab.Size = new System.Drawing.Size(201, 22); - this.cmenTabDuplicateTab.Text = "Duplicate Tab"; - // - //cmenTabReconnect - // - this.cmenTabReconnect.Image = (System.Drawing.Image) (resources.GetObject("cmenTabReconnect.Image")); - this.cmenTabReconnect.Name = "cmenTabReconnect"; - this.cmenTabReconnect.Size = new System.Drawing.Size(201, 22); - this.cmenTabReconnect.Text = "Reconnect"; - // - //cmenTabDisconnect - // - this.cmenTabDisconnect.Image = global::My.Resources.Resources.Pause; - this.cmenTabDisconnect.Name = "cmenTabDisconnect"; - this.cmenTabDisconnect.Size = new System.Drawing.Size(201, 22); - this.cmenTabDisconnect.Text = "Disconnect"; - // - //cmenTabPuttySettings - // - this.cmenTabPuttySettings.Name = "cmenTabPuttySettings"; - this.cmenTabPuttySettings.Size = new System.Drawing.Size(201, 22); - this.cmenTabPuttySettings.Text = "PuTTY Settings"; - // - //Connection - // - this.ClientSize = new System.Drawing.Size(632, 453); - this.Controls.Add(this.TabController); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.Icon = global::My.Resources.Resources.mRemote_Icon; - this.Name = "Connection"; - this.TabText = "UI.Window.Connection"; - this.Text = "UI.Window.Connection"; - this.cmenTab.ResumeLayout(false); - this.ResumeLayout(false); + FormText = My.Language.strNewPanel; + } + this.WindowType = Type.Connection; + this.DockPnl = Panel; + this.InitializeComponent(); + this.Text = FormText; + this.TabText = FormText; + } + + public Crownwood.Magic.Controls.TabPage AddConnectionTab(Protocol.Info conI) + { + try + { + Crownwood.Magic.Controls.TabPage nTab = new Crownwood.Magic.Controls.TabPage(); + nTab.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); + + if (My.Settings.Default.ShowProtocolOnTabs) + { + nTab.Title = conI.Protocol.ToString() + ": "; } -#endregion - -#region Public Methods - public Connection(DockContent Panel, string FormText = "") + else { - - if (FormText == "") + nTab.Title = ""; + } + + nTab.Title += conI.Name; + + if (My.Settings.Default.ShowLogonInfoOnTabs) + { + nTab.Title += " ("; + + if (conI.Domain != "") { - FormText = My.Language.strNewPanel; + nTab.Title += conI.Domain; } - - this.WindowType = Type.Connection; - this.DockPnl = Panel; - this.InitializeComponent(); - this.Text = FormText; - this.TabText = FormText; - } - - public Crownwood.Magic.Controls.TabPage AddConnectionTab(Protocol.Info conI) - { - try + + if (conI.Username != "") { - Crownwood.Magic.Controls.TabPage nTab = new Crownwood.Magic.Controls.TabPage(); - nTab.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); - - if (My.Settings.Default.ShowProtocolOnTabs) + if (conI.Domain != "") { - nTab.Title = conI.Protocol.ToString() + ": "; + nTab.Title += "\\"; } - else - { - nTab.Title = ""; - } - - nTab.Title += conI.Name; - - if (My.Settings.Default.ShowLogonInfoOnTabs) - { - nTab.Title += " ("; - - if (conI.Domain != "") - { - nTab.Title += conI.Domain; - } - - if (conI.Username != "") - { - if (conI.Domain != "") - { - nTab.Title += "\\"; - } - nTab.Title += conI.Username; - } + nTab.Title += conI.Username; + } - nTab.Title += ")"; - } + nTab.Title += ")"; + } - nTab.Title = nTab.Title.Replace("&", "&&"); + nTab.Title = nTab.Title.Replace("&", "&&"); - System.Drawing.Icon conIcon = mRemoteNG.Connection.Icon.FromString(conI.Icon); - if (conIcon != null) - { - nTab.Icon = conIcon; - } + System.Drawing.Icon conIcon = mRemoteNG.Connection.Icon.FromString(conI.Icon); + if (conIcon != null) + { + nTab.Icon = conIcon; + } - if (My.Settings.Default.OpenTabsRightOfSelected) - { - this.TabController.TabPages.Insert(this.TabController.SelectedIndex + 1, nTab); - } - else - { - this.TabController.TabPages.Add(nTab); - } + if (My.Settings.Default.OpenTabsRightOfSelected) + { + this.TabController.TabPages.Insert(this.TabController.SelectedIndex + 1, nTab); + } + else + { + this.TabController.TabPages.Add(nTab); + } - nTab.Selected = true; - _ignoreChangeSelectedTabClick = false; + nTab.Selected = true; + _ignoreChangeSelectedTabClick = false; - return nTab; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddConnectionTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } + return nTab; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddConnectionTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } - return null; - } -#endregion + return null; + } + #endregion -#region Private Methods - public void UpdateSelectedConnection() + #region Private Methods + public void UpdateSelectedConnection() + { + if (TabController.SelectedTab == null) + { + frmMain.Default.SelectedConnection = null; + } + else + { + InterfaceControl interfaceControl = TabController.SelectedTab.Tag as InterfaceControl; + if (interfaceControl == null) { - if (TabController.SelectedTab == null) - { - frmMain.Default.SelectedConnection = null; - } - else - { - InterfaceControl interfaceControl = TabController.SelectedTab.Tag as InterfaceControl; - if (interfaceControl == null) - { - frmMain.Default.SelectedConnection = null; - } - else - { - frmMain.Default.SelectedConnection = interfaceControl.Info; - } - } + frmMain.Default.SelectedConnection = null; } -#endregion - -#region Form - private void Connection_Load(object sender, System.EventArgs e) + else { - ApplyLanguage(); + frmMain.Default.SelectedConnection = interfaceControl.Info; } + } + } + #endregion - private bool _documentHandlersAdded = false; - private bool _floatHandlersAdded = false; - private void Connection_DockStateChanged(System.Object sender, EventArgs e) + #region Form + private void Connection_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + } + + private bool _documentHandlersAdded = false; + private bool _floatHandlersAdded = false; + private void Connection_DockStateChanged(System.Object sender, EventArgs e) + { + if (DockState == DockState.Float) + { + if (_documentHandlersAdded) { - if (DockState == DockState.Float) - { - if (_documentHandlersAdded) - { - frmMain.Default.ResizeBegin -= Connection_ResizeBegin; - frmMain.Default.ResizeEnd -= Connection_ResizeEnd; - _documentHandlersAdded = false; - } - DockHandler.FloatPane.FloatWindow.ResizeBegin += Connection_ResizeBegin; - DockHandler.FloatPane.FloatWindow.ResizeEnd += Connection_ResizeEnd; - _floatHandlersAdded = true; - } - else if (DockState == DockState.Document) - { - if (_floatHandlersAdded) - { - DockHandler.FloatPane.FloatWindow.ResizeBegin -= Connection_ResizeBegin; - DockHandler.FloatPane.FloatWindow.ResizeEnd -= Connection_ResizeEnd; - _floatHandlersAdded = false; - } - frmMain.Default.ResizeBegin += Connection_ResizeBegin; - frmMain.Default.ResizeEnd += Connection_ResizeEnd; - _documentHandlersAdded = true; - } + frmMain.Default.ResizeBegin -= Connection_ResizeBegin; + frmMain.Default.ResizeEnd -= Connection_ResizeEnd; + _documentHandlersAdded = false; } - - private void ApplyLanguage() + DockHandler.FloatPane.FloatWindow.ResizeBegin += Connection_ResizeBegin; + DockHandler.FloatPane.FloatWindow.ResizeEnd += Connection_ResizeEnd; + _floatHandlersAdded = true; + } + else if (DockState == DockState.Document) + { + if (_floatHandlersAdded) { - cmenTabFullscreen.Text = My.Language.strMenuFullScreenRDP; - cmenTabSmartSize.Text = My.Language.strMenuSmartSize; - cmenTabViewOnly.Text = My.Language.strMenuViewOnly; - cmenTabScreenshot.Text = My.Language.strMenuScreenshot; - cmenTabStartChat.Text = My.Language.strMenuStartChat; - cmenTabTransferFile.Text = My.Language.strMenuTransferFile; - cmenTabRefreshScreen.Text = My.Language.strMenuRefreshScreen; - cmenTabSendSpecialKeys.Text = My.Language.strMenuSendSpecialKeys; - cmenTabSendSpecialKeysCtrlAltDel.Text = My.Language.strMenuCtrlAltDel; - cmenTabSendSpecialKeysCtrlEsc.Text = My.Language.strMenuCtrlEsc; - cmenTabExternalApps.Text = My.Language.strMenuExternalTools; - cmenTabRenameTab.Text = My.Language.strMenuRenameTab; - cmenTabDuplicateTab.Text = My.Language.strMenuDuplicateTab; - cmenTabReconnect.Text = My.Language.strMenuReconnect; - cmenTabDisconnect.Text = My.Language.strMenuDisconnect; - cmenTabPuttySettings.Text = My.Language.strPuttySettings; + DockHandler.FloatPane.FloatWindow.ResizeBegin -= Connection_ResizeBegin; + DockHandler.FloatPane.FloatWindow.ResizeEnd -= Connection_ResizeEnd; + _floatHandlersAdded = false; } + frmMain.Default.ResizeBegin += Connection_ResizeBegin; + frmMain.Default.ResizeEnd += Connection_ResizeEnd; + _documentHandlersAdded = true; + } + } - private void Connection_FormClosing(object sender, FormClosingEventArgs e) + private void ApplyLanguage() + { + cmenTabFullscreen.Text = My.Language.strMenuFullScreenRDP; + cmenTabSmartSize.Text = My.Language.strMenuSmartSize; + cmenTabViewOnly.Text = My.Language.strMenuViewOnly; + cmenTabScreenshot.Text = My.Language.strMenuScreenshot; + cmenTabStartChat.Text = My.Language.strMenuStartChat; + cmenTabTransferFile.Text = My.Language.strMenuTransferFile; + cmenTabRefreshScreen.Text = My.Language.strMenuRefreshScreen; + cmenTabSendSpecialKeys.Text = My.Language.strMenuSendSpecialKeys; + cmenTabSendSpecialKeysCtrlAltDel.Text = My.Language.strMenuCtrlAltDel; + cmenTabSendSpecialKeysCtrlEsc.Text = My.Language.strMenuCtrlEsc; + cmenTabExternalApps.Text = My.Language.strMenuExternalTools; + cmenTabRenameTab.Text = My.Language.strMenuRenameTab; + cmenTabDuplicateTab.Text = My.Language.strMenuDuplicateTab; + cmenTabReconnect.Text = My.Language.strMenuReconnect; + cmenTabDisconnect.Text = My.Language.strMenuDisconnect; + cmenTabPuttySettings.Text = My.Language.strPuttySettings; + } + + private void Connection_FormClosing(object sender, FormClosingEventArgs e) + { + if (!frmMain.Default.IsClosing && + ((My.Settings.Default.ConfirmCloseConnection == ConfirmClose.All & TabController.TabPages.Count > 0) || + (My.Settings.Default.ConfirmCloseConnection == ConfirmClose.Multiple & TabController.TabPages.Count > 1))) + { + DialogResult result = cTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(My.Language.strConfirmCloseConnectionPanelMainInstruction, this.Text), "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, null); + if (cTaskDialog.VerificationChecked) { - if (!frmMain.Default.IsClosing && - ((My.Settings.Default.ConfirmCloseConnection == ConfirmClose.All & TabController.TabPages.Count > 0) || - (My.Settings.Default.ConfirmCloseConnection == ConfirmClose.Multiple & TabController.TabPages.Count > 1))) - { - DialogResult result = cTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(My.Language.strConfirmCloseConnectionPanelMainInstruction, this.Text), "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, null); - if (cTaskDialog.VerificationChecked) - { - My.Settings.Default.ConfirmCloseConnection--; - } - if (result == DialogResult.No) - { - e.Cancel = true; - return; - } - } + My.Settings.Default.ConfirmCloseConnection--; + } + if (result == DialogResult.No) + { + e.Cancel = true; + return; + } + } - try + try + { + foreach (Crownwood.Magic.Controls.TabPage tabP in this.TabController.TabPages) + { + if (tabP.Tag != null) { - foreach (Crownwood.Magic.Controls.TabPage tabP in this.TabController.TabPages) - { - if (tabP.Tag != null) - { - mRemoteNG.Connection.InterfaceControl interfaceControl = tabP.Tag; - interfaceControl.Protocol.Close(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Connection.Connection_FormClosing() failed" + Constants.vbNewLine + ex.Message, true); + mRemoteNG.Connection.InterfaceControl interfaceControl = tabP.Tag; + interfaceControl.Protocol.Close(); } } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Connection.Connection_FormClosing() failed" + Constants.vbNewLine + ex.Message, true); + } + } - private EventHandler ResizeBeginEvent; - public new event EventHandler ResizeBegin - { - add - { - ResizeBeginEvent = (EventHandler) System.Delegate.Combine(ResizeBeginEvent, value); - } - remove - { - ResizeBeginEvent = (EventHandler) System.Delegate.Remove(ResizeBeginEvent, value); - } - } + private EventHandler ResizeBeginEvent; + public new event EventHandler ResizeBegin + { + add + { + ResizeBeginEvent = (EventHandler) System.Delegate.Combine(ResizeBeginEvent, value); + } + remove + { + ResizeBeginEvent = (EventHandler) System.Delegate.Remove(ResizeBeginEvent, value); + } + } - private void Connection_ResizeBegin(System.Object sender, EventArgs e) - { - if (ResizeBeginEvent != null) - ResizeBeginEvent(this, e); - } + private void Connection_ResizeBegin(System.Object sender, EventArgs e) + { + if (ResizeBeginEvent != null) + ResizeBeginEvent(this, e); + } - private EventHandler ResizeEndEvent; - public new event EventHandler ResizeEnd - { - add - { - ResizeEndEvent = (EventHandler) System.Delegate.Combine(ResizeEndEvent, value); - } - remove - { - ResizeEndEvent = (EventHandler) System.Delegate.Remove(ResizeEndEvent, value); - } - } + private EventHandler ResizeEndEvent; + public new event EventHandler ResizeEnd + { + add + { + ResizeEndEvent = (EventHandler) System.Delegate.Combine(ResizeEndEvent, value); + } + remove + { + ResizeEndEvent = (EventHandler) System.Delegate.Remove(ResizeEndEvent, value); + } + } - public void Connection_ResizeEnd(System.Object sender, EventArgs e) - { - if (ResizeEndEvent != null) - ResizeEndEvent(sender, e); - } -#endregion + public void Connection_ResizeEnd(System.Object sender, EventArgs e) + { + if (ResizeEndEvent != null) + ResizeEndEvent(sender, e); + } + #endregion -#region TabController - private void TabController_ClosePressed(object sender, System.EventArgs e) - { - if (this.TabController.SelectedTab == null) - { - return; - } + #region TabController + private void TabController_ClosePressed(object sender, System.EventArgs e) + { + if (this.TabController.SelectedTab == null) + { + return; + } - this.CloseConnectionTab(); - } + this.CloseConnectionTab(); + } - private void CloseConnectionTab() + private void CloseConnectionTab() + { + Crownwood.Magic.Controls.TabPage selectedTab = TabController.SelectedTab; + if (My.Settings.Default.ConfirmCloseConnection == ConfirmClose.All) + { + DialogResult result = cTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(My.Language.strConfirmCloseConnectionMainInstruction, selectedTab.Title), "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, null); + if (cTaskDialog.VerificationChecked) { - Crownwood.Magic.Controls.TabPage selectedTab = TabController.SelectedTab; - if (My.Settings.Default.ConfirmCloseConnection == ConfirmClose.All) - { - DialogResult result = cTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(My.Language.strConfirmCloseConnectionMainInstruction, selectedTab.Title), "", "", "", My.Language.strCheckboxDoNotShowThisMessageAgain, eTaskDialogButtons.YesNo, eSysIcons.Question, null); - if (cTaskDialog.VerificationChecked) - { - My.Settings.Default.ConfirmCloseConnection--; - } - if (result == DialogResult.No) - { - return; - } - } + My.Settings.Default.ConfirmCloseConnection--; + } + if (result == DialogResult.No) + { + return; + } + } - try - { - if (selectedTab.Tag != null) - { - mRemoteNG.Connection.InterfaceControl interfaceControl = selectedTab.Tag; - interfaceControl.Protocol.Close(); - } - else - { - CloseTab(selectedTab); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Connection.CloseConnectionTab() failed" + Constants.vbNewLine + ex.Message, true); - } + try + { + if (selectedTab.Tag != null) + { + mRemoteNG.Connection.InterfaceControl interfaceControl = selectedTab.Tag; + interfaceControl.Protocol.Close(); + } + else + { + CloseTab(selectedTab); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Connection.CloseConnectionTab() failed" + Constants.vbNewLine + ex.Message, true); + } - UpdateSelectedConnection(); - } + UpdateSelectedConnection(); + } - private void TabController_DoubleClickTab(Crownwood.Magic.Controls.TabControl sender, Crownwood.Magic.Controls.TabPage page) - { - _firstClickTicks = 0; - if (My.Settings.Default.DoubleClickOnTabClosesIt) - { - this.CloseConnectionTab(); - } - } + private void TabController_DoubleClickTab(Crownwood.Magic.Controls.TabControl sender, Crownwood.Magic.Controls.TabPage page) + { + _firstClickTicks = 0; + if (My.Settings.Default.DoubleClickOnTabClosesIt) + { + this.CloseConnectionTab(); + } + } -#region Drag and Drop - private void TabController_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) - { - if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) - { - App.Runtime.OpenConnection(e.Data.GetData("System.Windows.Forms.TreeNode", true).Tag, this, mRemoteNG.Connection.Info.Force.DoNotJump); - } - } + #region Drag and Drop + private void TabController_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) + { + if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) + { + App.Runtime.OpenConnection(e.Data.GetData("System.Windows.Forms.TreeNode", true).Tag, this, mRemoteNG.Connection.Info.Force.DoNotJump); + } + } - private void TabController_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) - { - if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) - { - e.Effect = DragDropEffects.Move; - } - } + private void TabController_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) + { + if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) + { + e.Effect = DragDropEffects.Move; + } + } - private void TabController_DragOver(object sender, System.Windows.Forms.DragEventArgs e) - { - e.Effect = DragDropEffects.Move; - } -#endregion -#endregion + private void TabController_DragOver(object sender, System.Windows.Forms.DragEventArgs e) + { + e.Effect = DragDropEffects.Move; + } + #endregion + #endregion -#region Tab Menu - private void ShowHideMenuButtons() + #region Tab Menu + private void ShowHideMenuButtons() + { + try + { + if (this.TabController.SelectedTab == null) { - try - { - if (this.TabController.SelectedTab == null) - { - return; - } + return; + } + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC == null) + { + return; + } + + if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP) + { + mRemoteNG.Connection.Protocol.RDP rdp = IC.Protocol; + + cmenTabFullscreen.Enabled = true; + cmenTabFullscreen.Checked = rdp.Fullscreen; + + cmenTabSmartSize.Enabled = true; + cmenTabSmartSize.Checked = rdp.SmartSize; + } + else + { + cmenTabFullscreen.Enabled = false; + cmenTabSmartSize.Enabled = false; + } + + if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) + { + this.cmenTabSendSpecialKeys.Enabled = true; + this.cmenTabViewOnly.Enabled = true; + + this.cmenTabSmartSize.Enabled = true; + this.cmenTabStartChat.Enabled = true; + this.cmenTabRefreshScreen.Enabled = true; + this.cmenTabTransferFile.Enabled = false; + + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + this.cmenTabSmartSize.Checked = vnc.SmartSize; + this.cmenTabViewOnly.Checked = vnc.ViewOnly; + } + else + { + this.cmenTabSendSpecialKeys.Enabled = false; + this.cmenTabViewOnly.Enabled = false; + this.cmenTabStartChat.Enabled = false; + this.cmenTabRefreshScreen.Enabled = false; + this.cmenTabTransferFile.Enabled = false; + } + + if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2) + { + this.cmenTabTransferFile.Enabled = true; + } + + if (IC.Protocol is mRemoteNG.Connection.Protocol.PuttyBase) + { + this.cmenTabPuttySettings.Enabled = true; + } + else + { + this.cmenTabPuttySettings.Enabled = false; + } + + AddExternalApps(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowHideMenuButtons (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void cmenTabScreenshot_Click(System.Object sender, System.EventArgs e) + { + cmenTab.Close(); + Application.DoEvents(); + Windows.screenshotForm.AddScreenshot(Tools.Misc.TakeScreenshot(this)); + } + + private void cmenTabSmartSize_Click(System.Object sender, System.EventArgs e) + { + this.ToggleSmartSize(); + } + + private void cmenTabReconnect_Click(System.Object sender, System.EventArgs e) + { + this.Reconnect(); + } + + private void cmenTabTransferFile_Click(System.Object sender, System.EventArgs e) + { + this.TransferFile(); + } + + private void cmenTabViewOnly_Click(System.Object sender, System.EventArgs e) + { + this.ToggleViewOnly(); + } + + private void cmenTabStartChat_Click(object sender, System.EventArgs e) + { + this.StartChat(); + } + + private void cmenTabRefreshScreen_Click(object sender, System.EventArgs e) + { + this.RefreshScreen(); + } + + private void cmenTabSendSpecialKeysCtrlAltDel_Click(System.Object sender, System.EventArgs e) + { + this.SendSpecialKeys(mRemoteNG.Connection.Protocol.VNC.SpecialKeys.CtrlAltDel); + } + + private void cmenTabSendSpecialKeysCtrlEsc_Click(System.Object sender, System.EventArgs e) + { + this.SendSpecialKeys(mRemoteNG.Connection.Protocol.VNC.SpecialKeys.CtrlEsc); + } + + private void cmenTabFullscreen_Click(System.Object sender, System.EventArgs e) + { + this.ToggleFullscreen(); + } + + private void cmenTabPuttySettings_Click(System.Object sender, System.EventArgs e) + { + this.ShowPuttySettingsDialog(); + } + + private void cmenTabExternalAppsEntry_Click(object sender, System.EventArgs e) + { + StartExternalApp(sender.Tag); + } + + private void cmenTabDisconnect_Click(System.Object sender, System.EventArgs e) + { + this.CloseTabMenu(); + } + + private void cmenTabDuplicateTab_Click(System.Object sender, System.EventArgs e) + { + this.DuplicateTab(); + } + + private void cmenTabRenameTab_Click(System.Object sender, System.EventArgs e) + { + this.RenameTab(); + } + #endregion + + #region Tab Actions + private void ToggleSmartSize() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC == null) - { - return; - } - - if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP) + + if (IC.Protocol is mRemoteNG.Connection.Protocol.RDP) { mRemoteNG.Connection.Protocol.RDP rdp = IC.Protocol; - - cmenTabFullscreen.Enabled = true; - cmenTabFullscreen.Checked = rdp.Fullscreen; - - cmenTabSmartSize.Enabled = true; - cmenTabSmartSize.Checked = rdp.SmartSize; + rdp.ToggleSmartSize(); } - else + else if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) { - cmenTabFullscreen.Enabled = false; - cmenTabSmartSize.Enabled = false; - } - - if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) - { - this.cmenTabSendSpecialKeys.Enabled = true; - this.cmenTabViewOnly.Enabled = true; - - this.cmenTabSmartSize.Enabled = true; - this.cmenTabStartChat.Enabled = true; - this.cmenTabRefreshScreen.Enabled = true; - this.cmenTabTransferFile.Enabled = false; - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - this.cmenTabSmartSize.Checked = vnc.SmartSize; - this.cmenTabViewOnly.Checked = vnc.ViewOnly; + vnc.ToggleSmartSize(); } - else - { - this.cmenTabSendSpecialKeys.Enabled = false; - this.cmenTabViewOnly.Enabled = false; - this.cmenTabStartChat.Enabled = false; - this.cmenTabRefreshScreen.Enabled = false; - this.cmenTabTransferFile.Enabled = false; - } - + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleSmartSize (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void TransferFile() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2) { - this.cmenTabTransferFile.Enabled = true; + SSHTransferFile(); } + else if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) + { + VNCTransferFile(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "TransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void SSHTransferFile() + { + try + { - if (IC.Protocol is mRemoteNG.Connection.Protocol.PuttyBase) - { - this.cmenTabPuttySettings.Enabled = true; - } - else - { - this.cmenTabPuttySettings.Enabled = false; - } + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - AddExternalApps(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowHideMenuButtons (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void cmenTabScreenshot_Click(System.Object sender, System.EventArgs e) - { - cmenTab.Close(); - Application.DoEvents(); - Windows.screenshotForm.AddScreenshot(Tools.Misc.TakeScreenshot(this)); - } - - private void cmenTabSmartSize_Click(System.Object sender, System.EventArgs e) - { - this.ToggleSmartSize(); - } - - private void cmenTabReconnect_Click(System.Object sender, System.EventArgs e) - { - this.Reconnect(); - } - - private void cmenTabTransferFile_Click(System.Object sender, System.EventArgs e) - { - this.TransferFile(); - } - - private void cmenTabViewOnly_Click(System.Object sender, System.EventArgs e) - { - this.ToggleViewOnly(); - } - - private void cmenTabStartChat_Click(object sender, System.EventArgs e) - { - this.StartChat(); - } - - private void cmenTabRefreshScreen_Click(object sender, System.EventArgs e) - { - this.RefreshScreen(); - } - - private void cmenTabSendSpecialKeysCtrlAltDel_Click(System.Object sender, System.EventArgs e) - { - this.SendSpecialKeys(mRemoteNG.Connection.Protocol.VNC.SpecialKeys.CtrlAltDel); - } - - private void cmenTabSendSpecialKeysCtrlEsc_Click(System.Object sender, System.EventArgs e) - { - this.SendSpecialKeys(mRemoteNG.Connection.Protocol.VNC.SpecialKeys.CtrlEsc); - } - - private void cmenTabFullscreen_Click(System.Object sender, System.EventArgs e) - { - this.ToggleFullscreen(); - } - - private void cmenTabPuttySettings_Click(System.Object sender, System.EventArgs e) - { - this.ShowPuttySettingsDialog(); - } - - private void cmenTabExternalAppsEntry_Click(object sender, System.EventArgs e) - { - StartExternalApp(sender.Tag); - } - - private void cmenTabDisconnect_Click(System.Object sender, System.EventArgs e) - { - this.CloseTabMenu(); - } - - private void cmenTabDuplicateTab_Click(System.Object sender, System.EventArgs e) - { - this.DuplicateTab(); - } - - private void cmenTabRenameTab_Click(System.Object sender, System.EventArgs e) - { - this.RenameTab(); - } -#endregion - -#region Tab Actions - private void ToggleSmartSize() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.RDP) - { - mRemoteNG.Connection.Protocol.RDP rdp = IC.Protocol; - rdp.ToggleSmartSize(); - } - else if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) - { - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.ToggleSmartSize(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleSmartSize (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void TransferFile() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2) - { - SSHTransferFile(); - } - else if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) - { - VNCTransferFile(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "TransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void SSHTransferFile() - { - try - { + Windows.Show(Type.SSHTransfer); + mRemoteNG.Connection.Info conI = IC.Info; + + Windows.sshtransferForm.Hostname = conI.Hostname; + Windows.sshtransferForm.Username = conI.Username; + Windows.sshtransferForm.Password = conI.Password; + Windows.sshtransferForm.Port = System.Convert.ToString(conI.Port); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SSHTransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void VNCTransferFile() + { + try + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + vnc.StartFileTransfer(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "VNCTransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void ToggleViewOnly() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) + { + cmenTabViewOnly.Checked = !cmenTabViewOnly.Checked; + + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + vnc.ToggleViewOnly(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleViewOnly (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void StartChat() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) + { + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + vnc.StartChat(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartChat (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void RefreshScreen() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) + { + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + vnc.RefreshScreen(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RefreshScreen (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void SendSpecialKeys(mRemoteNG.Protocol.Protocol.VNC.SpecialKeys Keys) + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) + { + mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; + vnc.SendSpecialKeys(Keys); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SendSpecialKeys (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void ToggleFullscreen() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Protocol is mRemoteNG.Connection.Protocol.RDP) + { + mRemoteNG.Connection.Protocol.RDP rdp = IC.Protocol; + rdp.ToggleFullscreen(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleFullscreen (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void ShowPuttySettingsDialog() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl objInterfaceControl = this.TabController.SelectedTab.Tag; + + if (objInterfaceControl.Protocol is mRemoteNG.Connection.Protocol.PuttyBase) + { + mRemoteNG.Connection.Protocol.PuttyBase objPuttyBase = objInterfaceControl.Protocol; + + objPuttyBase.ShowSettingsDialog(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowPuttySettingsDialog (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void AddExternalApps() + { + try + { + //clean up + cmenTabExternalApps.DropDownItems.Clear(); - Windows.Show(Type.SSHTransfer); + //add ext apps + foreach (Tools.ExternalTool extA in Runtime.ExternalTools) + { + ToolStripMenuItem nItem = new ToolStripMenuItem(); + nItem.Text = extA.DisplayName; + nItem.Tag = extA; + + nItem.Image = extA.Image; + + nItem.Click += cmenTabExternalAppsEntry_Click; + + cmenTabExternalApps.DropDownItems.Add(nItem); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeTools_DropDownOpening failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); + } + } + + private void StartExternalApp(Tools.ExternalTool ExtA) + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + ExtA.Start(IC.Info); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cmenTabExternalAppsEntry_Click failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); + } + } + + private void CloseTabMenu() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + IC.Protocol.Close(); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "CloseTabMenu (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void DuplicateTab() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + App.Runtime.OpenConnection(IC.Info, mRemoteNG.Connection.Info.Force.DoNotJump); + _ignoreChangeSelectedTabClick = false; + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "DuplicateTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void Reconnect() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; mRemoteNG.Connection.Info conI = IC.Info; + + IC.Protocol.Close(); + + App.Runtime.OpenConnection(conI, mRemoteNG.Connection.Info.Force.DoNotJump); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Reconnect (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void RenameTab() + { + try + { + string nTitle = Interaction.InputBox(Prompt: My.Language.strNewTitle + ":", DefaultResponse: this.TabController.SelectedTab.Title.Replace("&&", "&")); - Windows.sshtransferForm.Hostname = conI.Hostname; - Windows.sshtransferForm.Username = conI.Username; - Windows.sshtransferForm.Password = conI.Password; - Windows.sshtransferForm.Port = System.Convert.ToString(conI.Port); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SSHTransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void VNCTransferFile() + if (!string.IsNullOrEmpty(nTitle)) { - try - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.StartFileTransfer(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "VNCTransferFile (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void ToggleViewOnly() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) - { - cmenTabViewOnly.Checked = !cmenTabViewOnly.Checked; - - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.ToggleViewOnly(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleViewOnly (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void StartChat() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) - { - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.StartChat(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartChat (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void RefreshScreen() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) - { - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.RefreshScreen(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RefreshScreen (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void SendSpecialKeys(mRemoteNG.Protocol.Protocol.VNC.SpecialKeys Keys) - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.VNC) - { - mRemoteNG.Connection.Protocol.VNC vnc = IC.Protocol; - vnc.SendSpecialKeys(Keys); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SendSpecialKeys (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void ToggleFullscreen() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Protocol is mRemoteNG.Connection.Protocol.RDP) - { - mRemoteNG.Connection.Protocol.RDP rdp = IC.Protocol; - rdp.ToggleFullscreen(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ToggleFullscreen (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void ShowPuttySettingsDialog() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl objInterfaceControl = this.TabController.SelectedTab.Tag; - - if (objInterfaceControl.Protocol is mRemoteNG.Connection.Protocol.PuttyBase) - { - mRemoteNG.Connection.Protocol.PuttyBase objPuttyBase = objInterfaceControl.Protocol; - - objPuttyBase.ShowSettingsDialog(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowPuttySettingsDialog (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void AddExternalApps() - { - try - { - //clean up - cmenTabExternalApps.DropDownItems.Clear(); - - //add ext apps - foreach (Tools.ExternalTool extA in Runtime.ExternalTools) - { - ToolStripMenuItem nItem = new ToolStripMenuItem(); - nItem.Text = extA.DisplayName; - nItem.Tag = extA; - - nItem.Image = extA.Image; - - nItem.Click += cmenTabExternalAppsEntry_Click; - - cmenTabExternalApps.DropDownItems.Add(nItem); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeTools_DropDownOpening failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); - } - } - - private void StartExternalApp(Tools.ExternalTool ExtA) - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - ExtA.Start(IC.Info); - } - } - - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cmenTabExternalAppsEntry_Click failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); - } - } - - private void CloseTabMenu() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - IC.Protocol.Close(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "CloseTabMenu (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void DuplicateTab() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - App.Runtime.OpenConnection(IC.Info, mRemoteNG.Connection.Info.Force.DoNotJump); - _ignoreChangeSelectedTabClick = false; - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "DuplicateTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void Reconnect() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - mRemoteNG.Connection.Info conI = IC.Info; - - IC.Protocol.Close(); - - App.Runtime.OpenConnection(conI, mRemoteNG.Connection.Info.Force.DoNotJump); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Reconnect (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void RenameTab() - { - try - { - string nTitle = Interaction.InputBox(Prompt: My.Language.strNewTitle + ":", DefaultResponse: this.TabController.SelectedTab.Title.Replace("&&", "&")); - - if (!string.IsNullOrEmpty(nTitle)) - { - this.TabController.SelectedTab.Title = nTitle.Replace("&", "&&"); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RenameTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } + this.TabController.SelectedTab.Title = nTitle.Replace("&", "&&"); } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RenameTab (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } #endregion #region Protocols - public void Prot_Event_Closed(object sender) - { - mRemoteNG.Connection.Protocol.Base Prot = sender; - CloseTab((Crownwood.Magic.Controls.TabPage) Prot.InterfaceControl.Parent); - } + public void Prot_Event_Closed(object sender) + { + mRemoteNG.Connection.Protocol.Base Prot = sender; + CloseTab((Crownwood.Magic.Controls.TabPage) Prot.InterfaceControl.Parent); + } #endregion #region Tabs - private delegate void CloseTabCB(Crownwood.Magic.Controls.TabPage TabToBeClosed); - private void CloseTab(Crownwood.Magic.Controls.TabPage TabToBeClosed) - { - if (this.TabController.InvokeRequired) - { - CloseTabCB s = new CloseTabCB(CloseTab); + private delegate void CloseTabCB(Crownwood.Magic.Controls.TabPage TabToBeClosed); + private void CloseTab(Crownwood.Magic.Controls.TabPage TabToBeClosed) + { + if (this.TabController.InvokeRequired) + { + CloseTabCB s = new CloseTabCB(CloseTab); - try - { - this.TabController.Invoke(s, TabToBeClosed); - } - catch (System.Runtime.InteropServices.COMException) - { - this.TabController.Invoke(s, TabToBeClosed); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t close tab" + Constants.vbNewLine + ex.Message, true); - } - } - else - { - try - { - this.TabController.TabPages.Remove(TabToBeClosed); - _ignoreChangeSelectedTabClick = false; - } - catch (System.Runtime.InteropServices.COMException) - { - CloseTab(TabToBeClosed); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t close tab" + Constants.vbNewLine + ex.Message, true); - } - - if (this.TabController.TabPages.Count == 0) - { - this.Close(); - } - } - } - - private bool _ignoreChangeSelectedTabClick = false; - private void TabController_SelectionChanged(object sender, EventArgs e) + try { - _ignoreChangeSelectedTabClick = true; - UpdateSelectedConnection(); - FocusIC(); - RefreshIC(); + this.TabController.Invoke(s, TabToBeClosed); } - - private int _firstClickTicks = 0; - private Rectangle _doubleClickRectangle; - private void TabController_MouseUp(object sender, MouseEventArgs e) + catch (System.Runtime.InteropServices.COMException) { - try - { - if (!(Native.GetForegroundWindow() == frmMain.Default.Handle) && !_ignoreChangeSelectedTabClick) - { - Crownwood.Magic.Controls.TabPage clickedTab = TabController.TabPageFromPoint(e.Location); - if (clickedTab != null && TabController.SelectedTab != clickedTab) - { - Native.SetForegroundWindow(Handle); - TabController.SelectedTab = clickedTab; - } - } - _ignoreChangeSelectedTabClick = false; - - switch (e.Button) - { - case MouseButtons.Left: - int currentTicks = Environment.TickCount; - int elapsedTicks = currentTicks - _firstClickTicks; - if (elapsedTicks > SystemInformation.DoubleClickTime || !_doubleClickRectangle.Contains(MousePosition)) - { - _firstClickTicks = currentTicks; - _doubleClickRectangle = new Rectangle(MousePosition.X - ((double) SystemInformation.DoubleClickSize.Width / 2), MousePosition.Y - ((double) SystemInformation.DoubleClickSize.Height / 2), SystemInformation.DoubleClickSize.Width, SystemInformation.DoubleClickSize.Height); - FocusIC(); - } - else - { - TabController.OnDoubleClickTab(TabController.SelectedTab); - } - break; - case MouseButtons.Middle: - CloseConnectionTab(); - break; - case MouseButtons.Right: - ShowHideMenuButtons(); - Native.SetForegroundWindow(Handle); - cmenTab.Show(TabController, e.Location); - break; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "TabController_MouseUp (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } + this.TabController.Invoke(s, TabToBeClosed); } - - private void FocusIC() + catch (Exception ex) { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - IC.Protocol.Focus(); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "FocusIC (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); - } + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t close tab" + Constants.vbNewLine + ex.Message, true); } - - public void RefreshIC() - { - try - { - if (this.TabController.SelectedTab != null) - { - if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) - { - mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; - - if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) - { - (IC.Protocol as mRemoteNG.Connection.Protocol.VNC).RefreshScreen(); - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RefreshIC (UI.Window.Connection) failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Window Overrides - protected override void WndProc(ref Message m) - { - try - { - if (m.Msg == Native.WM_MOUSEACTIVATE) - { - Crownwood.Magic.Controls.TabPage selectedTab = TabController.SelectedTab; - if (selectedTab != null) - { - Rectangle tabClientRectangle = selectedTab.RectangleToScreen(selectedTab.ClientRectangle); - if (tabClientRectangle.Contains(MousePosition)) - { - InterfaceControl interfaceControl = TabController.SelectedTab.Tag as InterfaceControl; - if (interfaceControl != null && interfaceControl.Info != null) - { - if (interfaceControl.Info.Protocol == Protocol.Protocols.RDP) - { - interfaceControl.Protocol.Focus(); - return ; // Do not pass to base class - } - } - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.Connection.WndProc() failed.", ex: ex, logOnly: true); - } - - base.WndProc(ref m); - } -#endregion - -#region Tab drag and drop - private bool _InTabDrag = false; -public bool InTabDrag - { - get - { - return _InTabDrag; - } - set - { - _InTabDrag = value; - } - } - private void TabController_PageDragStart(object sender, MouseEventArgs e) - { - Cursor = Cursors.SizeWE; - } - - private void TabController_PageDragMove(object sender, MouseEventArgs e) - { - InTabDrag = true; // For some reason PageDragStart gets raised again after PageDragEnd so set this here instead - - Crownwood.Magic.Controls.TabPage sourceTab = TabController.SelectedTab; - Crownwood.Magic.Controls.TabPage destinationTab = TabController.TabPageFromPoint(e.Location); - - if (!TabController.TabPages.Contains(destinationTab) || sourceTab == destinationTab) - { - return ; - } - - int targetIndex = TabController.TabPages.IndexOf(destinationTab); - - TabController.TabPages.SuspendEvents(); - TabController.TabPages.Remove(sourceTab); - TabController.TabPages.Insert(targetIndex, sourceTab); - TabController.SelectedTab = sourceTab; - TabController.TabPages.ResumeEvents(); - } - - private void TabController_PageDragEnd(object sender, MouseEventArgs e) - { - Cursor = Cursors.Default; - InTabDrag = false; - mRemoteNG.Connection.InterfaceControl interfaceControl = TabController.SelectedTab.Tag as mRemoteNG.Connection.InterfaceControl; - if (interfaceControl != null) - { - interfaceControl.Protocol.Focus(); - } - } -#endregion } + else + { + try + { + this.TabController.TabPages.Remove(TabToBeClosed); + _ignoreChangeSelectedTabClick = false; + } + catch (System.Runtime.InteropServices.COMException) + { + CloseTab(TabToBeClosed); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Couldn\'t close tab" + Constants.vbNewLine + ex.Message, true); + } + + if (this.TabController.TabPages.Count == 0) + { + this.Close(); + } + } + } + + private bool _ignoreChangeSelectedTabClick = false; + private void TabController_SelectionChanged(object sender, EventArgs e) + { + _ignoreChangeSelectedTabClick = true; + UpdateSelectedConnection(); + FocusIC(); + RefreshIC(); + } + + private int _firstClickTicks = 0; + private Rectangle _doubleClickRectangle; + private void TabController_MouseUp(object sender, MouseEventArgs e) + { + try + { + if (!(Native.GetForegroundWindow() == frmMain.Default.Handle) && !_ignoreChangeSelectedTabClick) + { + Crownwood.Magic.Controls.TabPage clickedTab = TabController.TabPageFromPoint(e.Location); + if (clickedTab != null && TabController.SelectedTab != clickedTab) + { + Native.SetForegroundWindow(Handle); + TabController.SelectedTab = clickedTab; + } + } + _ignoreChangeSelectedTabClick = false; + + switch (e.Button) + { + case MouseButtons.Left: + int currentTicks = Environment.TickCount; + int elapsedTicks = currentTicks - _firstClickTicks; + if (elapsedTicks > SystemInformation.DoubleClickTime || !_doubleClickRectangle.Contains(MousePosition)) + { + _firstClickTicks = currentTicks; + _doubleClickRectangle = new Rectangle(MousePosition.X - ((double) SystemInformation.DoubleClickSize.Width / 2), MousePosition.Y - ((double) SystemInformation.DoubleClickSize.Height / 2), SystemInformation.DoubleClickSize.Width, SystemInformation.DoubleClickSize.Height); + FocusIC(); + } + else + { + TabController.OnDoubleClickTab(TabController.SelectedTab); + } + break; + case MouseButtons.Middle: + CloseConnectionTab(); + break; + case MouseButtons.Right: + ShowHideMenuButtons(); + Native.SetForegroundWindow(Handle); + cmenTab.Show(TabController, e.Location); + break; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "TabController_MouseUp (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void FocusIC() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + IC.Protocol.Focus(); + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "FocusIC (UI.Window.Connections) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void RefreshIC() + { + try + { + if (this.TabController.SelectedTab != null) + { + if (this.TabController.SelectedTab.Tag is mRemoteNG.Connection.InterfaceControl) + { + mRemoteNG.Connection.InterfaceControl IC = this.TabController.SelectedTab.Tag; + + if (IC.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.VNC) + { + (IC.Protocol as mRemoteNG.Connection.Protocol.VNC).RefreshScreen(); + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "RefreshIC (UI.Window.Connection) failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Window Overrides + protected override void WndProc(ref Message m) + { + try + { + if (m.Msg == Native.WM_MOUSEACTIVATE) + { + Crownwood.Magic.Controls.TabPage selectedTab = TabController.SelectedTab; + if (selectedTab != null) + { + Rectangle tabClientRectangle = selectedTab.RectangleToScreen(selectedTab.ClientRectangle); + if (tabClientRectangle.Contains(MousePosition)) + { + InterfaceControl interfaceControl = TabController.SelectedTab.Tag as InterfaceControl; + if (interfaceControl != null && interfaceControl.Info != null) + { + if (interfaceControl.Info.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP) + { + interfaceControl.Protocol.Focus(); + return ; // Do not pass to base class + } + } + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.Connection.WndProc() failed.", ex: ex, logOnly: true); + } + + base.WndProc(ref m); + } + #endregion + + #region Tab drag and drop + private bool _InTabDrag = false; + public bool InTabDrag + { + get + { + return _InTabDrag; + } + set + { + _InTabDrag = value; + } + } + private void TabController_PageDragStart(object sender, MouseEventArgs e) + { + Cursor = Cursors.SizeWE; + } + + private void TabController_PageDragMove(object sender, MouseEventArgs e) + { + InTabDrag = true; // For some reason PageDragStart gets raised again after PageDragEnd so set this here instead + + Crownwood.Magic.Controls.TabPage sourceTab = TabController.SelectedTab; + Crownwood.Magic.Controls.TabPage destinationTab = TabController.TabPageFromPoint(e.Location); + + if (!TabController.TabPages.Contains(destinationTab) || sourceTab == destinationTab) + { + return ; + } + + int targetIndex = TabController.TabPages.IndexOf(destinationTab); + + TabController.TabPages.SuspendEvents(); + TabController.TabPages.Remove(sourceTab); + TabController.TabPages.Insert(targetIndex, sourceTab); + TabController.SelectedTab = sourceTab; + TabController.TabPages.ResumeEvents(); + } + + private void TabController_PageDragEnd(object sender, MouseEventArgs e) + { + Cursor = Cursors.Default; + InTabDrag = false; + mRemoteNG.Connection.InterfaceControl interfaceControl = TabController.SelectedTab.Tag as mRemoteNG.Connection.InterfaceControl; + if (interfaceControl != null) + { + interfaceControl.Protocol.Focus(); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.ErrorsAndInfos.cs b/mRemoteV1/CS/UI/UI.Window.ErrorsAndInfos.cs index d8f119235..155295854 100644 --- a/mRemoteV1/CS/UI/UI.Window.ErrorsAndInfos.cs +++ b/mRemoteV1/CS/UI/UI.Window.ErrorsAndInfos.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,495 +8,492 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Text; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public class ErrorsAndInfos : Base + { + #region Form Init + internal System.Windows.Forms.PictureBox pbError; + internal System.Windows.Forms.Label lblMsgDate; + internal System.Windows.Forms.ListView lvErrorCollector; + internal System.Windows.Forms.ColumnHeader clmMessage; + internal System.Windows.Forms.TextBox txtMsgText; + internal System.Windows.Forms.ImageList imgListMC; + private System.ComponentModel.Container components = null; + internal System.Windows.Forms.ContextMenuStrip cMenMC; + internal System.Windows.Forms.ToolStripMenuItem cMenMCCopy; + internal System.Windows.Forms.ToolStripMenuItem cMenMCDelete; + internal System.Windows.Forms.Panel pnlErrorMsg; + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Load += new System.EventHandler(ErrorsAndInfos_Load); + this.Resize += new System.EventHandler(ErrorsAndInfos_Resize); + this.pnlErrorMsg = new System.Windows.Forms.Panel(); + this.txtMsgText = new System.Windows.Forms.TextBox(); + this.txtMsgText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MC_KeyDown); + this.lblMsgDate = new System.Windows.Forms.Label(); + this.pbError = new System.Windows.Forms.PictureBox(); + this.lvErrorCollector = new System.Windows.Forms.ListView(); + this.lvErrorCollector.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MC_KeyDown); + this.lvErrorCollector.SelectedIndexChanged += new System.EventHandler(this.lvErrorCollector_SelectedIndexChanged); + this.clmMessage = (System.Windows.Forms.ColumnHeader) (new System.Windows.Forms.ColumnHeader()); + this.cMenMC = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cMenMC.Opening += new System.ComponentModel.CancelEventHandler(this.cMenMC_Opening); + this.cMenMCCopy = new System.Windows.Forms.ToolStripMenuItem(); + this.cMenMCCopy.Click += new System.EventHandler(this.cMenMCCopy_Click); + this.cMenMCDelete = new System.Windows.Forms.ToolStripMenuItem(); + this.cMenMCDelete.Click += new System.EventHandler(this.cMenMCDelete_Click); + this.imgListMC = new System.Windows.Forms.ImageList(this.components); + this.pnlErrorMsg.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbError).BeginInit(); + this.cMenMC.SuspendLayout(); + this.SuspendLayout(); + // + //pnlErrorMsg + // + this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlErrorMsg.BackColor = System.Drawing.SystemColors.Control; + this.pnlErrorMsg.Controls.Add(this.txtMsgText); + this.pnlErrorMsg.Controls.Add(this.lblMsgDate); + this.pnlErrorMsg.Controls.Add(this.pbError); + this.pnlErrorMsg.Location = new System.Drawing.Point(0, 1); + this.pnlErrorMsg.Name = "pnlErrorMsg"; + this.pnlErrorMsg.Size = new System.Drawing.Size(198, 232); + this.pnlErrorMsg.TabIndex = 20; + // + //txtMsgText + // + this.txtMsgText.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtMsgText.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtMsgText.Location = new System.Drawing.Point(40, 20); + this.txtMsgText.Multiline = true; + this.txtMsgText.Name = "txtMsgText"; + this.txtMsgText.ReadOnly = true; + this.txtMsgText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtMsgText.Size = new System.Drawing.Size(158, 211); + this.txtMsgText.TabIndex = 30; + // + //lblMsgDate + // + this.lblMsgDate.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lblMsgDate.Font = new System.Drawing.Font("Tahoma", (float) (8.25F), System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.lblMsgDate.Location = new System.Drawing.Point(40, 5); + this.lblMsgDate.Name = "lblMsgDate"; + this.lblMsgDate.Size = new System.Drawing.Size(155, 13); + this.lblMsgDate.TabIndex = 40; + // + //pbError + // + this.pbError.InitialImage = null; + this.pbError.Location = new System.Drawing.Point(2, 5); + this.pbError.Name = "pbError"; + this.pbError.Size = new System.Drawing.Size(32, 32); + this.pbError.TabIndex = 0; + this.pbError.TabStop = false; + // + //lvErrorCollector + // + this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.lvErrorCollector.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.lvErrorCollector.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {this.clmMessage}); + this.lvErrorCollector.ContextMenuStrip = this.cMenMC; + this.lvErrorCollector.FullRowSelect = true; + this.lvErrorCollector.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.lvErrorCollector.HideSelection = false; + this.lvErrorCollector.Location = new System.Drawing.Point(203, 1); + this.lvErrorCollector.Name = "lvErrorCollector"; + this.lvErrorCollector.ShowGroups = false; + this.lvErrorCollector.Size = new System.Drawing.Size(413, 232); + this.lvErrorCollector.SmallImageList = this.imgListMC; + this.lvErrorCollector.TabIndex = 10; + this.lvErrorCollector.UseCompatibleStateImageBehavior = false; + this.lvErrorCollector.View = System.Windows.Forms.View.Details; + // + //clmMessage + // + this.clmMessage.Text = global::mRemoteNG.My.Language.strColumnMessage; + this.clmMessage.Width = 184; + // + //cMenMC + // + this.cMenMC.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.cMenMC.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cMenMCCopy, this.cMenMCDelete}); + this.cMenMC.Name = "cMenMC"; + this.cMenMC.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.cMenMC.Size = new System.Drawing.Size(153, 70); + // + //cMenMCCopy + // + this.cMenMCCopy.Image = global::My.Resources.Resources.Copy; + this.cMenMCCopy.Name = "cMenMCCopy"; + this.cMenMCCopy.ShortcutKeys = (System.Windows.Forms.Keys) (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C); + this.cMenMCCopy.Size = new System.Drawing.Size(152, 22); + this.cMenMCCopy.Text = global::mRemoteNG.My.Language.strMenuCopy; + // + //cMenMCDelete + // + this.cMenMCDelete.Image = global::My.Resources.Resources.Delete; + this.cMenMCDelete.Name = "cMenMCDelete"; + this.cMenMCDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.cMenMCDelete.Size = new System.Drawing.Size(152, 22); + this.cMenMCDelete.Text = global::mRemoteNG.My.Language.strMenuDelete; + // + //imgListMC + // + this.imgListMC.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; + this.imgListMC.ImageSize = new System.Drawing.Size(16, 16); + this.imgListMC.TransparentColor = System.Drawing.Color.Transparent; + // + //ErrorsAndInfos + // + this.ClientSize = new System.Drawing.Size(617, 233); + this.Controls.Add(this.lvErrorCollector); + this.Controls.Add(this.pnlErrorMsg); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.HideOnClose = true; + this.Icon = global::My.Resources.Resources.Info_Icon; + this.Name = "ErrorsAndInfos"; + this.TabText = global::mRemoteNG.My.Language.strMenuNotifications; + this.Text = "Notifications"; + this.pnlErrorMsg.ResumeLayout(false); + this.pnlErrorMsg.PerformLayout(); + ((System.ComponentModel.ISupportInitialize) this.pbError).EndInit(); + this.cMenMC.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + #region Public Properties + private DockContent _PreviousActiveForm; + public DockContent PreviousActiveForm + { + get { + return this._PreviousActiveForm; + } + set + { + this._PreviousActiveForm = value; + } + } + #endregion -#region Form Init - internal System.Windows.Forms.PictureBox pbError; - internal System.Windows.Forms.Label lblMsgDate; - internal System.Windows.Forms.ListView lvErrorCollector; - internal System.Windows.Forms.ColumnHeader clmMessage; - internal System.Windows.Forms.TextBox txtMsgText; - internal System.Windows.Forms.ImageList imgListMC; - private System.ComponentModel.Container components = null; - internal System.Windows.Forms.ContextMenuStrip cMenMC; - internal System.Windows.Forms.ToolStripMenuItem cMenMCCopy; - internal System.Windows.Forms.ToolStripMenuItem cMenMCDelete; - internal System.Windows.Forms.Panel pnlErrorMsg; - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.Load += new System.EventHandler(ErrorsAndInfos_Load); - this.Resize += new System.EventHandler(ErrorsAndInfos_Resize); - this.pnlErrorMsg = new System.Windows.Forms.Panel(); - this.txtMsgText = new System.Windows.Forms.TextBox(); - this.txtMsgText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MC_KeyDown); - this.lblMsgDate = new System.Windows.Forms.Label(); - this.pbError = new System.Windows.Forms.PictureBox(); - this.lvErrorCollector = new System.Windows.Forms.ListView(); - this.lvErrorCollector.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MC_KeyDown); - this.lvErrorCollector.SelectedIndexChanged += new System.EventHandler(this.lvErrorCollector_SelectedIndexChanged); - this.clmMessage = (System.Windows.Forms.ColumnHeader) (new System.Windows.Forms.ColumnHeader()); - this.cMenMC = new System.Windows.Forms.ContextMenuStrip(this.components); - this.cMenMC.Opening += new System.ComponentModel.CancelEventHandler(this.cMenMC_Opening); - this.cMenMCCopy = new System.Windows.Forms.ToolStripMenuItem(); - this.cMenMCCopy.Click += new System.EventHandler(this.cMenMCCopy_Click); - this.cMenMCDelete = new System.Windows.Forms.ToolStripMenuItem(); - this.cMenMCDelete.Click += new System.EventHandler(this.cMenMCDelete_Click); - this.imgListMC = new System.Windows.Forms.ImageList(this.components); - this.pnlErrorMsg.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbError).BeginInit(); - this.cMenMC.SuspendLayout(); - this.SuspendLayout(); - // - //pnlErrorMsg - // - this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlErrorMsg.BackColor = System.Drawing.SystemColors.Control; - this.pnlErrorMsg.Controls.Add(this.txtMsgText); - this.pnlErrorMsg.Controls.Add(this.lblMsgDate); - this.pnlErrorMsg.Controls.Add(this.pbError); - this.pnlErrorMsg.Location = new System.Drawing.Point(0, 1); - this.pnlErrorMsg.Name = "pnlErrorMsg"; - this.pnlErrorMsg.Size = new System.Drawing.Size(198, 232); - this.pnlErrorMsg.TabIndex = 20; - // - //txtMsgText - // - this.txtMsgText.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtMsgText.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtMsgText.Location = new System.Drawing.Point(40, 20); - this.txtMsgText.Multiline = true; - this.txtMsgText.Name = "txtMsgText"; - this.txtMsgText.ReadOnly = true; - this.txtMsgText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtMsgText.Size = new System.Drawing.Size(158, 211); - this.txtMsgText.TabIndex = 30; - // - //lblMsgDate - // - this.lblMsgDate.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lblMsgDate.Font = new System.Drawing.Font("Tahoma", (float) (8.25F), System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.lblMsgDate.Location = new System.Drawing.Point(40, 5); - this.lblMsgDate.Name = "lblMsgDate"; - this.lblMsgDate.Size = new System.Drawing.Size(155, 13); - this.lblMsgDate.TabIndex = 40; - // - //pbError - // - this.pbError.InitialImage = null; - this.pbError.Location = new System.Drawing.Point(2, 5); - this.pbError.Name = "pbError"; - this.pbError.Size = new System.Drawing.Size(32, 32); - this.pbError.TabIndex = 0; - this.pbError.TabStop = false; - // - //lvErrorCollector - // - this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.lvErrorCollector.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.lvErrorCollector.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {this.clmMessage}); - this.lvErrorCollector.ContextMenuStrip = this.cMenMC; - this.lvErrorCollector.FullRowSelect = true; - this.lvErrorCollector.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.lvErrorCollector.HideSelection = false; - this.lvErrorCollector.Location = new System.Drawing.Point(203, 1); - this.lvErrorCollector.Name = "lvErrorCollector"; - this.lvErrorCollector.ShowGroups = false; - this.lvErrorCollector.Size = new System.Drawing.Size(413, 232); - this.lvErrorCollector.SmallImageList = this.imgListMC; - this.lvErrorCollector.TabIndex = 10; - this.lvErrorCollector.UseCompatibleStateImageBehavior = false; - this.lvErrorCollector.View = System.Windows.Forms.View.Details; - // - //clmMessage - // - this.clmMessage.Text = global::mRemoteNG.My.Language.strColumnMessage; - this.clmMessage.Width = 184; - // - //cMenMC - // - this.cMenMC.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.cMenMC.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cMenMCCopy, this.cMenMCDelete}); - this.cMenMC.Name = "cMenMC"; - this.cMenMC.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.cMenMC.Size = new System.Drawing.Size(153, 70); - // - //cMenMCCopy - // - this.cMenMCCopy.Image = global::My.Resources.Resources.Copy; - this.cMenMCCopy.Name = "cMenMCCopy"; - this.cMenMCCopy.ShortcutKeys = (System.Windows.Forms.Keys) (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C); - this.cMenMCCopy.Size = new System.Drawing.Size(152, 22); - this.cMenMCCopy.Text = global::mRemoteNG.My.Language.strMenuCopy; - // - //cMenMCDelete - // - this.cMenMCDelete.Image = global::My.Resources.Resources.Delete; - this.cMenMCDelete.Name = "cMenMCDelete"; - this.cMenMCDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.cMenMCDelete.Size = new System.Drawing.Size(152, 22); - this.cMenMCDelete.Text = global::mRemoteNG.My.Language.strMenuDelete; - // - //imgListMC - // - this.imgListMC.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; - this.imgListMC.ImageSize = new System.Drawing.Size(16, 16); - this.imgListMC.TransparentColor = System.Drawing.Color.Transparent; - // - //ErrorsAndInfos - // - this.ClientSize = new System.Drawing.Size(617, 233); - this.Controls.Add(this.lvErrorCollector); - this.Controls.Add(this.pnlErrorMsg); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.HideOnClose = true; - this.Icon = global::My.Resources.Resources.Info_Icon; - this.Name = "ErrorsAndInfos"; - this.TabText = global::mRemoteNG.My.Language.strMenuNotifications; - this.Text = "Notifications"; - this.pnlErrorMsg.ResumeLayout(false); - this.pnlErrorMsg.PerformLayout(); - ((System.ComponentModel.ISupportInitialize) this.pbError).EndInit(); - this.cMenMC.ResumeLayout(false); - this.ResumeLayout(false); - - } -#endregion + #region Form Stuff + private void ErrorsAndInfos_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + } -#region Public Properties - private DockContent _PreviousActiveForm; -public DockContent PreviousActiveForm - { - get - { - return this._PreviousActiveForm; - } - set - { - this._PreviousActiveForm = value; - } - } -#endregion + private void ApplyLanguage() + { + clmMessage.Text = My.Language.strColumnMessage; + cMenMCCopy.Text = My.Language.strMenuNotificationsCopyAll; + cMenMCDelete.Text = My.Language.strMenuNotificationsDeleteAll; + TabText = My.Language.strMenuNotifications; + Text = My.Language.strMenuNotifications; + } + #endregion -#region Form Stuff - private void ErrorsAndInfos_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - } + #region Public Methods + public ErrorsAndInfos(DockContent Panel) + { + this.WindowType = Type.ErrorsAndInfos; + this.DockPnl = Panel; + this.InitializeComponent(); + this.LayoutVertical(); + this.FillImageList(); + } + #endregion - private void ApplyLanguage() - { - clmMessage.Text = My.Language.strColumnMessage; - cMenMCCopy.Text = My.Language.strMenuNotificationsCopyAll; - cMenMCDelete.Text = My.Language.strMenuNotificationsDeleteAll; - TabText = My.Language.strMenuNotifications; - Text = My.Language.strMenuNotifications; - } -#endregion - -#region Public Methods - public ErrorsAndInfos(DockContent Panel) - { - this.WindowType = Type.ErrorsAndInfos; - this.DockPnl = Panel; - this.InitializeComponent(); - this.LayoutVertical(); - this.FillImageList(); - } -#endregion - -#region Private Methods - private void FillImageList() - { - this.imgListMC.Images.Add(global::My.Resources.InformationSmall); - this.imgListMC.Images.Add(global::My.Resources.WarningSmall); - this.imgListMC.Images.Add(global::My.Resources.ErrorSmall); - } + #region Private Methods + private void FillImageList() + { + this.imgListMC.Images.Add(global::My.Resources.InformationSmall); + this.imgListMC.Images.Add(global::My.Resources.WarningSmall); + this.imgListMC.Images.Add(global::My.Resources.ErrorSmall); + } - private ControlLayout _Layout = ControlLayout.Vertical; + private ControlLayout _Layout = ControlLayout.Vertical; - private void LayoutVertical() - { - try - { - this.pnlErrorMsg.Location = new Point(0, this.Height - 200); - this.pnlErrorMsg.Size = new Size(this.Width, this.Height - this.pnlErrorMsg.Top); - this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); - this.txtMsgText.Size = new Size(this.pnlErrorMsg.Width - this.pbError.Width - 8, this.pnlErrorMsg.Height - 20); - this.lvErrorCollector.Location = new Point(0, 0); - this.lvErrorCollector.Size = new Size(this.Width, this.Height - this.pnlErrorMsg.Height - 5); - this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); + private void LayoutVertical() + { + try + { + this.pnlErrorMsg.Location = new Point(0, this.Height - 200); + this.pnlErrorMsg.Size = new Size(this.Width, this.Height - this.pnlErrorMsg.Top); + this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); + this.txtMsgText.Size = new Size(this.pnlErrorMsg.Width - this.pbError.Width - 8, this.pnlErrorMsg.Height - 20); + this.lvErrorCollector.Location = new Point(0, 0); + this.lvErrorCollector.Size = new Size(this.Width, this.Height - this.pnlErrorMsg.Height - 5); + this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); - this._Layout = ControlLayout.Vertical; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "LayoutVertical (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); - } - } + this._Layout = ControlLayout.Vertical; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "LayoutVertical (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private void LayoutHorizontal() - { - try - { - this.pnlErrorMsg.Location = new Point(0, 0); - this.pnlErrorMsg.Size = new Size(200, this.Height); - this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top); - this.txtMsgText.Size = new Size(this.pnlErrorMsg.Width - this.pbError.Width - 8, this.pnlErrorMsg.Height - 20); - this.lvErrorCollector.Location = new Point(this.pnlErrorMsg.Width + 5, 0); - this.lvErrorCollector.Size = new Size(this.Width - this.pnlErrorMsg.Width - 5, this.Height); - this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); + private void LayoutHorizontal() + { + try + { + this.pnlErrorMsg.Location = new Point(0, 0); + this.pnlErrorMsg.Size = new Size(200, this.Height); + this.pnlErrorMsg.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top); + this.txtMsgText.Size = new Size(this.pnlErrorMsg.Width - this.pbError.Width - 8, this.pnlErrorMsg.Height - 20); + this.lvErrorCollector.Location = new Point(this.pnlErrorMsg.Width + 5, 0); + this.lvErrorCollector.Size = new Size(this.Width - this.pnlErrorMsg.Width - 5, this.Height); + this.lvErrorCollector.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); - this._Layout = ControlLayout.Horizontal; - } - catch (Exception ex) + this._Layout = ControlLayout.Horizontal; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "LayoutHorizontal (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void ErrorsAndInfos_Resize(object sender, System.EventArgs e) + { + try + { + if (this.Width > this.Height) + { + if (this._Layout == ControlLayout.Vertical) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "LayoutHorizontal (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + this.LayoutHorizontal(); } } + else + { + if (this._Layout == ControlLayout.Horizontal) + { + this.LayoutVertical(); + } + } + + this.lvErrorCollector.Columns[0].Width = this.lvErrorCollector.Width - 20; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ErrorsAndInfos_Resize (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private void ErrorsAndInfos_Resize(object sender, System.EventArgs e) + private void pnlErrorMsg_ResetDefaultStyle() + { + try + { + this.pnlErrorMsg.BackColor = Color.FromKnownColor(KnownColor.Control); + this.pbError.Image = null; + this.txtMsgText.Text = ""; + this.txtMsgText.BackColor = Color.FromKnownColor(KnownColor.Control); + this.lblMsgDate.Text = ""; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "pnlErrorMsg_ResetDefaultStyle (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void MC_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) + { + try + { + if (e.KeyCode == Keys.Escape) { try { - if (this.Width > this.Height) + if (this._PreviousActiveForm != null) { - if (this._Layout == ControlLayout.Vertical) - { - this.LayoutHorizontal(); - } + this._PreviousActiveForm.Show(frmMain.Default.pnlDock); } else { - if (this._Layout == ControlLayout.Horizontal) - { - this.LayoutVertical(); - } - } - - this.lvErrorCollector.Columns[0].Width = this.lvErrorCollector.Width - 20; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ErrorsAndInfos_Resize (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void pnlErrorMsg_ResetDefaultStyle() - { - try - { - this.pnlErrorMsg.BackColor = Color.FromKnownColor(KnownColor.Control); - this.pbError.Image = null; - this.txtMsgText.Text = ""; - this.txtMsgText.BackColor = Color.FromKnownColor(KnownColor.Control); - this.lblMsgDate.Text = ""; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "pnlErrorMsg_ResetDefaultStyle (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void MC_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) - { - try - { - if (e.KeyCode == Keys.Escape) - { - try - { - if (this._PreviousActiveForm != null) - { - this._PreviousActiveForm.Show(frmMain.Default.pnlDock); - } - else - { - App.Runtime.Windows.treeForm.Show(frmMain.Default.pnlDock); - } - } - catch (Exception) - { - } + App.Runtime.Windows.treeForm.Show(frmMain.Default.pnlDock); } } - catch (Exception ex) + catch (Exception) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MC_KeyDown (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); } } - - private void lvErrorCollector_SelectedIndexChanged(System.Object sender, System.EventArgs e) - { - try - { - if (this.lvErrorCollector.SelectedItems.Count == 0 | this.lvErrorCollector.SelectedItems.Count > 1) - { - this.pnlErrorMsg_ResetDefaultStyle(); - return; - } - - ListViewItem sItem = this.lvErrorCollector.SelectedItems[0]; - Messages.Message eMsg = sItem.Tag; - switch (eMsg.MsgClass) - { - case Messages.MessageClass.InformationMsg: - this.pbError.Image = global::My.Resources.Information; - this.pnlErrorMsg.BackColor = Color.LightSteelBlue; - this.txtMsgText.BackColor = Color.LightSteelBlue; - break; - case Messages.MessageClass.WarningMsg: - this.pbError.Image = global::My.Resources.Warning; - this.pnlErrorMsg.BackColor = Color.Gold; - this.txtMsgText.BackColor = Color.Gold; - break; - case Messages.MessageClass.ErrorMsg: - this.pbError.Image = global::My.Resources._Error; - this.pnlErrorMsg.BackColor = Color.IndianRed; - this.txtMsgText.BackColor = Color.IndianRed; - break; - } - - this.lblMsgDate.Text = eMsg.MsgDate.ToString(); - this.txtMsgText.Text = eMsg.MsgText; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "lvErrorCollector_SelectedIndexChanged (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void cMenMC_Opening(System.Object sender, System.ComponentModel.CancelEventArgs e) - { - if (lvErrorCollector.Items.Count) - { - cMenMCCopy.Enabled = true; - cMenMCDelete.Enabled = true; - } - else - { - cMenMCCopy.Enabled = false; - cMenMCDelete.Enabled = false; - } - - if (lvErrorCollector.SelectedItems.Count) - { - cMenMCCopy.Text = My.Language.strMenuCopy; - cMenMCDelete.Text = My.Language.strMenuNotificationsDelete; - } - else - { - cMenMCCopy.Text = My.Language.strMenuNotificationsCopyAll; - cMenMCDelete.Text = My.Language.strMenuNotificationsDeleteAll; - } - } - - private void cMenMCCopy_Click(System.Object sender, System.EventArgs e) - { - CopyMessagesToClipboard(); - } - - private void CopyMessagesToClipboard() - { - try - { - IEnumerable items = default(IEnumerable); - if (lvErrorCollector.SelectedItems.Count) - { - items = lvErrorCollector.SelectedItems; - } - else - { - items = lvErrorCollector.Items; - } - - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.AppendLine("----------"); - - lvErrorCollector.BeginUpdate(); - - Messages.Message message = default(Messages.Message); - foreach (ListViewItem item in items) - { - message = item.Tag as Messages.Message; - if (message == null) - { - continue; - } - - stringBuilder.AppendLine(message.MsgClass.ToString()); - stringBuilder.AppendLine(message.MsgDate.ToString()); - stringBuilder.AppendLine(message.MsgText); - stringBuilder.AppendLine("----------"); - } - - Clipboard.SetText(stringBuilder.ToString()); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.ErrorsAndInfos.CopyMessagesToClipboard() failed." + Constants.vbNewLine + ex.Message, true); - } - finally - { - lvErrorCollector.EndUpdate(); - } - } - - private void cMenMCDelete_Click(System.Object sender, System.EventArgs e) - { - DeleteMessages(); - } - - private void DeleteMessages() - { - try - { - lvErrorCollector.BeginUpdate(); - - if (lvErrorCollector.SelectedItems.Count) - { - foreach (ListViewItem item in lvErrorCollector.SelectedItems) - { - item.Remove(); - } - } - else - { - lvErrorCollector.Items.Clear(); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.ErrorsAndInfos.DeleteMessages() failed" + Constants.vbNewLine + ex.Message, true); - } - finally - { - lvErrorCollector.EndUpdate(); - } - } -#endregion - - public enum ControlLayout - { - Vertical = 0, - Horizontal = 1 - } } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MC_KeyDown (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void lvErrorCollector_SelectedIndexChanged(System.Object sender, System.EventArgs e) + { + try + { + if (this.lvErrorCollector.SelectedItems.Count == 0 | this.lvErrorCollector.SelectedItems.Count > 1) + { + this.pnlErrorMsg_ResetDefaultStyle(); + return; + } + + ListViewItem sItem = this.lvErrorCollector.SelectedItems[0]; + Messages.Message eMsg = sItem.Tag; + switch (eMsg.MsgClass) + { + case Messages.MessageClass.InformationMsg: + this.pbError.Image = global::My.Resources.Information; + this.pnlErrorMsg.BackColor = Color.LightSteelBlue; + this.txtMsgText.BackColor = Color.LightSteelBlue; + break; + case Messages.MessageClass.WarningMsg: + this.pbError.Image = global::My.Resources.Warning; + this.pnlErrorMsg.BackColor = Color.Gold; + this.txtMsgText.BackColor = Color.Gold; + break; + case Messages.MessageClass.ErrorMsg: + this.pbError.Image = global::My.Resources._Error; + this.pnlErrorMsg.BackColor = Color.IndianRed; + this.txtMsgText.BackColor = Color.IndianRed; + break; + } + + this.lblMsgDate.Text = eMsg.MsgDate.ToString(); + this.txtMsgText.Text = eMsg.MsgText; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "lvErrorCollector_SelectedIndexChanged (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void cMenMC_Opening(System.Object sender, System.ComponentModel.CancelEventArgs e) + { + if (lvErrorCollector.Items.Count) + { + cMenMCCopy.Enabled = true; + cMenMCDelete.Enabled = true; + } + else + { + cMenMCCopy.Enabled = false; + cMenMCDelete.Enabled = false; + } + + if (lvErrorCollector.SelectedItems.Count) + { + cMenMCCopy.Text = My.Language.strMenuCopy; + cMenMCDelete.Text = My.Language.strMenuNotificationsDelete; + } + else + { + cMenMCCopy.Text = My.Language.strMenuNotificationsCopyAll; + cMenMCDelete.Text = My.Language.strMenuNotificationsDeleteAll; + } + } + + private void cMenMCCopy_Click(System.Object sender, System.EventArgs e) + { + CopyMessagesToClipboard(); + } + + private void CopyMessagesToClipboard() + { + try + { + IEnumerable items = default(IEnumerable); + if (lvErrorCollector.SelectedItems.Count) + { + items = lvErrorCollector.SelectedItems; + } + else + { + items = lvErrorCollector.Items; + } + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine("----------"); + + lvErrorCollector.BeginUpdate(); + + Messages.Message message = default(Messages.Message); + foreach (ListViewItem item in items) + { + message = item.Tag as Messages.Message; + if (message == null) + { + continue; + } + + stringBuilder.AppendLine(message.MsgClass.ToString()); + stringBuilder.AppendLine(message.MsgDate.ToString()); + stringBuilder.AppendLine(message.MsgText); + stringBuilder.AppendLine("----------"); + } + + Clipboard.SetText(stringBuilder.ToString()); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.ErrorsAndInfos.CopyMessagesToClipboard() failed." + Constants.vbNewLine + ex.Message, true); + } + finally + { + lvErrorCollector.EndUpdate(); + } + } + + private void cMenMCDelete_Click(System.Object sender, System.EventArgs e) + { + DeleteMessages(); + } + + private void DeleteMessages() + { + try + { + lvErrorCollector.BeginUpdate(); + + if (lvErrorCollector.SelectedItems.Count) + { + foreach (ListViewItem item in lvErrorCollector.SelectedItems) + { + item.Remove(); + } + } + else + { + lvErrorCollector.Items.Clear(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.ErrorsAndInfos.DeleteMessages() failed" + Constants.vbNewLine + ex.Message, true); + } + finally + { + lvErrorCollector.EndUpdate(); + } + } + #endregion + + public enum ControlLayout + { + Vertical = 0, + Horizontal = 1 + } + } } diff --git a/mRemoteV1/CS/UI/UI.Window.ExternalTools.cs b/mRemoteV1/CS/UI/UI.Window.ExternalTools.cs index e46cef06e..95894f951 100644 --- a/mRemoteV1/CS/UI/UI.Window.ExternalTools.cs +++ b/mRemoteV1/CS/UI/UI.Window.ExternalTools.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,302 +8,300 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using mRemoteNG.App; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using mRemoteNG.My; namespace mRemoteNG.UI.Window { public partial class ExternalTools : Base - { -#region Constructors - public ExternalTools(DockContent panel) - { - InitializeComponent(); + { + #region Constructors + public ExternalTools(DockContent panel) + { + InitializeComponent(); - WindowType = Type.ExternalApps; - DockPnl = panel; - } -#endregion + WindowType = Type.ExternalApps; + DockPnl = panel; + } + #endregion -#region Private Fields - private Tools.ExternalTool _selectedTool = null; -#endregion + #region Private Fields + private Tools.ExternalTool _selectedTool = null; + #endregion -#region Private Methods -#region Event Handlers - public void ExternalTools_Load(object sender, EventArgs e) + #region Private Methods + #region Event Handlers + public void ExternalTools_Load(object sender, EventArgs e) + { + ApplyLanguage(); + UpdateToolsListView(); + } + + static public void ExternalTools_FormClosed(System.Object sender, FormClosedEventArgs e) + { + mRemoteNG.Config.Settings.Save.SaveExternalAppsToXML(); + } + + public void NewTool_Click(System.Object sender, EventArgs e) + { + try + { + Tools.ExternalTool externalTool = new Tools.ExternalTool(Language.strExternalToolDefaultName); + Runtime.ExternalTools.Add(externalTool); + UpdateToolsListView(externalTool); + DisplayNameTextBox.Focus(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.NewTool_Click() failed.", ex: ex, logOnly: true); + } + } + + public void DeleteTool_Click(System.Object sender, EventArgs e) + { + try + { + string message = ""; + if (ToolsListView.SelectedItems.Count == 1) { - ApplyLanguage(); - UpdateToolsListView(); + message = string.Format(Language.strConfirmDeleteExternalTool, ToolsListView.SelectedItems[0].Text); } - - static public void ExternalTools_FormClosed(System.Object sender, FormClosedEventArgs e) + else if (ToolsListView.SelectedItems.Count > 1) { - mRemoteNG.Config.Settings.Save.SaveExternalAppsToXML(); + message = string.Format(Language.strConfirmDeleteExternalToolMultiple, ToolsListView.SelectedItems.Count); } - - public void NewTool_Click(System.Object sender, EventArgs e) + else { - try - { - Tools.ExternalTool externalTool = new Tools.ExternalTool(Language.strExternalToolDefaultName); - Runtime.ExternalTools.Add(externalTool); - UpdateToolsListView(externalTool); - DisplayNameTextBox.Focus(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.NewTool_Click() failed.", ex: ex, logOnly: true); - } + return ; } - - public void DeleteTool_Click(System.Object sender, EventArgs e) - { - try - { - string message = ""; - if (ToolsListView.SelectedItems.Count == 1) - { - message = string.Format(Language.strConfirmDeleteExternalTool, ToolsListView.SelectedItems[0].Text); - } - else if (ToolsListView.SelectedItems.Count > 1) - { - message = string.Format(Language.strConfirmDeleteExternalToolMultiple, ToolsListView.SelectedItems.Count); - } - else - { - return ; - } - if (!(Interaction.MsgBox(message, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.Yes)) - { - return ; - } + if (!(Interaction.MsgBox(message, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.Yes)) + { + return ; + } - foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) - { - Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; - if (externalTool == null) - { - continue; - } + foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) + { + Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; + if (externalTool == null) + { + continue; + } - Runtime.ExternalTools.Remove(listViewItem.Tag); - listViewItem.Remove(); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.DeleteTool_Click() failed.", ex: ex, logOnly: true); - } + Runtime.ExternalTools.Remove(listViewItem.Tag); + listViewItem.Remove(); } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.DeleteTool_Click() failed.", ex: ex, logOnly: true); + } + } - public void LaunchTool_Click(System.Object sender, EventArgs e) - { - LaunchTool(); - } + public void LaunchTool_Click(System.Object sender, EventArgs e) + { + LaunchTool(); + } - public void ToolsListView_SelectedIndexChanged(System.Object sender, EventArgs e) - { - try - { - if (ToolsListView.SelectedItems.Count == 1) - { - PropertiesGroupBox.Enabled = true; - _selectedTool = ToolsListView.SelectedItems[0].Tag as Tools.ExternalTool; - if (_selectedTool == null) - { - return ; - } - - DisplayNameTextBox.Text = _selectedTool.DisplayName; - FilenameTextBox.Text = _selectedTool.FileName; - ArgumentsCheckBox.Text = _selectedTool.Arguments; - WaitForExitCheckBox.Checked = _selectedTool.WaitForExit; - TryToIntegrateCheckBox.Checked = _selectedTool.TryIntegrate; - } - else - { - PropertiesGroupBox.Enabled = false; - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.ToolsListView_SelectedIndexChanged() failed.", ex: ex, logOnly: true); - } - } - - public void ToolsListView_DoubleClick(object sender, EventArgs e) - { - if (ToolsListView.SelectedItems.Count > 0) - { - LaunchTool(); - } - } - - public void PropertyControl_ChangedOrLostFocus(object sender, EventArgs e) + public void ToolsListView_SelectedIndexChanged(System.Object sender, EventArgs e) + { + try + { + if (ToolsListView.SelectedItems.Count == 1) { + PropertiesGroupBox.Enabled = true; + _selectedTool = ToolsListView.SelectedItems[0].Tag as Tools.ExternalTool; if (_selectedTool == null) { return ; } - - try - { - _selectedTool.DisplayName = DisplayNameTextBox.Text; - _selectedTool.FileName = FilenameTextBox.Text; - _selectedTool.Arguments = ArgumentsCheckBox.Text; - _selectedTool.WaitForExit = WaitForExitCheckBox.Checked; - _selectedTool.TryIntegrate = TryToIntegrateCheckBox.Checked; - - UpdateToolsListView(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PropertyControl_ChangedOrLostFocus() failed.", ex: ex, logOnly: true); - } - } - - public void BrowseButton_Click(System.Object sender, EventArgs e) - { - try - { - using (OpenFileDialog browseDialog = new OpenFileDialog()) - { - browseDialog.Filter = string.Join("|", new string[] {Language.strFilterApplication, "*.exe", Language.strFilterAll, "*.*"}); - if (browseDialog.ShowDialog() == DialogResult.OK) - { - FilenameTextBox.Text = browseDialog.FileName; - } - } - - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.BrowseButton_Click() failed.", ex: ex, logOnly: true); - } - } - - public void TryToIntegrateCheckBox_CheckedChanged(System.Object sender, EventArgs e) - { - if (TryToIntegrateCheckBox.Checked) - { - WaitForExitCheckBox.Enabled = false; - WaitForExitCheckBox.Checked = false; - } - else - { - WaitForExitCheckBox.Enabled = true; - } - } -#endregion - - private void ApplyLanguage() - { - Text = Language.strMenuExternalTools; - TabText = Language.strMenuExternalTools; - - NewToolToolstripButton.Text = Language.strButtonNew; - DeleteToolToolstripButton.Text = Language.strOptionsKeyboardButtonDelete; - LaunchToolToolstripButton.Text = Language.strButtonLaunch; - - DisplayNameColumnHeader.Text = Language.strColumnDisplayName; - FilenameColumnHeader.Text = Language.strColumnFilename; - ArgumentsColumnHeader.Text = Language.strColumnArguments; - WaitForExitColumnHeader.Text = Language.strColumnWaitForExit; - TryToIntegrateCheckBox.Text = Language.strTryIntegrate; - - PropertiesGroupBox.Text = Language.strGroupboxExternalToolProperties; - - DisplayNameLabel.Text = Language.strLabelDisplayName; - FilenameLabel.Text = Language.strLabelFilename; - ArgumentsLabel.Text = Language.strLabelArguments; - OptionsLabel.Text = Language.strLabelOptions; - WaitForExitCheckBox.Text = Language.strCheckboxWaitForExit; - BrowseButton.Text = Language.strButtonBrowse; - - NewToolMenuItem.Text = Language.strMenuNewExternalTool; - DeleteToolMenuItem.Text = Language.strMenuDeleteExternalTool; - LaunchToolMenuItem.Text = Language.strMenuLaunchExternalTool; - } - - private void UpdateToolsListView(Tools.ExternalTool selectTool = null) - { - try - { - List selectedTools = new List(); - if (selectTool == null) - { - foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) - { - Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; - if (externalTool != null) - { - selectedTools.Add(externalTool); - } - } - } - else - { - selectedTools.Add(selectTool); - } - - ToolsListView.BeginUpdate(); - ToolsListView.Items.Clear(); - - foreach (Tools.ExternalTool externalTool in Runtime.ExternalTools) - { - ListViewItem listViewItem = new ListViewItem(); - listViewItem.Text = externalTool.DisplayName; - listViewItem.SubItems.Add(externalTool.FileName); - listViewItem.SubItems.Add(externalTool.Arguments); - listViewItem.SubItems.Add(externalTool.WaitForExit); - listViewItem.SubItems.Add(externalTool.TryIntegrate); - listViewItem.Tag = externalTool; - ToolsListView.Items.Add(listViewItem); - - if (selectedTools.Contains(externalTool)) - { - listViewItem.Selected = true; - } - } - - ToolsListView.EndUpdate(); - - frmMain.Default.AddExternalToolsToToolBar(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PopulateToolsListView()", ex: ex, logOnly: true); - } + DisplayNameTextBox.Text = _selectedTool.DisplayName; + FilenameTextBox.Text = _selectedTool.FileName; + ArgumentsCheckBox.Text = _selectedTool.Arguments; + WaitForExitCheckBox.Checked = _selectedTool.WaitForExit; + TryToIntegrateCheckBox.Checked = _selectedTool.TryIntegrate; } - - private void LaunchTool() + else { - try - { - foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) - { - Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; - if (externalTool == null) - { - continue; - } - - externalTool.Start(); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.LaunchTool() failed.", ex: ex, logOnly: true); - } + PropertiesGroupBox.Enabled = false; } -#endregion } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.ToolsListView_SelectedIndexChanged() failed.", ex: ex, logOnly: true); + } + } + + public void ToolsListView_DoubleClick(object sender, EventArgs e) + { + if (ToolsListView.SelectedItems.Count > 0) + { + LaunchTool(); + } + } + + public void PropertyControl_ChangedOrLostFocus(object sender, EventArgs e) + { + if (_selectedTool == null) + { + return ; + } + + try + { + _selectedTool.DisplayName = DisplayNameTextBox.Text; + _selectedTool.FileName = FilenameTextBox.Text; + _selectedTool.Arguments = ArgumentsCheckBox.Text; + _selectedTool.WaitForExit = WaitForExitCheckBox.Checked; + _selectedTool.TryIntegrate = TryToIntegrateCheckBox.Checked; + + UpdateToolsListView(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PropertyControl_ChangedOrLostFocus() failed.", ex: ex, logOnly: true); + } + } + + public void BrowseButton_Click(System.Object sender, EventArgs e) + { + try + { + using (OpenFileDialog browseDialog = new OpenFileDialog()) + { + browseDialog.Filter = string.Join("|", new string[] {Language.strFilterApplication, "*.exe", Language.strFilterAll, "*.*"}); + if (browseDialog.ShowDialog() == DialogResult.OK) + { + FilenameTextBox.Text = browseDialog.FileName; + } + } + + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.BrowseButton_Click() failed.", ex: ex, logOnly: true); + } + } + + public void TryToIntegrateCheckBox_CheckedChanged(System.Object sender, EventArgs e) + { + if (TryToIntegrateCheckBox.Checked) + { + WaitForExitCheckBox.Enabled = false; + WaitForExitCheckBox.Checked = false; + } + else + { + WaitForExitCheckBox.Enabled = true; + } + } + #endregion + + private void ApplyLanguage() + { + Text = Language.strMenuExternalTools; + TabText = Language.strMenuExternalTools; + + NewToolToolstripButton.Text = Language.strButtonNew; + DeleteToolToolstripButton.Text = Language.strOptionsKeyboardButtonDelete; + LaunchToolToolstripButton.Text = Language.strButtonLaunch; + + DisplayNameColumnHeader.Text = Language.strColumnDisplayName; + FilenameColumnHeader.Text = Language.strColumnFilename; + ArgumentsColumnHeader.Text = Language.strColumnArguments; + WaitForExitColumnHeader.Text = Language.strColumnWaitForExit; + TryToIntegrateCheckBox.Text = Language.strTryIntegrate; + + PropertiesGroupBox.Text = Language.strGroupboxExternalToolProperties; + + DisplayNameLabel.Text = Language.strLabelDisplayName; + FilenameLabel.Text = Language.strLabelFilename; + ArgumentsLabel.Text = Language.strLabelArguments; + OptionsLabel.Text = Language.strLabelOptions; + WaitForExitCheckBox.Text = Language.strCheckboxWaitForExit; + BrowseButton.Text = Language.strButtonBrowse; + + NewToolMenuItem.Text = Language.strMenuNewExternalTool; + DeleteToolMenuItem.Text = Language.strMenuDeleteExternalTool; + LaunchToolMenuItem.Text = Language.strMenuLaunchExternalTool; + } + + private void UpdateToolsListView(Tools.ExternalTool selectTool = null) + { + try + { + List selectedTools = new List(); + if (selectTool == null) + { + foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) + { + Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; + if (externalTool != null) + { + selectedTools.Add(externalTool); + } + } + } + else + { + selectedTools.Add(selectTool); + } + + ToolsListView.BeginUpdate(); + ToolsListView.Items.Clear(); + + foreach (Tools.ExternalTool externalTool in Runtime.ExternalTools) + { + ListViewItem listViewItem = new ListViewItem(); + listViewItem.Text = externalTool.DisplayName; + listViewItem.SubItems.Add(externalTool.FileName); + listViewItem.SubItems.Add(externalTool.Arguments); + listViewItem.SubItems.Add(externalTool.WaitForExit); + listViewItem.SubItems.Add(externalTool.TryIntegrate); + listViewItem.Tag = externalTool; + + ToolsListView.Items.Add(listViewItem); + + if (selectedTools.Contains(externalTool)) + { + listViewItem.Selected = true; + } + } + + ToolsListView.EndUpdate(); + + frmMain.Default.AddExternalToolsToToolBar(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PopulateToolsListView()", ex: ex, logOnly: true); + } + } + + private void LaunchTool() + { + try + { + foreach (ListViewItem listViewItem in ToolsListView.SelectedItems) + { + Tools.ExternalTool externalTool = listViewItem.Tag as Tools.ExternalTool; + if (externalTool == null) + { + continue; + } + + externalTool.Start(); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.LaunchTool() failed.", ex: ex, logOnly: true); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.PortScan.cs b/mRemoteV1/CS/UI/UI.Window.PortScan.cs index 76d34ee64..71462e355 100644 --- a/mRemoteV1/CS/UI/UI.Window.PortScan.cs +++ b/mRemoteV1/CS/UI/UI.Window.PortScan.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,283 +8,281 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - //using mRemoteNG.Tools.PortScan; using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public partial class PortScan : Base + { + #region Constructors + public PortScan(DockContent panel, bool import) + { + InitializeComponent(); + + WindowType = Type.PortScan; + DockPnl = panel; + _import = import; + } + #endregion + + #region Private Properties + private bool IpsValid + { + get { -#region Constructors - public PortScan(DockContent panel, bool import) + if (string.IsNullOrEmpty(ipStart.Octet1)) { - InitializeComponent(); - - WindowType = Type.PortScan; - DockPnl = panel; - _import = import; + return false; } -#endregion - -#region Private Properties -private bool IpsValid + if (string.IsNullOrEmpty(ipStart.Octet2)) { - get - { - if (string.IsNullOrEmpty(ipStart.Octet1)) - { - return false; - } - if (string.IsNullOrEmpty(ipStart.Octet2)) - { - return false; - } - if (string.IsNullOrEmpty(ipStart.Octet3)) - { - return false; - } - if (string.IsNullOrEmpty(ipStart.Octet4)) - { - return false; - } + return false; + } + if (string.IsNullOrEmpty(ipStart.Octet3)) + { + return false; + } + if (string.IsNullOrEmpty(ipStart.Octet4)) + { + return false; + } - if (string.IsNullOrEmpty(ipEnd.Octet1)) - { - return false; - } - if (string.IsNullOrEmpty(ipEnd.Octet2)) - { - return false; - } - if (string.IsNullOrEmpty(ipEnd.Octet3)) - { - return false; - } - if (string.IsNullOrEmpty(ipEnd.Octet4)) - { - return false; - } + if (string.IsNullOrEmpty(ipEnd.Octet1)) + { + return false; + } + if (string.IsNullOrEmpty(ipEnd.Octet2)) + { + return false; + } + if (string.IsNullOrEmpty(ipEnd.Octet3)) + { + return false; + } + if (string.IsNullOrEmpty(ipEnd.Octet4)) + { + return false; + } - return true; - } - } -#endregion - -#region Private Fields - private bool _import; - private Tools.PortScan.Scanner _portScanner; - private bool _scanning = false; -#endregion - -#region Private Methods -#region Event Handlers - public void PortScan_Load(System.Object sender, EventArgs e) - { - ApplyLanguage(); - - try - { - if (_import) - { - lvHosts.Columns.AddRange(new ColumnHeader[] {clmHost, clmSSH, clmTelnet, clmHTTP, clmHTTPS, clmRlogin, clmRDP, clmVNC}); - ShowImportControls(true); - cbProtocol.SelectedIndex = 0; - } - else - { - lvHosts.Columns.AddRange(new ColumnHeader[] {clmHost, clmOpenPorts, clmClosedPorts}); - ShowImportControls(false); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(My.Language.strPortScanCouldNotLoadPanel, ex); - } - } - - public void portStart_Enter(System.Object sender, EventArgs e) - { - portStart.Select(0, portStart.Text.Length); - } - - public void portEnd_Enter(System.Object sender, EventArgs e) - { - portEnd.Select(0, portEnd.Text.Length); - } - - public void btnScan_Click(System.Object sender, EventArgs e) - { - if (_scanning) - { - StopScan(); - } - else - { - if (IpsValid) - { - StartScan(); - } - else - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strCannotStartPortScan); - } - } - } - - public void btnImport_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Connection.Protocol.Protocols protocol = Tools.Misc.StringToEnum(typeof(mRemoteNG.Connection.Protocol.Protocols), System.Convert.ToString(cbProtocol.SelectedItem)); - - List hosts = new List(); - foreach (ListViewItem item in lvHosts.SelectedItems) - { - Tools.PortScan.ScanHost scanHost = item.Tag as Tools.PortScan.ScanHost; - if (scanHost != null) - { - hosts.Add(item.Tag); - } - } - - App.Import.ImportFromPortScan(hosts, protocol); - - DialogResult = DialogResult.OK; - Close(); - } -#endregion - - private void ApplyLanguage() - { - lblStartIP.Text = string.Format("{0}:", My.Language.strStartIP); - lblEndIP.Text = string.Format("{0}:", My.Language.strEndIP); - btnScan.Text = My.Language.strButtonScan; - btnImport.Text = My.Language.strButtonImport; - lblOnlyImport.Text = string.Format("{0}:", My.Language.strProtocolToImport); - clmHost.Text = My.Language.strColumnHostnameIP; - clmOpenPorts.Text = My.Language.strOpenPorts; - clmClosedPorts.Text = My.Language.strClosedPorts; - Label2.Text = string.Format("{0}:", My.Language.strEndPort); - Label1.Text = string.Format("{0}:", My.Language.strStartPort); - TabText = My.Language.strMenuPortScan; - Text = My.Language.strMenuPortScan; - } - - private void ShowImportControls(bool controlsVisible) - { - pnlPorts.Visible = controlsVisible; - pnlImport.Visible = controlsVisible; - if (controlsVisible) - { - lvHosts.Height = pnlImport.Top - lvHosts.Top; - } - else - { - lvHosts.Height = pnlImport.Bottom - lvHosts.Top; - } - } - - private void StartScan() - { - try - { - _scanning = true; - SwitchButtonText(); - lvHosts.Items.Clear(); - - System.Net.IPAddress ipAddressStart = System.Net.IPAddress.Parse(ipStart.Text); - System.Net.IPAddress ipAddressEnd = System.Net.IPAddress.Parse(ipEnd.Text); - - if (_import) - { - _portScanner = new Tools.PortScan.Scanner(ipAddressStart, ipAddressEnd); - } - else - { - _portScanner = new Tools.PortScan.Scanner(ipAddressStart, ipAddressEnd, (int) portStart.Value, (int) portEnd.Value); - } - - _portScanner.BeginHostScan += PortScanner_BeginHostScan; - _portScanner.HostScanned += PortScanner_HostScanned; - _portScanner.ScanComplete += PortScanner_ScanComplete; - - _portScanner.StartScan(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartScan failed (UI.Window.PortScan)" + Constants.vbNewLine + ex.Message, true); - } - } - - private void StopScan() - { - if (_portScanner != null) - { - _portScanner.StopScan(); - } - _scanning = false; - SwitchButtonText(); - } - - private void SwitchButtonText() - { - if (_scanning) - { - btnScan.Text = My.Language.strButtonStop; - } - else - { - btnScan.Text = My.Language.strButtonScan; - } - - prgBar.Maximum = 100; - prgBar.Value = 0; - } - - private static void PortScanner_BeginHostScan(string host) - { - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, "Scanning " + host, true); - } - - private delegate void PortScannerHostScannedDelegate(Tools.PortScan.ScanHost host, int scannedCount, int totalCount); - private void PortScanner_HostScanned(Tools.PortScan.ScanHost host, int scannedCount, int totalCount) - { - if (InvokeRequired) - { - Invoke(new PortScannerHostScannedDelegate(PortScanner_HostScanned), new object[] {host, scannedCount, totalCount}); - return ; - } - - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, "Host scanned " + host.HostIp, true); - - ListViewItem listViewItem = host.ToListViewItem(_import); - if (listViewItem != null) - { - lvHosts.Items.Add(listViewItem); - listViewItem.EnsureVisible(); - } - - prgBar.Maximum = totalCount; - prgBar.Value = scannedCount; - } - - private delegate void PortScannerScanComplete(List hosts); - private void PortScanner_ScanComplete(List hosts) - { - if (InvokeRequired) - { - Invoke(new PortScannerScanComplete(PortScanner_ScanComplete), new object[] {hosts}); - return ; - } - - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strPortScanComplete); - - _scanning = false; - SwitchButtonText(); - } -#endregion + return true; } + } + #endregion + + #region Private Fields + private bool _import; + private Tools.PortScan.Scanner _portScanner; + private bool _scanning = false; + #endregion + + #region Private Methods + #region Event Handlers + public void PortScan_Load(System.Object sender, EventArgs e) + { + ApplyLanguage(); + + try + { + if (_import) + { + lvHosts.Columns.AddRange(new ColumnHeader[] {clmHost, clmSSH, clmTelnet, clmHTTP, clmHTTPS, clmRlogin, clmRDP, clmVNC}); + ShowImportControls(true); + cbProtocol.SelectedIndex = 0; + } + else + { + lvHosts.Columns.AddRange(new ColumnHeader[] {clmHost, clmOpenPorts, clmClosedPorts}); + ShowImportControls(false); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(My.Language.strPortScanCouldNotLoadPanel, ex); + } + } + + public void portStart_Enter(System.Object sender, EventArgs e) + { + portStart.Select(0, portStart.Text.Length); + } + + public void portEnd_Enter(System.Object sender, EventArgs e) + { + portEnd.Select(0, portEnd.Text.Length); + } + + public void btnScan_Click(System.Object sender, EventArgs e) + { + if (_scanning) + { + StopScan(); + } + else + { + if (IpsValid) + { + StartScan(); + } + else + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strCannotStartPortScan); + } + } + } + + public void btnImport_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Connection.Protocol.Protocols protocol = Tools.Misc.StringToEnum(typeof(mRemoteNG.Connection.Protocol.Protocols), System.Convert.ToString(cbProtocol.SelectedItem)); + + List hosts = new List(); + foreach (ListViewItem item in lvHosts.SelectedItems) + { + Tools.PortScan.ScanHost scanHost = item.Tag as Tools.PortScan.ScanHost; + if (scanHost != null) + { + hosts.Add(item.Tag); + } + } + + App.Import.ImportFromPortScan(hosts, protocol); + + DialogResult = DialogResult.OK; + Close(); + } + #endregion + + private void ApplyLanguage() + { + lblStartIP.Text = string.Format("{0}:", My.Language.strStartIP); + lblEndIP.Text = string.Format("{0}:", My.Language.strEndIP); + btnScan.Text = My.Language.strButtonScan; + btnImport.Text = My.Language.strButtonImport; + lblOnlyImport.Text = string.Format("{0}:", My.Language.strProtocolToImport); + clmHost.Text = My.Language.strColumnHostnameIP; + clmOpenPorts.Text = My.Language.strOpenPorts; + clmClosedPorts.Text = My.Language.strClosedPorts; + Label2.Text = string.Format("{0}:", My.Language.strEndPort); + Label1.Text = string.Format("{0}:", My.Language.strStartPort); + TabText = My.Language.strMenuPortScan; + Text = My.Language.strMenuPortScan; + } + + private void ShowImportControls(bool controlsVisible) + { + pnlPorts.Visible = controlsVisible; + pnlImport.Visible = controlsVisible; + if (controlsVisible) + { + lvHosts.Height = pnlImport.Top - lvHosts.Top; + } + else + { + lvHosts.Height = pnlImport.Bottom - lvHosts.Top; + } + } + + private void StartScan() + { + try + { + _scanning = true; + SwitchButtonText(); + lvHosts.Items.Clear(); + + System.Net.IPAddress ipAddressStart = System.Net.IPAddress.Parse(ipStart.Text); + System.Net.IPAddress ipAddressEnd = System.Net.IPAddress.Parse(ipEnd.Text); + + if (_import) + { + _portScanner = new Tools.PortScan.Scanner(ipAddressStart, ipAddressEnd); + } + else + { + _portScanner = new Tools.PortScan.Scanner(ipAddressStart, ipAddressEnd, (int) portStart.Value, (int) portEnd.Value); + } + + _portScanner.BeginHostScan += PortScanner_BeginHostScan; + _portScanner.HostScanned += PortScanner_HostScanned; + _portScanner.ScanComplete += PortScanner_ScanComplete; + + _portScanner.StartScan(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartScan failed (UI.Window.PortScan)" + Constants.vbNewLine + ex.Message, true); + } + } + + private void StopScan() + { + if (_portScanner != null) + { + _portScanner.StopScan(); + } + _scanning = false; + SwitchButtonText(); + } + + private void SwitchButtonText() + { + if (_scanning) + { + btnScan.Text = My.Language.strButtonStop; + } + else + { + btnScan.Text = My.Language.strButtonScan; + } + + prgBar.Maximum = 100; + prgBar.Value = 0; + } + + private static void PortScanner_BeginHostScan(string host) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, "Scanning " + host, true); + } + + private delegate void PortScannerHostScannedDelegate(Tools.PortScan.ScanHost host, int scannedCount, int totalCount); + private void PortScanner_HostScanned(Tools.PortScan.ScanHost host, int scannedCount, int totalCount) + { + if (InvokeRequired) + { + Invoke(new PortScannerHostScannedDelegate(PortScanner_HostScanned), new object[] {host, scannedCount, totalCount}); + return ; + } + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, "Host scanned " + host.HostIp, true); + + ListViewItem listViewItem = host.ToListViewItem(_import); + if (listViewItem != null) + { + lvHosts.Items.Add(listViewItem); + listViewItem.EnsureVisible(); + } + + prgBar.Maximum = totalCount; + prgBar.Value = scannedCount; + } + + private delegate void PortScannerScanComplete(List hosts); + private void PortScanner_ScanComplete(List hosts) + { + if (InvokeRequired) + { + Invoke(new PortScannerScanComplete(PortScanner_ScanComplete), new object[] {hosts}); + return ; + } + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strPortScanComplete); + + _scanning = false; + SwitchButtonText(); + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.SSHTransfer.cs b/mRemoteV1/CS/UI/UI.Window.SSHTransfer.cs index 162cae957..31413f739 100644 --- a/mRemoteV1/CS/UI/UI.Window.SSHTransfer.cs +++ b/mRemoteV1/CS/UI/UI.Window.SSHTransfer.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,616 +8,613 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using WeifenLuo.WinFormsUI.Docking; using Tamir.SharpSsh; using System.IO; using System.Threading; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public class SSHTransfer : Base + { + #region Form Init + internal System.Windows.Forms.ProgressBar pbStatus; + internal System.Windows.Forms.Button btnTransfer; + internal System.Windows.Forms.TextBox txtUser; + internal System.Windows.Forms.TextBox txtPassword; + internal System.Windows.Forms.TextBox txtHost; + internal System.Windows.Forms.TextBox txtPort; + internal System.Windows.Forms.Label lblHost; + internal System.Windows.Forms.Label lblPort; + internal System.Windows.Forms.Label lblUser; + internal System.Windows.Forms.Label lblPassword; + internal System.Windows.Forms.Label lblProtocol; + internal System.Windows.Forms.RadioButton radProtSCP; + internal System.Windows.Forms.RadioButton radProtSFTP; + internal System.Windows.Forms.GroupBox grpConnection; + internal System.Windows.Forms.Button btnBrowse; + internal System.Windows.Forms.Label lblRemoteFile; + internal System.Windows.Forms.TextBox txtRemoteFile; + internal System.Windows.Forms.TextBox txtLocalFile; + internal System.Windows.Forms.Label lblLocalFile; + internal System.Windows.Forms.GroupBox grpFiles; + + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SSHTransfer)); + this.grpFiles = new System.Windows.Forms.GroupBox(); + this.Load += new System.EventHandler(SSHTransfer_Load); + this.lblLocalFile = new System.Windows.Forms.Label(); + this.txtLocalFile = new System.Windows.Forms.TextBox(); + this.txtRemoteFile = new System.Windows.Forms.TextBox(); + this.lblRemoteFile = new System.Windows.Forms.Label(); + this.btnBrowse = new System.Windows.Forms.Button(); + this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); + this.grpConnection = new System.Windows.Forms.GroupBox(); + this.radProtSFTP = new System.Windows.Forms.RadioButton(); + this.radProtSCP = new System.Windows.Forms.RadioButton(); + this.lblProtocol = new System.Windows.Forms.Label(); + this.lblPassword = new System.Windows.Forms.Label(); + this.lblUser = new System.Windows.Forms.Label(); + this.lblPort = new System.Windows.Forms.Label(); + this.lblHost = new System.Windows.Forms.Label(); + this.txtPort = new System.Windows.Forms.TextBox(); + this.txtHost = new System.Windows.Forms.TextBox(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtUser = new System.Windows.Forms.TextBox(); + this.btnTransfer = new System.Windows.Forms.Button(); + this.btnTransfer.Click += new System.EventHandler(this.btnTransfer_Click); + this.pbStatus = new System.Windows.Forms.ProgressBar(); + this.grpFiles.SuspendLayout(); + this.grpConnection.SuspendLayout(); + this.SuspendLayout(); + // + //grpFiles + // + this.grpFiles.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.grpFiles.Controls.Add(this.lblLocalFile); + this.grpFiles.Controls.Add(this.txtLocalFile); + this.grpFiles.Controls.Add(this.txtRemoteFile); + this.grpFiles.Controls.Add(this.lblRemoteFile); + this.grpFiles.Controls.Add(this.btnBrowse); + this.grpFiles.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.grpFiles.Location = new System.Drawing.Point(12, 153); + this.grpFiles.Name = "grpFiles"; + this.grpFiles.Size = new System.Drawing.Size(668, 194); + this.grpFiles.TabIndex = 2000; + this.grpFiles.TabStop = false; + this.grpFiles.Text = "Files"; + // + //lblLocalFile + // + this.lblLocalFile.AutoSize = true; + this.lblLocalFile.Location = new System.Drawing.Point(20, 25); + this.lblLocalFile.Name = "lblLocalFile"; + this.lblLocalFile.Size = new System.Drawing.Size(52, 13); + this.lblLocalFile.TabIndex = 10; + this.lblLocalFile.Text = "Local file:"; + // + //txtLocalFile + // + this.txtLocalFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtLocalFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtLocalFile.Location = new System.Drawing.Point(105, 23); + this.txtLocalFile.Name = "txtLocalFile"; + this.txtLocalFile.Size = new System.Drawing.Size(455, 20); + this.txtLocalFile.TabIndex = 20; + // + //txtRemoteFile + // + this.txtRemoteFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtRemoteFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtRemoteFile.Location = new System.Drawing.Point(105, 49); + this.txtRemoteFile.Name = "txtRemoteFile"; + this.txtRemoteFile.Size = new System.Drawing.Size(542, 20); + this.txtRemoteFile.TabIndex = 50; + // + //lblRemoteFile + // + this.lblRemoteFile.AutoSize = true; + this.lblRemoteFile.Location = new System.Drawing.Point(20, 51); + this.lblRemoteFile.Name = "lblRemoteFile"; + this.lblRemoteFile.Size = new System.Drawing.Size(63, 13); + this.lblRemoteFile.TabIndex = 40; + this.lblRemoteFile.Text = "Remote file:"; + // + //btnBrowse + // + this.btnBrowse.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.btnBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnBrowse.Location = new System.Drawing.Point(566, 21); + this.btnBrowse.Name = "btnBrowse"; + this.btnBrowse.Size = new System.Drawing.Size(81, 23); + this.btnBrowse.TabIndex = 30; + this.btnBrowse.Text = "Browse"; + this.btnBrowse.UseVisualStyleBackColor = true; + // + //grpConnection + // + this.grpConnection.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.grpConnection.Controls.Add(this.radProtSFTP); + this.grpConnection.Controls.Add(this.radProtSCP); + this.grpConnection.Controls.Add(this.lblProtocol); + this.grpConnection.Controls.Add(this.lblPassword); + this.grpConnection.Controls.Add(this.lblUser); + this.grpConnection.Controls.Add(this.lblPort); + this.grpConnection.Controls.Add(this.lblHost); + this.grpConnection.Controls.Add(this.txtPort); + this.grpConnection.Controls.Add(this.txtHost); + this.grpConnection.Controls.Add(this.txtPassword); + this.grpConnection.Controls.Add(this.txtUser); + this.grpConnection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.grpConnection.Location = new System.Drawing.Point(12, 12); + this.grpConnection.Name = "grpConnection"; + this.grpConnection.Size = new System.Drawing.Size(668, 135); + this.grpConnection.TabIndex = 1000; + this.grpConnection.TabStop = false; + this.grpConnection.Text = "Connection"; + // + //radProtSFTP + // + this.radProtSFTP.AutoSize = true; + this.radProtSFTP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.radProtSFTP.Location = new System.Drawing.Point(153, 103); + this.radProtSFTP.Name = "radProtSFTP"; + this.radProtSFTP.Size = new System.Drawing.Size(51, 17); + this.radProtSFTP.TabIndex = 110; + this.radProtSFTP.Text = "SFTP"; + this.radProtSFTP.UseVisualStyleBackColor = true; + // + //radProtSCP + // + this.radProtSCP.AutoSize = true; + this.radProtSCP.Checked = true; + this.radProtSCP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.radProtSCP.Location = new System.Drawing.Point(92, 103); + this.radProtSCP.Name = "radProtSCP"; + this.radProtSCP.Size = new System.Drawing.Size(45, 17); + this.radProtSCP.TabIndex = 100; + this.radProtSCP.TabStop = true; + this.radProtSCP.Text = "SCP"; + this.radProtSCP.UseVisualStyleBackColor = true; + // + //lblProtocol + // + this.lblProtocol.AutoSize = true; + this.lblProtocol.Location = new System.Drawing.Point(20, 105); + this.lblProtocol.Name = "lblProtocol"; + this.lblProtocol.Size = new System.Drawing.Size(49, 13); + this.lblProtocol.TabIndex = 90; + this.lblProtocol.Text = "Protocol:"; + // + //lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.Location = new System.Drawing.Point(20, 79); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(56, 13); + this.lblPassword.TabIndex = 70; + this.lblPassword.Text = "Password:"; + // + //lblUser + // + this.lblUser.AutoSize = true; + this.lblUser.Location = new System.Drawing.Point(20, 53); + this.lblUser.Name = "lblUser"; + this.lblUser.Size = new System.Drawing.Size(32, 13); + this.lblUser.TabIndex = 50; + this.lblUser.Text = "User:"; + // + //lblPort + // + this.lblPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.lblPort.AutoSize = true; + this.lblPort.Location = new System.Drawing.Point(582, 27); + this.lblPort.Name = "lblPort"; + this.lblPort.Size = new System.Drawing.Size(29, 13); + this.lblPort.TabIndex = 30; + this.lblPort.Text = "Port:"; + // + //lblHost + // + this.lblHost.AutoSize = true; + this.lblHost.Location = new System.Drawing.Point(20, 27); + this.lblHost.Name = "lblHost"; + this.lblHost.Size = new System.Drawing.Size(32, 13); + this.lblHost.TabIndex = 10; + this.lblHost.Text = "Host:"; + // + //txtPort + // + this.txtPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); + this.txtPort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtPort.Location = new System.Drawing.Point(617, 25); + this.txtPort.Name = "txtPort"; + this.txtPort.Size = new System.Drawing.Size(30, 20); + this.txtPort.TabIndex = 40; + // + //txtHost + // + this.txtHost.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtHost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtHost.Location = new System.Drawing.Point(105, 25); + this.txtHost.Name = "txtHost"; + this.txtHost.Size = new System.Drawing.Size(471, 20); + this.txtHost.TabIndex = 20; + // + //txtPassword + // + this.txtPassword.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtPassword.Location = new System.Drawing.Point(105, 77); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = global::Microsoft.VisualBasic.Strings.ChrW(42); + this.txtPassword.Size = new System.Drawing.Size(471, 20); + this.txtPassword.TabIndex = 80; + // + //txtUser + // + this.txtUser.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.txtUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtUser.Location = new System.Drawing.Point(105, 51); + this.txtUser.Name = "txtUser"; + this.txtUser.Size = new System.Drawing.Size(471, 20); + this.txtUser.TabIndex = 60; + // + //btnTransfer + // + this.btnTransfer.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); + this.btnTransfer.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnTransfer.Image = global::My.Resources.Resources.SSHTransfer; + this.btnTransfer.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btnTransfer.Location = new System.Drawing.Point(597, 382); + this.btnTransfer.Name = "btnTransfer"; + this.btnTransfer.Size = new System.Drawing.Size(83, 29); + this.btnTransfer.TabIndex = 10000; + this.btnTransfer.Text = "Transfer"; + this.btnTransfer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.btnTransfer.UseVisualStyleBackColor = true; + // + //pbStatus + // + this.pbStatus.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pbStatus.Location = new System.Drawing.Point(12, 353); + this.pbStatus.Name = "pbStatus"; + this.pbStatus.Size = new System.Drawing.Size(668, 23); + this.pbStatus.TabIndex = 3000; + // + //SSHTransfer + // + this.ClientSize = new System.Drawing.Size(692, 423); + this.Controls.Add(this.grpFiles); + this.Controls.Add(this.grpConnection); + this.Controls.Add(this.btnTransfer); + this.Controls.Add(this.pbStatus); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.Icon = (System.Drawing.Icon) (resources.GetObject("$this.Icon")); + this.Name = "SSHTransfer"; + this.TabText = "SSH File Transfer"; + this.Text = "SSH File Transfer"; + this.grpFiles.ResumeLayout(false); + this.grpFiles.PerformLayout(); + this.grpConnection.ResumeLayout(false); + this.grpConnection.PerformLayout(); + this.ResumeLayout(false); + + } + #endregion + + #region Private Properties + private SshTransferProtocolBase sshT; + private OpenFileDialog oDlg; + #endregion + + #region Public Properties + public string Hostname + { + get { + return this.txtHost.Text; + } + set + { + this.txtHost.Text = value; + } + } -#region Form Init - internal System.Windows.Forms.ProgressBar pbStatus; - internal System.Windows.Forms.Button btnTransfer; - internal System.Windows.Forms.TextBox txtUser; - internal System.Windows.Forms.TextBox txtPassword; - internal System.Windows.Forms.TextBox txtHost; - internal System.Windows.Forms.TextBox txtPort; - internal System.Windows.Forms.Label lblHost; - internal System.Windows.Forms.Label lblPort; - internal System.Windows.Forms.Label lblUser; - internal System.Windows.Forms.Label lblPassword; - internal System.Windows.Forms.Label lblProtocol; - internal System.Windows.Forms.RadioButton radProtSCP; - internal System.Windows.Forms.RadioButton radProtSFTP; - internal System.Windows.Forms.GroupBox grpConnection; - internal System.Windows.Forms.Button btnBrowse; - internal System.Windows.Forms.Label lblRemoteFile; - internal System.Windows.Forms.TextBox txtRemoteFile; - internal System.Windows.Forms.TextBox txtLocalFile; - internal System.Windows.Forms.Label lblLocalFile; - internal System.Windows.Forms.GroupBox grpFiles; + public string Port + { + get + { + return this.txtPort.Text; + } + set + { + this.txtPort.Text = value; + } + } - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SSHTransfer)); - this.grpFiles = new System.Windows.Forms.GroupBox(); - this.Load += new System.EventHandler(SSHTransfer_Load); - this.lblLocalFile = new System.Windows.Forms.Label(); - this.txtLocalFile = new System.Windows.Forms.TextBox(); - this.txtRemoteFile = new System.Windows.Forms.TextBox(); - this.lblRemoteFile = new System.Windows.Forms.Label(); - this.btnBrowse = new System.Windows.Forms.Button(); - this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); - this.grpConnection = new System.Windows.Forms.GroupBox(); - this.radProtSFTP = new System.Windows.Forms.RadioButton(); - this.radProtSCP = new System.Windows.Forms.RadioButton(); - this.lblProtocol = new System.Windows.Forms.Label(); - this.lblPassword = new System.Windows.Forms.Label(); - this.lblUser = new System.Windows.Forms.Label(); - this.lblPort = new System.Windows.Forms.Label(); - this.lblHost = new System.Windows.Forms.Label(); - this.txtPort = new System.Windows.Forms.TextBox(); - this.txtHost = new System.Windows.Forms.TextBox(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtUser = new System.Windows.Forms.TextBox(); - this.btnTransfer = new System.Windows.Forms.Button(); - this.btnTransfer.Click += new System.EventHandler(this.btnTransfer_Click); - this.pbStatus = new System.Windows.Forms.ProgressBar(); - this.grpFiles.SuspendLayout(); - this.grpConnection.SuspendLayout(); - this.SuspendLayout(); - // - //grpFiles - // - this.grpFiles.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.grpFiles.Controls.Add(this.lblLocalFile); - this.grpFiles.Controls.Add(this.txtLocalFile); - this.grpFiles.Controls.Add(this.txtRemoteFile); - this.grpFiles.Controls.Add(this.lblRemoteFile); - this.grpFiles.Controls.Add(this.btnBrowse); - this.grpFiles.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.grpFiles.Location = new System.Drawing.Point(12, 153); - this.grpFiles.Name = "grpFiles"; - this.grpFiles.Size = new System.Drawing.Size(668, 194); - this.grpFiles.TabIndex = 2000; - this.grpFiles.TabStop = false; - this.grpFiles.Text = "Files"; - // - //lblLocalFile - // - this.lblLocalFile.AutoSize = true; - this.lblLocalFile.Location = new System.Drawing.Point(20, 25); - this.lblLocalFile.Name = "lblLocalFile"; - this.lblLocalFile.Size = new System.Drawing.Size(52, 13); - this.lblLocalFile.TabIndex = 10; - this.lblLocalFile.Text = "Local file:"; - // - //txtLocalFile - // - this.txtLocalFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtLocalFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtLocalFile.Location = new System.Drawing.Point(105, 23); - this.txtLocalFile.Name = "txtLocalFile"; - this.txtLocalFile.Size = new System.Drawing.Size(455, 20); - this.txtLocalFile.TabIndex = 20; - // - //txtRemoteFile - // - this.txtRemoteFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtRemoteFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtRemoteFile.Location = new System.Drawing.Point(105, 49); - this.txtRemoteFile.Name = "txtRemoteFile"; - this.txtRemoteFile.Size = new System.Drawing.Size(542, 20); - this.txtRemoteFile.TabIndex = 50; - // - //lblRemoteFile - // - this.lblRemoteFile.AutoSize = true; - this.lblRemoteFile.Location = new System.Drawing.Point(20, 51); - this.lblRemoteFile.Name = "lblRemoteFile"; - this.lblRemoteFile.Size = new System.Drawing.Size(63, 13); - this.lblRemoteFile.TabIndex = 40; - this.lblRemoteFile.Text = "Remote file:"; - // - //btnBrowse - // - this.btnBrowse.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.btnBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnBrowse.Location = new System.Drawing.Point(566, 21); - this.btnBrowse.Name = "btnBrowse"; - this.btnBrowse.Size = new System.Drawing.Size(81, 23); - this.btnBrowse.TabIndex = 30; - this.btnBrowse.Text = "Browse"; - this.btnBrowse.UseVisualStyleBackColor = true; - // - //grpConnection - // - this.grpConnection.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.grpConnection.Controls.Add(this.radProtSFTP); - this.grpConnection.Controls.Add(this.radProtSCP); - this.grpConnection.Controls.Add(this.lblProtocol); - this.grpConnection.Controls.Add(this.lblPassword); - this.grpConnection.Controls.Add(this.lblUser); - this.grpConnection.Controls.Add(this.lblPort); - this.grpConnection.Controls.Add(this.lblHost); - this.grpConnection.Controls.Add(this.txtPort); - this.grpConnection.Controls.Add(this.txtHost); - this.grpConnection.Controls.Add(this.txtPassword); - this.grpConnection.Controls.Add(this.txtUser); - this.grpConnection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.grpConnection.Location = new System.Drawing.Point(12, 12); - this.grpConnection.Name = "grpConnection"; - this.grpConnection.Size = new System.Drawing.Size(668, 135); - this.grpConnection.TabIndex = 1000; - this.grpConnection.TabStop = false; - this.grpConnection.Text = "Connection"; - // - //radProtSFTP - // - this.radProtSFTP.AutoSize = true; - this.radProtSFTP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radProtSFTP.Location = new System.Drawing.Point(153, 103); - this.radProtSFTP.Name = "radProtSFTP"; - this.radProtSFTP.Size = new System.Drawing.Size(51, 17); - this.radProtSFTP.TabIndex = 110; - this.radProtSFTP.Text = "SFTP"; - this.radProtSFTP.UseVisualStyleBackColor = true; - // - //radProtSCP - // - this.radProtSCP.AutoSize = true; - this.radProtSCP.Checked = true; - this.radProtSCP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radProtSCP.Location = new System.Drawing.Point(92, 103); - this.radProtSCP.Name = "radProtSCP"; - this.radProtSCP.Size = new System.Drawing.Size(45, 17); - this.radProtSCP.TabIndex = 100; - this.radProtSCP.TabStop = true; - this.radProtSCP.Text = "SCP"; - this.radProtSCP.UseVisualStyleBackColor = true; - // - //lblProtocol - // - this.lblProtocol.AutoSize = true; - this.lblProtocol.Location = new System.Drawing.Point(20, 105); - this.lblProtocol.Name = "lblProtocol"; - this.lblProtocol.Size = new System.Drawing.Size(49, 13); - this.lblProtocol.TabIndex = 90; - this.lblProtocol.Text = "Protocol:"; - // - //lblPassword - // - this.lblPassword.AutoSize = true; - this.lblPassword.Location = new System.Drawing.Point(20, 79); - this.lblPassword.Name = "lblPassword"; - this.lblPassword.Size = new System.Drawing.Size(56, 13); - this.lblPassword.TabIndex = 70; - this.lblPassword.Text = "Password:"; - // - //lblUser - // - this.lblUser.AutoSize = true; - this.lblUser.Location = new System.Drawing.Point(20, 53); - this.lblUser.Name = "lblUser"; - this.lblUser.Size = new System.Drawing.Size(32, 13); - this.lblUser.TabIndex = 50; - this.lblUser.Text = "User:"; - // - //lblPort - // - this.lblPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.lblPort.AutoSize = true; - this.lblPort.Location = new System.Drawing.Point(582, 27); - this.lblPort.Name = "lblPort"; - this.lblPort.Size = new System.Drawing.Size(29, 13); - this.lblPort.TabIndex = 30; - this.lblPort.Text = "Port:"; - // - //lblHost - // - this.lblHost.AutoSize = true; - this.lblHost.Location = new System.Drawing.Point(20, 27); - this.lblHost.Name = "lblHost"; - this.lblHost.Size = new System.Drawing.Size(32, 13); - this.lblHost.TabIndex = 10; - this.lblHost.Text = "Host:"; - // - //txtPort - // - this.txtPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.txtPort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtPort.Location = new System.Drawing.Point(617, 25); - this.txtPort.Name = "txtPort"; - this.txtPort.Size = new System.Drawing.Size(30, 20); - this.txtPort.TabIndex = 40; - // - //txtHost - // - this.txtHost.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtHost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtHost.Location = new System.Drawing.Point(105, 25); - this.txtHost.Name = "txtHost"; - this.txtHost.Size = new System.Drawing.Size(471, 20); - this.txtHost.TabIndex = 20; - // - //txtPassword - // - this.txtPassword.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtPassword.Location = new System.Drawing.Point(105, 77); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = global::Microsoft.VisualBasic.Strings.ChrW(42); - this.txtPassword.Size = new System.Drawing.Size(471, 20); - this.txtPassword.TabIndex = 80; - // - //txtUser - // - this.txtUser.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtUser.Location = new System.Drawing.Point(105, 51); - this.txtUser.Name = "txtUser"; - this.txtUser.Size = new System.Drawing.Size(471, 20); - this.txtUser.TabIndex = 60; - // - //btnTransfer - // - this.btnTransfer.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - this.btnTransfer.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnTransfer.Image = global::My.Resources.Resources.SSHTransfer; - this.btnTransfer.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnTransfer.Location = new System.Drawing.Point(597, 382); - this.btnTransfer.Name = "btnTransfer"; - this.btnTransfer.Size = new System.Drawing.Size(83, 29); - this.btnTransfer.TabIndex = 10000; - this.btnTransfer.Text = "Transfer"; - this.btnTransfer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.btnTransfer.UseVisualStyleBackColor = true; - // - //pbStatus - // - this.pbStatus.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pbStatus.Location = new System.Drawing.Point(12, 353); - this.pbStatus.Name = "pbStatus"; - this.pbStatus.Size = new System.Drawing.Size(668, 23); - this.pbStatus.TabIndex = 3000; - // - //SSHTransfer - // - this.ClientSize = new System.Drawing.Size(692, 423); - this.Controls.Add(this.grpFiles); - this.Controls.Add(this.grpConnection); - this.Controls.Add(this.btnTransfer); - this.Controls.Add(this.pbStatus); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.Icon = (System.Drawing.Icon) (resources.GetObject("$this.Icon")); - this.Name = "SSHTransfer"; - this.TabText = "SSH File Transfer"; - this.Text = "SSH File Transfer"; - this.grpFiles.ResumeLayout(false); - this.grpFiles.PerformLayout(); - this.grpConnection.ResumeLayout(false); - this.grpConnection.PerformLayout(); - this.ResumeLayout(false); + public string Username + { + get + { + return this.txtUser.Text; + } + set + { + this.txtUser.Text = value; + } + } + + public string Password + { + get + { + return this.txtPassword.Text; + } + set + { + this.txtPassword.Text = value; + } + } + #endregion + + #region Form Stuff + private void SSHTransfer_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + } + + private void ApplyLanguage() + { + grpFiles.Text = My.Language.strGroupboxFiles; + lblLocalFile.Text = My.Language.strLocalFile + ":"; + lblRemoteFile.Text = My.Language.strRemoteFile + ":"; + btnBrowse.Text = My.Language.strButtonBrowse; + grpConnection.Text = My.Language.strGroupboxConnection; + lblProtocol.Text = My.Language.strLabelProtocol; + lblPassword.Text = My.Language.strLabelPassword; + lblUser.Text = My.Language.strUser + ":"; + lblPort.Text = My.Language.strLabelPort; + lblHost.Text = My.Language.strHost + ":"; + btnTransfer.Text = My.Language.strTransfer; + TabText = My.Language.strMenuSSHFileTransfer; + Text = My.Language.strMenuSSHFileTransfer; + } + #endregion + + #region Private Methods + private void StartTransfer(SSHTransferProtocol Protocol) + { + if (AllFieldsSet() == false) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPleaseFillAllFields); + return; + } - } -#endregion - -#region Private Properties - private SshTransferProtocolBase sshT; - private OpenFileDialog oDlg; -#endregion - -#region Public Properties -public string Hostname - { - get - { - return this.txtHost.Text; - } - set - { - this.txtHost.Text = value; - } - } - -public string Port - { - get - { - return this.txtPort.Text; - } - set - { - this.txtPort.Text = value; - } - } - -public string Username - { - get - { - return this.txtUser.Text; - } - set - { - this.txtUser.Text = value; - } - } - -public string Password - { - get - { - return this.txtPassword.Text; - } - set - { - this.txtPassword.Text = value; - } - } -#endregion - -#region Form Stuff - private void SSHTransfer_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - } - - private void ApplyLanguage() - { - grpFiles.Text = My.Language.strGroupboxFiles; - lblLocalFile.Text = My.Language.strLocalFile + ":"; - lblRemoteFile.Text = My.Language.strRemoteFile + ":"; - btnBrowse.Text = My.Language.strButtonBrowse; - grpConnection.Text = My.Language.strGroupboxConnection; - lblProtocol.Text = My.Language.strLabelProtocol; - lblPassword.Text = My.Language.strLabelPassword; - lblUser.Text = My.Language.strUser + ":"; - lblPort.Text = My.Language.strLabelPort; - lblHost.Text = My.Language.strHost + ":"; - btnTransfer.Text = My.Language.strTransfer; - TabText = My.Language.strMenuSSHFileTransfer; - Text = My.Language.strMenuSSHFileTransfer; - } -#endregion - -#region Private Methods - private void StartTransfer(SSHTransferProtocol Protocol) - { - if (AllFieldsSet() == false) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strPleaseFillAllFields); - return; - } + if (File.Exists(this.txtLocalFile.Text) == false) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strLocalFileDoesNotExist); + return; + } - if (File.Exists(this.txtLocalFile.Text) == false) - { - MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, My.Language.strLocalFileDoesNotExist); - return; - } - - try - { - if (Protocol == SSHTransferProtocol.SCP) - { - this.sshT = new Scp(txtHost.Text, txtUser.Text, txtPassword.Text); - } - else if (Protocol == SSHTransferProtocol.SFTP) - { - this.sshT = new Sftp(txtHost.Text, txtUser.Text, txtPassword.Text); - } - - sshT.OnTransferStart += SshTransfer_Start; - sshT.OnTransferProgress += SshTransfer_Progress; - sshT.OnTransferEnd += SshTransfer_End; - - this.sshT.Connect((int) this.txtPort.Text); - - LocalFile = this.txtLocalFile.Text; - RemoteFile = this.txtRemoteFile.Text; - - Thread t = new Thread(new System.Threading.ThreadStart(StartTransferBG)); - t.SetApartmentState(ApartmentState.STA); - t.IsBackground = true; - t.Start(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHTransferFailed + Constants.vbNewLine + ex.Message); - this.sshT.Close(); - } - } - - private string LocalFile; - private string RemoteFile; - - private void StartTransferBG() + try + { + if (Protocol == SSHTransferProtocol.SCP) { - try - { - DisableButtons(); - this.sshT.Put(LocalFile, RemoteFile); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHStartTransferBG + Constants.vbNewLine + ex.Message, true); - } + this.sshT = new Scp(txtHost.Text, txtUser.Text, txtPassword.Text); } - - private bool AllFieldsSet() + else if (Protocol == SSHTransferProtocol.SFTP) { - if (this.txtHost.Text != "" && this.txtPort.Text != "" && this.txtUser.Text != "" && this.txtLocalFile.Text != "" && this.txtRemoteFile.Text != "") - { - if (this.txtPassword.Text == "") - { - if (Interaction.MsgBox(My.Language.strEmptyPasswordContinue, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.No) - { - return false; - } - } + this.sshT = new Sftp(txtHost.Text, txtUser.Text, txtPassword.Text); + } - if (this.txtRemoteFile.Text.EndsWith("/") || this.txtRemoteFile.Text.EndsWith("\\")) - { - this.txtRemoteFile.Text += this.txtLocalFile.Text.Substring(this.txtLocalFile.Text.LastIndexOf("\\") + 1); - } + sshT.OnTransferStart += SshTransfer_Start; + sshT.OnTransferProgress += SshTransfer_Progress; + sshT.OnTransferEnd += SshTransfer_End; - return true; - } - else + this.sshT.Connect((int) this.txtPort.Text); + + LocalFile = this.txtLocalFile.Text; + RemoteFile = this.txtRemoteFile.Text; + + Thread t = new Thread(new System.Threading.ThreadStart(StartTransferBG)); + t.SetApartmentState(ApartmentState.STA); + t.IsBackground = true; + t.Start(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHTransferFailed + Constants.vbNewLine + ex.Message); + this.sshT.Close(); + } + } + + private string LocalFile; + private string RemoteFile; + + private void StartTransferBG() + { + try + { + DisableButtons(); + this.sshT.Put(LocalFile, RemoteFile); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHStartTransferBG + Constants.vbNewLine + ex.Message, true); + } + } + + private bool AllFieldsSet() + { + if (this.txtHost.Text != "" && this.txtPort.Text != "" && this.txtUser.Text != "" && this.txtLocalFile.Text != "" && this.txtRemoteFile.Text != "") + { + if (this.txtPassword.Text == "") + { + if (Interaction.MsgBox(My.Language.strEmptyPasswordContinue, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.No) { return false; } } - - - private long maxVal; - private long curVal; - - delegate void SetStatusCB(); - private void SetStatus() - { - if (pbStatus.InvokeRequired) - { - SetStatusCB d = new SetStatusCB(SetStatus); - this.pbStatus.Invoke(d); - } - else - { - pbStatus.Maximum = maxVal; - pbStatus.Value = curVal; - } - } - - delegate void EnableButtonsCB(); - private void EnableButtons() - { - if (btnTransfer.InvokeRequired) - { - EnableButtonsCB d = new EnableButtonsCB(EnableButtons); - this.btnTransfer.Invoke(d); - } - else - { - btnTransfer.Enabled = true; - } - } - - delegate void DisableButtonsCB(); - private void DisableButtons() - { - if (btnTransfer.InvokeRequired) - { - DisableButtonsCB d = new DisableButtonsCB(DisableButtons); - this.btnTransfer.Invoke(d); - } - else - { - btnTransfer.Enabled = false; - } - } - - private void SshTransfer_Start(string src, string dst, int transferredBytes, int totalBytes, string message) - { - maxVal = totalBytes; - curVal = transferredBytes; - - SetStatus(); - } - - private void SshTransfer_Progress(string src, string dst, int transferredBytes, int totalBytes, string message) - { - maxVal = totalBytes; - curVal = transferredBytes; - - SetStatus(); - } - - private void SshTransfer_End(string src, string dst, int transferredBytes, int totalBytes, string message) - { - try - { - maxVal = totalBytes; - curVal = transferredBytes; - EnableButtons(); - SetStatus(); - - MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strSSHTransferFailed); - - if (this.sshT != null) - { - this.sshT.Close(); - } - else if (this.sshT != null) - { - this.sshT.Close(); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHTransferEndFailed + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Public Methods - public SSHTransfer(DockContent Panel) + if (this.txtRemoteFile.Text.EndsWith("/") || this.txtRemoteFile.Text.EndsWith("\\")) { - this.WindowType = Type.SSHTransfer; - this.DockPnl = Panel; - this.InitializeComponent(); + this.txtRemoteFile.Text += this.txtLocalFile.Text.Substring(this.txtLocalFile.Text.LastIndexOf("\\") + 1); + } + + return true; + } + else + { + return false; + } + } + + + private long maxVal; + private long curVal; + + delegate void SetStatusCB(); + private void SetStatus() + { + if (pbStatus.InvokeRequired) + { + SetStatusCB d = new SetStatusCB(SetStatus); + this.pbStatus.Invoke(d); + } + else + { + pbStatus.Maximum = maxVal; + pbStatus.Value = curVal; + } + } + + delegate void EnableButtonsCB(); + private void EnableButtons() + { + if (btnTransfer.InvokeRequired) + { + EnableButtonsCB d = new EnableButtonsCB(EnableButtons); + this.btnTransfer.Invoke(d); + } + else + { + btnTransfer.Enabled = true; + } + } + + delegate void DisableButtonsCB(); + private void DisableButtons() + { + if (btnTransfer.InvokeRequired) + { + DisableButtonsCB d = new DisableButtonsCB(DisableButtons); + this.btnTransfer.Invoke(d); + } + else + { + btnTransfer.Enabled = false; + } + } + + private void SshTransfer_Start(string src, string dst, int transferredBytes, int totalBytes, string message) + { + maxVal = totalBytes; + curVal = transferredBytes; - this.oDlg = new OpenFileDialog(); - this.oDlg.Filter = "All Files (*.*)|*.*"; - this.oDlg.CheckFileExists = true; - } -#endregion + SetStatus(); + } -#region Form Stuff - private void btnBrowse_Click(System.Object sender, System.EventArgs e) - { - if (this.oDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) - { - if (this.oDlg.FileName != "") - { - this.txtLocalFile.Text = this.oDlg.FileName; - } - } - } + private void SshTransfer_Progress(string src, string dst, int transferredBytes, int totalBytes, string message) + { + maxVal = totalBytes; + curVal = transferredBytes; + + SetStatus(); + } - private void btnTransfer_Click(System.Object sender, System.EventArgs e) + private void SshTransfer_End(string src, string dst, int transferredBytes, int totalBytes, string message) + { + try + { + maxVal = totalBytes; + curVal = transferredBytes; + + EnableButtons(); + SetStatus(); + + Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, My.Language.strSSHTransferFailed); + + if (this.sshT != null) { - if (this.radProtSCP.Checked) - { - this.StartTransfer(SSHTransferProtocol.SCP); - } - else if (this.radProtSFTP.Checked) - { - this.StartTransfer(SSHTransferProtocol.SFTP); - } + this.sshT.Close(); } -#endregion - - private enum SSHTransferProtocol + else if (this.sshT != null) { - SCP = 0, - SFTP = 1 + this.sshT.Close(); } } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSSHTransferEndFailed + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Public Methods + public SSHTransfer(DockContent Panel) + { + this.WindowType = Type.SSHTransfer; + this.DockPnl = Panel; + this.InitializeComponent(); + + this.oDlg = new OpenFileDialog(); + this.oDlg.Filter = "All Files (*.*)|*.*"; + this.oDlg.CheckFileExists = true; + } + #endregion + + #region Form Stuff + private void btnBrowse_Click(System.Object sender, System.EventArgs e) + { + if (this.oDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + if (this.oDlg.FileName != "") + { + this.txtLocalFile.Text = this.oDlg.FileName; + } + } + } + + private void btnTransfer_Click(System.Object sender, System.EventArgs e) + { + if (this.radProtSCP.Checked) + { + this.StartTransfer(SSHTransferProtocol.SCP); + } + else if (this.radProtSFTP.Checked) + { + this.StartTransfer(SSHTransferProtocol.SFTP); + } + } + #endregion + + private enum SSHTransferProtocol + { + SCP = 0, + SFTP = 1 + } + } } diff --git a/mRemoteV1/CS/UI/UI.Window.ScreenshotManager.cs b/mRemoteV1/CS/UI/UI.Window.ScreenshotManager.cs index 89d820847..24007c937 100644 --- a/mRemoteV1/CS/UI/UI.Window.ScreenshotManager.cs +++ b/mRemoteV1/CS/UI/UI.Window.ScreenshotManager.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,393 +8,389 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; using System.IO; namespace mRemoteNG.UI.Window { public class ScreenshotManager : Base + { + #region Form Init + internal System.Windows.Forms.MenuStrip msMain; + internal System.Windows.Forms.ToolStripMenuItem mMenFile; + internal System.Windows.Forms.ToolStripMenuItem mMenFileSaveAll; + internal System.Windows.Forms.ToolStripMenuItem mMenFileRemoveAll; + internal System.Windows.Forms.ContextMenuStrip cMenScreenshot; + private System.ComponentModel.Container components = null; + internal System.Windows.Forms.ToolStripMenuItem cMenScreenshotCopy; + internal System.Windows.Forms.ToolStripMenuItem cMenScreenshotSave; + internal System.Windows.Forms.SaveFileDialog dlgSaveSingleImage; + internal System.Windows.Forms.FolderBrowserDialog dlgSaveAllImages; + internal System.Windows.Forms.FlowLayoutPanel flpScreenshots; + + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Load += new System.EventHandler(ScreenshotManager_Load); + this.flpScreenshots = new System.Windows.Forms.FlowLayoutPanel(); + this.msMain = new System.Windows.Forms.MenuStrip(); + this.mMenFile = new System.Windows.Forms.ToolStripMenuItem(); + this.mMenFile.DropDownOpening += new System.EventHandler(this.mMenFile_DropDownOpening); + this.mMenFileSaveAll = new System.Windows.Forms.ToolStripMenuItem(); + this.mMenFileSaveAll.Click += new System.EventHandler(this.mMenFileSaveAll_Click); + this.mMenFileRemoveAll = new System.Windows.Forms.ToolStripMenuItem(); + this.mMenFileRemoveAll.Click += new System.EventHandler(this.mMenFileRemoveAll_Click); + this.cMenScreenshot = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cMenScreenshotCopy = new System.Windows.Forms.ToolStripMenuItem(); + this.cMenScreenshotCopy.Click += new System.EventHandler(this.cMenScreenshotCopy_Click); + this.cMenScreenshotSave = new System.Windows.Forms.ToolStripMenuItem(); + this.cMenScreenshotSave.Click += new System.EventHandler(this.cMenScreenshotSave_Click); + this.dlgSaveSingleImage = new System.Windows.Forms.SaveFileDialog(); + this.dlgSaveAllImages = new System.Windows.Forms.FolderBrowserDialog(); + this.msMain.SuspendLayout(); + this.cMenScreenshot.SuspendLayout(); + this.SuspendLayout(); + // + //flpScreenshots + // + this.flpScreenshots.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.flpScreenshots.AutoScroll = true; + this.flpScreenshots.Location = new System.Drawing.Point(0, 26); + this.flpScreenshots.Name = "flpScreenshots"; + this.flpScreenshots.Size = new System.Drawing.Size(542, 296); + this.flpScreenshots.TabIndex = 0; + // + //msMain + // + this.msMain.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); + this.msMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.mMenFile}); + this.msMain.Location = new System.Drawing.Point(0, 0); + this.msMain.Name = "msMain"; + this.msMain.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.msMain.Size = new System.Drawing.Size(542, 24); + this.msMain.TabIndex = 1; + this.msMain.Text = "MenuStrip1"; + // + //mMenFile + // + this.mMenFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {this.mMenFileSaveAll, this.mMenFileRemoveAll}); + this.mMenFile.Image = global::My.Resources.Resources.File; + this.mMenFile.Name = "mMenFile"; + this.mMenFile.Size = new System.Drawing.Size(51, 20); + this.mMenFile.Text = "&File"; + // + //mMenFileSaveAll + // + this.mMenFileSaveAll.Image = global::My.Resources.Resources.Screenshot_Save; + this.mMenFileSaveAll.Name = "mMenFileSaveAll"; + this.mMenFileSaveAll.Size = new System.Drawing.Size(128, 22); + this.mMenFileSaveAll.Text = "Save All"; + // + //mMenFileRemoveAll + // + this.mMenFileRemoveAll.Image = global::My.Resources.Resources.Screenshot_Delete; + this.mMenFileRemoveAll.Name = "mMenFileRemoveAll"; + this.mMenFileRemoveAll.Size = new System.Drawing.Size(128, 22); + this.mMenFileRemoveAll.Text = "Remove All"; + // + //cMenScreenshot + // + this.cMenScreenshot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cMenScreenshotCopy, this.cMenScreenshotSave}); + this.cMenScreenshot.Name = "cMenScreenshot"; + this.cMenScreenshot.Size = new System.Drawing.Size(100, 48); + // + //cMenScreenshotCopy + // + this.cMenScreenshotCopy.Image = global::My.Resources.Resources.Screenshot_Copy; + this.cMenScreenshotCopy.Name = "cMenScreenshotCopy"; + this.cMenScreenshotCopy.Size = new System.Drawing.Size(99, 22); + this.cMenScreenshotCopy.Text = "Copy"; + // + //cMenScreenshotSave + // + this.cMenScreenshotSave.Image = global::My.Resources.Resources.Screenshot_Save; + this.cMenScreenshotSave.Name = "cMenScreenshotSave"; + this.cMenScreenshotSave.Size = new System.Drawing.Size(99, 22); + this.cMenScreenshotSave.Text = "Save"; + // + //dlgSaveSingleImage + // + this.dlgSaveSingleImage.Filter = "Graphics Interchange Format File (.gif)|*.gif|Joint Photographic Experts Group Fi" + + "le (.jpeg)|*.jpeg|Joint Photographic Experts Group File (.jpg)|*.jpg|Portable Ne" + + "twork Graphics File (.png)|*.png"; + this.dlgSaveSingleImage.FilterIndex = 4; + // + //ScreenshotManager + // + this.ClientSize = new System.Drawing.Size(542, 323); + this.Controls.Add(this.flpScreenshots); + this.Controls.Add(this.msMain); + this.HideOnClose = true; + this.Icon = global::My.Resources.Resources.Screenshot_Icon; + this.MainMenuStrip = this.msMain; + this.Name = "ScreenshotManager"; + this.TabText = "Screenshots"; + this.Text = "Screenshots"; + this.msMain.ResumeLayout(false); + this.msMain.PerformLayout(); + this.cMenScreenshot.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + #region Form Stuff + private void ScreenshotManager_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + } + + private void ApplyLanguage() + { + mMenFile.Text = My.Language.strMenuFile; + mMenFileSaveAll.Text = My.Language.strSaveAll; + mMenFileRemoveAll.Text = My.Language.strRemoveAll; + cMenScreenshotCopy.Text = My.Language.strMenuCopy; + cMenScreenshotSave.Text = My.Language.strSave; + dlgSaveSingleImage.Filter = My.Language.strSaveImageFilter; + TabText = My.Language.strScreenshots; + Text = My.Language.strScreenshots; + } + #endregion + + #region Public Methods + public ScreenshotManager(DockContent Panel) + { + this.WindowType = Type.ScreenshotManager; + this.DockPnl = Panel; + this.InitializeComponent(); + } + + public void AddScreenshot(Image Screenshot) + { + try { - -#region Form Init - internal System.Windows.Forms.MenuStrip msMain; - internal System.Windows.Forms.ToolStripMenuItem mMenFile; - internal System.Windows.Forms.ToolStripMenuItem mMenFileSaveAll; - internal System.Windows.Forms.ToolStripMenuItem mMenFileRemoveAll; - internal System.Windows.Forms.ContextMenuStrip cMenScreenshot; - private System.ComponentModel.Container components = null; - internal System.Windows.Forms.ToolStripMenuItem cMenScreenshotCopy; - internal System.Windows.Forms.ToolStripMenuItem cMenScreenshotSave; - internal System.Windows.Forms.SaveFileDialog dlgSaveSingleImage; - internal System.Windows.Forms.FolderBrowserDialog dlgSaveAllImages; - internal System.Windows.Forms.FlowLayoutPanel flpScreenshots; - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.Load += new System.EventHandler(ScreenshotManager_Load); - this.flpScreenshots = new System.Windows.Forms.FlowLayoutPanel(); - this.msMain = new System.Windows.Forms.MenuStrip(); - this.mMenFile = new System.Windows.Forms.ToolStripMenuItem(); - this.mMenFile.DropDownOpening += new System.EventHandler(this.mMenFile_DropDownOpening); - this.mMenFileSaveAll = new System.Windows.Forms.ToolStripMenuItem(); - this.mMenFileSaveAll.Click += new System.EventHandler(this.mMenFileSaveAll_Click); - this.mMenFileRemoveAll = new System.Windows.Forms.ToolStripMenuItem(); - this.mMenFileRemoveAll.Click += new System.EventHandler(this.mMenFileRemoveAll_Click); - this.cMenScreenshot = new System.Windows.Forms.ContextMenuStrip(this.components); - this.cMenScreenshotCopy = new System.Windows.Forms.ToolStripMenuItem(); - this.cMenScreenshotCopy.Click += new System.EventHandler(this.cMenScreenshotCopy_Click); - this.cMenScreenshotSave = new System.Windows.Forms.ToolStripMenuItem(); - this.cMenScreenshotSave.Click += new System.EventHandler(this.cMenScreenshotSave_Click); - this.dlgSaveSingleImage = new System.Windows.Forms.SaveFileDialog(); - this.dlgSaveAllImages = new System.Windows.Forms.FolderBrowserDialog(); - this.msMain.SuspendLayout(); - this.cMenScreenshot.SuspendLayout(); - this.SuspendLayout(); - // - //flpScreenshots - // - this.flpScreenshots.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.flpScreenshots.AutoScroll = true; - this.flpScreenshots.Location = new System.Drawing.Point(0, 26); - this.flpScreenshots.Name = "flpScreenshots"; - this.flpScreenshots.Size = new System.Drawing.Size(542, 296); - this.flpScreenshots.TabIndex = 0; - // - //msMain - // - this.msMain.Font = new System.Drawing.Font("Microsoft Sans Serif", (float) (8.25F), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0)); - this.msMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.mMenFile}); - this.msMain.Location = new System.Drawing.Point(0, 0); - this.msMain.Name = "msMain"; - this.msMain.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.msMain.Size = new System.Drawing.Size(542, 24); - this.msMain.TabIndex = 1; - this.msMain.Text = "MenuStrip1"; - // - //mMenFile - // - this.mMenFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {this.mMenFileSaveAll, this.mMenFileRemoveAll}); - this.mMenFile.Image = global::My.Resources.Resources.File; - this.mMenFile.Name = "mMenFile"; - this.mMenFile.Size = new System.Drawing.Size(51, 20); - this.mMenFile.Text = "&File"; - // - //mMenFileSaveAll - // - this.mMenFileSaveAll.Image = global::My.Resources.Resources.Screenshot_Save; - this.mMenFileSaveAll.Name = "mMenFileSaveAll"; - this.mMenFileSaveAll.Size = new System.Drawing.Size(128, 22); - this.mMenFileSaveAll.Text = "Save All"; - // - //mMenFileRemoveAll - // - this.mMenFileRemoveAll.Image = global::My.Resources.Resources.Screenshot_Delete; - this.mMenFileRemoveAll.Name = "mMenFileRemoveAll"; - this.mMenFileRemoveAll.Size = new System.Drawing.Size(128, 22); - this.mMenFileRemoveAll.Text = "Remove All"; - // - //cMenScreenshot - // - this.cMenScreenshot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cMenScreenshotCopy, this.cMenScreenshotSave}); - this.cMenScreenshot.Name = "cMenScreenshot"; - this.cMenScreenshot.Size = new System.Drawing.Size(100, 48); - // - //cMenScreenshotCopy - // - this.cMenScreenshotCopy.Image = global::My.Resources.Resources.Screenshot_Copy; - this.cMenScreenshotCopy.Name = "cMenScreenshotCopy"; - this.cMenScreenshotCopy.Size = new System.Drawing.Size(99, 22); - this.cMenScreenshotCopy.Text = "Copy"; - // - //cMenScreenshotSave - // - this.cMenScreenshotSave.Image = global::My.Resources.Resources.Screenshot_Save; - this.cMenScreenshotSave.Name = "cMenScreenshotSave"; - this.cMenScreenshotSave.Size = new System.Drawing.Size(99, 22); - this.cMenScreenshotSave.Text = "Save"; - // - //dlgSaveSingleImage - // - this.dlgSaveSingleImage.Filter = "Graphics Interchange Format File (.gif)|*.gif|Joint Photographic Experts Group Fi" + - "le (.jpeg)|*.jpeg|Joint Photographic Experts Group File (.jpg)|*.jpg|Portable Ne" + - "twork Graphics File (.png)|*.png"; - this.dlgSaveSingleImage.FilterIndex = 4; - // - //ScreenshotManager - // - this.ClientSize = new System.Drawing.Size(542, 323); - this.Controls.Add(this.flpScreenshots); - this.Controls.Add(this.msMain); - this.HideOnClose = true; - this.Icon = global::My.Resources.Resources.Screenshot_Icon; - this.MainMenuStrip = this.msMain; - this.Name = "ScreenshotManager"; - this.TabText = "Screenshots"; - this.Text = "Screenshots"; - this.msMain.ResumeLayout(false); - this.msMain.PerformLayout(); - this.cMenScreenshot.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } -#endregion - -#region Form Stuff - private void ScreenshotManager_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - } - - private void ApplyLanguage() - { - mMenFile.Text = My.Language.strMenuFile; - mMenFileSaveAll.Text = My.Language.strSaveAll; - mMenFileRemoveAll.Text = My.Language.strRemoveAll; - cMenScreenshotCopy.Text = My.Language.strMenuCopy; - cMenScreenshotSave.Text = My.Language.strSave; - dlgSaveSingleImage.Filter = My.Language.strSaveImageFilter; - TabText = My.Language.strScreenshots; - Text = My.Language.strScreenshots; - } -#endregion - -#region Public Methods - public ScreenshotManager(DockContent Panel) - { - this.WindowType = Type.ScreenshotManager; - this.DockPnl = Panel; - this.InitializeComponent(); - } - - public void AddScreenshot(Image Screenshot) - { - try - { - PictureBox nPB = new PictureBox(); - nPB.MouseDown += this.pbScreenshot_MouseDown; + PictureBox nPB = new PictureBox(); + nPB.MouseDown += this.pbScreenshot_MouseDown; - nPB.Parent = this.flpScreenshots; - nPB.SizeMode = PictureBoxSizeMode.StretchImage; - nPB.BorderStyle = BorderStyle.FixedSingle; - nPB.ContextMenuStrip = this.cMenScreenshot; - nPB.Image = Screenshot; - nPB.Size = new Size(100, 100); //New Size((Screenshot.Width / 100) * 20, (Screenshot.Height / 100) * 20) - nPB.Show(); + nPB.Parent = this.flpScreenshots; + nPB.SizeMode = PictureBoxSizeMode.StretchImage; + nPB.BorderStyle = BorderStyle.FixedSingle; + nPB.ContextMenuStrip = this.cMenScreenshot; + nPB.Image = Screenshot; + nPB.Size = new Size(100, 100); //New Size((Screenshot.Width / 100) * 20, (Screenshot.Height / 100) * 20) + nPB.Show(); - Button nBtn = new Button(); - nBtn.Click += btnCloseScreenshot_Click; + Button nBtn = new Button(); + nBtn.Click += btnCloseScreenshot_Click; - nBtn.Parent = nPB; - nBtn.FlatStyle = FlatStyle.Flat; - nBtn.Text = "×"; - nBtn.Size = new Size(22, 22); - nBtn.Location = new Point(nPB.Width - nBtn.Width, -1); - nBtn.Show(); + nBtn.Parent = nPB; + nBtn.FlatStyle = FlatStyle.Flat; + nBtn.Text = "×"; + nBtn.Size = new Size(22, 22); + nBtn.Location = new Point(nPB.Width - nBtn.Width, -1); + nBtn.Show(); - this.Show(frmMain.Default.pnlDock); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddScreenshot (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Private Methods - private void pbScreenshot_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) - { - this.cMenScreenshot.Tag = sender; - - if (e.Button == System.Windows.Forms.MouseButtons.Left) - { - this.OpenScreenshot(sender); - } - } - - private void pbScreenshotOpen_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) - { - if (e.Button == System.Windows.Forms.MouseButtons.Left) - { - this.CloseOpenedScreenshot(sender.Parent); - } - } - - private void CloseOpenedScreenshot(Form form) - { - form.Close(); - } - - private void OpenScreenshot(PictureBox sender) - { - try - { - Image mImage = sender.Image; - - Form nForm = new Form(); - nForm.StartPosition = FormStartPosition.CenterParent; - nForm.ShowInTaskbar = false; - nForm.ShowIcon = false; - nForm.MaximizeBox = false; - nForm.MinimizeBox = false; - nForm.Width = mImage.Width + 2; - nForm.Height = mImage.Height + 2; - nForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - - PictureBox nPB = new PictureBox(); - nPB.Parent = nForm; - nPB.BorderStyle = BorderStyle.FixedSingle; - nPB.Location = new Point(0, 0); - nPB.SizeMode = PictureBoxSizeMode.AutoSize; - nPB.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top); - nPB.Image = mImage; - nPB.ContextMenuStrip = this.cMenScreenshot; - nPB.Show(); - - nPB.MouseDown += this.pbScreenshotOpen_MouseDown; - - nForm.ShowDialog(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "OpenScreenshot (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void btnCloseScreenshot_Click(System.Object sender, System.EventArgs e) - { - try - { - sender.Parent.Dispose(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "btnCloseScreenshot_Click (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void mMenFileRemoveAll_Click(System.Object sender, System.EventArgs e) - { - this.RemoveAllImages(); - } - - private void RemoveAllImages() - { - this.flpScreenshots.Controls.Clear(); - } - - private void mMenFileSaveAll_Click(System.Object sender, System.EventArgs e) - { - this.SaveAllImages(); - } - - private void SaveAllImages() - { - try - { - int pCount = 1; - - if (this.dlgSaveAllImages.ShowDialog() == System.Windows.Forms.DialogResult.OK) - { - foreach (string fPath in Directory.GetFiles(this.dlgSaveAllImages.SelectedPath, "Screenshot_*", SearchOption.TopDirectoryOnly)) - { - FileInfo f = new FileInfo(fPath); - - string fCount = f.Name; - fCount = fCount.Replace(f.Extension, ""); - fCount = fCount.Replace("Screenshot_", ""); - - pCount = (int) (double.Parse(fCount) + 1); - } - - foreach (System.Windows.Forms.Control ctrl in this.flpScreenshots.Controls) - { - if (ctrl is PictureBox) - { - (ctrl as PictureBox).Image.Save(this.dlgSaveAllImages.SelectedPath + "\\Screenshot_" + Tools.Misc.LeadingZero(System.Convert.ToString(pCount)) +".png", System.Drawing.Imaging.ImageFormat.Png); - pCount++; - } - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveAllImages (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void cMenScreenshotCopy_Click(System.Object sender, System.EventArgs e) - { - this.CopyImageToClipboard(); - } - - private void CopyImageToClipboard() - { - try - { - Clipboard.SetImage((cMenScreenshot.Tag as PictureBox).Image); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "CopyImageToClipboard (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void cMenScreenshotSave_Click(System.Object sender, System.EventArgs e) - { - this.SaveSingleImage(); - } - - private void SaveSingleImage() - { - try - { - if (this.dlgSaveSingleImage.ShowDialog() == System.Windows.Forms.DialogResult.OK) - { - switch (this.dlgSaveSingleImage.FileName.Substring(this.dlgSaveSingleImage.FileName.LastIndexOf(".") + 1).ToLower()) - { - case "gif": - (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Gif); - break; - case "jpeg": - (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); - break; - case "jpg": - (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); - break; - case "png": - (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Png); - break; - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveSingleImage (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - private void mMenFile_DropDownOpening(object sender, System.EventArgs e) - { - if (this.flpScreenshots.Controls.Count < 1) - { - this.mMenFileSaveAll.Enabled = false; - this.mMenFileRemoveAll.Enabled = false; - } - else - { - this.mMenFileSaveAll.Enabled = true; - this.mMenFileRemoveAll.Enabled = true; - } - } -#endregion - + this.Show(frmMain.Default.pnlDock); } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "AddScreenshot (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Private Methods + private void pbScreenshot_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) + { + this.cMenScreenshot.Tag = sender; + + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + this.OpenScreenshot(sender); + } + } + + private void pbScreenshotOpen_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) + { + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + this.CloseOpenedScreenshot(sender.Parent); + } + } + + private void CloseOpenedScreenshot(Form form) + { + form.Close(); + } + + private void OpenScreenshot(PictureBox sender) + { + try + { + Image mImage = sender.Image; + + Form nForm = new Form(); + nForm.StartPosition = FormStartPosition.CenterParent; + nForm.ShowInTaskbar = false; + nForm.ShowIcon = false; + nForm.MaximizeBox = false; + nForm.MinimizeBox = false; + nForm.Width = mImage.Width + 2; + nForm.Height = mImage.Height + 2; + nForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + + PictureBox nPB = new PictureBox(); + nPB.Parent = nForm; + nPB.BorderStyle = BorderStyle.FixedSingle; + nPB.Location = new Point(0, 0); + nPB.SizeMode = PictureBoxSizeMode.AutoSize; + nPB.Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top); + nPB.Image = mImage; + nPB.ContextMenuStrip = this.cMenScreenshot; + nPB.Show(); + + nPB.MouseDown += this.pbScreenshotOpen_MouseDown; + + nForm.ShowDialog(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "OpenScreenshot (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void btnCloseScreenshot_Click(System.Object sender, System.EventArgs e) + { + try + { + sender.Parent.Dispose(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "btnCloseScreenshot_Click (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void mMenFileRemoveAll_Click(System.Object sender, System.EventArgs e) + { + this.RemoveAllImages(); + } + + private void RemoveAllImages() + { + this.flpScreenshots.Controls.Clear(); + } + + private void mMenFileSaveAll_Click(System.Object sender, System.EventArgs e) + { + this.SaveAllImages(); + } + + private void SaveAllImages() + { + try + { + int pCount = 1; + + if (this.dlgSaveAllImages.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + foreach (string fPath in Directory.GetFiles(this.dlgSaveAllImages.SelectedPath, "Screenshot_*", SearchOption.TopDirectoryOnly)) + { + FileInfo f = new FileInfo(fPath); + + string fCount = f.Name; + fCount = fCount.Replace(f.Extension, ""); + fCount = fCount.Replace("Screenshot_", ""); + + pCount = (int) (double.Parse(fCount) + 1); + } + + foreach (System.Windows.Forms.Control ctrl in this.flpScreenshots.Controls) + { + if (ctrl is PictureBox) + { + (ctrl as PictureBox).Image.Save(this.dlgSaveAllImages.SelectedPath + "\\Screenshot_" + Tools.Misc.LeadingZero(System.Convert.ToString(pCount)) +".png", System.Drawing.Imaging.ImageFormat.Png); + pCount++; + } + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveAllImages (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void cMenScreenshotCopy_Click(System.Object sender, System.EventArgs e) + { + this.CopyImageToClipboard(); + } + + private void CopyImageToClipboard() + { + try + { + Clipboard.SetImage((cMenScreenshot.Tag as PictureBox).Image); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "CopyImageToClipboard (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void cMenScreenshotSave_Click(System.Object sender, System.EventArgs e) + { + this.SaveSingleImage(); + } + + private void SaveSingleImage() + { + try + { + if (this.dlgSaveSingleImage.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + switch (this.dlgSaveSingleImage.FileName.Substring(this.dlgSaveSingleImage.FileName.LastIndexOf(".") + 1).ToLower()) + { + case "gif": + (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Gif); + break; + case "jpeg": + (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); + break; + case "jpg": + (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); + break; + case "png": + (this.cMenScreenshot.Tag as PictureBox).Image.Save(this.dlgSaveSingleImage.FileName, System.Drawing.Imaging.ImageFormat.Png); + break; + } + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveSingleImage (UI.Window.ScreenshotManager) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private void mMenFile_DropDownOpening(object sender, System.EventArgs e) + { + if (this.flpScreenshots.Controls.Count < 1) + { + this.mMenFileSaveAll.Enabled = false; + this.mMenFileRemoveAll.Enabled = false; + } + else + { + this.mMenFileSaveAll.Enabled = true; + this.mMenFileRemoveAll.Enabled = true; + } + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Sessions.cs b/mRemoteV1/CS/UI/UI.Window.Sessions.cs index c57f2a4a1..49634bfe3 100644 --- a/mRemoteV1/CS/UI/UI.Window.Sessions.cs +++ b/mRemoteV1/CS/UI/UI.Window.Sessions.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,367 +8,365 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.Threading; using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public partial class Sessions : Base + { + #region Private Fields + private Thread _getSessionsThread; + private bool _retrieved = false; + #endregion + + #region Public Methods + public Sessions(DockContent panel) + { + WindowType = Type.Sessions; + DockPnl = panel; + InitializeComponent(); + } + + public void GetSessions(bool Auto = false) + { + ClearList(); + if (Auto) { -#region Private Fields - private Thread _getSessionsThread; - private bool _retrieved = false; -#endregion - -#region Public Methods - public Sessions(DockContent panel) + _retrieved = false; + if (!Settings.AutomaticallyGetSessionInfo) { - WindowType = Type.Sessions; - DockPnl = panel; - InitializeComponent(); + return ; } - - public void GetSessions(bool Auto = false) - { - ClearList(); - if (Auto) - { - _retrieved = false; - if (!Settings.AutomaticallyGetSessionInfo) - { - return ; - } - } - - try - { - mRemoteNG.Connection.Info connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; - if (connectionInfo == null) - { - return ; - } - - if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA)) - { - return ; - } - - BackgroundData data = new BackgroundData(); - data.Hostname = connectionInfo.Hostname; - data.Username = connectionInfo.Username; - data.Password = connectionInfo.Password; - data.Domain = connectionInfo.Domain; - - if (Settings.EmptyCredentials == "custom") - { - if (string.IsNullOrEmpty(data.Username)) - { - data.Username = Settings.DefaultUsername; - } - - if (string.IsNullOrEmpty(data.Password)) - { - data.Password = Security.Crypt.Decrypt(Settings.DefaultPassword, App.Info.General.EncryptionKey); - } - - if (string.IsNullOrEmpty(data.Domain)) - { - data.Domain = Settings.DefaultDomain; - } - } - - if (_getSessionsThread != null) - { - if (_getSessionsThread.IsAlive) - { - _getSessionsThread.Abort(); - } - } - _getSessionsThread = new Thread(new System.Threading.ThreadStart(GetSessionsBackground)); - _getSessionsThread.SetApartmentState(ApartmentState.STA); - _getSessionsThread.IsBackground = true; - _getSessionsThread.Start(data); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Sessions.GetSessions() failed." + Constants.vbNewLine + ex.Message, true); - } - } - - public void KillSession() - { - if (sessionList.SelectedItems.Count == 0) - { - return ; - } - - mRemoteNG.Connection.Info connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; - if (connectionInfo == null) - { - return ; - } - - if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP)) - { - return ; - } - - foreach (ListViewItem lvItem in sessionList.SelectedItems) - { - KillSession(connectionInfo.Hostname, connectionInfo.Username, connectionInfo.Password, connectionInfo.Domain, System.Convert.ToString(lvItem.Tag)); - } - } - - public void KillSession(string hostname, string username, string password, string domain, string sessionId) - { - try - { - BackgroundData data = new BackgroundData(); - data.Hostname = hostname; - data.Username = username; - data.Password = password; - data.Domain = domain; - data.SessionId = long.Parse(sessionId); - - Thread thread = new Thread(new System.Threading.ThreadStart(KillSessionBackground)); - thread.SetApartmentState(ApartmentState.STA); - thread.IsBackground = true; - thread.Start(data); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Sessions.KillSession() failed." + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Private Methods -#region Form Stuff - public void Sessions_Load(object sender, EventArgs e) - { - ApplyLanguage(); - } - - private void ApplyLanguage() - { - TabText = Language.strMenuSessions; - Text = Language.strMenuSessions; - sessionActivityColumn.Text = Language.strActivity; - sessionMenuLogoff.Text = Language.strLogOff; - sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; - sessionTypeColumn.Text = Language.strType; - sessionUsernameColumn.Text = Language.strColumnUsername; - } -#endregion - - private void GetSessionsBackground(object dataObject) - { - BackgroundData data = dataObject as BackgroundData; - if (data == null) - { - return ; - } - - Security.Impersonator impersonator = new Security.Impersonator(); - mRemoteNG.Connection.Protocol.RDP.TerminalSessions terminalSessions = new mRemoteNG.Connection.Protocol.RDP.TerminalSessions(); - long serverHandle = 0; - try - { - impersonator.StartImpersonation(data.Domain, data.Username, data.Password); - - serverHandle = terminalSessions.OpenConnection(data.Hostname); - if (serverHandle == 0) - { - return ; - } - - GetSessions(terminalSessions, serverHandle); - - _retrieved = true; - } - catch (ThreadAbortException) - { - - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strSessionGetFailed + Constants.vbNewLine + ex.Message, true); - } - finally - { - impersonator.StopImpersonation(); - if (!(serverHandle == 0)) - { - terminalSessions.CloseConnection(serverHandle); - } - } - } - - // Get sessions from an already impersonated and connected TerminalSessions object - private void GetSessions(mRemoteNG.Protocol.Protocol.RDP.TerminalSessions terminalSessions, long serverHandle) - { - mRemoteNG.Connection.Protocol.RDP.SessionsCollection rdpSessions = terminalSessions.GetSessions(serverHandle); - foreach (mRemoteNG.Connection.Protocol.RDP.Session session in rdpSessions) - { - ListViewItem item = new ListViewItem(); - item.Tag = session.SessionId; - item.Text = session.SessionUser; - item.SubItems.Add(session.SessionState); - item.SubItems.Add(session.SessionName.Replace(Constants.vbNewLine, "")); - AddToList(item); - } - } - - private void KillSessionBackground(object dataObject) - { - BackgroundData data = dataObject as BackgroundData; - if (data == null) - { - return ; - } - - Security.Impersonator impersonator = new Security.Impersonator(); - mRemoteNG.Connection.Protocol.RDP.TerminalSessions terminalSessions = new mRemoteNG.Connection.Protocol.RDP.TerminalSessions(); - long serverHandle = 0; - try - { - if (string.IsNullOrEmpty(data.Username) || string.IsNullOrEmpty(data.Password)) - { - return ; - } - - impersonator.StartImpersonation(data.Domain, data.Username, data.Password); - - serverHandle = terminalSessions.OpenConnection(data.Hostname); - if (!(serverHandle == 0)) - { - terminalSessions.KillSession(serverHandle, data.SessionId); - } - - ClearList(); - GetSessions(terminalSessions, serverHandle); - - _retrieved = true; - } - catch (ThreadAbortException) - { - - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strSessionKillFailed + Constants.vbNewLine + ex.Message, true); - } - finally - { - impersonator.StopImpersonation(); - if (!(serverHandle == 0)) - { - terminalSessions.CloseConnection(serverHandle); - } - } - } - - delegate void AddToListCallback(ListViewItem item); - private void AddToList(ListViewItem item) - { - if (sessionList.InvokeRequired) - { - AddToListCallback callback = new AddToListCallback(AddToList); - sessionList.Invoke(callback, new object[] {item}); - } - else - { - sessionList.Items.Add(item); - } - } - - delegate void ClearListCallback(); - private void ClearList() - { - if (sessionList.InvokeRequired) - { - ClearListCallback callback = new ClearListCallback(ClearList); - sessionList.Invoke(callback); - } - else - { - sessionList.Items.Clear(); - } - } - - private void menuSession_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - mRemoteNG.Connection.Info connectionInfo = default(mRemoteNG.Connection.Info); - if (mRemoteNG.Tree.Node.TreeView == null || mRemoteNG.Tree.Node.SelectedNode == null) - { - connectionInfo = null; - } - else - { - connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; - } - - if (connectionInfo == null) - { - sessionMenuLogoff.Enabled = false; - sessionMenuRetrieve.Enabled = false; - sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; - return ; - } - - if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP & sessionList.SelectedItems.Count > 0) - { - sessionMenuLogoff.Enabled = true; - } - else - { - sessionMenuLogoff.Enabled = false; - } - - if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA) - { - sessionMenuRetrieve.Enabled = true; - } - else - { - sessionMenuRetrieve.Enabled = false; - } - - if (!_retrieved) - { - sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; - } - else - { - sessionMenuRetrieve.Text = Language.strRefresh; - } - } - - public void sessionMenuRetrieve_Click(System.Object sender, EventArgs e) - { - GetSessions(); - } - - public void sessionMenuLogoff_Click(System.Object sender, EventArgs e) - { - KillSession(); - } -#endregion - -#region Private Classes - private class BackgroundData - { - public string Hostname; - public string Username; - public string Password; - public string Domain; - public long SessionId; - } -#endregion } + + try + { + mRemoteNG.Connection.Info connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; + if (connectionInfo == null) + { + return ; + } + + if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA)) + { + return ; + } + + BackgroundData data = new BackgroundData(); + data.Hostname = connectionInfo.Hostname; + data.Username = connectionInfo.Username; + data.Password = connectionInfo.Password; + data.Domain = connectionInfo.Domain; + + if (Settings.EmptyCredentials == "custom") + { + if (string.IsNullOrEmpty(data.Username)) + { + data.Username = Settings.DefaultUsername; + } + + if (string.IsNullOrEmpty(data.Password)) + { + data.Password = Security.Crypt.Decrypt(Settings.DefaultPassword, App.Info.General.EncryptionKey); + } + + if (string.IsNullOrEmpty(data.Domain)) + { + data.Domain = Settings.DefaultDomain; + } + } + + if (_getSessionsThread != null) + { + if (_getSessionsThread.IsAlive) + { + _getSessionsThread.Abort(); + } + } + _getSessionsThread = new Thread(new System.Threading.ThreadStart(GetSessionsBackground)); + _getSessionsThread.SetApartmentState(ApartmentState.STA); + _getSessionsThread.IsBackground = true; + _getSessionsThread.Start(data); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Sessions.GetSessions() failed." + Constants.vbNewLine + ex.Message, true); + } + } + + public void KillSession() + { + if (sessionList.SelectedItems.Count == 0) + { + return ; + } + + mRemoteNG.Connection.Info connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; + if (connectionInfo == null) + { + return ; + } + + if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP)) + { + return ; + } + + foreach (ListViewItem lvItem in sessionList.SelectedItems) + { + KillSession(connectionInfo.Hostname, connectionInfo.Username, connectionInfo.Password, connectionInfo.Domain, System.Convert.ToString(lvItem.Tag)); + } + } + + public void KillSession(string hostname, string username, string password, string domain, string sessionId) + { + try + { + BackgroundData data = new BackgroundData(); + data.Hostname = hostname; + data.Username = username; + data.Password = password; + data.Domain = domain; + data.SessionId = long.Parse(sessionId); + + Thread thread = new Thread(new System.Threading.ThreadStart(KillSessionBackground)); + thread.SetApartmentState(ApartmentState.STA); + thread.IsBackground = true; + thread.Start(data); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Sessions.KillSession() failed." + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Private Methods + #region Form Stuff + public void Sessions_Load(object sender, EventArgs e) + { + ApplyLanguage(); + } + + private void ApplyLanguage() + { + TabText = Language.strMenuSessions; + Text = Language.strMenuSessions; + sessionActivityColumn.Text = Language.strActivity; + sessionMenuLogoff.Text = Language.strLogOff; + sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; + sessionTypeColumn.Text = Language.strType; + sessionUsernameColumn.Text = Language.strColumnUsername; + } + #endregion + + private void GetSessionsBackground(object dataObject) + { + BackgroundData data = dataObject as BackgroundData; + if (data == null) + { + return ; + } + + Security.Impersonator impersonator = new Security.Impersonator(); + mRemoteNG.Connection.Protocol.RDP.TerminalSessions terminalSessions = new mRemoteNG.Connection.Protocol.RDP.TerminalSessions(); + long serverHandle = 0; + try + { + impersonator.StartImpersonation(data.Domain, data.Username, data.Password); + + serverHandle = terminalSessions.OpenConnection(data.Hostname); + if (serverHandle == 0) + { + return ; + } + + GetSessions(terminalSessions, serverHandle); + + _retrieved = true; + } + catch (ThreadAbortException) + { + + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strSessionGetFailed + Constants.vbNewLine + ex.Message, true); + } + finally + { + impersonator.StopImpersonation(); + if (!(serverHandle == 0)) + { + terminalSessions.CloseConnection(serverHandle); + } + } + } + + // Get sessions from an already impersonated and connected TerminalSessions object + private void GetSessions(mRemoteNG.Protocol.Protocol.RDP.TerminalSessions terminalSessions, long serverHandle) + { + mRemoteNG.Connection.Protocol.RDP.SessionsCollection rdpSessions = terminalSessions.GetSessions(serverHandle); + foreach (mRemoteNG.Connection.Protocol.RDP.Session session in rdpSessions) + { + ListViewItem item = new ListViewItem(); + item.Tag = session.SessionId; + item.Text = session.SessionUser; + item.SubItems.Add(session.SessionState); + item.SubItems.Add(session.SessionName.Replace(Constants.vbNewLine, "")); + AddToList(item); + } + } + + private void KillSessionBackground(object dataObject) + { + BackgroundData data = dataObject as BackgroundData; + if (data == null) + { + return ; + } + + Security.Impersonator impersonator = new Security.Impersonator(); + mRemoteNG.Connection.Protocol.RDP.TerminalSessions terminalSessions = new mRemoteNG.Connection.Protocol.RDP.TerminalSessions(); + long serverHandle = 0; + try + { + if (string.IsNullOrEmpty(data.Username) || string.IsNullOrEmpty(data.Password)) + { + return ; + } + + impersonator.StartImpersonation(data.Domain, data.Username, data.Password); + + serverHandle = terminalSessions.OpenConnection(data.Hostname); + if (!(serverHandle == 0)) + { + terminalSessions.KillSession(serverHandle, data.SessionId); + } + + ClearList(); + GetSessions(terminalSessions, serverHandle); + + _retrieved = true; + } + catch (ThreadAbortException) + { + + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strSessionKillFailed + Constants.vbNewLine + ex.Message, true); + } + finally + { + impersonator.StopImpersonation(); + if (!(serverHandle == 0)) + { + terminalSessions.CloseConnection(serverHandle); + } + } + } + + delegate void AddToListCallback(ListViewItem item); + private void AddToList(ListViewItem item) + { + if (sessionList.InvokeRequired) + { + AddToListCallback callback = new AddToListCallback(AddToList); + sessionList.Invoke(callback, new object[] {item}); + } + else + { + sessionList.Items.Add(item); + } + } + + delegate void ClearListCallback(); + private void ClearList() + { + if (sessionList.InvokeRequired) + { + ClearListCallback callback = new ClearListCallback(ClearList); + sessionList.Invoke(callback); + } + else + { + sessionList.Items.Clear(); + } + } + + private void menuSession_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + mRemoteNG.Connection.Info connectionInfo = default(mRemoteNG.Connection.Info); + if (mRemoteNG.Tree.Node.TreeView == null || mRemoteNG.Tree.Node.SelectedNode == null) + { + connectionInfo = null; + } + else + { + connectionInfo = mRemoteNG.Tree.Node.SelectedNode.Tag as mRemoteNG.Connection.Info; + } + + if (connectionInfo == null) + { + sessionMenuLogoff.Enabled = false; + sessionMenuRetrieve.Enabled = false; + sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; + return ; + } + + if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP & sessionList.SelectedItems.Count > 0) + { + sessionMenuLogoff.Enabled = true; + } + else + { + sessionMenuLogoff.Enabled = false; + } + + if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA) + { + sessionMenuRetrieve.Enabled = true; + } + else + { + sessionMenuRetrieve.Enabled = false; + } + + if (!_retrieved) + { + sessionMenuRetrieve.Text = Language.strMenuSessionRetrieve; + } + else + { + sessionMenuRetrieve.Text = Language.strRefresh; + } + } + + public void sessionMenuRetrieve_Click(System.Object sender, EventArgs e) + { + GetSessions(); + } + + public void sessionMenuLogoff_Click(System.Object sender, EventArgs e) + { + KillSession(); + } + #endregion + + #region Private Classes + private class BackgroundData + { + public string Hostname; + public string Username; + public string Password; + public string Domain; + public long SessionId; + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Tree.cs b/mRemoteV1/CS/UI/UI.Window.Tree.cs index ae75a1216..9543b8b01 100644 --- a/mRemoteV1/CS/UI/UI.Window.Tree.cs +++ b/mRemoteV1/CS/UI/UI.Window.Tree.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,1028 +8,1026 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using mRemoteNG.App; using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public partial class Tree : Base + { + #region Form Stuff + public void Tree_Load(object sender, EventArgs e) + { + ApplyLanguage(); + + Themes.ThemeManager.ThemeChanged += ApplyTheme; + ApplyTheme(); + + txtSearch.Multiline = true; + txtSearch.MinimumSize = new Size(0, 14); + txtSearch.Size = new Size(txtSearch.Size.Width, 14); + txtSearch.Multiline = false; + } + + private void ApplyLanguage() + { + Text = Language.strConnections; + TabText = Language.strConnections; + + mMenAddConnection.ToolTipText = Language.strAddConnection; + mMenAddFolder.ToolTipText = Language.strAddFolder; + mMenView.ToolTipText = Language.strMenuView.Replace("&", ""); + mMenViewExpandAllFolders.Text = Language.strExpandAllFolders; + mMenViewCollapseAllFolders.Text = Language.strCollapseAllFolders; + mMenSortAscending.ToolTipText = Language.strSortAsc; + + cMenTreeConnect.Text = Language.strConnect; + cMenTreeConnectWithOptions.Text = Language.strConnectWithOptions; + cMenTreeConnectWithOptionsConnectToConsoleSession.Text = Language.strConnectToConsoleSession; + cMenTreeConnectWithOptionsDontConnectToConsoleSession.Text = Language.strDontConnectToConsoleSessionMenuItem; + cMenTreeConnectWithOptionsConnectInFullscreen.Text = Language.strConnectInFullscreen; + cMenTreeConnectWithOptionsNoCredentials.Text = Language.strConnectNoCredentials; + cMenTreeConnectWithOptionsChoosePanelBeforeConnecting.Text = Language.strChoosePanelBeforeConnecting; + cMenTreeDisconnect.Text = Language.strMenuDisconnect; + + cMenTreeToolsExternalApps.Text = Language.strMenuExternalTools; + cMenTreeToolsTransferFile.Text = Language.strMenuTransferFile; + + cMenTreeDuplicate.Text = Language.strDuplicate; + cMenTreeRename.Text = Language.strRename; + cMenTreeDelete.Text = Language.strMenuDelete; + + cMenTreeImport.Text = Language.strImportMenuItem; + cMenTreeImportFile.Text = Language.strImportFromFileMenuItem; + cMenTreeImportActiveDirectory.Text = Language.strImportAD; + cMenTreeImportPortScan.Text = Language.strImportPortScan; + cMenTreeExportFile.Text = Language.strExportToFileMenuItem; + + cMenTreeAddConnection.Text = Language.strAddConnection; + cMenTreeAddFolder.Text = Language.strAddFolder; + + cMenTreeToolsSort.Text = Language.strSort; + cMenTreeToolsSortAscending.Text = Language.strSortAsc; + cMenTreeToolsSortDescending.Text = Language.strSortDesc; + cMenTreeMoveUp.Text = Language.strMoveUp; + cMenTreeMoveDown.Text = Language.strMoveDown; + + txtSearch.Text = Language.strSearchPrompt; + } + + public void ApplyTheme() + { + msMain.BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; + msMain.ForeColor = Themes.ThemeManager.ActiveTheme.ToolbarTextColor; + tvConnections.BackColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelBackgroundColor; + tvConnections.ForeColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelTextColor; + tvConnections.LineColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelTreeLineColor; + BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; + txtSearch.BackColor = Themes.ThemeManager.ActiveTheme.SearchBoxBackgroundColor; + txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextPromptColor; + } + #endregion + + #region Public Methods + public Tree(DockContent panel) + { + WindowType = Type.Tree; + DockPnl = panel; + InitializeComponent(); + FillImageList(); + + DescriptionTooltip = new ToolTip(); + DescriptionTooltip.InitialDelay = 300; + DescriptionTooltip.ReshowDelay = 0; + } + + public void InitialRefresh() + { + tvConnections_AfterSelect(tvConnections, new TreeViewEventArgs(tvConnections.SelectedNode, TreeViewAction.ByMouse)); + } + #endregion + + #region Public Properties + public ToolTip DescriptionTooltip {get; set;} + #endregion + + #region Private Methods + private void FillImageList() + { + try { -#region Form Stuff - public void Tree_Load(object sender, EventArgs e) - { - ApplyLanguage(); - - Themes.ThemeManager.ThemeChanged += ApplyTheme; - ApplyTheme(); - - txtSearch.Multiline = true; - txtSearch.MinimumSize = new Size(0, 14); - txtSearch.Size = new Size(txtSearch.Size.Width, 14); - txtSearch.Multiline = false; - } + imgListTree.Images.Add(Resources.Root); + imgListTree.Images.Add(Resources.Folder); + imgListTree.Images.Add(Resources.Play); + imgListTree.Images.Add(Resources.Pause); + imgListTree.Images.Add(Resources.PuttySessions); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "FillImageList (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private void ApplyLanguage() - { - Text = Language.strConnections; - TabText = Language.strConnections; - - mMenAddConnection.ToolTipText = Language.strAddConnection; - mMenAddFolder.ToolTipText = Language.strAddFolder; - mMenView.ToolTipText = Language.strMenuView.Replace("&", ""); - mMenViewExpandAllFolders.Text = Language.strExpandAllFolders; - mMenViewCollapseAllFolders.Text = Language.strCollapseAllFolders; - mMenSortAscending.ToolTipText = Language.strSortAsc; - - cMenTreeConnect.Text = Language.strConnect; - cMenTreeConnectWithOptions.Text = Language.strConnectWithOptions; - cMenTreeConnectWithOptionsConnectToConsoleSession.Text = Language.strConnectToConsoleSession; - cMenTreeConnectWithOptionsDontConnectToConsoleSession.Text = Language.strDontConnectToConsoleSessionMenuItem; - cMenTreeConnectWithOptionsConnectInFullscreen.Text = Language.strConnectInFullscreen; - cMenTreeConnectWithOptionsNoCredentials.Text = Language.strConnectNoCredentials; - cMenTreeConnectWithOptionsChoosePanelBeforeConnecting.Text = Language.strChoosePanelBeforeConnecting; - cMenTreeDisconnect.Text = Language.strMenuDisconnect; - - cMenTreeToolsExternalApps.Text = Language.strMenuExternalTools; - cMenTreeToolsTransferFile.Text = Language.strMenuTransferFile; - - cMenTreeDuplicate.Text = Language.strDuplicate; - cMenTreeRename.Text = Language.strRename; - cMenTreeDelete.Text = Language.strMenuDelete; - - cMenTreeImport.Text = Language.strImportMenuItem; - cMenTreeImportFile.Text = Language.strImportFromFileMenuItem; - cMenTreeImportActiveDirectory.Text = Language.strImportAD; - cMenTreeImportPortScan.Text = Language.strImportPortScan; - cMenTreeExportFile.Text = Language.strExportToFileMenuItem; - - cMenTreeAddConnection.Text = Language.strAddConnection; - cMenTreeAddFolder.Text = Language.strAddFolder; - - cMenTreeToolsSort.Text = Language.strSort; - cMenTreeToolsSortAscending.Text = Language.strSortAsc; - cMenTreeToolsSortDescending.Text = Language.strSortDesc; - cMenTreeMoveUp.Text = Language.strMoveUp; - cMenTreeMoveDown.Text = Language.strMoveDown; - - txtSearch.Text = Language.strSearchPrompt; - } + public void tvConnections_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) + { + cMenTreeDelete.ShortcutKeys = Keys.None; + } - public void ApplyTheme() - { - msMain.BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; - msMain.ForeColor = Themes.ThemeManager.ActiveTheme.ToolbarTextColor; - tvConnections.BackColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelBackgroundColor; - tvConnections.ForeColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelTextColor; - tvConnections.LineColor = Themes.ThemeManager.ActiveTheme.ConnectionsPanelTreeLineColor; - BackColor = Themes.ThemeManager.ActiveTheme.ToolbarBackgroundColor; - txtSearch.BackColor = Themes.ThemeManager.ActiveTheme.SearchBoxBackgroundColor; - txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextPromptColor; - } -#endregion - -#region Public Methods - public Tree(DockContent panel) - { - WindowType = Type.Tree; - DockPnl = panel; - InitializeComponent(); - FillImageList(); - - DescriptionTooltip = new ToolTip(); - DescriptionTooltip.InitialDelay = 300; - DescriptionTooltip.ReshowDelay = 0; - } - - public void InitialRefresh() - { - tvConnections_AfterSelect(tvConnections, new TreeViewEventArgs(tvConnections.SelectedNode, TreeViewAction.ByMouse)); - } -#endregion - -#region Public Properties - public ToolTip DescriptionTooltip {get; set;} -#endregion - -#region Private Methods - private void FillImageList() - { - try - { - imgListTree.Images.Add(Resources.Root); - imgListTree.Images.Add(Resources.Folder); - imgListTree.Images.Add(Resources.Play); - imgListTree.Images.Add(Resources.Pause); - imgListTree.Images.Add(Resources.PuttySessions); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "FillImageList (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public void tvConnections_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) - { - cMenTreeDelete.ShortcutKeys = Keys.None; - } - - public void tvConnections_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) - { - try - { - cMenTreeDelete.ShortcutKeys = Keys.Delete; + public void tvConnections_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) + { + try + { + cMenTreeDelete.ShortcutKeys = Keys.Delete; - mRemoteNG.Tree.Node.FinishRenameSelectedNode(e.Label); - Windows.configForm.pGrid_SelectedObjectChanged(); - ShowHideTreeContextMenuItems(e.Node); - SaveConnectionsBG(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_AfterLabelEdit (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } + mRemoteNG.Tree.Node.FinishRenameSelectedNode(e.Label); + Windows.configForm.pGrid_SelectedObjectChanged(); + ShowHideTreeContextMenuItems(e.Node); + SaveConnectionsBG(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_AfterLabelEdit (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - public void tvConnections_AfterSelect(object sender, TreeViewEventArgs e) + public void tvConnections_AfterSelect(object sender, TreeViewEventArgs e) + { + try + { + if ((mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection) || (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttySession)) { - try - { - if ((mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection) || (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttySession)) - { - Windows.configForm.SetPropertyGridObject(e.Node.Tag); - } - else if (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Container) - { - Windows.configForm.SetPropertyGridObject((e.Node.Tag as Container.Info).ConnectionInfo); - } - else if ((mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Root) || (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttyRoot)) - { - Windows.configForm.SetPropertyGridObject(e.Node.Tag); - } - else - { - return; - } - - Windows.configForm.pGrid_SelectedObjectChanged(); - ShowHideTreeContextMenuItems(e.Node); - Windows.sessionsForm.GetSessions(true); - - LastSelected = mRemoteNG.Tree.Node.GetConstantID(e.Node); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_AfterSelect (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } + Windows.configForm.SetPropertyGridObject(e.Node.Tag); } - - public void tvConnections_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) + else if (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Container) { - try - { - ShowHideTreeContextMenuItems(tvConnections.SelectedNode); - tvConnections.SelectedNode = e.Node; - - if (e.Button == MouseButtons.Left) - { - if (Settings.SingleClickOnConnectionOpensIt && - (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection | - mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttySession)) - { - OpenConnection(); - } - - if (Settings.SingleClickSwitchesToOpenConnection && mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection) - { - SwitchToOpenConnection(e.Node.Tag); - } - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_NodeMouseClick (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } + Windows.configForm.SetPropertyGridObject((e.Node.Tag as Container.Info).ConnectionInfo); } - - static public void tvConnections_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + else if ((mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Root) || (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttyRoot)) { - if (mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.Connection | - mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) + Windows.configForm.SetPropertyGridObject(e.Node.Tag); + } + else + { + return; + } + + Windows.configForm.pGrid_SelectedObjectChanged(); + ShowHideTreeContextMenuItems(e.Node); + Windows.sessionsForm.GetSessions(true); + + LastSelected = mRemoteNG.Tree.Node.GetConstantID(e.Node); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_AfterSelect (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void tvConnections_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) + { + try + { + ShowHideTreeContextMenuItems(tvConnections.SelectedNode); + tvConnections.SelectedNode = e.Node; + + if (e.Button == MouseButtons.Left) + { + if (Settings.SingleClickOnConnectionOpensIt && + (mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection | + mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.PuttySession)) { OpenConnection(); } - } - - public void tvConnections_MouseMove(object sender, MouseEventArgs e) - { - try + + if (Settings.SingleClickSwitchesToOpenConnection && mRemoteNG.Tree.Node.GetNodeType(e.Node) == mRemoteNG.Tree.Node.Type.Connection) { - mRemoteNG.Tree.Node.SetNodeToolTip(e, DescriptionTooltip); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_MouseMove (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + SwitchToOpenConnection(e.Node.Tag); } } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_NodeMouseClick (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private static void EnableMenuItemsRecursive(ToolStripItemCollection items, bool enable = true) + static public void tvConnections_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if (mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.Connection | + mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) + { + OpenConnection(); + } + } + + public void tvConnections_MouseMove(object sender, MouseEventArgs e) + { + try + { + mRemoteNG.Tree.Node.SetNodeToolTip(e, DescriptionTooltip); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_MouseMove (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + private static void EnableMenuItemsRecursive(ToolStripItemCollection items, bool enable = true) + { + ToolStripMenuItem menuItem = default(ToolStripMenuItem); + foreach (ToolStripItem item in items) + { + menuItem = item as ToolStripMenuItem; + if (menuItem == null) { - ToolStripMenuItem menuItem = default(ToolStripMenuItem); - foreach (ToolStripItem item in items) + continue; + } + menuItem.Enabled = enable; + if (menuItem.HasDropDownItems) + { + EnableMenuItemsRecursive(menuItem.DropDownItems, enable); + } + } + } + + private void ShowHideTreeContextMenuItems(TreeNode selectedNode) + { + if (selectedNode == null) + { + return ; + } + + try + { + cMenTree.Enabled = true; + EnableMenuItemsRecursive(cMenTree.Items); + + if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Connection) + { + mRemoteNG.Connection.Info connectionInfo = selectedNode.Tag; + + if (connectionInfo.OpenConnections.Count == 0) { - menuItem = item as ToolStripMenuItem; - if (menuItem == null) + cMenTreeDisconnect.Enabled = false; + } + + if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | + connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2)) + { + cMenTreeToolsTransferFile.Enabled = false; + } + + if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA)) + { + cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; + cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; + } + + if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.IntApp) + { + cMenTreeConnectWithOptionsNoCredentials.Enabled = false; + } + } + else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) + { + mRemoteNG.Connection.PuttySession.Info puttySessionInfo = selectedNode.Tag; + + cMenTreeAddConnection.Enabled = false; + cMenTreeAddFolder.Enabled = false; + + if (puttySessionInfo.OpenConnections.Count == 0) + { + cMenTreeDisconnect.Enabled = false; + } + + if (!(puttySessionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | puttySessionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2)) + { + cMenTreeToolsTransferFile.Enabled = false; + } + + cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; + cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; + cMenTreeToolsSort.Enabled = false; + cMenTreeDuplicate.Enabled = false; + cMenTreeRename.Enabled = false; + cMenTreeDelete.Enabled = false; + cMenTreeMoveUp.Enabled = false; + cMenTreeMoveDown.Enabled = false; + } + else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Container) + { + cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; + cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; + cMenTreeDisconnect.Enabled = false; + + int openConnections = 0; + mRemoteNG.Connection.Info connectionInfo = default(mRemoteNG.Connection.Info); + foreach (TreeNode node in selectedNode.Nodes) + { + if (node.Tag is mRemoteNG.Connection.Info) { - continue; + connectionInfo = node.Tag; + openConnections = openConnections + connectionInfo.OpenConnections.Count; } - menuItem.Enabled = enable; - if (menuItem.HasDropDownItems) + } + if (openConnections == 0) + { + cMenTreeDisconnect.Enabled = false; + } + + cMenTreeToolsTransferFile.Enabled = false; + cMenTreeToolsExternalApps.Enabled = false; + } + else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Root) + { + cMenTreeConnect.Enabled = false; + cMenTreeConnectWithOptions.Enabled = false; + cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; + cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; + cMenTreeConnectWithOptionsChoosePanelBeforeConnecting.Enabled = false; + cMenTreeDisconnect.Enabled = false; + cMenTreeToolsTransferFile.Enabled = false; + cMenTreeToolsExternalApps.Enabled = false; + cMenTreeDuplicate.Enabled = false; + cMenTreeDelete.Enabled = false; + cMenTreeMoveUp.Enabled = false; + cMenTreeMoveDown.Enabled = false; + } + else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.PuttyRoot) + { + cMenTreeAddConnection.Enabled = false; + cMenTreeAddFolder.Enabled = false; + cMenTreeConnect.Enabled = false; + cMenTreeConnectWithOptions.Enabled = false; + cMenTreeDisconnect.Enabled = false; + cMenTreeToolsTransferFile.Enabled = false; + cMenTreeConnectWithOptions.Enabled = false; + cMenTreeToolsSort.Enabled = false; + cMenTreeToolsExternalApps.Enabled = false; + cMenTreeDuplicate.Enabled = false; + cMenTreeRename.Enabled = true; + cMenTreeDelete.Enabled = false; + cMenTreeMoveUp.Enabled = false; + cMenTreeMoveDown.Enabled = false; + } + else + { + cMenTree.Enabled = false; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowHideTreeContextMenuItems (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Drag and Drop + static public void tvConnections_DragDrop(object sender, DragEventArgs e) + { + try + { + //Check that there is a TreeNode being dragged + if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false) + { + return; + } + + //Get the TreeView raising the event (in case multiple on form) + TreeView selectedTreeview = (TreeView) sender; + + //Get the TreeNode being dragged + System.Windows.Forms.TreeNode dropNode = (System.Windows.Forms.TreeNode) (e.Data.GetData("System.Windows.Forms.TreeNode")); + + //The target node should be selected from the DragOver event + TreeNode targetNode = selectedTreeview.SelectedNode; + + if (dropNode == targetNode) + { + return; + } + + if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Root) + { + return; + } + + if (dropNode == targetNode.Parent) + { + return; + } + + //Remove the drop node from its current location + dropNode.Remove(); + + //If there is no targetNode add dropNode to the bottom of + //the TreeView root nodes, otherwise add it to the end of + //the dropNode child nodes + + if (mRemoteNG.Tree.Node.GetNodeType(targetNode) == mRemoteNG.Tree.Node.Type.Root | mRemoteNG.Tree.Node.GetNodeType(targetNode) == mRemoteNG.Tree.Node.Type.Container) + { + targetNode.Nodes.Insert(0, dropNode); + } + else + { + targetNode.Parent.Nodes.Insert(targetNode.Index + 1, dropNode); + } + + if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Connection | mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Container) + { + if (mRemoteNG.Tree.Node.GetNodeType(dropNode.Parent) == mRemoteNG.Tree.Node.Type.Container) + { + dropNode.Tag.Parent = dropNode.Parent.Tag; + } + else if (mRemoteNG.Tree.Node.GetNodeType(dropNode.Parent) == mRemoteNG.Tree.Node.Type.Root) + { + dropNode.Tag.Parent = null; + if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Connection) { - EnableMenuItemsRecursive(menuItem.DropDownItems, enable); + dropNode.Tag.Inherit.TurnOffInheritanceCompletely(); + } + else if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Container) + { + dropNode.Tag.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); } } } + + //Ensure the newly created node is visible to + //the user and select it + dropNode.EnsureVisible(); + selectedTreeview.SelectedNode = dropNode; + + SaveConnectionsBG(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragDrop (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private void ShowHideTreeContextMenuItems(TreeNode selectedNode) + static public void tvConnections_DragEnter(object sender, DragEventArgs e) + { + try + { + //See if there is a TreeNode being dragged + if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) { - if (selectedNode == null) + //TreeNode found allow move effect + e.Effect = DragDropEffects.Move; + } + else + { + //No TreeNode found, prevent move + e.Effect = DragDropEffects.None; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragEnter (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + static public void tvConnections_DragOver(object sender, DragEventArgs e) + { + try + { + //Check that there is a TreeNode being dragged + if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false) + { + return; + } + + //Get the TreeView raising the event (in case multiple on form) + TreeView selectedTreeview = (TreeView) sender; + + //As the mouse moves over nodes, provide feedback to + //the user by highlighting the node that is the + //current drop target + Point pt = ((TreeView) sender).PointToClient(new Point(e.X, e.Y)); + TreeNode targetNode = selectedTreeview.GetNodeAt(pt); + + //Select the node currently under the cursor + selectedTreeview.SelectedNode = targetNode; + + //Check that the selected node is not the dropNode and + //also that it is not a child of the dropNode and + //therefore an invalid target + TreeNode dropNode = (TreeNode) (e.Data.GetData("System.Windows.Forms.TreeNode")); + + Root.PuttySessions.Info puttyRootInfo = default(Root.PuttySessions.Info); + while (!(targetNode == null)) + { + puttyRootInfo = targetNode.Tag as Root.PuttySessions.Info; + if (puttyRootInfo != null || targetNode == dropNode) { + e.Effect = DragDropEffects.None; return ; } - - try - { - cMenTree.Enabled = true; - EnableMenuItemsRecursive(cMenTree.Items); + targetNode = targetNode.Parent; + } - if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Connection) + //Currently selected node is a suitable target + e.Effect = DragDropEffects.Move; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragOver (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void tvConnections_ItemDrag(object sender, ItemDragEventArgs e) + { + try + { + TreeNode dragTreeNode = e.Item as TreeNode; + if (dragTreeNode == null) + { + return ; + } + + if (dragTreeNode.Tag == null) + { + return ; + } + if (dragTreeNode.Tag is mRemoteNG.Connection.PuttySession.Info|| !(dragTreeNode.Tag is mRemoteNG.Connection.Info|| dragTreeNode.Tag is Container.Info)) + { + tvConnections.SelectedNode = dragTreeNode; + return ; + } + + //Set the drag node and initiate the DragDrop + DoDragDrop(e.Item, DragDropEffects.Move); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_ItemDrag (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Tree Context Menu + public void cMenTreeAddConnection_Click(System.Object sender, EventArgs e) + { + AddConnection(); + SaveConnectionsBG(); + } + + public void cMenTreeAddFolder_Click(System.Object sender, EventArgs e) + { + AddFolder(); + SaveConnectionsBG(); + } + + static public void cMenTreeConnect_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.DoNotJump); + } + + static public void cMenTreeConnectWithOptionsConnectToConsoleSession_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.UseConsoleSession | mRemoteNG.Connection.Info.Force.DoNotJump); + } + + static public void cMenTreeConnectWithOptionsNoCredentials_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.NoCredentials); + } + + static public void cMenTreeConnectWithOptionsDontConnectToConsoleSession_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.DontUseConsoleSession | mRemoteNG.Connection.Info.Force.DoNotJump); + } + + static public void cMenTreeConnectWithOptionsConnectInFullscreen_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.Fullscreen | mRemoteNG.Connection.Info.Force.DoNotJump); + } + + static public void cMenTreeConnectWithOptionsChoosePanelBeforeConnecting_Click(System.Object sender, EventArgs e) + { + OpenConnection(mRemoteNG.Connection.Info.Force.OverridePanel | mRemoteNG.Connection.Info.Force.DoNotJump); + } + + public void cMenTreeDisconnect_Click(System.Object sender, EventArgs e) + { + DisconnectConnection(); + } + + static public void cMenTreeToolsTransferFile_Click(System.Object sender, EventArgs e) + { + SshTransferFile(); + } + + public void mMenSortAscending_Click(System.Object sender, EventArgs e) + { + tvConnections.BeginUpdate(); + mRemoteNG.Tree.Node.Sort(tvConnections.Nodes[0], SortOrder.Ascending); + tvConnections.EndUpdate(); + SaveConnectionsBG(); + } + + public void cMenTreeToolsSortAscending_Click(System.Object sender, EventArgs e) + { + tvConnections.BeginUpdate(); + mRemoteNG.Tree.Node.Sort(tvConnections.SelectedNode, SortOrder.Ascending); + tvConnections.EndUpdate(); + SaveConnectionsBG(); + } + + public void cMenTreeToolsSortDescending_Click(System.Object sender, EventArgs e) + { + tvConnections.BeginUpdate(); + mRemoteNG.Tree.Node.Sort(tvConnections.SelectedNode, SortOrder.Descending); + tvConnections.EndUpdate(); + SaveConnectionsBG(); + } + + public void cMenTree_DropDownOpening(object sender, EventArgs e) + { + AddExternalApps(); + } + + private static void cMenTreeToolsExternalAppsEntry_Click(object sender, EventArgs e) + { + StartExternalApp(sender.Tag); + } + + public void cMenTreeDuplicate_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.CloneNode(tvConnections.SelectedNode); + SaveConnectionsBG(); + } + + static public void cMenTreeRename_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.StartRenameSelectedNode(); + SaveConnectionsBG(); + } + + static public void cMenTreeDelete_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.DeleteSelectedNode(); + SaveConnectionsBG(); + } + + static public void cMenTreeImportFile_Click(System.Object sender, EventArgs e) + { + Import.ImportFromFile(Windows.treeForm.tvConnections.Nodes[0], Windows.treeForm.tvConnections.SelectedNode, true); + } + + static public void cMenTreeImportActiveDirectory_Click(System.Object sender, EventArgs e) + { + Windows.Show(Type.ActiveDirectoryImport); + } + + static public void cMenTreeImportPortScan_Click(System.Object sender, EventArgs e) + { + Windows.Show(UI.Window.Type.PortScan, true); + } + + static public void cMenTreeExportFile_Click(System.Object sender, EventArgs e) + { + Export.ExportToFile(Windows.treeForm.tvConnections.Nodes[0], Windows.treeForm.tvConnections.SelectedNode); + } + static public void cMenTreeMoveUp_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.MoveNodeUp(); + SaveConnectionsBG(); + } + + static public void cMenTreeMoveDown_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.MoveNodeDown(); + SaveConnectionsBG(); + } + #endregion + + #region Context Menu Actions + public void AddConnection() + { + try + { + if (tvConnections.SelectedNode == null) + { + tvConnections.SelectedNode = tvConnections.Nodes[0]; + } + + TreeNode newTreeNode = mRemoteNG.Tree.Node.AddNode(mRemoteNG.Tree.Node.Type.Connection); + if (newTreeNode == null) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Tree.AddConnection() failed." + Constants.vbNewLine + "mRemoteNG.Tree.Node.AddNode() returned Nothing.", true); + return ; + } + + TreeNode containerNode = tvConnections.SelectedNode; + if (mRemoteNG.Tree.Node.GetNodeType(containerNode) == mRemoteNG.Tree.Node.Type.Connection) + { + containerNode = containerNode.Parent; + } + + mRemoteNG.Connection.Info newConnectionInfo = new mRemoteNG.Connection.Info(); + if (mRemoteNG.Tree.Node.GetNodeType(containerNode) == mRemoteNG.Tree.Node.Type.Root) + { + newConnectionInfo.Inherit.TurnOffInheritanceCompletely(); + } + else + { + newConnectionInfo.Parent = containerNode.Tag; + } + + newConnectionInfo.TreeNode = newTreeNode; + newTreeNode.Tag = newConnectionInfo; + ConnectionList.Add(newConnectionInfo); + + containerNode.Nodes.Add(newTreeNode); + + tvConnections.SelectedNode = newTreeNode; + tvConnections.SelectedNode.BeginEdit(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Tree.AddConnection() failed." + Constants.vbNewLine + ex.Message, true); + } + } + + public void AddFolder() + { + try + { + TreeNode newNode = mRemoteNG.Tree.Node.AddNode(mRemoteNG.Tree.Node.Type.Container); + Container.Info newContainerInfo = new Container.Info(); + newNode.Tag = newContainerInfo; + newContainerInfo.TreeNode = newNode; + + TreeNode selectedNode = mRemoteNG.Tree.Node.SelectedNode; + TreeNode parentNode = default(TreeNode); + if (selectedNode == null) + { + parentNode = tvConnections.Nodes[0]; + } + else + { + if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Connection) + { + parentNode = selectedNode.Parent; + } + else + { + parentNode = selectedNode; + } + } + + newContainerInfo.ConnectionInfo = new mRemoteNG.Connection.Info(newContainerInfo); + newContainerInfo.ConnectionInfo.Name = newNode.Text; + + // We can only inherit from a container node, not the root node or connection nodes + if (mRemoteNG.Tree.Node.GetNodeType(parentNode) == mRemoteNG.Tree.Node.Type.Container) + { + newContainerInfo.Parent = parentNode.Tag; + } + else + { + newContainerInfo.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); + } + + ContainerList.Add(newContainerInfo); + parentNode.Nodes.Add(newNode); + + tvConnections.SelectedNode = newNode; + tvConnections.SelectedNode.BeginEdit(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(Language.strErrorAddFolderFailed, ex.Message), true); + } + } + + private void DisconnectConnection() + { + try + { + if (tvConnections.SelectedNode != null) + { + if (tvConnections.SelectedNode.Tag is mRemoteNG.Connection.Info) + { + mRemoteNG.Connection.Info conI = tvConnections.SelectedNode.Tag; + for (int i = 0; i <= conI.OpenConnections.Count - 1; i++) { - mRemoteNG.Connection.Info connectionInfo = selectedNode.Tag; + conI.OpenConnections[i].Disconnect(); + } + } - if (connectionInfo.OpenConnections.Count == 0) - { - cMenTreeDisconnect.Enabled = false; - } - - if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | - connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2)) - { - cMenTreeToolsTransferFile.Enabled = false; - } - - if (!(connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.RDP | connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.ICA)) - { - cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; - cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; - } - - if (connectionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.IntApp) - { - cMenTreeConnectWithOptionsNoCredentials.Enabled = false; - } - } - else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) - { - mRemoteNG.Connection.PuttySession.Info puttySessionInfo = selectedNode.Tag; - - cMenTreeAddConnection.Enabled = false; - cMenTreeAddFolder.Enabled = false; - - if (puttySessionInfo.OpenConnections.Count == 0) - { - cMenTreeDisconnect.Enabled = false; - } - - if (!(puttySessionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH1 | puttySessionInfo.Protocol == mRemoteNG.Connection.Protocol.Protocols.SSH2)) - { - cMenTreeToolsTransferFile.Enabled = false; - } - - cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; - cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; - cMenTreeToolsSort.Enabled = false; - cMenTreeDuplicate.Enabled = false; - cMenTreeRename.Enabled = false; - cMenTreeDelete.Enabled = false; - cMenTreeMoveUp.Enabled = false; - cMenTreeMoveDown.Enabled = false; - } - else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Container) - { - cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; - cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; - cMenTreeDisconnect.Enabled = false; - - int openConnections = 0; - mRemoteNG.Connection.Info connectionInfo = default(mRemoteNG.Connection.Info); - foreach (TreeNode node in selectedNode.Nodes) - { - if (node.Tag is mRemoteNG.Connection.Info) - { - connectionInfo = node.Tag; - openConnections = openConnections + connectionInfo.OpenConnections.Count; - } - } - if (openConnections == 0) - { - cMenTreeDisconnect.Enabled = false; - } - - cMenTreeToolsTransferFile.Enabled = false; - cMenTreeToolsExternalApps.Enabled = false; - } - else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Root) - { - cMenTreeConnect.Enabled = false; - cMenTreeConnectWithOptions.Enabled = false; - cMenTreeConnectWithOptionsConnectInFullscreen.Enabled = false; - cMenTreeConnectWithOptionsConnectToConsoleSession.Enabled = false; - cMenTreeConnectWithOptionsChoosePanelBeforeConnecting.Enabled = false; - cMenTreeDisconnect.Enabled = false; - cMenTreeToolsTransferFile.Enabled = false; - cMenTreeToolsExternalApps.Enabled = false; - cMenTreeDuplicate.Enabled = false; - cMenTreeDelete.Enabled = false; - cMenTreeMoveUp.Enabled = false; - cMenTreeMoveDown.Enabled = false; - } - else if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.PuttyRoot) - { - cMenTreeAddConnection.Enabled = false; - cMenTreeAddFolder.Enabled = false; - cMenTreeConnect.Enabled = false; - cMenTreeConnectWithOptions.Enabled = false; - cMenTreeDisconnect.Enabled = false; - cMenTreeToolsTransferFile.Enabled = false; - cMenTreeConnectWithOptions.Enabled = false; - cMenTreeToolsSort.Enabled = false; - cMenTreeToolsExternalApps.Enabled = false; - cMenTreeDuplicate.Enabled = false; - cMenTreeRename.Enabled = true; - cMenTreeDelete.Enabled = false; - cMenTreeMoveUp.Enabled = false; - cMenTreeMoveDown.Enabled = false; - } - else - { - cMenTree.Enabled = false; - } - } - catch (Exception ex) + if (tvConnections.SelectedNode.Tag is Container.Info) { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ShowHideTreeContextMenuItems (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Drag and Drop - static public void tvConnections_DragDrop(object sender, DragEventArgs e) - { - try - { - //Check that there is a TreeNode being dragged - if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false) + foreach (TreeNode n in tvConnections.SelectedNode.Nodes) { - return; - } - - //Get the TreeView raising the event (in case multiple on form) - TreeView selectedTreeview = (TreeView) sender; - - //Get the TreeNode being dragged - System.Windows.Forms.TreeNode dropNode = (System.Windows.Forms.TreeNode) (e.Data.GetData("System.Windows.Forms.TreeNode")); - - //The target node should be selected from the DragOver event - TreeNode targetNode = selectedTreeview.SelectedNode; - - if (dropNode == targetNode) - { - return; - } - - if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Root) - { - return; - } - - if (dropNode == targetNode.Parent) - { - return; - } - - //Remove the drop node from its current location - dropNode.Remove(); - - //If there is no targetNode add dropNode to the bottom of - //the TreeView root nodes, otherwise add it to the end of - //the dropNode child nodes - - if (mRemoteNG.Tree.Node.GetNodeType(targetNode) == mRemoteNG.Tree.Node.Type.Root | mRemoteNG.Tree.Node.GetNodeType(targetNode) == mRemoteNG.Tree.Node.Type.Container) - { - targetNode.Nodes.Insert(0, dropNode); - } - else - { - targetNode.Parent.Nodes.Insert(targetNode.Index + 1, dropNode); - } - - if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Connection | mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Container) - { - if (mRemoteNG.Tree.Node.GetNodeType(dropNode.Parent) == mRemoteNG.Tree.Node.Type.Container) + if (n.Tag is mRemoteNG.Connection.Info) { - dropNode.Tag.Parent = dropNode.Parent.Tag; - } - else if (mRemoteNG.Tree.Node.GetNodeType(dropNode.Parent) == mRemoteNG.Tree.Node.Type.Root) - { - dropNode.Tag.Parent = null; - if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Connection) - { - dropNode.Tag.Inherit.TurnOffInheritanceCompletely(); - } - else if (mRemoteNG.Tree.Node.GetNodeType(dropNode) == mRemoteNG.Tree.Node.Type.Container) - { - dropNode.Tag.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); - } - } - } - - //Ensure the newly created node is visible to - //the user and select it - dropNode.EnsureVisible(); - selectedTreeview.SelectedNode = dropNode; - - SaveConnectionsBG(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragDrop (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - static public void tvConnections_DragEnter(object sender, DragEventArgs e) - { - try - { - //See if there is a TreeNode being dragged - if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true)) - { - //TreeNode found allow move effect - e.Effect = DragDropEffects.Move; - } - else - { - //No TreeNode found, prevent move - e.Effect = DragDropEffects.None; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragEnter (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - static public void tvConnections_DragOver(object sender, DragEventArgs e) - { - try - { - //Check that there is a TreeNode being dragged - if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true) == false) - { - return; - } - - //Get the TreeView raising the event (in case multiple on form) - TreeView selectedTreeview = (TreeView) sender; - - //As the mouse moves over nodes, provide feedback to - //the user by highlighting the node that is the - //current drop target - Point pt = ((TreeView) sender).PointToClient(new Point(e.X, e.Y)); - TreeNode targetNode = selectedTreeview.GetNodeAt(pt); - - //Select the node currently under the cursor - selectedTreeview.SelectedNode = targetNode; - - //Check that the selected node is not the dropNode and - //also that it is not a child of the dropNode and - //therefore an invalid target - TreeNode dropNode = (TreeNode) (e.Data.GetData("System.Windows.Forms.TreeNode")); - - Root.PuttySessions.Info puttyRootInfo = default(Root.PuttySessions.Info); - while (!(targetNode == null)) - { - puttyRootInfo = targetNode.Tag as Root.PuttySessions.Info; - if (puttyRootInfo != null || targetNode == dropNode) - { - e.Effect = DragDropEffects.None; - return ; - } - targetNode = targetNode.Parent; - } - - //Currently selected node is a suitable target - e.Effect = DragDropEffects.Move; - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_DragOver (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public void tvConnections_ItemDrag(object sender, ItemDragEventArgs e) - { - try - { - TreeNode dragTreeNode = e.Item as TreeNode; - if (dragTreeNode == null) - { - return ; - } - - if (dragTreeNode.Tag == null) - { - return ; - } - if (dragTreeNode.Tag is mRemoteNG.Connection.PuttySession.Info|| !(dragTreeNode.Tag is mRemoteNG.Connection.Info|| dragTreeNode.Tag is Container.Info)) - { - tvConnections.SelectedNode = dragTreeNode; - return ; - } - - //Set the drag node and initiate the DragDrop - DoDragDrop(e.Item, DragDropEffects.Move); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_ItemDrag (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Tree Context Menu - public void cMenTreeAddConnection_Click(System.Object sender, EventArgs e) - { - AddConnection(); - SaveConnectionsBG(); - } - - public void cMenTreeAddFolder_Click(System.Object sender, EventArgs e) - { - AddFolder(); - SaveConnectionsBG(); - } - - static public void cMenTreeConnect_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.DoNotJump); - } - - static public void cMenTreeConnectWithOptionsConnectToConsoleSession_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.UseConsoleSession | mRemoteNG.Connection.Info.Force.DoNotJump); - } - - static public void cMenTreeConnectWithOptionsNoCredentials_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.NoCredentials); - } - - static public void cMenTreeConnectWithOptionsDontConnectToConsoleSession_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.DontUseConsoleSession | mRemoteNG.Connection.Info.Force.DoNotJump); - } - - static public void cMenTreeConnectWithOptionsConnectInFullscreen_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.Fullscreen | mRemoteNG.Connection.Info.Force.DoNotJump); - } - - static public void cMenTreeConnectWithOptionsChoosePanelBeforeConnecting_Click(System.Object sender, EventArgs e) - { - OpenConnection(mRemoteNG.Connection.Info.Force.OverridePanel | mRemoteNG.Connection.Info.Force.DoNotJump); - } - - public void cMenTreeDisconnect_Click(System.Object sender, EventArgs e) - { - DisconnectConnection(); - } - - static public void cMenTreeToolsTransferFile_Click(System.Object sender, EventArgs e) - { - SshTransferFile(); - } - - public void mMenSortAscending_Click(System.Object sender, EventArgs e) - { - tvConnections.BeginUpdate(); - mRemoteNG.Tree.Node.Sort(tvConnections.Nodes[0], SortOrder.Ascending); - tvConnections.EndUpdate(); - SaveConnectionsBG(); - } - - public void cMenTreeToolsSortAscending_Click(System.Object sender, EventArgs e) - { - tvConnections.BeginUpdate(); - mRemoteNG.Tree.Node.Sort(tvConnections.SelectedNode, SortOrder.Ascending); - tvConnections.EndUpdate(); - SaveConnectionsBG(); - } - - public void cMenTreeToolsSortDescending_Click(System.Object sender, EventArgs e) - { - tvConnections.BeginUpdate(); - mRemoteNG.Tree.Node.Sort(tvConnections.SelectedNode, SortOrder.Descending); - tvConnections.EndUpdate(); - SaveConnectionsBG(); - } - - public void cMenTree_DropDownOpening(object sender, EventArgs e) - { - AddExternalApps(); - } - - private static void cMenTreeToolsExternalAppsEntry_Click(object sender, EventArgs e) - { - StartExternalApp(sender.Tag); - } - - public void cMenTreeDuplicate_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.CloneNode(tvConnections.SelectedNode); - SaveConnectionsBG(); - } - - static public void cMenTreeRename_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.StartRenameSelectedNode(); - SaveConnectionsBG(); - } - - static public void cMenTreeDelete_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.DeleteSelectedNode(); - SaveConnectionsBG(); - } - - static public void cMenTreeImportFile_Click(System.Object sender, EventArgs e) - { - Import.ImportFromFile(Windows.treeForm.tvConnections.Nodes[0], Windows.treeForm.tvConnections.SelectedNode, true); - } - - static public void cMenTreeImportActiveDirectory_Click(System.Object sender, EventArgs e) - { - Windows.Show(Type.ActiveDirectoryImport); - } - - static public void cMenTreeImportPortScan_Click(System.Object sender, EventArgs e) - { - Windows.Show(UI.Window.Type.PortScan, true); - } - - static public void cMenTreeExportFile_Click(System.Object sender, EventArgs e) - { - Export.ExportToFile(Windows.treeForm.tvConnections.Nodes[0], Windows.treeForm.tvConnections.SelectedNode); - } - static public void cMenTreeMoveUp_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.MoveNodeUp(); - SaveConnectionsBG(); - } - - static public void cMenTreeMoveDown_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.MoveNodeDown(); - SaveConnectionsBG(); - } -#endregion - -#region Context Menu Actions - public void AddConnection() - { - try - { - if (tvConnections.SelectedNode == null) - { - tvConnections.SelectedNode = tvConnections.Nodes[0]; - } - - TreeNode newTreeNode = mRemoteNG.Tree.Node.AddNode(mRemoteNG.Tree.Node.Type.Connection); - if (newTreeNode == null) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Tree.AddConnection() failed." + Constants.vbNewLine + "mRemoteNG.Tree.Node.AddNode() returned Nothing.", true); - return ; - } - - TreeNode containerNode = tvConnections.SelectedNode; - if (mRemoteNG.Tree.Node.GetNodeType(containerNode) == mRemoteNG.Tree.Node.Type.Connection) - { - containerNode = containerNode.Parent; - } - - mRemoteNG.Connection.Info newConnectionInfo = new mRemoteNG.Connection.Info(); - if (mRemoteNG.Tree.Node.GetNodeType(containerNode) == mRemoteNG.Tree.Node.Type.Root) - { - newConnectionInfo.Inherit.TurnOffInheritanceCompletely(); - } - else - { - newConnectionInfo.Parent = containerNode.Tag; - } - - newConnectionInfo.TreeNode = newTreeNode; - newTreeNode.Tag = newConnectionInfo; - ConnectionList.Add(newConnectionInfo); - - containerNode.Nodes.Add(newTreeNode); - - tvConnections.SelectedNode = newTreeNode; - tvConnections.SelectedNode.BeginEdit(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Tree.AddConnection() failed." + Constants.vbNewLine + ex.Message, true); - } - } - - public void AddFolder() - { - try - { - TreeNode newNode = mRemoteNG.Tree.Node.AddNode(mRemoteNG.Tree.Node.Type.Container); - Container.Info newContainerInfo = new Container.Info(); - newNode.Tag = newContainerInfo; - newContainerInfo.TreeNode = newNode; - - TreeNode selectedNode = mRemoteNG.Tree.Node.SelectedNode; - TreeNode parentNode = default(TreeNode); - if (selectedNode == null) - { - parentNode = tvConnections.Nodes[0]; - } - else - { - if (mRemoteNG.Tree.Node.GetNodeType(selectedNode) == mRemoteNG.Tree.Node.Type.Connection) - { - parentNode = selectedNode.Parent; - } - else - { - parentNode = selectedNode; - } - } - - newContainerInfo.ConnectionInfo = new mRemoteNG.Connection.Info(newContainerInfo); - newContainerInfo.ConnectionInfo.Name = newNode.Text; - - // We can only inherit from a container node, not the root node or connection nodes - if (mRemoteNG.Tree.Node.GetNodeType(parentNode) == mRemoteNG.Tree.Node.Type.Container) - { - newContainerInfo.Parent = parentNode.Tag; - } - else - { - newContainerInfo.ConnectionInfo.Inherit.TurnOffInheritanceCompletely(); - } - - ContainerList.Add(newContainerInfo); - parentNode.Nodes.Add(newNode); - - tvConnections.SelectedNode = newNode; - tvConnections.SelectedNode.BeginEdit(); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(Language.strErrorAddFolderFailed, ex.Message), true); - } - } - - private void DisconnectConnection() - { - try - { - if (tvConnections.SelectedNode != null) - { - if (tvConnections.SelectedNode.Tag is mRemoteNG.Connection.Info) - { - mRemoteNG.Connection.Info conI = tvConnections.SelectedNode.Tag; + mRemoteNG.Connection.Info conI = n.Tag; for (int i = 0; i <= conI.OpenConnections.Count - 1; i++) { conI.OpenConnections[i].Disconnect(); } } - - if (tvConnections.SelectedNode.Tag is Container.Info) - { - foreach (TreeNode n in tvConnections.SelectedNode.Nodes) - { - if (n.Tag is mRemoteNG.Connection.Info) - { - mRemoteNG.Connection.Info conI = n.Tag; - for (int i = 0; i <= conI.OpenConnections.Count - 1; i++) - { - conI.OpenConnections[i].Disconnect(); - } - } - } - } } } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "DisconnectConnection (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "DisconnectConnection (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private static void SshTransferFile() - { - try - { - Windows.Show(Type.SSHTransfer); + private static void SshTransferFile() + { + try + { + Windows.Show(Type.SSHTransfer); - mRemoteNG.Connection.Info conI = mRemoteNG.Tree.Node.SelectedNode.Tag; + mRemoteNG.Connection.Info conI = mRemoteNG.Tree.Node.SelectedNode.Tag; - Windows.sshtransferForm.Hostname = conI.Hostname; - Windows.sshtransferForm.Username = conI.Username; - Windows.sshtransferForm.Password = conI.Password; - Windows.sshtransferForm.Port = System.Convert.ToString(conI.Port); - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SSHTransferFile (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } + Windows.sshtransferForm.Hostname = conI.Hostname; + Windows.sshtransferForm.Username = conI.Username; + Windows.sshtransferForm.Password = conI.Password; + Windows.sshtransferForm.Port = System.Convert.ToString(conI.Port); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SSHTransferFile (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } - private void AddExternalApps() - { - try - { - //clean up - cMenTreeToolsExternalApps.DropDownItems.Clear(); + private void AddExternalApps() + { + try + { + //clean up + cMenTreeToolsExternalApps.DropDownItems.Clear(); - //add ext apps - foreach (Tools.ExternalTool extA in Runtime.ExternalTools) - { - ToolStripMenuItem nItem = new ToolStripMenuItem(); - nItem.Text = extA.DisplayName; - nItem.Tag = extA; + //add ext apps + foreach (Tools.ExternalTool extA in Runtime.ExternalTools) + { + ToolStripMenuItem nItem = new ToolStripMenuItem(); + nItem.Text = extA.DisplayName; + nItem.Tag = extA; - nItem.Image = extA.Image; + nItem.Image = extA.Image; - nItem.Click += cMenTreeToolsExternalAppsEntry_Click; + nItem.Click += cMenTreeToolsExternalAppsEntry_Click; - cMenTreeToolsExternalApps.DropDownItems.Add(nItem); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeTools_DropDownOpening failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); - } + cMenTreeToolsExternalApps.DropDownItems.Add(nItem); } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeTools_DropDownOpening failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); + } + } - private static void StartExternalApp(Tools.ExternalTool externalTool) + private static void StartExternalApp(Tools.ExternalTool externalTool) + { + try + { + if (mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.Connection | mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) { - try + externalTool.Start(mRemoteNG.Tree.Node.SelectedNode.Tag); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeToolsExternalAppsEntry_Click failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + + #region Menu + static public void mMenViewExpandAllFolders_Click(System.Object sender, EventArgs e) + { + mRemoteNG.Tree.Node.ExpandAllNodes(); + } + + public void mMenViewCollapseAllFolders_Click(System.Object sender, EventArgs e) + { + if (tvConnections.SelectedNode != null) + { + if (tvConnections.SelectedNode.IsEditing) + { + tvConnections.SelectedNode.EndEdit(false); + } + } + mRemoteNG.Tree.Node.CollapseAllNodes(); + } + #endregion + + #region Search + public void txtSearch_GotFocus(object sender, EventArgs e) + { + txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextColor; + if (txtSearch.Text == Language.strSearchPrompt) + { + txtSearch.Text = ""; + } + } + + public void txtSearch_LostFocus(object sender, EventArgs e) + { + if (txtSearch.Text == "") + { + txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextPromptColor; + txtSearch.Text = Language.strSearchPrompt; + } + } + + public void txtSearch_KeyDown(object sender, KeyEventArgs e) + { + try + { + if (e.KeyCode == Keys.Escape) + { + e.Handled = true; + tvConnections.Focus(); + } + else if (e.KeyCode == Keys.Up) + { + tvConnections.SelectedNode = tvConnections.SelectedNode.PrevVisibleNode; + } + else if (e.KeyCode == Keys.Down) + { + tvConnections.SelectedNode = tvConnections.SelectedNode.NextVisibleNode; + } + else + { + tvConnections_KeyDown(sender, e); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "txtSearch_KeyDown (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void txtSearch_TextChanged(System.Object sender, EventArgs e) + { + tvConnections.SelectedNode = mRemoteNG.Tree.Node.Find(tvConnections.Nodes[0], txtSearch.Text); + } + + public void tvConnections_KeyPress(object sender, KeyPressEventArgs e) + { + try + { + if (char.IsLetterOrDigit(e.KeyChar)) + { + txtSearch.Text = e.KeyChar.ToString(); + + txtSearch.Focus(); + txtSearch.SelectionStart = txtSearch.TextLength; + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_KeyPress (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + + public void tvConnections_KeyDown(object sender, KeyEventArgs e) + { + try + { + if (e.KeyCode == Keys.Enter) + { + if (tvConnections.SelectedNode.Tag is mRemoteNG.Connection.Info) { - if (mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.Connection | mRemoteNG.Tree.Node.GetNodeType(mRemoteNG.Tree.Node.SelectedNode) == mRemoteNG.Tree.Node.Type.PuttySession) + e.Handled = true; + OpenConnection(); + } + else + { + if (tvConnections.SelectedNode.IsExpanded) { - externalTool.Start(mRemoteNG.Tree.Node.SelectedNode.Tag); - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "cMenTreeToolsExternalAppsEntry_Click failed (UI.Window.Tree)" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion - -#region Menu - static public void mMenViewExpandAllFolders_Click(System.Object sender, EventArgs e) - { - mRemoteNG.Tree.Node.ExpandAllNodes(); - } - - public void mMenViewCollapseAllFolders_Click(System.Object sender, EventArgs e) - { - if (tvConnections.SelectedNode != null) - { - if (tvConnections.SelectedNode.IsEditing) - { - tvConnections.SelectedNode.EndEdit(false); - } - } - mRemoteNG.Tree.Node.CollapseAllNodes(); - } -#endregion - -#region Search - public void txtSearch_GotFocus(object sender, EventArgs e) - { - txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextColor; - if (txtSearch.Text == Language.strSearchPrompt) - { - txtSearch.Text = ""; - } - } - - public void txtSearch_LostFocus(object sender, EventArgs e) - { - if (txtSearch.Text == "") - { - txtSearch.ForeColor = Themes.ThemeManager.ActiveTheme.SearchBoxTextPromptColor; - txtSearch.Text = Language.strSearchPrompt; - } - } - - public void txtSearch_KeyDown(object sender, KeyEventArgs e) - { - try - { - if (e.KeyCode == Keys.Escape) - { - e.Handled = true; - tvConnections.Focus(); - } - else if (e.KeyCode == Keys.Up) - { - tvConnections.SelectedNode = tvConnections.SelectedNode.PrevVisibleNode; - } - else if (e.KeyCode == Keys.Down) - { - tvConnections.SelectedNode = tvConnections.SelectedNode.NextVisibleNode; + tvConnections.SelectedNode.Collapse(true); } else { - tvConnections_KeyDown(sender, e); + tvConnections.SelectedNode.Expand(); } } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "txtSearch_KeyDown (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } } - - public void txtSearch_TextChanged(System.Object sender, EventArgs e) + else if (e.KeyCode == Keys.Escape ^ e.KeyCode == Keys.Control | e.KeyCode == Keys.F) { - tvConnections.SelectedNode = mRemoteNG.Tree.Node.Find(tvConnections.Nodes[0], txtSearch.Text); + txtSearch.Focus(); + txtSearch.SelectionStart = txtSearch.TextLength; } - - public void tvConnections_KeyPress(object sender, KeyPressEventArgs e) - { - try - { - if (char.IsLetterOrDigit(e.KeyChar)) - { - txtSearch.Text = e.KeyChar.ToString(); - - txtSearch.Focus(); - txtSearch.SelectionStart = txtSearch.TextLength; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_KeyPress (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } - - public void tvConnections_KeyDown(object sender, KeyEventArgs e) - { - try - { - if (e.KeyCode == Keys.Enter) - { - if (tvConnections.SelectedNode.Tag is mRemoteNG.Connection.Info) - { - e.Handled = true; - OpenConnection(); - } - else - { - if (tvConnections.SelectedNode.IsExpanded) - { - tvConnections.SelectedNode.Collapse(true); - } - else - { - tvConnections.SelectedNode.Expand(); - } - } - } - else if (e.KeyCode == Keys.Escape ^ e.KeyCode == Keys.Control | e.KeyCode == Keys.F) - { - txtSearch.Focus(); - txtSearch.SelectionStart = txtSearch.TextLength; - } - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_KeyDown (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); - } - } -#endregion } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "tvConnections_KeyDown (UI.Window.Tree) failed" + Constants.vbNewLine + ex.Message, true); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/UI/UI.Window.UltraVNCSC.cs b/mRemoteV1/CS/UI/UI.Window.UltraVNCSC.cs index fde13c4b2..28fda5209 100644 --- a/mRemoteV1/CS/UI/UI.Window.UltraVNCSC.cs +++ b/mRemoteV1/CS/UI/UI.Window.UltraVNCSC.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,162 +8,160 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - +using mRemoteNG.App; using WeifenLuo.WinFormsUI.Docking; -//using mRemoteNG.App.Runtime; namespace mRemoteNG.UI.Window { public class UltraVNCSC : Base + { + + #region Form Init + internal System.Windows.Forms.ToolStrip tsMain; + internal System.Windows.Forms.Panel pnlContainer; + internal System.Windows.Forms.ToolStripButton btnDisconnect; + + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UltraVNCSC)); + this.tsMain = new System.Windows.Forms.ToolStrip(); + this.Load += new System.EventHandler(UltraVNCSC_Load); + this.btnDisconnect = new System.Windows.Forms.ToolStripButton(); + this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click); + this.pnlContainer = new System.Windows.Forms.Panel(); + this.tsMain.SuspendLayout(); + this.SuspendLayout(); + // + //tsMain + // + this.tsMain.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.tsMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.btnDisconnect}); + this.tsMain.Location = new System.Drawing.Point(0, 0); + this.tsMain.Name = "tsMain"; + this.tsMain.Size = new System.Drawing.Size(446, 25); + this.tsMain.TabIndex = 0; + this.tsMain.Text = "ToolStrip1"; + // + //btnDisconnect + // + this.btnDisconnect.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.btnDisconnect.Image = (System.Drawing.Image) (resources.GetObject("btnDisconnect.Image")); + this.btnDisconnect.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnDisconnect.Name = "btnDisconnect"; + this.btnDisconnect.Size = new System.Drawing.Size(63, 22); + this.btnDisconnect.Text = "Disconnect"; + // + //pnlContainer + // + this.pnlContainer.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right); + this.pnlContainer.Location = new System.Drawing.Point(0, 27); + this.pnlContainer.Name = "pnlContainer"; + this.pnlContainer.Size = new System.Drawing.Size(446, 335); + this.pnlContainer.TabIndex = 1; + // + //UltraVNCSC + // + this.ClientSize = new System.Drawing.Size(446, 362); + this.Controls.Add(this.pnlContainer); + this.Controls.Add(this.tsMain); + this.Icon = global::My.Resources.UVNC_SC_Icon; + this.Name = "UltraVNCSC"; + this.TabText = "UltraVNC SC"; + this.Text = "UltraVNC SC"; + this.tsMain.ResumeLayout(false); + this.tsMain.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + #region Declarations + //Private WithEvents vnc As AxCSC_ViewerXControl + #endregion + + #region Public Methods + public UltraVNCSC(DockContent Panel) + { + this.WindowType = Type.UltraVNCSC; + this.DockPnl = Panel; + this.InitializeComponent(); + } + #endregion + + #region Private Methods + private void UltraVNCSC_Load(object sender, System.EventArgs e) + { + ApplyLanguage(); + + StartListening(); + } + + private void ApplyLanguage() + { + btnDisconnect.Text = My.Language.strButtonDisconnect; + } + + private void StartListening() + { + try { - -#region Form Init - internal System.Windows.Forms.ToolStrip tsMain; - internal System.Windows.Forms.Panel pnlContainer; - internal System.Windows.Forms.ToolStripButton btnDisconnect; - - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UltraVNCSC)); - this.tsMain = new System.Windows.Forms.ToolStrip(); - this.Load += new System.EventHandler(UltraVNCSC_Load); - this.btnDisconnect = new System.Windows.Forms.ToolStripButton(); - this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click); - this.pnlContainer = new System.Windows.Forms.Panel(); - this.tsMain.SuspendLayout(); - this.SuspendLayout(); - // - //tsMain - // - this.tsMain.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.tsMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.btnDisconnect}); - this.tsMain.Location = new System.Drawing.Point(0, 0); - this.tsMain.Name = "tsMain"; - this.tsMain.Size = new System.Drawing.Size(446, 25); - this.tsMain.TabIndex = 0; - this.tsMain.Text = "ToolStrip1"; - // - //btnDisconnect - // - this.btnDisconnect.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.btnDisconnect.Image = (System.Drawing.Image) (resources.GetObject("btnDisconnect.Image")); - this.btnDisconnect.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnDisconnect.Name = "btnDisconnect"; - this.btnDisconnect.Size = new System.Drawing.Size(63, 22); - this.btnDisconnect.Text = "Disconnect"; - // - //pnlContainer - // - this.pnlContainer.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pnlContainer.Location = new System.Drawing.Point(0, 27); - this.pnlContainer.Name = "pnlContainer"; - this.pnlContainer.Size = new System.Drawing.Size(446, 335); - this.pnlContainer.TabIndex = 1; - // - //UltraVNCSC - // - this.ClientSize = new System.Drawing.Size(446, 362); - this.Controls.Add(this.pnlContainer); - this.Controls.Add(this.tsMain); - this.Icon = global::My.Resources.UVNC_SC_Icon; - this.Name = "UltraVNCSC"; - this.TabText = "UltraVNC SC"; - this.Text = "UltraVNC SC"; - this.tsMain.ResumeLayout(false); - this.tsMain.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } -#endregion - -#region Declarations - //Private WithEvents vnc As AxCSC_ViewerXControl -#endregion - -#region Public Methods - public UltraVNCSC(DockContent Panel) - { - this.WindowType = Type.UltraVNCSC; - this.DockPnl = Panel; - this.InitializeComponent(); - } -#endregion - -#region Private Methods - private void UltraVNCSC_Load(object sender, System.EventArgs e) - { - ApplyLanguage(); - - StartListening(); - } - - private void ApplyLanguage() - { - btnDisconnect.Text = My.Language.strButtonDisconnect; - } - - private void StartListening() - { - try - { - //If vnc IsNot Nothing Then - // vnc.Dispose() - // vnc = Nothing - //End If + //If vnc IsNot Nothing Then + // vnc.Dispose() + // vnc = Nothing + //End If - //vnc = New AxCSC_ViewerXControl() - //SetupLicense() + //vnc = New AxCSC_ViewerXControl() + //SetupLicense() - //vnc.Parent = pnlContainer - //vnc.Dock = DockStyle.Fill - //vnc.Show() + //vnc.Parent = pnlContainer + //vnc.Dock = DockStyle.Fill + //vnc.Show() - //vnc.StretchMode = ViewerX.ScreenStretchMode.SSM_ASPECT - //vnc.ListeningText = My.Language.strInheritListeningForIncomingVNCConnections & " " & My.Settings.UVNCSCPort + //vnc.StretchMode = ViewerX.ScreenStretchMode.SSM_ASPECT + //vnc.ListeningText = My.Language.strInheritListeningForIncomingVNCConnections & " " & My.Settings.UVNCSCPort - //vnc.ListenEx(My.Settings.UVNCSCPort) - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartListening (UI.Window.UltraVNCSC) failed" + Constants.vbNewLine + ex.Message, false); - Close(); - } - } - - private void SetupLicense() - { - try - { - //Dim f As System.Reflection.FieldInfo - //f = GetType(AxHost).GetField("licenseKey", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance) - //f.SetValue(vnc, "{072169039103041044176252035252117103057101225235137221179204110241121074}") - } - catch (Exception ex) - { - MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "VNC SetupLicense failed (UI.Window.UltraVNCSC)" + Constants.vbNewLine + ex.Message, true); - } - } - - //Private Sub vnc_ConnectionAccepted(ByVal sender As Object, ByVal e As AxViewerX._ISmartCodeVNCViewerEvents_ConnectionAcceptedEvent) Handles vnc.ConnectionAccepted - // mC.AddMessage(Messages.MessageClass.InformationMsg, e.bstrServerAddress & " is now connected to your UltraVNC SingleClick panel!") - //End Sub - - //Private Sub vnc_Disconnected(ByVal sender As Object, ByVal e As System.EventArgs) Handles vnc.Disconnected - // StartListening() - //End Sub - - private void btnDisconnect_Click(System.Object sender, System.EventArgs e) - { - //vnc.Dispose() - Dispose(); - App.Runtime.Windows.Show(Type.UltraVNCSC); - } -#endregion - + //vnc.ListenEx(My.Settings.UVNCSCPort) } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "StartListening (UI.Window.UltraVNCSC) failed" + Constants.vbNewLine + ex.Message, false); + Close(); + } + } + + private void SetupLicense() + { + try + { + //Dim f As System.Reflection.FieldInfo + //f = GetType(AxHost).GetField("licenseKey", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance) + //f.SetValue(vnc, "{072169039103041044176252035252117103057101225235137221179204110241121074}") + } + catch (Exception ex) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "VNC SetupLicense failed (UI.Window.UltraVNCSC)" + Constants.vbNewLine + ex.Message, true); + } + } + + //Private Sub vnc_ConnectionAccepted(ByVal sender As Object, ByVal e As AxViewerX._ISmartCodeVNCViewerEvents_ConnectionAcceptedEvent) Handles vnc.ConnectionAccepted + // mC.AddMessage(Messages.MessageClass.InformationMsg, e.bstrServerAddress & " is now connected to your UltraVNC SingleClick panel!") + //End Sub + + //Private Sub vnc_Disconnected(ByVal sender As Object, ByVal e As System.EventArgs) Handles vnc.Disconnected + // StartListening() + //End Sub + + private void btnDisconnect_Click(System.Object sender, System.EventArgs e) + { + //vnc.Dispose() + Dispose(); + Runtime.Windows.Show(Type.UltraVNCSC); + } + #endregion + + } } diff --git a/mRemoteV1/CS/UI/UI.Window.Update.cs b/mRemoteV1/CS/UI/UI.Window.Update.cs index 29ab8977f..5d45706d8 100644 --- a/mRemoteV1/CS/UI/UI.Window.Update.cs +++ b/mRemoteV1/CS/UI/UI.Window.Update.cs @@ -1,4 +1,3 @@ -// VBConversions Note: VB project level imports using System.Collections.Generic; using System; using AxWFICALib; @@ -9,273 +8,271 @@ using AxMSTSCLib; using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; -// End of VB project level imports - using System.ComponentModel; using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; using System.IO; -//using mRemoteNG.App.Runtime; +using mRemoteNG.App; namespace mRemoteNG.UI.Window { public partial class Update : Base + { + #region Public Methods + public Update(DockContent panel) + { + WindowType = Type.Update; + DockPnl = panel; + InitializeComponent(); + FontOverride(this); + } + #endregion + + #region Form Stuff + public void Update_Load(object sender, EventArgs e) + { + ApplyLanguage(); + CheckForUpdate(); + } + + private void ApplyLanguage() + { + Text = Language.strMenuCheckForUpdates; + TabText = Language.strMenuCheckForUpdates; + btnCheckForUpdate.Text = Language.strCheckForUpdate; + btnDownload.Text = Language.strDownloadAndInstall; + lblChangeLogLabel.Text = Language.strLabelChangeLog; + lblInstalledVersion.Text = Language.strVersion; + lblInstalledVersionLabel.Text = string.Format("{0}:", Language.strCurrentVersion); + lblLatestVersion.Text = Language.strVersion; + lblLatestVersionLabel.Text = string.Format("{0}:", Language.strAvailableVersion); + } + + public void btnCheckForUpdate_Click(System.Object sender, EventArgs e) + { + CheckForUpdate(); + } + + public void btnDownload_Click(System.Object sender, EventArgs e) + { + DownloadUpdate(); + } + + public void pbUpdateImage_Click(System.Object sender, EventArgs e) + { + Uri linkUri = pbUpdateImage.Tag as Uri; + if (linkUri == null || linkUri.IsFile || linkUri.IsUnc || linkUri.IsLoopback) { -#region Public Methods - public Update(DockContent panel) - { - WindowType = Type.Update; - DockPnl = panel; - InitializeComponent(); - FontOverride(this); - } -#endregion + return ; + } + Process.Start(linkUri.ToString()); + } + #endregion -#region Form Stuff - public void Update_Load(object sender, EventArgs e) - { - ApplyLanguage(); - CheckForUpdate(); - } + #region Private Fields + private App.Update _appUpdate; + private bool _isUpdateDownloadHandlerDeclared = false; + #endregion - private void ApplyLanguage() - { - Text = Language.strMenuCheckForUpdates; - TabText = Language.strMenuCheckForUpdates; - btnCheckForUpdate.Text = Language.strCheckForUpdate; - btnDownload.Text = Language.strDownloadAndInstall; - lblChangeLogLabel.Text = Language.strLabelChangeLog; - lblInstalledVersion.Text = Language.strVersion; - lblInstalledVersionLabel.Text = string.Format("{0}:", Language.strCurrentVersion); - lblLatestVersion.Text = Language.strVersion; - lblLatestVersionLabel.Text = string.Format("{0}:", Language.strAvailableVersion); - } - - public void btnCheckForUpdate_Click(System.Object sender, EventArgs e) - { - CheckForUpdate(); - } - - public void btnDownload_Click(System.Object sender, EventArgs e) - { - DownloadUpdate(); - } - - public void pbUpdateImage_Click(System.Object sender, EventArgs e) - { - Uri linkUri = pbUpdateImage.Tag as Uri; - if (linkUri == null || linkUri.IsFile || linkUri.IsUnc || linkUri.IsLoopback) - { - return ; - } - Process.Start(linkUri.ToString()); - } -#endregion - -#region Private Fields - private App.Update _appUpdate; - private bool _isUpdateDownloadHandlerDeclared = false; -#endregion - -#region Private Methods - private void CheckForUpdate() - { - if (_appUpdate == null) - { - _appUpdate = new App.Update(); - _appUpdate.Load += _appUpdate.Update_Load; - } - else if (_appUpdate.IsGetUpdateInfoRunning) - { - return ; - } + #region Private Methods + private void CheckForUpdate() + { + if (_appUpdate == null) + { + _appUpdate = new App.Update(); + _appUpdate.Load += _appUpdate.Update_Load; + } + else if (_appUpdate.IsGetUpdateInfoRunning) + { + return ; + } - lblStatus.Text = Language.strUpdateCheckingLabel; - lblStatus.ForeColor = SystemColors.WindowText; - lblLatestVersionLabel.Visible = false; - lblInstalledVersion.Visible = false; - lblInstalledVersionLabel.Visible = false; - lblLatestVersion.Visible = false; - btnCheckForUpdate.Visible = false; - pnlUpdate.Visible = false; + lblStatus.Text = Language.strUpdateCheckingLabel; + lblStatus.ForeColor = SystemColors.WindowText; + lblLatestVersionLabel.Visible = false; + lblInstalledVersion.Visible = false; + lblInstalledVersionLabel.Visible = false; + lblLatestVersion.Visible = false; + btnCheckForUpdate.Visible = false; + pnlUpdate.Visible = false; - _appUpdate.GetUpdateInfoCompletedEvent += GetUpdateInfoCompleted; + _appUpdate.GetUpdateInfoCompletedEvent += GetUpdateInfoCompleted; - _appUpdate.GetUpdateInfoAsync(); - } + _appUpdate.GetUpdateInfoAsync(); + } - private void GetUpdateInfoCompleted(object sender, AsyncCompletedEventArgs e) - { - if (InvokeRequired) - { - AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetUpdateInfoCompleted); - Invoke(myDelegate, new object[] {sender, e}); - return ; - } + private void GetUpdateInfoCompleted(object sender, AsyncCompletedEventArgs e) + { + if (InvokeRequired) + { + AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetUpdateInfoCompleted); + Invoke(myDelegate, new object[] {sender, e}); + return ; + } - try - { - _appUpdate.GetUpdateInfoCompletedEvent -= GetUpdateInfoCompleted; + try + { + _appUpdate.GetUpdateInfoCompletedEvent -= GetUpdateInfoCompleted; - lblInstalledVersion.Text = System.Convert.ToString(Application.Info.Version.ToString()); - lblInstalledVersion.Visible = true; - lblInstalledVersionLabel.Visible = true; - btnCheckForUpdate.Visible = true; + lblInstalledVersion.Text = System.Convert.ToString(Application.Info.Version.ToString()); + lblInstalledVersion.Visible = true; + lblInstalledVersionLabel.Visible = true; + btnCheckForUpdate.Visible = true; - if (e.Cancelled) - { - return ; - } - if (e.Error != null) - { - throw (e.Error); - } + if (e.Cancelled) + { + return ; + } + if (e.Error != null) + { + throw (e.Error); + } - if (_appUpdate.IsUpdateAvailable()) - { - lblStatus.Text = Language.strUpdateAvailable; - lblStatus.ForeColor = Color.OrangeRed; - pnlUpdate.Visible = true; + if (_appUpdate.IsUpdateAvailable()) + { + lblStatus.Text = Language.strUpdateAvailable; + lblStatus.ForeColor = Color.OrangeRed; + pnlUpdate.Visible = true; - App.Update.UpdateInfo updateInfo = _appUpdate.CurrentUpdateInfo; + App.Update.UpdateInfo updateInfo = _appUpdate.CurrentUpdateInfo; + lblLatestVersion.Text = updateInfo.Version.ToString(); + lblLatestVersionLabel.Visible = true; + lblLatestVersion.Visible = true; + + if (updateInfo.ImageAddress == null || string.IsNullOrEmpty(updateInfo.ImageAddress.ToString())) + { + pbUpdateImage.Visible = false; + } + else + { + pbUpdateImage.ImageLocation = updateInfo.ImageAddress.ToString(); + pbUpdateImage.Tag = updateInfo.ImageLinkAddress; + pbUpdateImage.Visible = true; + } + + _appUpdate.GetChangeLogCompletedEvent += GetChangeLogCompleted; + _appUpdate.GetChangeLogAsync(); + + btnDownload.Focus(); + } + else + { + lblStatus.Text = Language.strNoUpdateAvailable; + lblStatus.ForeColor = Color.ForestGreen; + + if (_appUpdate.CurrentUpdateInfo != null) + { + App.Update.UpdateInfo updateInfo = _appUpdate.CurrentUpdateInfo; + if (updateInfo.IsValid && updateInfo.Version != null) + { lblLatestVersion.Text = updateInfo.Version.ToString(); lblLatestVersionLabel.Visible = true; lblLatestVersion.Visible = true; - - if (updateInfo.ImageAddress == null || string.IsNullOrEmpty(updateInfo.ImageAddress.ToString())) - { - pbUpdateImage.Visible = false; - } - else - { - pbUpdateImage.ImageLocation = updateInfo.ImageAddress.ToString(); - pbUpdateImage.Tag = updateInfo.ImageLinkAddress; - pbUpdateImage.Visible = true; - } - - _appUpdate.GetChangeLogCompletedEvent += GetChangeLogCompleted; - _appUpdate.GetChangeLogAsync(); - - btnDownload.Focus(); } - else - { - lblStatus.Text = Language.strNoUpdateAvailable; - lblStatus.ForeColor = Color.ForestGreen; - - if (_appUpdate.CurrentUpdateInfo != null) - { - App.Update.UpdateInfo updateInfo = _appUpdate.CurrentUpdateInfo; - if (updateInfo.IsValid && updateInfo.Version != null) - { - lblLatestVersion.Text = updateInfo.Version.ToString(); - lblLatestVersionLabel.Visible = true; - lblLatestVersion.Visible = true; - } - } - } - } - catch (Exception ex) - { - lblStatus.Text = Language.strUpdateCheckFailedLabel; - lblStatus.ForeColor = Color.OrangeRed; - - MessageCollector.AddExceptionMessage(Language.strUpdateCheckCompleteFailed, ex); } } - - private void GetChangeLogCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - if (InvokeRequired) - { - AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetChangeLogCompleted); - Invoke(myDelegate, new object[] {sender, e}); - return ; - } - - try - { - _appUpdate.GetChangeLogCompletedEvent -= GetChangeLogCompleted; - - if (e.Cancelled) - { - return ; - } - if (e.Error != null) - { - throw (e.Error); - } - - txtChangeLog.Text = _appUpdate.ChangeLog; - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(Language.strUpdateGetChangeLogFailed, ex); - } - } - - private void DownloadUpdate() - { - try - { - btnDownload.Enabled = false; - prgbDownload.Visible = true; - prgbDownload.Value = 0; - - if (_isUpdateDownloadHandlerDeclared == false) - { - _appUpdate.DownloadUpdateProgressChangedEvent += DownloadUpdateProgressChanged; - _appUpdate.DownloadUpdateCompletedEvent += DownloadUpdateCompleted; - _isUpdateDownloadHandlerDeclared = true; - } - - _appUpdate.DownloadUpdateAsync(); - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(Language.strUpdateDownloadFailed, ex); - } - } -#endregion - -#region Events - private void DownloadUpdateProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e) - { - prgbDownload.Value = e.ProgressPercentage; - } - - private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - try - { - btnDownload.Enabled = true; - prgbDownload.Visible = false; - - if (e.Cancelled) - { - return ; - } - if (e.Error != null) - { - throw (e.Error); - } - - if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) - { - Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath); - return ; - } - else - { - File.Delete(_appUpdate.CurrentUpdateInfo.UpdateFilePath); - } - } - catch (Exception ex) - { - MessageCollector.AddExceptionMessage(Language.strUpdateDownloadCompleteFailed, ex); - } - } -#endregion } + catch (Exception ex) + { + lblStatus.Text = Language.strUpdateCheckFailedLabel; + lblStatus.ForeColor = Color.OrangeRed; + + Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateCheckCompleteFailed, ex); + } + } + + private void GetChangeLogCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + { + if (InvokeRequired) + { + AsyncCompletedEventHandler myDelegate = new AsyncCompletedEventHandler(GetChangeLogCompleted); + Invoke(myDelegate, new object[] {sender, e}); + return ; + } + + try + { + _appUpdate.GetChangeLogCompletedEvent -= GetChangeLogCompleted; + + if (e.Cancelled) + { + return ; + } + if (e.Error != null) + { + throw (e.Error); + } + + txtChangeLog.Text = _appUpdate.ChangeLog; + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateGetChangeLogFailed, ex); + } + } + + private void DownloadUpdate() + { + try + { + btnDownload.Enabled = false; + prgbDownload.Visible = true; + prgbDownload.Value = 0; + + if (_isUpdateDownloadHandlerDeclared == false) + { + _appUpdate.DownloadUpdateProgressChangedEvent += DownloadUpdateProgressChanged; + _appUpdate.DownloadUpdateCompletedEvent += DownloadUpdateCompleted; + _isUpdateDownloadHandlerDeclared = true; + } + + _appUpdate.DownloadUpdateAsync(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateDownloadFailed, ex); + } + } + #endregion + + #region Events + private void DownloadUpdateProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e) + { + prgbDownload.Value = e.ProgressPercentage; + } + + private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + { + try + { + btnDownload.Enabled = true; + prgbDownload.Visible = false; + + if (e.Cancelled) + { + return ; + } + if (e.Error != null) + { + throw (e.Error); + } + + if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) + { + Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath); + return ; + } + else + { + File.Delete(_appUpdate.CurrentUpdateInfo.UpdateFilePath); + } + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateDownloadCompleteFailed, ex); + } + } + #endregion + } } diff --git a/mRemoteV1/CS/mRemoteV1.v12.suo b/mRemoteV1/CS/mRemoteV1.v12.suo index f3b968181..bae31ba9d 100644 Binary files a/mRemoteV1/CS/mRemoteV1.v12.suo and b/mRemoteV1/CS/mRemoteV1.v12.suo differ diff --git a/mRemoteV1/CS/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache b/mRemoteV1/CS/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache index cf1588193..4755e215e 100644 Binary files a/mRemoteV1/CS/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache and b/mRemoteV1/CS/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/mRemoteV1/CS/obj/Debug Portable/Interop.WFICALib.dll b/mRemoteV1/CS/obj/Debug Portable/Interop.WFICALib.dll index 876f40d41..a026cf52b 100644 Binary files a/mRemoteV1/CS/obj/Debug Portable/Interop.WFICALib.dll and b/mRemoteV1/CS/obj/Debug Portable/Interop.WFICALib.dll differ diff --git a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.GenerateResource.Cache b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.GenerateResource.Cache index 21a6e438e..c97090bd0 100644 Binary files a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.GenerateResource.Cache and b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.GenerateResource.Cache differ diff --git a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.ResolveComReference.cache b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.ResolveComReference.cache index 1da81edaa..dd2d9b9f0 100644 Binary files a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.ResolveComReference.cache and b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csproj.ResolveComReference.cache differ diff --git a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csprojResolveAssemblyReference.cache b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csprojResolveAssemblyReference.cache index 5575c61bf..4e5b3a090 100644 Binary files a/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csprojResolveAssemblyReference.cache and b/mRemoteV1/CS/obj/Debug Portable/mRemoteV1.csprojResolveAssemblyReference.cache differ diff --git a/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferences.cache b/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferences.cache index 1ce41ddac..83df2b7f9 100644 Binary files a/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferences.cache and b/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferences.cache differ diff --git a/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache b/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache index d12272501..47aa13a08 100644 Binary files a/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache and b/mRemoteV1/obj/Debug Portable/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/mRemoteV1/obj/Debug Portable/Interop.WFICALib.dll b/mRemoteV1/obj/Debug Portable/Interop.WFICALib.dll index b0b26acfe..355cb0f76 100644 Binary files a/mRemoteV1/obj/Debug Portable/Interop.WFICALib.dll and b/mRemoteV1/obj/Debug Portable/Interop.WFICALib.dll differ diff --git a/mRemoteV1/obj/Debug Portable/mRemoteV1.vbproj.ResolveComReference.cache b/mRemoteV1/obj/Debug Portable/mRemoteV1.vbproj.ResolveComReference.cache index 1da81edaa..dd2d9b9f0 100644 Binary files a/mRemoteV1/obj/Debug Portable/mRemoteV1.vbproj.ResolveComReference.cache and b/mRemoteV1/obj/Debug Portable/mRemoteV1.vbproj.ResolveComReference.cache differ