Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'
SuspendLayout()
AutoScroll = False
BackColor = Drawing.SystemColors.ControlLight
Name = "ApplicationDesignerView"
ResumeLayout(False)
PerformLayout()
Expand Down Expand Up @@ -1239,6 +1238,13 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
End If
End Sub

Protected Overrides Sub OnThemeChanged()
Dim VsUIShell5 = VsUIShell5Service
BackColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell5, "Background", __THEMEDCOLORTYPE.TCT_Background, Drawing.SystemColors.Window)

MyBase.OnThemeChanged()
End Sub


''' <summary>
''' WndProc for the project designer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Imports Common = Microsoft.VisualStudio.Editors.AppDesCommon
Imports Microsoft.VisualStudio.Shell.Design
Imports System.Windows.Forms
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Reflection
Imports IOleDataObject = Microsoft.VisualStudio.OLE.Interop.IDataObject

Expand All @@ -26,7 +27,11 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner

Private _host As IDesignerHost
Private _viewHelper As CmdTargetHelper
Private _UIShellService As IVsUIShell
Private _UIShell2Service As IVsUIShell2
Private _UIShell5Service As IVsUIShell5

Private WithEvents _broadcastMessageEventsHelper As Common.ShellUtil.BroadcastMessageEventsHelper


''' <summary>
Expand All @@ -43,9 +48,10 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'
_view = New ApplicationDesignerWindowPaneControl()
AddHandler _view.GotFocus, AddressOf OnViewFocus
_view.BackColor = PropertyPages.PropPageUserControlBase.PropPageBackColor
OnThemeChanged()

_host = TryCast(GetService(GetType(IDesignerHost)), IDesignerHost)
_broadcastMessageEventsHelper = New Common.ShellUtil.BroadcastMessageEventsHelper(Me)

AddHandler surface.Unloaded, AddressOf OnSurfaceUnloaded

Expand Down Expand Up @@ -110,6 +116,18 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
End If
End Sub

Private Sub OnThemeChanged()
Dim VsUIShell5 = VsUIShell5Service
_view.BackColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell5Service, "Background", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Window)
End Sub

Private Sub OnBroadcastMessageEventsHelperBroadcastMessage(msg As UInteger, wParam As IntPtr, lParam As IntPtr) Handles _broadcastMessageEventsHelper.BroadcastMessage
Select Case msg
Case win.WM_PALETTECHANGED, win.WM_SYSCOLORCHANGE, win.WM_THEMECHANGED
OnThemeChanged()
End Select
End Sub

Public Overrides ReadOnly Property Window() As IWin32Window
Get
Return _view
Expand Down Expand Up @@ -442,6 +460,23 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
Return hr
End Function

''' <summary>
''' Retrieves the IVsUIShell service
''' </summary>
''' <remarks></remarks>
Public ReadOnly Property VsUIShellService() As IVsUIShell
Get
If (_UIShellService Is Nothing) Then
If Common.VBPackageInstance IsNot Nothing Then
_UIShellService = TryCast(Common.VBPackageInstance.GetService(GetType(IVsUIShell)), IVsUIShell)
Else
_UIShellService = TryCast(GetService(GetType(IVsUIShell)), IVsUIShell)
End If
End If

Return _UIShellService
End Get
End Property

''' <summary>
''' Retrieves the IVsUIShell2 service
Expand All @@ -450,15 +485,30 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
Public ReadOnly Property VsUIShell2Service() As IVsUIShell2
Get
If (_UIShell2Service Is Nothing) Then
If (Common.VBPackageInstance IsNot Nothing) Then
Dim VsUiShell As IVsUIShell = CType(Common.VBPackageInstance.GetService(GetType(IVsUIShell)), IVsUIShell)
If VsUiShell IsNot Nothing Then
_UIShell2Service = TryCast(VsUiShell, IVsUIShell2)
End If
Dim VsUiShell As IVsUIShell = VsUIShellService
If VsUiShell IsNot Nothing Then
_UIShell2Service = TryCast(VsUiShell, IVsUIShell2)
End If
End If

Return _UIShell2Service
End Get
End Property

''' <summary>
''' Retrieves the IVsUIShell5 service
''' </summary>
''' <remarks></remarks>
Public ReadOnly Property VsUIShell5Service() As IVsUIShell5
Get
If (_UIShell5Service Is Nothing) Then
Dim VsUiShell As IVsUIShell = VsUIShellService
If VsUiShell IsNot Nothing Then
_UIShell5Service = TryCast(VsUiShell, IVsUIShell5)
End If
End If

Return _UIShell5Service
End Get
End Property

Expand Down Expand Up @@ -529,12 +579,18 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
' disposedView. After we're done calling base.Dispose()
' will take care of our own stuff.
'
_UIShellService = Nothing
_UIShell2Service = Nothing
_UIShell5Service = Nothing
_view = Nothing
Dim DesSurface As DesignSurface = Surface
If (DesSurface IsNot Nothing) Then
RemoveHandler DesSurface.Unloaded, AddressOf OnSurfaceUnloaded
End If
If (_broadcastMessageEventsHelper IsNot Nothing) Then
_broadcastMessageEventsHelper.Dispose()
_broadcastMessageEventsHelper = Nothing
End If
End If

Finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'Backs up the ServiceProvider property
Private _serviceProvider As IServiceProvider

'Backs up the VsUIShellService property
Private _UIShellService As IVsUIShell

'Backs up the VsUIShell2Service property
Private _UIShell2Service As IVsUIShell2

'Backs up the VsUIShell5Service property
Private _UIShell5Service As IVsUIShell5

''' <summary>
''' Listen for font/color changes from the shell
''' </summary>
''' <remarks></remarks>
Private WithEvents _broadcastMessageEventsHelper As Common.ShellUtil.BroadcastMessageEventsHelper

Private ReadOnly _defaultOverflowBorderColor As Color = SystemColors.MenuText
Private ReadOnly _defaultOverflowHoverColor As Color = SystemColors.Highlight


Public Event ThemeChanged(sender As Object, args As EventArgs)

#Region " Component Designer generated code "

Expand Down Expand Up @@ -98,7 +104,6 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
''' <remarks></remarks>
Private Sub Initialize()
_hostingPanel = New Panel()
_hostingPanel.BackColor = PropertyPages.PropPageUserControlBase.PropPageBackColor
_hostingPanel.Visible = True
_hostingPanel.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Bottom Or AnchorStyles.Right
_hostingPanel.AutoScroll = True
Expand Down Expand Up @@ -129,8 +134,6 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
.Name = "OverflowButton"
.Text = ""
.AccessibleName = My.Resources.Designer.APPDES_OverflowButton_AccessibilityName
.FlatAppearance.BorderColor = _defaultOverflowBorderColor
.FlatAppearance.MouseOverBackColor = _defaultOverflowHoverColor
.Size = New Size(18, 18)
.Visible = False 'Don't show it until we need it
_overflowTooltip.SetToolTip(OverflowButton, My.Resources.Designer.APPDES_OverflowButton_Tooltip)
Expand Down Expand Up @@ -163,24 +166,56 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
End Set
End Property

Protected ReadOnly Property VsUIShellService As IVsUIShell
Get
If (_UIShellService Is Nothing) Then
If Common.VBPackageInstance IsNot Nothing Then
_UIShellService = TryCast(Common.VBPackageInstance.GetService(GetType(IVsUIShell)), IVsUIShell)
ElseIf ServiceProvider IsNot Nothing Then
_UIShellService = TryCast(ServiceProvider.GetService(GetType(IVsUIShell)), IVsUIShell)
End If
End If

Return _UIShellService
End Get
End Property

Protected ReadOnly Property VsUIShell2Service As IVsUIShell2
Get
If (_UIShell2Service Is Nothing) Then
Dim VsUIShell = VsUIShellService

If (VsUIShell IsNot Nothing) Then
_UIShell2Service = TryCast(VsUIShell, IVsUIShell2)
End If
End If

Return _UIShell2Service
End Get
End Property

Protected ReadOnly Property VsUIShell5Service As IVsUIShell5
Get
If (_UIShell5Service Is Nothing) Then
Dim VsUIShell = VsUIShellService

If (VsUIShell IsNot Nothing) Then
_UIShell5Service = TryCast(VsUIShell, IVsUIShell5)
End If
End If

Return _UIShell5Service
End Get
End Property


''' <summary>
''' Called when a non-empty service provider is given to the control.
''' </summary>
''' <remarks></remarks>
Private Sub OnGotServiceProvider()
'We now should have access to the color provider service
Dim vsUiShell As IVsUIShell = Nothing
Dim vsUiShell2 As IVsUIShell2 = DirectCast(vsUiShell, IVsUIShell2)
If _serviceProvider IsNot Nothing Then
vsUiShell = DirectCast(_serviceProvider.GetService(GetType(IVsUIShell)), IVsUIShell)
If vsUiShell IsNot Nothing Then
vsUiShell2 = DirectCast(vsUiShell, IVsUIShell2)
End If
End If

OverflowButton.FlatAppearance.BorderColor = Common.ShellUtil.GetColor(vsUiShell2, __VSSYSCOLOREX.VSCOLOR_COMMANDBAR_BORDER, _defaultOverflowBorderColor)
OverflowButton.FlatAppearance.MouseOverBackColor = Common.ShellUtil.GetColor(vsUiShell2, __VSSYSCOLOREX.VSCOLOR_COMMANDBAR_HOVER, _defaultOverflowHoverColor)
OnThemeChanged()

If _broadcastMessageEventsHelper IsNot Nothing Then
_broadcastMessageEventsHelper.Dispose()
Expand All @@ -191,6 +226,22 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
End If
End Sub

Protected Overridable Sub OnThemeChanged()
'Update our themed colors
Dim VsUIShell5 = VsUIShell5Service
_hostingPanel.BackColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell5Service, "Background", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Window)

'Update our system colors
Dim VsUIShell2 = VsUIShell2Service
OverflowButton.FlatAppearance.BorderColor = Common.ShellUtil.GetColor(VsUIShell2, __VSSYSCOLOREX.VSCOLOR_COMMANDBAR_BORDER, SystemColors.WindowFrame)
OverflowButton.FlatAppearance.MouseOverBackColor = Common.ShellUtil.GetColor(VsUIShell2, __VSSYSCOLOREX.VSCOLOR_COMMANDBAR_HOVER, SystemColors.Highlight)

'Force the renderer to recreate its GDI objects
_renderer.CreateGDIObjects(True)

RaiseEvent ThemeChanged(Me, EventArgs.Empty)
End Sub


''' <summary>
''' Returns an enumerable set of tab buttons
Expand Down Expand Up @@ -525,8 +576,8 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
If _overflowMenu.Items.Count > 0 Then
'Show the overflow menu
Dim OverflowMenuDistanceFromButtonButtonLeft As Size = New Size(-2, 2)
_overflowMenu.Show(Me, _
OverflowButton.Left + OverflowMenuDistanceFromButtonButtonLeft.Width, _
_overflowMenu.Show(Me,
OverflowButton.Left + OverflowMenuDistanceFromButtonButtonLeft.Width,
OverflowButton.Bottom + OverflowMenuDistanceFromButtonButtonLeft.Height)
Else
Debug.Fail("How did the overflow button get clicked if there are no items to show in the overflow area?")
Expand Down Expand Up @@ -566,7 +617,7 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
Private Sub OnBroadcastMessageEventsHelperBroadcastMessage(msg As UInteger, wParam As IntPtr, lParam As IntPtr) Handles _broadcastMessageEventsHelper.BroadcastMessage
Select Case msg
Case AppDesInterop.win.WM_PALETTECHANGED, AppDesInterop.win.WM_SYSCOLORCHANGE, AppDesInterop.win.WM_THEMECHANGED
_renderer.CreateGDIObjects(True)
OnThemeChanged()
End Select
End Sub

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner

#End Region

' Category guid for project designer theme colors
Private Shared ReadOnly s_projectDesignerThemeCategory As New Guid("ef1a2d2c-5d16-4ddb-8d04-79d0f6c1c56e")

'The left X position for all tab buttons
Private _buttonsLocationX As Integer
'The top Y position for the topmost button
Expand Down Expand Up @@ -101,6 +98,9 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
'The service provider to use. May be Nothing
Private _serviceProvider As IServiceProvider

Private _UIShellService As IVsUIShell
Private _UIShell5Service As IVsUIShell5

'Backs the PreferredButtonInSwitchableSlot property
Private _preferredButtonForSwitchableSlot As ProjectDesignerTabButton

Expand Down Expand Up @@ -155,23 +155,41 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
End Set
End Property

''' <summary>
''' Attempts to obtain the IVsUIShell interface.
''' </summary>
''' <value>The IVsUIShell service if found, otherwise null</value>
''' <remarks>Uses the publicly-obtained ServiceProvider property, if it was set.</remarks>
Private ReadOnly Property VsUIShellService() As IVsUIShell
Get
If (_UIShellService Is Nothing) Then
If Common.VBPackageInstance IsNot Nothing Then
_UIShellService = TryCast(Common.VBPackageInstance.GetService(GetType(IVsUIShell)), IVsUIShell)
ElseIf ServiceProvider IsNot Nothing Then
_UIShellService = TryCast(ServiceProvider.GetService(GetType(IVsUIShell)), IVsUIShell)
End If
End If

Return _UIShellService
End Get
End Property

''' <summary>
''' Attempts to obtain the IVsUIShell5 interface.
''' </summary>
''' <value>The IVsUIShell5 service if found, otherwise null</value>
''' <remarks>Uses the publicly-obtained ServiceProvider property, if it was set.</remarks>
Private ReadOnly Property VsUIShell5Service() As IVsUIShell5
Get
Dim sp As IServiceProvider = ServiceProvider
If sp IsNot Nothing Then
Dim vsUiShell As IVsUIShell = TryCast(sp.GetService(GetType(IVsUIShell)), IVsUIShell)
If vsUiShell IsNot Nothing Then
Dim uIShell2Service As IVsUIShell5 = TryCast(vsUiShell, IVsUIShell5)
Return uIShell2Service
If (_UIShell5Service Is Nothing) Then
Dim VsUIShell = VsUIShellService

If (VsUIShell IsNot Nothing) Then
_UIShell5Service = TryCast(VsUIShell, IVsUIShell5)
End If
End If

Return Nothing
Return _UIShell5Service
End Get
End Property

Expand Down Expand Up @@ -228,16 +246,16 @@ Namespace Microsoft.VisualStudio.Editors.ApplicationDesigner
' do the right thing when not hosted inside Visual Studio, and change according to the theme.


_controlBackgroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "Background", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Control)
_controlBackgroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "Background", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Window)

_buttonForegroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "CategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.ControlText)
_buttonBackgroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "CategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Control)
_buttonForegroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "CategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.WindowText)
_buttonBackgroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "CategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Window)

_selectedButtonForegroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "SelectedCategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.HighlightText)
_selectedButtonBackgroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "SelectedCategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Highlight)
_selectedButtonForegroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "SelectedCategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.HighlightText)
_selectedButtonBackgroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "SelectedCategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.Highlight)

_hoverButtonForegroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "MouseOverCategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.HighlightText)
_hoverButtonBackgroundColor = Common.ShellUtil.GetDesignerThemeColor(VsUIShell, s_projectDesignerThemeCategory, "MouseOverCategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.HotTrack)
_hoverButtonForegroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "MouseOverCategoryTab", __THEMEDCOLORTYPE.TCT_Foreground, SystemColors.HighlightText)
_hoverButtonBackgroundColor = Common.ShellUtil.GetProjectDesignerThemeColor(VsUIShell, "MouseOverCategoryTab", __THEMEDCOLORTYPE.TCT_Background, SystemColors.HotTrack)

'Get GDI objects
_controlBackgroundBrush = New SolidBrush(_controlBackgroundColor)
Expand Down
Loading