added some development tools
[windows-sources.git] / developer / VSSDK / Samples / Completion_Tooltip_Customization / C# / CompletionTooltipCustomization.cs
blob77403fc24bc9f6323226a61c7acf0e28e3841700
1 //***************************************************************************
2 //
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.
9 //
10 //***************************************************************************
12 using System.ComponentModel.Composition;
13 using System.Globalization;
14 using System.Windows;
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 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
24 #region MEF Exports
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")]
30 [ContentType("text")]
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);
39 else
41 return null;
46 #endregion
48 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
49 #region Constructors
51 /// <summary>
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
53 /// </summary>
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);
58 FontSize = 24;
59 FontStyle = FontStyles.Italic;
62 #endregion