Skip to content

Commit 764f001

Browse files
authored
Merge pull request #9265 from RadwanFaci/dev/rafaci/FixResourceDesigner
Fix Resource Designer For Async Open
2 parents 0e3a298 + 545b10a commit 764f001

File tree

4 files changed

+28
-37
lines changed

4 files changed

+28
-37
lines changed

src/Microsoft.VisualStudio.Editors/DesignerFramework/BaseDesignerLoader.vb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,14 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
684684
Protected Overridable Sub OnDesignerWindowActivated(Activated As Boolean)
685685
End Sub
686686

687+
''' <summary>
688+
''' Called before the frame that's hosting the designer is shown.
689+
''' </summary>
690+
''' <param name="FirstShow">Indicates whether this is the first time the designer is being shown.</param>
691+
''' <param name="Frame">The frame hosting the designer.</param>
692+
Protected Overridable Sub OnBeforeDesignerWindowShow(FirstShow As Boolean, Frame As IVsWindowFrame)
693+
End Sub
694+
687695
#End Region
688696

689697
''' <summary>
@@ -818,6 +826,16 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
818826
End If
819827
End Function
820828

829+
Private Function OnBeforeDocumentWindowShow(docCookie As UInteger, firstShow As Integer, frame As IVsWindowFrame) As Integer _
830+
Implements IVsRunningDocTableEvents.OnBeforeDocumentWindowShow, IVsRunningDocTableEvents2.OnBeforeDocumentWindowShow
831+
832+
' Only notify if our frame showing
833+
If CType(GetService(GetType(IVsWindowFrame)), IVsWindowFrame) Is frame Then
834+
OnBeforeDesignerWindowShow(firstShow = 1, frame)
835+
End If
836+
837+
End Function
838+
821839
#Region "RDT events we don't care about"
822840

823841
Private Function OnAfterAttributeChange(docCookie As UInteger, attributes As UInteger) As Integer _
@@ -840,10 +858,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
840858
Implements IVsRunningDocTableEvents.OnAfterSave, IVsRunningDocTableEvents2.OnAfterSave
841859
End Function
842860

843-
Private Function OnBeforeDocumentWindowShow(docCookie As UInteger, firstShow As Integer, frame As IVsWindowFrame) As Integer _
844-
Implements IVsRunningDocTableEvents.OnBeforeDocumentWindowShow, IVsRunningDocTableEvents2.OnBeforeDocumentWindowShow
845-
End Function
846-
847861
#End Region
848862
#End Region
849863

src/Microsoft.VisualStudio.Editors/DesignerFramework/DesignerWindowPaneProviderBase.vb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
8888
_host = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
8989
If _host IsNot Nothing AndAlso Not _host.Loading Then
9090
PopulateView()
91+
EnableUndo()
9192
End If
9293

9394
AddHandler surface.Loaded, AddressOf OnLoaded
@@ -138,6 +139,7 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
138139
'
139140
If _view IsNot Nothing AndAlso _view.Controls.Count = 0 Then
140141
PopulateView()
142+
EnableUndo()
141143
End If
142144
Return _view
143145
End Get
@@ -237,10 +239,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
237239
Protected Overrides Sub OnCreate()
238240
MyBase.OnCreate()
239241

240-
_host = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
241-
If _host IsNot Nothing AndAlso Not _host.Loading Then
242-
EnableUndo()
243-
End If
244242
End Sub
245243

246244
''' <summary>

src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorDesignerLoader.vb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
141141
'Try to restore the editor state from before the last reload, if any.
142142
NewResourceEditorRoot.RootDesigner.TryDepersistSavedEditorState()
143143

144-
'Now that we know the load succeeded, we can try registering our view helper
145-
NewResourceEditorRoot.RootDesigner.RegisterViewHelper()
146144
Catch ex As Exception When ReportWithoutCrash(ex, NameOf(HandleLoad), NameOf(ResourceEditorDesignerLoader))
147145
_rootComponent = Nothing
148146

@@ -258,6 +256,12 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
258256
End If
259257
End Sub
260258

259+
Protected Overrides Sub OnBeforeDesignerWindowShow(FirstShow As Boolean, Frame As IVsWindowFrame)
260+
If FirstShow Then
261+
_rootComponent.RootDesigner.RegisterViewHelper(Frame)
262+
End If
263+
End Sub
264+
261265
''' <summary>
262266
''' ManualCheckOut without the ProjectReloaded flag because it is not needed in
263267
''' the resource editor.

src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorRootDesigner.vb

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
3838
' Contains information about the current state of Find/Replace
3939
Private ReadOnly _findReplace As New FindReplace(Me)
4040

41-
' Indicates whether or not we are trying to register our view helper on a delayed basis
42-
Private _delayRegisteringViewHelper As Boolean
43-
4441
' The ErrorListProvider to support error list window
4542
Private _errorListProvider As ErrorListProvider
4643

@@ -410,34 +407,12 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
410407
''' Register this root designer as a view helper with the current frame so the shell will can find our
411408
''' implementations of IVsFindTarget, IOleCommandTarget, etc.
412409
''' </summary>
413-
Public Sub RegisterViewHelper()
410+
Public Sub RegisterViewHelper(VsWindowFrame As IVsWindowFrame)
414411
Try
415-
Dim VsWindowFrame As IVsWindowFrame = CType(GetService(GetType(IVsWindowFrame)), IVsWindowFrame)
416-
417412
If VsWindowFrame IsNot Nothing Then
418413
VSErrorHandler.ThrowOnFailure(VsWindowFrame.SetProperty(__VSFPROPID.VSFPROPID_ViewHelper, New UnknownWrapper(Me)))
419414
Else
420-
If _view IsNot Nothing Then
421-
'We don't have a window frame yet. Need to delay this registration until we do.
422-
' Easiest way is to use BeginInvoke.
423-
If _delayRegisteringViewHelper Then
424-
'This is already our second try
425-
Debug.Fail("Unable to delay-register our view helper")
426-
_delayRegisteringViewHelper = False
427-
Else
428-
'Try again, delayed.
429-
_delayRegisteringViewHelper = True
430-
431-
' VS Whidbey #260046 -- Make sure the control is created before calling Invoke/BeginInvoke
432-
If _view.Created = False Then
433-
_view.CreateControl()
434-
End If
435-
436-
_view.BeginInvoke(New System.Windows.Forms.MethodInvoker(AddressOf RegisterViewHelper))
437-
End If
438-
Else
439-
Debug.Fail("View not set in RegisterViewHelper() - can't delay-register view helper")
440-
End If
415+
Debug.Fail("Unable to register our view helper")
441416
End If
442417
Catch ex As Exception When ReportWithoutCrash(ex, NameOf(RegisterViewHelper), NameOf(ResourceEditorRootDesigner))
443418
End Try

0 commit comments

Comments
 (0)