1 //***************************************************************************
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // This code is licensed under the Visual Studio SDK license terms.
5 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
10 //***************************************************************************
12 using System
.ComponentModel
.Composition
;
13 using System
.Globalization
;
15 using System
.Windows
.Controls
;
16 using Microsoft
.VisualStudio
.Language
.Intellisense
;
17 using Microsoft
.VisualStudio
.Utilities
;
19 namespace CompletionTooltipCustomization
21 internal class CompletionTooltipCustomization
: TextBlock
23 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 [Export(typeof(IUIElementProvider
<Completion
, ICompletionSession
>))]
27 [Name("SampleCompletionTooltipCustomization")]
28 //Roslyn is the default Tooltip Provider. We must override it if we wish to use custom tooltips
29 [Order(Before
= "RoslynToolTipProvider")]
31 internal class CompletionTooltipCustomizationProvider
: IUIElementProvider
<Completion
, ICompletionSession
>
33 public UIElement
GetUIElement(Completion itemToRender
, ICompletionSession context
, UIElementType elementType
)
35 if (elementType
== UIElementType
.Tooltip
)
37 return new CompletionTooltipCustomization(itemToRender
);
48 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 /// Custom constructor enables us to modify the text values of the tooltip. In this case, we are just modifying the font style and size
54 /// <param name="completion">The tooltip to be modified</param>
55 internal CompletionTooltipCustomization(Completion completion
)
57 Text
= string.Format(CultureInfo
.CurrentCulture
, "{0}: {1}", completion
.DisplayText
, completion
.Description
);
59 FontStyle
= FontStyles
.Italic
;