Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 01 Private timer As System.Threading.Timer
- 02 Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpstring As String) As Boolean
- 03
- 04 Private _branchName As String = String.Empty
- 05 Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
- 06 Try
- 07 If timer Is Nothing Then
- 08 ' Create timer which refreshes the caption because
- 09 ' IDE resets the caption very often
- 10 Dim autoEvent As New System.Threading.AutoResetEvent(False)
- 11 Dim timerDelegate As System.Threading.TimerCallback = _
- 12 AddressOf tick
- 13 timer = New System.Threading.Timer(timerDelegate, autoEvent, 0, 25)
- 14 End If
- 15 Dim sourceIndex As Integer = DTE.Solution.FullName.IndexOf("Source")
- 16 Dim shortTitle As String = DTE.Solution.FullName.Substring(0, sourceIndex)
- 17 Dim lastIndex As Integer = shortTitle.LastIndexOf("")
- 18 _branchName = shortTitle.Substring(lastIndex + 1)
- 19 showTitle(_branchName)
- 20 Catch ex As Exception
- 21
- 22 End Try
- 23 End Sub
- 24
- 25 Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
- 26 If Not timer Is Nothing Then
- 27 timer.Dispose()
- 28 End If
- 29 End Sub
- 30
- 31
- 32 ''' <summary>Dispose the timer on IDE shutdown.</summary>
- 33 Public Sub DTEEvents_OnBeginShutdown() Handles DTEEvents.OnBeginShutdown
- 34 If Not timer Is Nothing Then
- 35 timer.Dispose()
- 36 End If
- 37 End Sub
- 38
- 39 '''<summary>Called by timer.</summary>
- 40 Public Sub tick(ByVal state As Object)
- 41 Try
- 42 showTitle(_branchName)
- 43 Catch ex As System.Exception
- 44 End Try
- 45 End Sub
- 46
- 47 '''<summary>Shows the title in main window.</summary>
- 48 Private Sub showTitle(ByVal title As String)
- 49 SetWindowText(New System.IntPtr(DTE.MainWindow.HWnd), title & " - " & DTE.Name)
- 50 End Sub
Add Comment
Please, Sign In to add comment