Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Visual Studio .NET flickers when add-in opens projectitem in the code window

$
0
0

I have an Extension to Visual Studio 2015 to print source code in color of one or more project items in a project or projects. While the extension is processing project items a progress form is displayed to give the user some feedback. If any projectItem is not Open (using ProjectItem.IsOpen() )then the extension opens it using:

ProjectItem.Open(EnvDTE.Constants.vsViewKindCode)

The extension opens the  projectItem to obtain the FileCodeModel so that it can iterate Names, Classes, methods etc.

On the call to ProjectItem.Open causes the progress Form to disappear behind the Visual Studio IDE. Bringing the Progress form to the fron causes very annoying flicker.

Is there any way to achieve this without the flicker? Making the progress form a TopMost windows does the trick but is not ideal as processing all projects items make take while and also VS sometime displays a message that goes behind the progress form causing a lockout.

Here is the test source code:

 Private Sub MenuItemCallback(sender As Object, e As EventArgs)
    Dim objProjectItem As ProjectItem
    Dim iCounter As Integer
    Dim objWindow As Window
    Dim activeDocument As Document = g_DTE.ActiveDocument

    If activeDocument Is Nothing Then
      MessageBox.Show("Please open a projectitem in the editor window and try again.")
    Else
      objProjectItem = activeDocument.ProjectItem

      ' Create and initialise a form to show progress
      Dim frmProgress As New ProgressForm
      With frmProgress.ProgressBar
        .Minimum = 1
        .Maximum = 500
      End With

      frmProgress.Show()

      ' Open the same projectitem in a loop to show thw flicker
      For iCounter = 1 To 500
        frmProgress.ShowProgress(iCounter)

        objWindow = objProjectItem.Open(EnvDTE.Constants.vsViewKindCode)

        objWindow.Close()
      Next

      frmProgress.Close()
    End If

  End Sub


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>