Permalink
Browse files

Make improvement MR-250 - Show the name of the selected connection ta…

…b in the title of the window
  • Loading branch information...
1 parent 771855f commit c9ca613348fa4c395817115f2382844ff6c01022 @rmcardle rmcardle committed Nov 20, 2013
View
@@ -4,6 +4,7 @@
Added feature MR-212 - Add option to connect without credentials
Added feature MR-512 - Add support for importing files from Remote Desktop Connection Manager
Added feature MR-547 - Add support for Xming Portable PuTTY
+ Made improvement MR-250 - Show the name of the selected connection tab in the title of the window
Made improvement MR-367 - Make the 'Connect' button on the 'Quick Connect' toolbar a forced dropdown
Made improvement MR-419 - Password prompt dialog should have a meaningful window title
Made improvement MR-486 - Allow escaping of variable names for external tools
@@ -1811,6 +1811,8 @@ Namespace App
End If
End If
End If
+
+ frmMain.SelectedConnection = newConnectionInfo
Catch ex As Exception
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionOpenFailed & vbNewLine & ex.Message)
End Try
@@ -1985,34 +1987,6 @@ Namespace App
End Try
End Function
- Public Shared Sub SetMainFormText(Optional ByVal ConnectionFileName As String = "")
- Try
- Dim txt As String = My.Application.Info.ProductName
-
- If ConnectionFileName <> "" And IsConnectionsFileLoaded = True Then
- If My.Settings.ShowCompleteConsPathInTitle Then
- txt &= " - " & ConnectionFileName
- Else
- txt &= " - " & ConnectionFileName.Substring(ConnectionFileName.LastIndexOf("\") + 1)
- End If
- End If
-
- ChangeMainFormText(txt)
- Catch ex As Exception
- MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strSettingMainFormTextFailed & vbNewLine & ex.Message, True)
- End Try
- End Sub
-
- Private Delegate Sub ChangeMainFormTextCB(ByVal Text As String)
- Private Shared Sub ChangeMainFormText(ByVal Text As String)
- If frmMain.InvokeRequired = True Then
- Dim d As New ChangeMainFormTextCB(AddressOf ChangeMainFormText)
- frmMain.Invoke(d, New Object() {Text})
- Else
- frmMain.Text = Text
- End If
- End Sub
-
Public Shared Function FindConnectionContainer(ByVal ConI As Connection.Info) As Connection.InterfaceControl
If ConI.OpenConnections.Count > 0 Then
For i As Integer = 0 To WindowList.Count - 1
@@ -141,18 +141,17 @@ Namespace Config
#Region "Public Methods"
Public Sub Load(ByVal import As Boolean)
- If _UseSQL = True Then
+ If UseSQL Then
LoadFromSQL()
- SetMainFormText("SQL Server")
Else
- Dim strCons As String = DecryptCompleteFile()
- LoadFromXML(strCons, import)
+ Dim connections As String = DecryptCompleteFile()
+ LoadFromXML(connections, import)
End If
- If import = False Then
- SetMainFormText(ConnectionFileName)
- Putty.Sessions.AddSessionsToTree()
- End If
+ frmMain.UsingSqlServer = UseSQL
+ frmMain.ConnectionsFileName = ConnectionFileName
+
+ If Not import Then Putty.Sessions.AddSessionsToTree()
End Sub
#End Region
@@ -51,7 +51,6 @@ Namespace Config
Select Case SaveFormat
Case Format.SQL
SaveToSQL()
- SetMainFormText("SQL Server")
Case Format.mRCSV
SaveTomRCSV()
Case Format.vRDvRE
@@ -63,8 +62,9 @@ Namespace Config
If My.Settings.EncryptCompleteConnectionsFile Then
EncryptCompleteFile()
End If
- If Not _Export Then SetMainFormText(ConnectionFileName)
+ If Not Export Then frmMain.ConnectionsFileName = ConnectionFileName
End Select
+ frmMain.UsingSqlServer = (SaveFormat = Format.SQL)
End Sub
#End Region
@@ -55,6 +55,7 @@ Namespace Forms.OptionsPages
Settings.ShowDescriptionTooltipsInTree = chkShowDescriptionTooltipsInTree.Checked
Settings.ShowCompleteConsPathInTitle = chkShowFullConnectionsFilePathInTitle.Checked
+ frmMain.ShowFullPathInTitle = chkShowFullConnectionsFilePathInTitle.Checked
Settings.ShowSystemTrayIcon = chkShowSystemTrayIcon.Checked
If Settings.ShowSystemTrayIcon Then
@@ -46,11 +46,9 @@ Namespace Forms.OptionsPages
My.Settings.SQLPass = Crypt.Encrypt(txtSQLPassword.Text, General.EncryptionKey)
Runtime.Startup.DestroySQLUpdateHandlerAndStopTimer()
+ frmMain.UsingSqlServer = My.Settings.UseSQLServer
If My.Settings.UseSQLServer Then
- Runtime.SetMainFormText("SQL Server")
Runtime.Startup.CreateSQLUpdateHandlerAndStartTimer()
- Else
- Runtime.SetMainFormText(Runtime.GetStartupConnectionFileName())
End If
End Sub
View
@@ -1,4 +1,7 @@
+Imports System.IO
+Imports mRemoteNG.My
Imports SharedLibraryNG
+Imports System.Text
Imports WeifenLuo.WinFormsUI.Docking
Imports mRemoteNG.App.Runtime
Imports System.Reflection
@@ -29,6 +32,54 @@ Public Class frmMain
Return _isClosing
End Get
End Property
+
+ Private _usingSqlServer As Boolean = False
+ Public Property UsingSqlServer As Boolean
+ Get
+ Return _usingSqlServer
+ End Get
+ Set(value As Boolean)
+ If _usingSqlServer = value Then Return
+ _usingSqlServer = value
+ UpdateWindowTitle()
+ End Set
+ End Property
+
+ Private _connectionsFileName As String = Nothing
+ Public Property ConnectionsFileName As String
+ Get
+ Return _connectionsFileName
+ End Get
+ Set(value As String)
+ If _connectionsFileName = value Then Return
+ _connectionsFileName = value
+ UpdateWindowTitle()
+ End Set
+ End Property
+
+ Private _showFullPathInTitle As Boolean = My.Settings.ShowCompleteConsPathInTitle
+ Public Property ShowFullPathInTitle As Boolean
+ Get
+ Return _showFullPathInTitle
+ End Get
+ Set(value As Boolean)
+ If _showFullPathInTitle = value Then Return
+ _showFullPathInTitle = value
+ UpdateWindowTitle()
+ End Set
+ End Property
+
+ Private _selectedConnection As Connection.Info = Nothing
+ Public Property SelectedConnection As Connection.Info
+ Get
+ Return _selectedConnection
+ End Get
+ Set(value As Connection.Info)
+ If _selectedConnection Is value Then Return
+ _selectedConnection = value
+ UpdateWindowTitle()
+ End Set
+ End Property
#End Region
#Region "Startup & Shutdown"
@@ -77,7 +128,7 @@ Public Class frmMain
'LoadCredentials()
LoadConnections()
If Not IsConnectionsFileLoaded Then
- Application.Exit()
+ System.Windows.Forms.Application.Exit()
Return
End If
@@ -875,8 +926,43 @@ Public Class frmMain
End If
End Sub
- Private Sub pnlDock_ActiveDocumentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlDock.ActiveDocumentChanged
+ Private Sub pnlDock_ActiveDocumentChanged(ByVal sender As Object, ByVal e As EventArgs) Handles pnlDock.ActiveDocumentChanged
ActivateConnection()
+ Dim connectionWindow As UI.Window.Connection = TryCast(pnlDock.ActiveDocument, UI.Window.Connection)
+ If connectionWindow IsNot Nothing Then connectionWindow.UpdateSelectedConnection()
+ End Sub
+
+ Private Sub UpdateWindowTitle()
+ If InvokeRequired Then
+ Invoke(New MethodInvoker(AddressOf UpdateWindowTitle))
+ Return
+ End If
+
+ Dim titleBuilder As New StringBuilder(Application.Info.ProductName)
+ Const separator As String = " - "
+
+ If IsConnectionsFileLoaded Then
+ If UsingSqlServer Then
+ titleBuilder.Append(separator)
+ titleBuilder.Append(Language.strSQLServer.TrimEnd(":"))
+ Else
+ If Not String.IsNullOrEmpty(ConnectionsFileName) Then
+ titleBuilder.Append(separator)
+ If My.Settings.ShowCompleteConsPathInTitle Then
+ titleBuilder.Append(ConnectionsFileName)
+ Else
+ titleBuilder.Append(Path.GetFileName(ConnectionsFileName))
+ End If
+ End If
+ End If
+ End If
+
+ If Not (SelectedConnection Is Nothing OrElse String.IsNullOrEmpty(SelectedConnection.Name)) Then
+ titleBuilder.Append(separator)
+ titleBuilder.Append(SelectedConnection.Name)
+ End If
+
+ Text = titleBuilder.ToString()
End Sub
Public Sub ShowHidePanelTabs(Optional closingDocument As DockContent = Nothing)
@@ -1,6 +1,7 @@
Imports System
Imports System.Windows
Imports System.Windows.Forms
+Imports mRemoteNG.Connection
Imports mRemoteNG.App
Imports Crownwood
Imports WeifenLuo.WinFormsUI.Docking
@@ -265,7 +266,7 @@ Namespace UI
nTab.Title = nTab.Title.Replace("&", "&&")
- Dim conIcon As Icon = mRemoteNG.Connection.Icon.FromString(conI.Icon)
+ Dim conIcon As Drawing.Icon = mRemoteNG.Connection.Icon.FromString(conI.Icon)
If conIcon IsNot Nothing Then
nTab.Icon = conIcon
End If
@@ -288,6 +289,21 @@ Namespace UI
End Function
#End Region
+#Region "Private Methods"
+ Public Sub UpdateSelectedConnection()
+ If TabController.SelectedTab Is Nothing Then
+ frmMain.SelectedConnection = Nothing
+ Else
+ Dim interfaceControl As InterfaceControl = TryCast(TabController.SelectedTab.Tag, InterfaceControl)
+ If interfaceControl Is Nothing Then
+ frmMain.SelectedConnection = Nothing
+ Else
+ frmMain.SelectedConnection = interfaceControl.Info
+ End If
+ End If
+ End Sub
+#End Region
+
#Region "Form"
Private Sub Connection_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ApplyLanguage()
@@ -404,6 +420,8 @@ Namespace UI
Catch ex As Exception
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.Connection.CloseConnectionTab() failed" & vbNewLine & ex.Message, True)
End Try
+
+ UpdateSelectedConnection()
End Sub
Private Sub TabController_DoubleClickTab(ByVal sender As Crownwood.Magic.Controls.TabControl, ByVal page As Crownwood.Magic.Controls.TabPage) Handles TabController.DoubleClickTab
@@ -862,8 +880,9 @@ Namespace UI
End Sub
Private _ignoreChangeSelectedTabClick As Boolean = False
- Private Sub TabController_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabController.SelectionChanged
+ Private Sub TabController_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TabController.SelectionChanged
_ignoreChangeSelectedTabClick = True
+ UpdateSelectedConnection()
FocusIC()
RefreshIC()
End Sub

0 comments on commit c9ca613

Please sign in to comment.