├── HotSettings ├── Key.snk ├── Resources │ ├── Toolbar.png │ ├── Screenshot.PNG │ ├── DefaultPackage.ico │ ├── EditorMarginMenu.png │ ├── HotSettings_128x.png │ ├── HotSettings_32x.png │ ├── HotSettings_90x.png │ ├── EditorContextMenu.png │ ├── EditorDistractions.png │ ├── SampleToolbarIcons.png │ ├── Screenshot - Full.png │ ├── DistractionFreeEditor.png │ ├── HotSettings_Icon_128x.png │ └── HotSettings_32x.svg ├── Common │ ├── ServicesUtil.cs │ ├── PropertiesUtil.cs │ └── ShellUtil.cs ├── ReleaseNotes.txt ├── VSInternal │ ├── IVsTextManager6.cs │ └── VIEWPREFERENCES5.cs ├── Properties │ └── AssemblyInfo.cs ├── HotSettingsPackage.cs ├── source.extension.vsixmanifest ├── Commands │ └── ToggleLiveUnitTesting.cs ├── HotSettingsCommandsTextViewCreationListener.cs ├── Constants.cs ├── ErrorStatus │ ├── ErrorStatusTextViewCreationListener.cs │ └── ErrorStatusTracker.cs ├── packages.config ├── HotSettingsContextMenuTextViewCreationListener.cs ├── VSPackage.resx ├── TrackActiveItemsCommandHandler.cs ├── HotSettings.csproj ├── HotSettingsCommandFilter.cs ├── HotSettingsCommandHandler.cs └── HotSettings.vsct ├── HotSettings.sln ├── README.md ├── .gitattributes ├── Description.html └── .gitignore /HotSettings/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Key.snk -------------------------------------------------------------------------------- /HotSettings/Resources/Toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/Toolbar.png -------------------------------------------------------------------------------- /HotSettings/Resources/Screenshot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/Screenshot.PNG -------------------------------------------------------------------------------- /HotSettings/Resources/DefaultPackage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/DefaultPackage.ico -------------------------------------------------------------------------------- /HotSettings/Resources/EditorMarginMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/EditorMarginMenu.png -------------------------------------------------------------------------------- /HotSettings/Resources/HotSettings_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/HotSettings_128x.png -------------------------------------------------------------------------------- /HotSettings/Resources/HotSettings_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/HotSettings_32x.png -------------------------------------------------------------------------------- /HotSettings/Resources/HotSettings_90x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/HotSettings_90x.png -------------------------------------------------------------------------------- /HotSettings/Resources/EditorContextMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/EditorContextMenu.png -------------------------------------------------------------------------------- /HotSettings/Resources/EditorDistractions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/EditorDistractions.png -------------------------------------------------------------------------------- /HotSettings/Resources/SampleToolbarIcons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/SampleToolbarIcons.png -------------------------------------------------------------------------------- /HotSettings/Resources/Screenshot - Full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/Screenshot - Full.png -------------------------------------------------------------------------------- /HotSettings/Resources/DistractionFreeEditor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/DistractionFreeEditor.png -------------------------------------------------------------------------------- /HotSettings/Resources/HotSettings_Icon_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/HotSettings/master/HotSettings/Resources/HotSettings_Icon_128x.png -------------------------------------------------------------------------------- /HotSettings/Common/ServicesUtil.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.ComponentModelHost; 2 | using System; 3 | 4 | namespace HotSettings 5 | { 6 | public class ServicesUtil 7 | { 8 | public static T GetMefService(IServiceProvider serviceProvider) where T : class 9 | { 10 | IComponentModel componentModel = serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; 11 | return componentModel?.GetService(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HotSettings/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 | Hot Settings 2 | 3 | 24-Apr-2018 v1.2.0: Made package load async / background load. 4 | 06-Apr-2018 v1.1.9: Corrected mistake with extenstion name (space at the beginning) 5 | 15-Mar-2018 v1.1.8: Added keyboard accelerators and grouping for Scrollbar menu items 6 | 14-Mar-2018 v1.1.7: Performance optimisations for Error Info on status bar 7 | 13-Mar-2018 v1.1.6: New feature - Error info on status bar (from Christian Gunderman) 8 | 20-Jan-2018 v1.1.5: Restored all toolbar buttons 9 | 11-Jan-2017 v1.1.4: Completed all margins and most editor adornments 10 | 26-Dec-2017 v1.1: Added support for Outling and Navigation Bar 11 | 20-Jun-2017 v1.0: Initial release (very beta!) -------------------------------------------------------------------------------- /HotSettings.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotSettings", "HotSettings\HotSettings.csproj", "{77787521-2611-4D00-BF57-2B514CF236BB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {77787521-2611-4D00-BF57-2B514CF236BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {77787521-2611-4D00-BF57-2B514CF236BB}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {77787521-2611-4D00-BF57-2B514CF236BB}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {77787521-2611-4D00-BF57-2B514CF236BB}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /HotSettings/VSInternal/IVsTextManager6.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Microsoft.VisualStudio.TextManager.Interop 5 | { 6 | [Guid("A50CF306-7BEE-4349-8789-DAE896A15E07"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | [ComImport] 8 | public interface IVsTextManager6 9 | { 10 | [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] 11 | int GetUserPreferences6([MarshalAs(UnmanagedType.LPArray)] [Out] VIEWPREFERENCES5[] pViewPrefs, [MarshalAs(UnmanagedType.LPArray)] [In] [Out] LANGPREFERENCES3[] pLangPrefs, [MarshalAs(UnmanagedType.LPArray)] [In] [Out] FONTCOLORPREFERENCES2[] pColorPrefs); 12 | 13 | [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] 14 | int SetUserPreferences6([MarshalAs(UnmanagedType.LPArray)] [In] VIEWPREFERENCES5[] pViewPrefs, [MarshalAs(UnmanagedType.LPArray)] [In] LANGPREFERENCES3[] pLangPrefs, [MarshalAs(UnmanagedType.LPArray)] [In] FONTCOLORPREFERENCES2[] pColorPrefs); 15 | } 16 | } -------------------------------------------------------------------------------- /HotSettings/VSInternal/VIEWPREFERENCES5.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Microsoft.VisualStudio.TextManager.Interop 4 | { 5 | [TypeIdentifier("96B36253-76A4-4DF5-9071-34CD1B5A5EFF", "Microsoft.VisualStudio.TextManager.Interop.VIEWPREFERENCES5")] 6 | [StructLayout(LayoutKind.Sequential, Pack = 8)] 7 | public struct VIEWPREFERENCES5 8 | { 9 | public uint fVisibleWhitespace; 10 | public uint fSelectionMargin; 11 | public uint fAutoDelimiterHighlight; 12 | public uint fGoToAnchorAfterEscape; 13 | public uint fDragDropEditing; 14 | public uint fUndoCaretMovements; 15 | public uint fOvertype; 16 | public uint fDragDropMove; 17 | public uint fWidgetMargin; 18 | public uint fReadOnly; 19 | public uint fActiveInModalState; 20 | public uint fClientDragDropFeedback; 21 | public uint fTrackChanges; 22 | public uint uCompletorSize; 23 | public uint fDetectUTF8; 24 | public int lEditorEmulation; 25 | public uint fHighlightCurrentLine; 26 | public uint fShowBlockStructure; 27 | public uint fEnableCodingConventions; 28 | public uint fEnableClickGotoDef; 29 | public uint uModifierKey; 30 | public uint fOpenDefInPeek; 31 | } 32 | } -------------------------------------------------------------------------------- /HotSettings/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("HotSettings")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("HotSettings")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /HotSettings/Common/PropertiesUtil.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using EnvDTE80; 3 | using Microsoft.VisualStudio.Shell; 4 | using System; 5 | using System.Diagnostics; 6 | 7 | namespace HotSettings.Common 8 | { 9 | class PropertiesUtil 10 | { 11 | 12 | public void PrintProperties() 13 | { 14 | Debug.WriteLine("===== General ========="); 15 | PrintItems("TextEditor", "General"); 16 | Debug.WriteLine("===== CSharp ========="); 17 | PrintItems("TextEditor", "CSharp"); 18 | Debug.WriteLine("===== CSharp-Specific ========="); 19 | PrintItems("TextEditor", "CSharp-Specific"); 20 | Debug.WriteLine("===== All Languages ========="); 21 | PrintItems("TextEditor", "AllLanguages"); 22 | } 23 | 24 | private void PrintItems(string category, string page) 25 | { 26 | DTE2 _DTE2 = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE)); 27 | Properties properties = _DTE2.Properties[category, page]; 28 | 29 | foreach (Property prop in properties) 30 | { 31 | try 32 | { 33 | Debug.WriteLine(prop.Name); 34 | } 35 | catch (Exception ex) 36 | { 37 | // Do nothing 38 | } 39 | } 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /HotSettings/HotSettingsPackage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Runtime.InteropServices; 4 | using Microsoft.VisualStudio.Shell; 5 | using Microsoft.VisualStudio; 6 | using System.Threading; 7 | using Task = System.Threading.Tasks.Task; 8 | 9 | namespace HotSettings 10 | { 11 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] 12 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] 13 | [ProvideMenuResource("Menus.ctmenu", 1)] 14 | [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string, PackageAutoLoadFlags.BackgroundLoad)] 15 | [Guid(HotSettingsPackage.PackageGuidString)] 16 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] 17 | public sealed class HotSettingsPackage : AsyncPackage 18 | { 19 | public const string PackageGuidString = "d570a6f3-b0ad-42c3-b71f-db7c6b3d39c0"; 20 | 21 | protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) 22 | { 23 | await JoinableTaskFactory.SwitchToMainThreadAsync(); 24 | HotSettingsCommandHandler.Initialize(this); 25 | TrackActiveItemsCommandHandler.Initialize(this); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /HotSettings/Common/ShellUtil.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.OLE.Interop; 2 | using Microsoft.VisualStudio.Shell; 3 | using Microsoft.VisualStudio.Shell.Interop; 4 | using EnvDTE; 5 | using System; 6 | 7 | namespace HotSettings 8 | { 9 | public class ShellUtil 10 | { 11 | /// 12 | /// Get the SUIHostCommandDispatcher from the global service provider. 13 | /// 14 | public static IOleCommandTarget GetShellCommandDispatcher() 15 | { 16 | return ServiceProvider.GlobalProvider.GetService(typeof(SUIHostCommandDispatcher)) as IOleCommandTarget; 17 | } 18 | 19 | public static TInterface GetGlobalService() 20 | where TService : class 21 | where TInterface : class 22 | => (TInterface)ServiceProvider.GlobalProvider.GetService(typeof(TService)); 23 | 24 | public static DTE GetDTE() 25 | => GetGlobalService(); 26 | 27 | public static bool IsCommandAvailable(string commandName) 28 | { 29 | try 30 | { 31 | var command = GetDTE().Commands.Item(commandName); 32 | if (command == null) return false; 33 | return command.IsAvailable; 34 | } 35 | catch (Exception e) 36 | { 37 | return false; 38 | } 39 | } 40 | 41 | public static void ExecuteCommand(string commandName, string args = "") 42 | => GetDTE().ExecuteCommand(commandName, args); 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HotSettings 2 | Menus and Toolbars that expose Visual Studio settings. 3 | 4 | ![Hot Settings screenshot](https://raw.githubusercontent.com/justcla/HotSettings/master/HotSettings/Resources/Screenshot.PNG) 5 | 6 | ## Intended to expose the following settings: 7 | 8 | ### Editor Margin Settings (Editor margin context menu) 9 | - Indicator margin (glyph margin) (Text editor setting) 10 | ○ Contains breakpoints 11 | ○ Contains bookmarks 12 | ○ Also used by 3rd party extensions like Inherit Margin 13 | - Line numbers (Language specific setting) 14 | - Quick Actions / Lightbulb Margin (future ?) 15 | - Selection margin (Text editor setting) 16 | ○ Track changes (separate item) 17 | - Git Diff Margin (need 3rd party extension) 18 | - Outlining (Edit->Outlining Cmd, C#->Advanced (default)) 19 | - Live Unit Testing (VS2017) 20 | - Annotate (Blame) 21 | 22 | ### General Settings (Editor window context menu) 23 | - Navigation Bar (language specific) 24 | - Code Lens [Enterprise only] (Language specific) 25 | - Indent guides [PPT/VS2017] 26 | - White space (Edit Advanced Cmd) 27 | - Word wrap (Edit Advanced Cmd) 28 | ○ Virtual glyphs 29 | - Highlight current line (Text editor setting) 30 | - Automatic delimiter highlighting (Text editor setting) 31 | - Show procedure line separator (C#/Basic->Advanced) 32 | - Show completion list [with keywords / code snippets] (C#->IntelliSense) 33 | - Show line endings (need 3rd party extension) 34 | - Highlight references to [symbol/keyword] under cursor (C#->Advanced) 35 | - IntelliSense squiggles (Basic) 36 | 37 | ### Scrollbar (Vertical scrollbar context menu) 38 | - Show changes 39 | - Show marks 40 | - Show errors 41 | - Show caret position 42 | 43 | ### Settings Toolbar 44 | - Contain a mix of settings from all groups above 45 | 46 | -------------------------------------------------------------------------------- /HotSettings/Resources/HotSettings_32x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /HotSettings/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hot Settings 6 | Menus and Toolbars that expose Visual Studio settings 7 | https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.HotSettings 8 | ReleaseNotes.txt 9 | Resources\HotSettings_Icon_128x.png 10 | Resources\Screenshot.PNG 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /HotSettings/Commands/ToggleLiveUnitTesting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Design; 3 | using Microsoft.VisualStudio.OLE.Interop; 4 | using Microsoft.VisualStudio.Shell; 5 | 6 | namespace HotSettings 7 | { 8 | public class ToggleLiveUnitTesting 9 | { 10 | // Constants for LUT commands 11 | private static Guid LutCmdGroupGuid = new Guid("1E198C22-5980-4E7E-92F3-F73168D1FB63"); // GuidID = 146 12 | private static readonly uint StartLutCmdId = 16897; 13 | private static readonly uint StopLutCmdId = 16900; 14 | 15 | public static void OnBeforeQueryStatus(object sender, EventArgs e) 16 | { 17 | OleMenuCommand command = (OleMenuCommand)sender; 18 | 19 | // Check correct command 20 | if (command.CommandID.ID != Constants.ToggleLiveUnitTestingCmdId) return; 21 | 22 | command.Checked = IsLiveUnitTestingRunning(); 23 | } 24 | 25 | public static void ToggleLUT(object sender, EventArgs e) 26 | { 27 | // Protect against inconsistent state. Don't toggle if the item is already in the correct state. 28 | MenuCommand command = (MenuCommand)sender; 29 | if (!command.Checked && IsLiveUnitTestingRunning() 30 | || command.Checked && !IsLiveUnitTestingRunning()) 31 | { 32 | // Already in desired state. Do not toggle. 33 | return; 34 | } 35 | 36 | // Now call action to Toggle LUT. 37 | ToggleLUTRunningState(); 38 | } 39 | 40 | private static bool IsLiveUnitTestingRunning() 41 | { 42 | return ShellUtil.IsCommandAvailable("Test.LiveUnitTesting.Stop"); 43 | } 44 | 45 | private static int ToggleLUTRunningState() 46 | { 47 | // Call command to Start or Stop LiveUnitTesting depending on current state 48 | uint cmdID = IsLiveUnitTestingRunning() ? StopLutCmdId : StartLutCmdId; 49 | return ShellUtil.GetShellCommandDispatcher().Exec(ref LutCmdGroupGuid, cmdID, (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /HotSettings/HotSettingsCommandsTextViewCreationListener.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Editor; 2 | using Microsoft.VisualStudio.OLE.Interop; 3 | using Microsoft.VisualStudio.TextManager.Interop; 4 | using Microsoft.VisualStudio.Text.Editor; 5 | using Microsoft.VisualStudio.Utilities; 6 | using System.ComponentModel.Composition; 7 | using Microsoft.VisualStudio.Text.Classification; 8 | using Microsoft.VisualStudio.Shell; 9 | using Microsoft.VisualStudio.Text.Operations; 10 | using System; 11 | #pragma warning disable 0649 12 | 13 | namespace HotSettings 14 | { 15 | [Export(typeof(IVsTextViewCreationListener))] 16 | [ContentType("text")] 17 | [TextViewRole(PredefinedTextViewRoles.Editable)] 18 | internal sealed class HotSettingsCommandsTextViewCreationListener : IVsTextViewCreationListener 19 | { 20 | [Import] 21 | private IVsEditorAdaptersFactoryService EditorAdaptersFactoryService { get; set; } 22 | 23 | [Import] 24 | private IClassifierAggregatorService _aggregatorFactory; 25 | 26 | [Import] 27 | private SVsServiceProvider _globalServiceProvider; 28 | 29 | [Import(typeof(IEditorOperationsFactoryService))] 30 | private IEditorOperationsFactoryService _editorOperationsFactory; 31 | 32 | private IVsTextManager6 TextManager; 33 | 34 | public void VsTextViewCreated(IVsTextView textViewAdapter) 35 | { 36 | IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); 37 | Guid langServiceGuid = GetLanguageServiceGuid(textView); 38 | 39 | TextManager = (IVsTextManager6)_globalServiceProvider.GetService(typeof(SVsTextManager)); 40 | 41 | HotSettingsCommandFilter commandFilter = new HotSettingsCommandFilter(textView, langServiceGuid, TextManager); 42 | textViewAdapter.AddCommandFilter(commandFilter, out IOleCommandTarget next); 43 | 44 | commandFilter.Next = next; 45 | } 46 | 47 | private Guid GetLanguageServiceGuid(IWpfTextView textView) 48 | { 49 | IVsTextBuffer textBuffer = EditorAdaptersFactoryService.GetBufferAdapter(textView.TextBuffer); 50 | textBuffer.GetLanguageServiceID(out Guid langServiceGuid); 51 | return langServiceGuid; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /HotSettings/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace HotSettings 4 | { 5 | class Constants 6 | { 7 | /// 8 | /// Command menu group (command set GUID). 9 | /// 10 | // See HotSettings.vsct file for Symdol IDs 11 | public static readonly Guid HotSettingsCmdSetGuid = new Guid("c75f116c-9249-4984-8d82-d3c6025afb17"); 12 | 13 | public const int EditorMarginContextMenuId = 0x1100; 14 | 15 | /// 16 | /// Command IDs. Note: These must be in sync with symbols in VSCT file. 17 | /// 18 | public const int ToggleIndicatorMarginCmdId = 0x1021; 19 | public const int ToggleLineNumbersCmdId = 0x1022; 20 | public const int ToggleQuickActionsCmdId = 0x1023; 21 | public const int ToggleSelectionMarginCmdId = 0x1024; 22 | public const int ToggleTrackChangesCmdId = 0x1025; 23 | public const int ToggleDiffMarginCmdId = 0x1026; 24 | public const int ToggleOutliningCmdId = 0x1027; 25 | public const int ToggleLiveUnitTestingCmdId = 0x1028; 26 | public const int ToggleAnnotateCmdId = 0x1029; 27 | // Editor Settings CmdIds 28 | public const int ToggleNavigationBarCmdId = 0x1041; 29 | public const int ToggleCodeLensCmdId = 0x1042; 30 | public const int ToggleStructureGuideLinesCmdId = 0x1043; 31 | public const int ToggleHighlightCurrentLineCmdId = 0x1050; 32 | public const int ToggleAutoDelimiterHighlightingCmdId = 0x1051; 33 | public const int ToggleProcedureLineSeparatorCmdId = 0x1052; 34 | public const int ToggleIntelliSensePopUpCmdId = 0x1053; 35 | public const int ToggleLineEndingsCmdId = 0x1054; 36 | public const int ToggleHighlightSymbolsCmdId = 0x1055; 37 | public const int ToggleHighlightKeywordsCmdId = 0x1056; 38 | public const int ToggleIntelliSenseSquigglesCmdId = 0x1057; 39 | // Scrollbar Settings CmdIds 40 | public const int ToggleShowScrollbarMarkersCmdId = 0x1070; 41 | public const int ToggleShowChangesCmdId = 0x1071; 42 | public const int ToggleShowMarksCmdId = 0x1072; 43 | public const int ToggleShowErrorsCmdId = 0x1073; 44 | public const int ToggleShowCaretPositionCmdId = 0x1074; 45 | public const int ToggleShowDiffsCmdId = 0x1080; 46 | // Distraction free mode CmdIds 47 | public const int ToggleCleanEditorCmdId = 0x1110; 48 | public const int ToggleCleanMarginsCmdId = 0x1120; 49 | 50 | // Solution Explorer Commands 51 | public const int ToggleTrackActiveItemCmdId = 0x1210; 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /HotSettings/ErrorStatus/ErrorStatusTextViewCreationListener.cs: -------------------------------------------------------------------------------- 1 | namespace HotSettings.ErrorStatus 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Shell; 7 | using Microsoft.VisualStudio.Shell.Interop; 8 | using Microsoft.VisualStudio.Text.Adornments; 9 | using Microsoft.VisualStudio.Text.Editor; 10 | using Microsoft.VisualStudio.Text.Tagging; 11 | using Microsoft.VisualStudio.Utilities; 12 | 13 | // Bring in ErrorStatus tracker for any view that is 'Analyzable'. A.K.A.: any view that can show squiggles, including peek. 14 | [Export(typeof(IWpfTextViewCreationListener))] 15 | [ContentType("any")] 16 | [TextViewRole(PredefinedTextViewRoles.Analyzable)] 17 | internal sealed class ErrorStatusTextViewCreationListener : IWpfTextViewCreationListener 18 | { 19 | internal readonly IBufferTagAggregatorFactoryService TagAggregatorFactoryService; 20 | internal readonly IEnumerable> UnorderedErrorTypeDefinition; 21 | internal readonly SVsServiceProvider ServiceProvider; 22 | 23 | private IEnumerable> orderedErrorTypeDefinitions; 24 | private IVsStatusbar statusBarService; 25 | 26 | [ImportingConstructor] 27 | public ErrorStatusTextViewCreationListener( 28 | IBufferTagAggregatorFactoryService tagAggregatorFactoryService, 29 | [ImportMany]IEnumerable> unorderedErrorTypeDefinitions, 30 | SVsServiceProvider serviceProvider) 31 | { 32 | this.TagAggregatorFactoryService = tagAggregatorFactoryService 33 | ?? throw new ArgumentNullException(nameof(tagAggregatorFactoryService)); 34 | this.UnorderedErrorTypeDefinition = unorderedErrorTypeDefinitions 35 | ?? throw new ArgumentNullException(nameof(unorderedErrorTypeDefinitions)); 36 | this.ServiceProvider = serviceProvider 37 | ?? throw new ArgumentNullException(nameof(serviceProvider)); 38 | } 39 | 40 | public void TextViewCreated(IWpfTextView textView) 41 | { 42 | // Looks weird, but ErrorStatusTracker tracks its own lifetime. 43 | ErrorStatusTracker.Attach(textView, this); 44 | } 45 | 46 | // Lazily sort all defined ErrorTypes by their precedence. 47 | internal IEnumerable> OrderedErrorTypeDefinitions => this.orderedErrorTypeDefinitions 48 | ?? (this.orderedErrorTypeDefinitions = Orderer.Order(this.UnorderedErrorTypeDefinition)); 49 | 50 | internal IVsStatusbar StatusBarService => this.statusBarService 51 | ?? (this.statusBarService = this.ServiceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar); 52 | 53 | // Keep track of the last error message added to the status bar so we don't clear other messages. 54 | internal string LastErrorText { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Description.html: -------------------------------------------------------------------------------- 1 |

Hot Settings

2 |

Menus and Toolbars that expose Visual Studio settings.

3 |

Note: Work in progress!! Not all functions are working. This is being uploaded in a Beta state so that users can take advantage of the features that do work, and others can start contributing to the project.

4 |

Please visit the open source repo on GitHub to raise issues or contribute fixes. Thanks!

5 |

Hot Settings screenshot

6 |

Intended to expose the following settings:

7 |

Editor Margin Settings (Editor margin context menu)

8 |
    9 |
  • Indicator margin (glyph margin) (Text editor setting)
    10 | - Contains breakpoints
    11 | - Contains bookmarks
    12 | - Also used by 3rd party extensions like Inherit Margin 13 |
  • 14 |
  • Line numbers (Language specific setting)
  • 15 |
  • Quick Actions / Lightbulb Margin (future ?)
  • 16 |
  • Selection margin (Text editor setting) 17 | ? Track changes (separate item)
  • 18 |
  • Git Diff Margin (need 3rd party extension)
  • 19 |
  • Outlining (Edit->Outlining Cmd, C#->Advanced (default))
  • 20 |
  • Live Unit Testing (VS2017)
  • 21 |
  • Annotate (Blame)
  • 22 |
23 |

General Settings (Editor window context menu)

24 |
    25 |
  • Navigation Bar (language specific)
  • 26 |
  • Code Lens [Enterprise only] (Language specific)
  • 27 |
  • Indent guides [PPT/VS2017]
  • 28 |
  • White space (Edit Advanced Cmd)
  • 29 |
  • Word wrap (Edit Advanced Cmd) 30 | ? Virtual glyphs
  • 31 |
  • Highlight current line (Text editor setting)
  • 32 |
  • Automatic delimiter highlighting (Text editor setting)
  • 33 |
  • Show procedure line separator (C#/Basic->Advanced)
  • 34 |
  • Show completion list [with keywords / code snippets] (C#->IntelliSense)
  • 35 |
  • Show line endings (need 3rd party extension)
  • 36 |
  • Highlight references to [symbol/keyword] under cursor (C#->Advanced)
  • 37 |
  • IntelliSense squiggles (Basic)
  • 38 |
39 |

Scrollbar (Vertical scrollbar context menu)

40 |
    41 |
  • Show changes
  • 42 |
  • Show marks
  • 43 |
  • Show errors
  • 44 |
  • Show caret position
  • 45 |
46 |

Settings Toolbar

47 |
  • Contain a mix of settings from all groups above
-------------------------------------------------------------------------------- /HotSettings/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ 246 | 247 | #JetBrains 248 | .idea 249 | 250 | #Dlls provided by Visual Studio 251 | Microsoft.VisualStudio.TextManager.Interop.15.1.DesignTime.dll 252 | -------------------------------------------------------------------------------- /HotSettings/HotSettingsContextMenuTextViewCreationListener.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Editor; 2 | using Microsoft.VisualStudio.TextManager.Interop; 3 | using Microsoft.VisualStudio.Text.Editor; 4 | using Microsoft.VisualStudio.Utilities; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Text.Classification; 7 | using Microsoft.VisualStudio.Shell; 8 | using Microsoft.VisualStudio.Text.Operations; 9 | using System.Windows; 10 | using System.Windows.Input; 11 | using Microsoft.VisualStudio.Shell.Interop; 12 | using System.Windows.Controls; 13 | using HotSettings; 14 | using System; 15 | using System.Diagnostics; 16 | 17 | #pragma warning disable 0649 18 | 19 | namespace HotCommands 20 | { 21 | [Export(typeof(IVsTextViewCreationListener))] 22 | [ContentType("text")] 23 | [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] 24 | internal sealed class HotSettingsContextMenuTextViewCreationListener : IVsTextViewCreationListener 25 | { 26 | [Import] 27 | private IVsEditorAdaptersFactoryService EditorAdaptersFactoryService { get; set; } 28 | 29 | [Import] 30 | private IClassifierAggregatorService _aggregatorFactory; 31 | 32 | [Import] 33 | private SVsServiceProvider _globalServiceProvider; 34 | 35 | [Import(typeof(IEditorOperationsFactoryService))] 36 | private IEditorOperationsFactoryService _editorOperationsFactory; 37 | 38 | public void VsTextViewCreated(IVsTextView textViewAdapter) 39 | { 40 | //System.Windows.Controls.ContextMenu contextMenu = null; 41 | //lineNumberFrameworkElement.ContextMenu = contextMenu; 42 | 43 | //IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); 44 | var textViewHost = EditorAdaptersFactoryService.GetWpfTextViewHost(textViewAdapter); 45 | //var lineNumberMargin = textViewHost.GetTextViewMargin("LineNumber"); 46 | //var glyphMargin = textViewHost.GetTextViewMargin("Glyph"); 47 | //var leftSelectionMargin = textViewHost.GetTextViewMargin("LeftSelection"); // Selection margin - inherited by all left margins 48 | //var outliningMargin = textViewHost.GetTextViewMargin("Outlining"); 49 | //var spacerMargin = textViewHost.GetTextViewMargin("Spacer"); // Selection margin ? 50 | 51 | // Add the Editor Margin Context Menu to the Left Margin 52 | var leftMargin = textViewHost.GetTextViewMargin("Left"); 53 | leftMargin.VisualElement.MouseRightButtonUp += OnMouseRightButtonUp; 54 | 55 | //IVsUIShell uiShell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; 56 | //if (uiShell == null) 57 | //{ 58 | // // TODO: Log error - Unable to access UIShell 59 | // return; 60 | //} 61 | 62 | //// Add the new Scrollbar Settings group to the existing Scoll bar context menu 63 | //var rightMargin = textViewHost.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar); 64 | 65 | //var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); 66 | //var contentType = textView.TextDataModel.ContentType; 67 | // //DocumentBuffer.Properties; 68 | ////foreach(var ) 69 | //var scrollbarContextMenu = rightMargin.VisualElement.ContextMenu; 70 | //var scrollbarMenuItems = scrollbarContextMenu.Items; 71 | //foreach (var scrollMenuItem in scrollbarMenuItems) 72 | //{ 73 | // Debug.WriteLine(scrollMenuItem.GetType()); 74 | //} 75 | ////var scrollbarSettingsGroup = Shell.GetGroupById(ScrollbarSettingsGroupId); 76 | //scrollbarMenuItems.Add(new Separator()); 77 | ////scrollbarMenuItems.Add(HotSettingsCommandHandler.CreateOleMenuCommand(HotSettings.Constants.HotSettingsCmdSetGuid, HotSettings.Constants.ToggleShowChangesCmdId, handler)); 78 | //scrollbarMenuItems.Add(HotSettingsCommandHandler.ToggleShowMarksCmd); 79 | ////scrollbarMenuItems.Add(new Separator()); 80 | } 81 | 82 | private void handler(object sender, EventArgs e) 83 | { 84 | throw new NotImplementedException(); 85 | } 86 | 87 | private void OnMouseRightButtonUp(object sender, MouseButtonEventArgs e) 88 | { 89 | ShowContextMenu((FrameworkElement) sender, e); 90 | } 91 | 92 | private void ShowContextMenu(FrameworkElement frameworkElement, MouseButtonEventArgs mouseButtonEvent) 93 | { 94 | const string guidVSPackageContextMenuCmdSet = "c75f116c-9249-4984-8d82-d3c6025afb17"; 95 | const int MyContextMenuId = 0x1100; 96 | 97 | IVsUIShell uiShell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; 98 | if (uiShell == null) 99 | { 100 | // TODO: Log error - Unable to access UIShell 101 | return; 102 | } 103 | 104 | System.Guid contextMenuGuid = new System.Guid(guidVSPackageContextMenuCmdSet); 105 | POINTS[] points = GetPointsFromMouseEvent(frameworkElement, mouseButtonEvent); 106 | 107 | // TODO: error handling 108 | uiShell.ShowContextMenu(0, ref contextMenuGuid, MyContextMenuId, points, null); 109 | } 110 | 111 | private static POINTS[] GetPointsFromMouseEvent(FrameworkElement frameworkElement, MouseButtonEventArgs mouseButtonEvent) 112 | { 113 | Point relativePoint = mouseButtonEvent.GetPosition(frameworkElement); 114 | Point screenPoint = frameworkElement.PointToScreen(relativePoint); 115 | POINTS point = new POINTS(); 116 | point.x = (short)screenPoint.X; 117 | point.y = (short)screenPoint.Y; 118 | return new[] { point }; 119 | } 120 | 121 | } 122 | } -------------------------------------------------------------------------------- /HotSettings/ErrorStatus/ErrorStatusTracker.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace HotSettings.ErrorStatus 4 | { 5 | using System; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Windows.Input; 9 | using Microsoft.VisualStudio.Text; 10 | using Microsoft.VisualStudio.Text.Editor; 11 | using Microsoft.VisualStudio.Text.Tagging; 12 | 13 | internal sealed class ErrorStatusTracker 14 | { 15 | private readonly IWpfTextView textView; 16 | private readonly ErrorStatusTextViewCreationListener factory; 17 | private readonly ITagAggregator errorTagAggregator; 18 | 19 | public static void Attach(IWpfTextView textView, ErrorStatusTextViewCreationListener factory) => new ErrorStatusTracker(textView, factory); 20 | 21 | private ErrorStatusTracker( 22 | IWpfTextView textView, 23 | ErrorStatusTextViewCreationListener factory) 24 | { 25 | this.textView = textView; 26 | this.factory = factory; 27 | 28 | this.errorTagAggregator = factory.TagAggregatorFactoryService.CreateTagAggregator(textView.TextBuffer); 29 | this.errorTagAggregator.BatchedTagsChanged += this.OnBatchedTagsChanged; 30 | 31 | textView.Closed += OnTextViewClosed; 32 | textView.Caret.PositionChanged += this.OnCaretPositionChanged; 33 | //textView.VisualElement.GotKeyboardFocus += this.OnGotKeyboardFocus; 34 | } 35 | 36 | private void OnBatchedTagsChanged(object sender, BatchedTagsChangedEventArgs e) => this.ShowErrorTagContentAtCaret(); 37 | 38 | private void OnCaretPositionChanged(object sender, CaretPositionChangedEventArgs e) => this.ShowErrorTagContentAtCaret(); 39 | 40 | private void OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) => this.ShowErrorTagContentAtCaret(); 41 | 42 | private void ShowErrorTagContentAtCaret() 43 | { 44 | // Get all error tags that intersect with the caret. 45 | var caretPosition = this.textView.Caret.Position.BufferPosition; 46 | var errorTagsAtCaret = this.errorTagAggregator.GetTags(new SnapshotSpan(caretPosition, 0)); 47 | 48 | // Optimisation: ErrorTags list is usually empty (or one). List of known error types is 6+ items. 49 | // Therefore, avoid iterating through the error type list where possible. 50 | // Convert the enum to list so we can easily see if it's empty or one. 51 | // Only where there are more than one ErrorTag do we need to sort by priority. 52 | var errorTagList = errorTagsAtCaret.ToList(); 53 | switch (errorTagList.Count) 54 | { 55 | case 0: 56 | // No error tag at caret location. Clear the status bar. 57 | ClearStatusBarText(); 58 | return; 59 | case 1: 60 | // Only one error tag at this location. Show it on the status bar. 61 | this.UpdateStatusBarFromErrorTag(errorTagList[0]); 62 | return; 63 | default: 64 | // More than one error tag. Show highest priority error. 65 | var highestPriorityErrorTag = GetHighestPriorityErrorTag(errorTagList); 66 | this.UpdateStatusBarFromErrorTag(highestPriorityErrorTag); 67 | return; 68 | } 69 | } 70 | 71 | private IMappingTagSpan GetHighestPriorityErrorTag(List> mappingTagSpans) 72 | { 73 | // Get first, highest priority error tag. 74 | return this.factory.OrderedErrorTypeDefinitions 75 | .Select(errorTypeDefinition => mappingTagSpans.FirstOrDefault(tag => 76 | string.Equals(tag.Tag.ErrorType, errorTypeDefinition.Metadata.Name, 77 | StringComparison.OrdinalIgnoreCase))) 78 | .FirstOrDefault(firstMatchingTag => firstMatchingTag != null); 79 | } 80 | 81 | private void UpdateStatusBarFromErrorTag(IMappingTagSpan mappingTagSpan) 82 | { 83 | var errorTagContent = mappingTagSpan?.Tag?.ToolTipContent?.ToString(); 84 | if (errorTagContent != null) 85 | { 86 | SetStatusBarText(errorTagContent); 87 | } else 88 | { 89 | // Handle the case of a Suggestion tag with no tooltip content 90 | ClearStatusBarText(); 91 | } 92 | // Always update the Last Error Text - even if it is null 93 | this.factory.LastErrorText = errorTagContent; 94 | } 95 | 96 | private void SetStatusBarText(string errorTagContent) 97 | { 98 | // Don't set the status bar text if it's already set. 99 | // Note: Costs a GetText operation. Is this faster than SetText? 100 | Marshal.ThrowExceptionForHR(this.factory.StatusBarService.GetText(out string currentStatusBarText)); 101 | if (currentStatusBarText.Equals(errorTagContent)) return; 102 | 103 | Marshal.ThrowExceptionForHR(this.factory.StatusBarService.SetText(errorTagContent)); 104 | this.factory.LastErrorText = errorTagContent; 105 | } 106 | 107 | private void ClearStatusBarText() 108 | { 109 | // Don't bother clearing the status bar if we didn't set anything 110 | if (string.IsNullOrEmpty(this.factory.LastErrorText)) return; 111 | 112 | // Don't clear the status bar if there's nothing in it or if it's not the last error text 113 | Marshal.ThrowExceptionForHR(this.factory.StatusBarService.GetText(out string currentStatusBarText)); 114 | if (string.IsNullOrEmpty(currentStatusBarText) || 115 | !string.Equals(currentStatusBarText, this.factory.LastErrorText)) return; 116 | 117 | // The text in the status bar is the text last set. Can safely clear it. 118 | Marshal.ThrowExceptionForHR(this.factory.StatusBarService.Clear()); 119 | this.factory.LastErrorText = null; 120 | } 121 | 122 | private void OnTextViewClosed(object sender, System.EventArgs e) 123 | { 124 | this.errorTagAggregator.BatchedTagsChanged -= this.OnBatchedTagsChanged; 125 | this.errorTagAggregator.Dispose(); 126 | 127 | this.textView.Closed -= this.OnTextViewClosed; 128 | this.textView.Caret.PositionChanged -= this.OnCaretPositionChanged; 129 | //textView.VisualElement.GotKeyboardFocus -= this.OnGotKeyboardFocus; 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /HotSettings/VSPackage.resx: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | text/microsoft-resx 120 | 121 | 122 | 2.0 123 | 124 | 125 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 126 | 127 | 128 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 129 | 130 | 131 | 132 | Command1 Extension 133 | 134 | 135 | Command1 Visual Studio Extension Detailed Info 136 | 137 | 138 | Resources\DefaultPackage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 139 | 140 | -------------------------------------------------------------------------------- /HotSettings/TrackActiveItemsCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Settings; 2 | using Microsoft.VisualStudio.Shell; 3 | using Microsoft.VisualStudio.Shell.Settings; 4 | using Microsoft.VisualStudio.Text.Editor; 5 | using System; 6 | using System.ComponentModel.Design; 7 | using Microsoft.VisualStudio.TextManager.Interop; 8 | using Microsoft.VisualStudio.Shell.Interop; 9 | 10 | namespace HotSettings 11 | { 12 | /// 13 | /// Command handler 14 | /// 15 | internal sealed class TrackActiveItemsCommandHandler 16 | { 17 | // Command Guid and ID 18 | private readonly Guid HotSettingsPackageCmdSetGuid = Constants.HotSettingsCmdSetGuid; 19 | private const int ToggleTrackActiveItemCmdId = Constants.ToggleTrackActiveItemCmdId; 20 | 21 | // UserSettingsStore properties 22 | private const string SOLUTION_NAVIGATOR_GROUP = @"ApplicationPrivateSettings\SolutionNavigator"; 23 | private const string TRACK_ACTIVE_ITEM_IN_SOLN_EXP = "TrackSelCtxInSlnExp"; 24 | 25 | /// 26 | /// VS Package that provides this command, not null. 27 | /// 28 | private readonly Package package; 29 | 30 | private SettingsStore SettingsStore; 31 | private IEditorOptionsFactoryService OptionsService; 32 | private IVsTextManager2 TextManager; 33 | //private IVsEditorAdaptersFactoryService EditorAdaptersFactoryService; 34 | 35 | /// 36 | /// Gets the instance of the command. 37 | /// 38 | public static TrackActiveItemsCommandHandler Instance { get; private set; } 39 | 40 | /// 41 | /// Gets the service provider from the owner package. 42 | /// 43 | private System.IServiceProvider ServiceProvider 44 | { 45 | get 46 | { 47 | return this.package; 48 | } 49 | } 50 | 51 | private WritableSettingsStore _userSettingsStore; 52 | private WritableSettingsStore UserSettingsStore 53 | { 54 | get 55 | { 56 | if (_userSettingsStore == null) 57 | { 58 | ShellSettingsManager settingsManager = new ShellSettingsManager(this.ServiceProvider); 59 | _userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); 60 | } 61 | return _userSettingsStore; 62 | } 63 | } 64 | 65 | /// 66 | /// Initializes the singleton instance of the command. 67 | /// 68 | /// Owner package, not null. 69 | public static void Initialize(Package package) 70 | { 71 | Instance = new TrackActiveItemsCommandHandler(package); 72 | } 73 | 74 | /// 75 | /// Initializes a new instance of the class. 76 | /// Adds our command handlers for menu (commands must exist in the command table file) 77 | /// 78 | /// Owner package, not null. 79 | private TrackActiveItemsCommandHandler(Package package) 80 | { 81 | this.package = package ?? throw new ArgumentNullException("package"); 82 | 83 | ShellSettingsManager settingsManager = new ShellSettingsManager(package); 84 | SettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); 85 | 86 | OptionsService = ServicesUtil.GetMefService(this.ServiceProvider); 87 | TextManager = (IVsTextManager2)ServiceProvider.GetService(typeof(SVsTextManager)); 88 | 89 | RegisterGlobalCommands(); 90 | } 91 | 92 | private void RegisterGlobalCommands() 93 | { 94 | if (ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService) 95 | { 96 | // Register command handler for TrackActiveItems menu command 97 | CommandID menuCommandID = new CommandID(HotSettingsPackageCmdSetGuid, ToggleTrackActiveItemCmdId); 98 | OleMenuCommand oleMenuCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID); 99 | oleMenuCommand.BeforeQueryStatus += this.OnBeforeQueryStatus; 100 | commandService.AddCommand(oleMenuCommand); 101 | } 102 | } 103 | 104 | /// 105 | /// This function is run whenever VS is considering displaying the command. 106 | /// For menu items, it runs it before opening the menu. For toolbar items, it seems to run is frequently. 107 | /// Here you can change the visibility of a menu item. Also set its Checked state, and other properties (like Enabled). 108 | /// 109 | public void OnBeforeQueryStatus(object sender, EventArgs e) 110 | { 111 | OleMenuCommand command = (OleMenuCommand)sender; 112 | switch ((uint)command.CommandID.ID) 113 | { 114 | case ToggleTrackActiveItemCmdId: 115 | QueryStatusToggleTrackActiveItems(command); 116 | break; 117 | } 118 | } 119 | 120 | private void MenuItemCallback(object sender, EventArgs e) 121 | { 122 | MenuCommand command = (MenuCommand)sender; 123 | // Dispatch the action 124 | switch (command.CommandID.ID) 125 | { 126 | case ToggleTrackActiveItemCmdId: 127 | HandleToggleTrackActiveItem(command); 128 | break; 129 | } 130 | } 131 | 132 | private void QueryStatusToggleTrackActiveItems(OleMenuCommand command) 133 | { 134 | command.Enabled = true; // TODO: Set true if there is a solution 135 | command.Visible = true; // TODO: Set true if there is a solution 136 | command.Checked = IsTrackActiveItemInSolnExpEnabled(); 137 | } 138 | 139 | private void HandleToggleTrackActiveItem(MenuCommand command) 140 | { 141 | // Optimisation: Don't check the UserSettingStore. It has just been checked during QueryStatus. 142 | // Instead, set new value based on current checked state of MenuCommand. 143 | bool newCheckedState = !command.Checked; 144 | SetTrackActiveItem(newCheckedState); 145 | } 146 | 147 | public void ToggleTrackActiveItem() 148 | { 149 | bool enabled = IsTrackActiveItemInSolnExpEnabled(); 150 | SetTrackActiveItem(!enabled); 151 | } 152 | 153 | private bool IsTrackActiveItemInSolnExpEnabled() 154 | { 155 | // The value is 0*System.Boolean*True or 0*System.Boolean*False 156 | string trackActiveString = UserSettingsStore.GetString(SOLUTION_NAVIGATOR_GROUP, TRACK_ACTIVE_ITEM_IN_SOLN_EXP); 157 | return trackActiveString.ToLower().Contains("true"); 158 | } 159 | 160 | private void SetTrackActiveItem(bool newValue) 161 | { 162 | object solutionExplorerDocView = GetSolutionExplorerDocView(); 163 | solutionExplorerDocView 164 | .GetType() 165 | .GetMethod("SetProperty") 166 | .Invoke(solutionExplorerDocView, new object[] { 2, newValue ? 1 : 0 }); 167 | } 168 | 169 | private object GetSolutionExplorerDocView() 170 | { 171 | // TODO: Consider if we can get the Solution Explorer frame from the command - since it's already docked on the Solution Exp window toolbar. 172 | IVsUIShell vsuiShell = this.ServiceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell; 173 | vsuiShell.FindToolWindow(0, new Guid("3AE79031-E1BC-11D0-8F78-00A0C9110057"), out IVsWindowFrame solutionExplorerFrame); 174 | solutionExplorerFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out object solutionExplorerDocView); 175 | return solutionExplorerDocView; 176 | } 177 | 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /HotSettings/HotSettings.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $(VisualStudioVersion) 8 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 9 | 10 | 11 | true 12 | 13 | 14 | true 15 | Key.snk 16 | 17 | 18 | Debug 19 | AnyCPU 20 | 2.0 21 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 22 | {77787521-2611-4D00-BF57-2B514CF236BB} 23 | Library 24 | v3 25 | Properties 26 | HotSettings 27 | HotSettings 28 | v4.5.2 29 | true 30 | true 31 | true 32 | true 33 | true 34 | false 35 | 36 | 37 | Program 38 | $(DevEnvDir)\devenv.exe 39 | /rootsuffix Exp 40 | 41 | 42 | true 43 | full 44 | false 45 | bin\Debug\ 46 | DEBUG;TRACE 47 | prompt 48 | 4 49 | 50 | 51 | 52 | 53 | pdbonly 54 | true 55 | bin\Release\ 56 | TRACE 57 | prompt 58 | 4 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Designer 84 | 85 | 86 | Designer 87 | 88 | 89 | 90 | 91 | true 92 | Always 93 | 94 | 95 | true 96 | Always 97 | 98 | 99 | 100 | Always 101 | true 102 | 103 | 104 | Menus.ctmenu 105 | Designer 106 | 107 | 108 | 109 | 110 | Always 111 | 112 | 113 | 114 | 115 | 116 | 117 | False 118 | 119 | 120 | False 121 | 122 | 123 | False 124 | 125 | 126 | False 127 | 128 | 129 | 130 | 131 | False 132 | 133 | 134 | ..\packages\VSSDK.ComponentModelHost.12.0.4\lib\net45\Microsoft.VisualStudio.ComponentModelHost.dll 135 | False 136 | 137 | 138 | ..\packages\Microsoft.VisualStudio.CoreUtility.14.3.25407\lib\net45\Microsoft.VisualStudio.CoreUtility.dll 139 | True 140 | 141 | 142 | ..\packages\Microsoft.VisualStudio.Editor.14.3.25407\lib\net45\Microsoft.VisualStudio.Editor.dll 143 | True 144 | 145 | 146 | ..\packages\Microsoft.VisualStudio.Imaging.14.3.25407\lib\net45\Microsoft.VisualStudio.Imaging.dll 147 | True 148 | 149 | 150 | ..\packages\Microsoft.VisualStudio.Language.Intellisense.14.3.25407\lib\net45\Microsoft.VisualStudio.Language.Intellisense.dll 151 | True 152 | 153 | 154 | ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll 155 | True 156 | 157 | 158 | ..\packages\Microsoft.VisualStudio.Shell.14.0.14.3.25407\lib\Microsoft.VisualStudio.Shell.14.0.dll 159 | True 160 | 161 | 162 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.10.0.10.0.30319\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll 163 | True 164 | 165 | 166 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll 167 | True 168 | 169 | 170 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.12.0.12.0.21003\lib\net45\Microsoft.VisualStudio.Shell.Immutable.12.0.dll 171 | True 172 | 173 | 174 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll 175 | True 176 | 177 | 178 | ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll 179 | True 180 | 181 | 182 | True 183 | ..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll 184 | True 185 | 186 | 187 | True 188 | ..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll 189 | True 190 | 191 | 192 | True 193 | ..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll 194 | True 195 | 196 | 197 | ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll 198 | True 199 | 200 | 201 | ..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll 202 | True 203 | 204 | 205 | ..\packages\Microsoft.VisualStudio.Text.Data.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Data.dll 206 | True 207 | 208 | 209 | ..\packages\Microsoft.VisualStudio.Text.Logic.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Logic.dll 210 | True 211 | 212 | 213 | ..\packages\Microsoft.VisualStudio.Text.UI.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.UI.dll 214 | True 215 | 216 | 217 | ..\packages\Microsoft.VisualStudio.Text.UI.Wpf.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.UI.Wpf.dll 218 | True 219 | 220 | 221 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll 222 | True 223 | 224 | 225 | True 226 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.TextManager.Interop.11.0.dll 227 | True 228 | 229 | 230 | True 231 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.TextManager.Interop.12.0.dll 232 | True 233 | 234 | 235 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll 236 | True 237 | 238 | 239 | ..\packages\Microsoft.VisualStudio.Threading.14.1.111\lib\net45\Microsoft.VisualStudio.Threading.dll 240 | True 241 | 242 | 243 | ..\packages\Microsoft.VisualStudio.Utilities.14.3.25407\lib\net45\Microsoft.VisualStudio.Utilities.dll 244 | True 245 | 246 | 247 | ..\packages\Microsoft.VisualStudio.Validation.14.1.111\lib\net45\Microsoft.VisualStudio.Validation.dll 248 | True 249 | 250 | 251 | 252 | 253 | False 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | true 269 | VSPackage 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 295 | -------------------------------------------------------------------------------- /HotSettings/HotSettingsCommandFilter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.OLE.Interop; 2 | using Microsoft.VisualStudio.Text.Editor; 3 | using OLEConstants = Microsoft.VisualStudio.OLE.Interop.Constants; 4 | using System; 5 | using Microsoft.VisualStudio; 6 | using Microsoft.VisualStudio.TextManager.Interop; 7 | using System.Runtime.InteropServices; 8 | using System.Collections.Generic; 9 | 10 | namespace HotSettings 11 | { 12 | internal sealed class HotSettingsCommandFilter : IOleCommandTarget 13 | { 14 | private readonly IWpfTextView textView; 15 | private Guid languageServiceGuid; 16 | 17 | private IVsTextManager6 TextManager; 18 | 19 | // Map 20 | private static Dictionary> RestoreSettingsMap = new Dictionary>(); 21 | 22 | public HotSettingsCommandFilter(IWpfTextView textView, Guid languageServiceGuid, IVsTextManager6 textManager) 23 | { 24 | this.textView = textView; 25 | this.languageServiceGuid = languageServiceGuid; 26 | TextManager = textManager; 27 | } 28 | 29 | public IOleCommandTarget Next { get; internal set; } 30 | 31 | public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) 32 | { 33 | // Command handling registration 34 | if (pguidCmdGroup == Constants.HotSettingsCmdSetGuid && cCmds == 1) 35 | { 36 | switch (prgCmds[0].cmdID) 37 | { 38 | // Editor Margins 39 | case Constants.ToggleCleanMarginsCmdId: 40 | QueryStatusToggleCleanMargins(prgCmds, pCmdText); 41 | return VSConstants.S_OK; 42 | case Constants.ToggleIndicatorMarginCmdId: 43 | QueryStatusToggleIndicatorMargin(prgCmds); 44 | return VSConstants.S_OK; 45 | case Constants.ToggleLineNumbersCmdId: 46 | QueryStatusToggleLineNumbers(languageServiceGuid, prgCmds); 47 | return VSConstants.S_OK; 48 | case Constants.ToggleQuickActionsCmdId: 49 | QueryStatusToggleLightbulbMargin(prgCmds); 50 | return VSConstants.S_OK; 51 | case Constants.ToggleSelectionMarginCmdId: 52 | QueryStatusToggleSelectionMargin(prgCmds); 53 | return VSConstants.S_OK; 54 | case Constants.ToggleTrackChangesCmdId: 55 | QueryStatusToggleTrackChanges(prgCmds); 56 | return VSConstants.S_OK; 57 | 58 | // Editor Navigational Aids 59 | case Constants.ToggleNavigationBarCmdId: 60 | QueryStatusToggleNavigationBar(languageServiceGuid, prgCmds); 61 | return VSConstants.S_OK; 62 | //case Constants.ToggleCodeLensCmdId: 63 | // QueryStatusToggleCodeLens(languageServiceGuid, prgCmds); 64 | // return VSConstants.S_OK; 65 | case Constants.ToggleStructureGuideLinesCmdId: 66 | QueryStatusToggleStructureGuideLines(prgCmds); 67 | return VSConstants.S_OK; 68 | } 69 | } 70 | 71 | if (Next != null) 72 | { 73 | return Next.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); 74 | } 75 | return (int)OLEConstants.OLECMDERR_E_UNKNOWNGROUP; 76 | } 77 | 78 | public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) 79 | { 80 | // Command handling 81 | if (pguidCmdGroup == Constants.HotSettingsCmdSetGuid) 82 | { 83 | // Dispatch to the correct command handler 84 | switch (nCmdID) 85 | { 86 | // Editor Margins 87 | case Constants.ToggleCleanMarginsCmdId: 88 | ExecToggleCleanMargins(textView); 89 | return VSConstants.S_OK; 90 | case Constants.ToggleIndicatorMarginCmdId: 91 | ExecToggleIndicatorMargin(); 92 | return VSConstants.S_OK; 93 | case Constants.ToggleLineNumbersCmdId: 94 | ExecToggleLineNumbers(languageServiceGuid); 95 | return VSConstants.S_OK; 96 | case Constants.ToggleQuickActionsCmdId: 97 | ExecToggleLightbulbMargin(textView); 98 | return VSConstants.S_OK; 99 | case Constants.ToggleSelectionMarginCmdId: 100 | ExecToggleSelectionMargin(textView); 101 | return VSConstants.S_OK; 102 | case Constants.ToggleTrackChangesCmdId: 103 | ExecToggleTrackChanges(textView); 104 | return VSConstants.S_OK; 105 | 106 | // Editor Navigational Aids 107 | case Constants.ToggleNavigationBarCmdId: 108 | ExecToggleNavigationBar(textView, languageServiceGuid); 109 | return VSConstants.S_OK; 110 | case Constants.ToggleStructureGuideLinesCmdId: 111 | ExecToggleStructureGuideLines(textView); 112 | return VSConstants.S_OK; 113 | } 114 | } 115 | 116 | // No commands called. Pass to next command handler. 117 | if (Next != null) 118 | { 119 | return Next.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); 120 | } 121 | return (int)OLEConstants.OLECMDERR_E_UNKNOWNGROUP; 122 | } 123 | 124 | private void EnableAndCheckCommand(OLECMD[] prgCmds, bool isEnabled) 125 | { 126 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_SUPPORTED; 127 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED; 128 | if (isEnabled) 129 | { 130 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_LATCHED; 131 | } 132 | } 133 | 134 | internal void QueryStatusToggleCleanMargins(OLECMD[] prgCmds, IntPtr pCmdText) 135 | { 136 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_SUPPORTED; 137 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED; 138 | 139 | // Toggle the text on the menu command - Hide/Restore editor margins 140 | if (CanRestoreEditorMargins()) 141 | { 142 | SetOleCmdText(pCmdText, "Restore Hidden &Margins"); 143 | } 144 | else 145 | { 146 | SetOleCmdText(pCmdText, "Hide Editor &Margins"); 147 | } 148 | } 149 | 150 | private bool CanRestoreEditorMargins() 151 | { 152 | // Check that there are restore settings saved and that all margins are hidden 153 | if (!RestoreSettingsMap.ContainsKey(languageServiceGuid)) return false; 154 | // Note: Checking if all margins are hidden is more costly (involves reading from UserPreferences), 155 | // so only call that if we have settings stored. 156 | GetAllUserPreferences(languageServiceGuid, out var viewPrefs, out var langPrefs); 157 | return AllMarginsAreHidden(viewPrefs, langPrefs); 158 | } 159 | 160 | public void SetOleCmdText(IntPtr pCmdText, string text) 161 | { 162 | OLECMDTEXT CmdText = (OLECMDTEXT)Marshal.PtrToStructure(pCmdText, typeof(OLECMDTEXT)); 163 | char[] buffer = text.ToCharArray(); 164 | IntPtr pText = (IntPtr)((long)pCmdText + (long)Marshal.OffsetOf(typeof(OLECMDTEXT), "rgwz")); 165 | IntPtr pCwActual = (IntPtr)((long)pCmdText + (long)Marshal.OffsetOf(typeof(OLECMDTEXT), "cwActual")); 166 | // The max chars we copy is our string, or one less than the buffer size, since we need a null at the end. 167 | int maxChars = (int)Math.Min(CmdText.cwBuf - 1, buffer.Length); 168 | Marshal.Copy(buffer, 0, pText, maxChars); 169 | // append a null 170 | Marshal.WriteInt16((IntPtr)((long)pText + (long)maxChars * 2), (Int16)0); 171 | // write out the length + null char 172 | Marshal.WriteInt32(pCwActual, maxChars + 1); 173 | } 174 | 175 | public void QueryStatusToggleIndicatorMargin(OLECMD[] prgCmds) 176 | { 177 | EnableAndCheckCommand(prgCmds, IsIndicatorMarginEnabled()); 178 | } 179 | 180 | public void QueryStatusToggleLineNumbers(Guid langServiceGuid, OLECMD[] prgCmds) 181 | { 182 | EnableAndCheckCommand(prgCmds, IsLineNumbersEnabled(langServiceGuid)); 183 | } 184 | 185 | private void QueryStatusToggleLightbulbMargin(OLECMD[] prgCmds) 186 | { 187 | EnableAndCheckCommand(prgCmds, IsLightbulbMarginEnabled()); 188 | } 189 | 190 | public void QueryStatusToggleSelectionMargin(OLECMD[] prgCmds) 191 | { 192 | EnableAndCheckCommand(prgCmds, IsSelectionMarginEnabled()); 193 | } 194 | 195 | public void QueryStatusToggleTrackChanges(OLECMD[] prgCmds) 196 | { 197 | //EnableAndCheckCommand(prgCmds, IsSelectionMarginEnabled()); 198 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_SUPPORTED; 199 | VIEWPREFERENCES5 viewPrefs = GetViewPreferences(); 200 | if (IsSelectionMarginEnabled(viewPrefs)) 201 | { 202 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED; 203 | } 204 | if (IsTrackChangesEnabled(viewPrefs)) 205 | { 206 | prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_LATCHED; 207 | } 208 | } 209 | 210 | public void QueryStatusToggleNavigationBar(Guid langServiceGuid, OLECMD[] prgCmds) 211 | { 212 | EnableAndCheckCommand(prgCmds, IsNavBarEnabled(langServiceGuid)); 213 | } 214 | 215 | internal void QueryStatusToggleStructureGuideLines(OLECMD[] prgCmds) 216 | { 217 | EnableAndCheckCommand(prgCmds, IsStructureGuideLinesEnabled()); 218 | } 219 | 220 | internal void ExecToggleCleanMargins(IWpfTextView textView) 221 | { 222 | GetAllUserPreferences(languageServiceGuid, out var viewPrefs, out var langPrefs); 223 | if (AllMarginsAreHidden(viewPrefs, langPrefs)) 224 | { 225 | RestoreMargins(); 226 | } else 227 | { 228 | SaveCurrentViewAndLangPrefs(viewPrefs, langPrefs); 229 | HideAllEditorMargins(viewPrefs, langPrefs); 230 | } 231 | } 232 | 233 | private bool AllMarginsAreHidden(VIEWPREFERENCES5 viewPrefs, LANGPREFERENCES3 langPrefs) 234 | { 235 | // Check for BreakPoint, LineNumbers, SelectionMargin, TrackChanges 236 | if (IsIndicatorMarginEnabled(viewPrefs)) return false; 237 | if (IsLineNumbersEnabled(langPrefs)) return false; 238 | if (IsSelectionMarginEnabled(viewPrefs)) return false; 239 | return true; 240 | } 241 | 242 | private void HideAllEditorMargins(VIEWPREFERENCES5 viewPrefs, LANGPREFERENCES3 langPrefs) 243 | { 244 | // Mark all editor margins as hidden 245 | viewPrefs.fWidgetMargin = 0; 246 | langPrefs.fLineNumbers = 0; 247 | viewPrefs.fSelectionMargin = 0; 248 | SaveAllUserPreferences(viewPrefs, langPrefs); 249 | } 250 | 251 | private void SaveCurrentViewAndLangPrefs(VIEWPREFERENCES5 viewPrefs, LANGPREFERENCES3 langPrefs) 252 | { 253 | // Create a Map of settings to restore to 254 | Dictionary restoreSettings = new Dictionary 255 | { 256 | // Save the viewPrefs and langPrefs 257 | ["ViewPrefs"] = viewPrefs, // Holds Breakpoint, SelectionMargin 258 | ["LangPrefs"] = langPrefs // Holds LineNumbers 259 | }; 260 | 261 | // Save the RestoreActions to the global map against the given language type 262 | RestoreSettingsMap[languageServiceGuid] = restoreSettings; 263 | } 264 | 265 | private void RestoreMargins() 266 | { 267 | // Get old user settings 268 | RestoreSettingsMap.TryGetValue(languageServiceGuid, out Dictionary restoreSettings); 269 | if (restoreSettings == null) return; // No previous settings found. Exit out. 270 | VIEWPREFERENCES5 oldViewPrefs = (VIEWPREFERENCES5)restoreSettings["ViewPrefs"]; 271 | LANGPREFERENCES3 oldLangPrefs = (LANGPREFERENCES3)restoreSettings["LangPrefs"]; 272 | // Fetch the latest settings 273 | GetAllUserPreferences(languageServiceGuid, out VIEWPREFERENCES5 viewPrefs, out LANGPREFERENCES3 langPrefs); 274 | // Update all the margins to be the same as the restore settings 275 | viewPrefs.fWidgetMargin = oldViewPrefs.fWidgetMargin; 276 | viewPrefs.fSelectionMargin = oldViewPrefs.fSelectionMargin; 277 | langPrefs.fLineNumbers = oldLangPrefs.fLineNumbers; 278 | // Save the new settings 279 | SaveAllUserPreferences(viewPrefs, langPrefs); 280 | } 281 | 282 | private void SaveAllUserPreferences(VIEWPREFERENCES5 viewPrefs, LANGPREFERENCES3 langPrefs) 283 | { 284 | Marshal.ThrowExceptionForHR(TextManager.SetUserPreferences6(new VIEWPREFERENCES5[] { viewPrefs }, new LANGPREFERENCES3[] { langPrefs }, null)); 285 | } 286 | 287 | private void EnableIndicatorMargin() 288 | { 289 | var viewPrefs = GetViewPreferences(); 290 | if (!IsSelectionMarginEnabled(viewPrefs)) 291 | { 292 | SetIndicatorMarginEnabled(viewPrefs, true); 293 | } 294 | } 295 | 296 | private void EnableLineNumbers() 297 | { 298 | var langPrefs = GetLanguagePreferences(languageServiceGuid); 299 | if (!IsLineNumbersEnabled(langPrefs)) 300 | { 301 | SetLineNumbersEnabled(true); 302 | } 303 | } 304 | 305 | private void EnableSelectionMargin() 306 | { 307 | var viewPrefs = GetViewPreferences(); 308 | if (!IsSelectionMarginEnabled(viewPrefs)) 309 | { 310 | SetSelectionMarginEnabled(viewPrefs, true); 311 | } 312 | } 313 | 314 | private void EnableTrackChanges() 315 | { 316 | var viewPrefs = GetViewPreferences(); 317 | if (!IsSelectionMarginEnabled(viewPrefs)) 318 | { 319 | SetTrackChangesEnabled(viewPrefs, true); 320 | } 321 | } 322 | 323 | private void ExecToggleLightbulbMargin(IWpfTextView textView) 324 | { 325 | bool enabled = (bool)textView.Options.GetOptionValue("TextViewHost/SuggestionMargin"); 326 | textView.Options.SetOptionValue("TextViewHost/SuggestionMargin", !enabled); 327 | } 328 | 329 | public void ExecToggleSelectionMargin(IWpfTextView textView) 330 | { 331 | // Get the view preferences 332 | VIEWPREFERENCES5 viewPrefs = GetViewPreferences(); 333 | bool enabled = IsSelectionMarginEnabled(viewPrefs); 334 | SetSelectionMarginEnabled(viewPrefs, !enabled); 335 | } 336 | 337 | public void ExecToggleLineNumbers(Guid langServiceGuid) 338 | { 339 | // Get the language preferences 340 | LANGPREFERENCES3 langPrefs = GetLanguagePreferences(langServiceGuid); 341 | bool enabled = IsLineNumbersEnabled(langPrefs); 342 | SetLineNumbersEnabled(langPrefs, !enabled); 343 | } 344 | 345 | 346 | 347 | private void SetLineNumbersEnabled(bool enabled) 348 | { 349 | SetLineNumbersEnabled(GetLanguagePreferences(languageServiceGuid), enabled); 350 | } 351 | 352 | private void SetLineNumbersEnabled(LANGPREFERENCES3 langPrefs, bool enabled) 353 | { 354 | // Update the Line Numbers state 355 | langPrefs.fLineNumbers = (uint)(enabled ? 1 : 0); 356 | // Save the update to the langPrefs 357 | SetLangPrefererences(langPrefs); 358 | } 359 | 360 | public void ExecToggleIndicatorMargin() 361 | { 362 | // Get the view preferences 363 | VIEWPREFERENCES5 viewPrefs = GetViewPreferences(); 364 | bool enabled = IsIndicatorMarginEnabled(viewPrefs); 365 | SetIndicatorMarginEnabled(!enabled); 366 | } 367 | 368 | public void SetIndicatorMarginEnabled(bool bShow) 369 | { 370 | // Get the view preferences 371 | SetIndicatorMarginEnabled(GetViewPreferences(), bShow); 372 | } 373 | 374 | public void SetIndicatorMarginEnabled(VIEWPREFERENCES5 viewPrefs, bool bShow) 375 | { 376 | // Set the value 377 | viewPrefs.fWidgetMargin = (uint)(bShow ? 1 : 0); 378 | // Save the update to the viewPrefs 379 | SetViewPrefererences(viewPrefs); 380 | } 381 | 382 | private void SetSelectionMarginEnabled(VIEWPREFERENCES5 viewPrefs, bool enabled) 383 | { 384 | viewPrefs.fSelectionMargin = (uint)(enabled ? 1 : 0); 385 | // Save the update to the viewPrefs 386 | SetViewPrefererences(viewPrefs); 387 | } 388 | 389 | private bool IsLightbulbMarginEnabled() 390 | { 391 | return (bool)textView.Options.GetOptionValue("TextViewHost/SuggestionMargin"); 392 | } 393 | 394 | private bool IsSelectionMarginEnabled() 395 | { 396 | return IsSelectionMarginEnabled(GetViewPreferences()); 397 | } 398 | 399 | private bool IsSelectionMarginEnabled(VIEWPREFERENCES5 viewPrefs) 400 | { 401 | return viewPrefs.fSelectionMargin == 1; 402 | } 403 | 404 | public void ExecToggleTrackChanges(IWpfTextView textView) 405 | { 406 | // Get the view preferences 407 | var viewPrefs = GetViewPreferences(); 408 | bool enabled = IsTrackChangesEnabled(viewPrefs); 409 | SetTrackChangesEnabled(viewPrefs, !enabled); 410 | } 411 | 412 | private void SetTrackChangesEnabled(VIEWPREFERENCES5 viewPrefs, bool enabled) 413 | { 414 | viewPrefs.fTrackChanges = (uint)(enabled ? 1 : 0); 415 | // Save the update to the viewPrefs 416 | SetViewPrefererences(viewPrefs); 417 | } 418 | 419 | public void ExecToggleStructureGuideLines(IWpfTextView textView) 420 | { 421 | // Get the view preferences 422 | VIEWPREFERENCES5 viewPrefs = GetViewPreferences(); 423 | bool enabled = IsStructureGuideLinesEnabled(viewPrefs); 424 | SetStructureGuideLinesEnabled(viewPrefs, !enabled); 425 | } 426 | 427 | private void SetStructureGuideLinesEnabled(VIEWPREFERENCES5 viewPrefs, bool enabled) 428 | { 429 | viewPrefs.fShowBlockStructure = (uint)(enabled ? 1 : 0); 430 | // Save the update to the viewPrefs 431 | SetViewPrefererences(viewPrefs); 432 | } 433 | 434 | private bool IsTrackChangesEnabled() 435 | { 436 | return IsTrackChangesEnabled(GetViewPreferences()); 437 | } 438 | 439 | private bool IsTrackChangesEnabled(VIEWPREFERENCES5 viewPrefs) 440 | { 441 | return viewPrefs.fTrackChanges == 1; 442 | } 443 | 444 | private bool IsIndicatorMarginEnabled() 445 | { 446 | return IsIndicatorMarginEnabled(GetViewPreferences()); 447 | } 448 | 449 | private bool IsIndicatorMarginEnabled(VIEWPREFERENCES5 viewPrefs) 450 | { 451 | return viewPrefs.fWidgetMargin == 1; 452 | } 453 | 454 | private bool IsLineNumbersEnabled(LANGPREFERENCES3 langPrefs) 455 | { 456 | return langPrefs.fLineNumbers == 1; 457 | } 458 | 459 | private bool IsLineNumbersEnabled(Guid langServiceGuid) 460 | { 461 | return IsLineNumbersEnabled(GetLanguagePreferences(langServiceGuid)); 462 | } 463 | 464 | private bool IsStructureGuideLinesEnabled() 465 | { 466 | VIEWPREFERENCES5 viewPrefs = GetViewPreferences(); 467 | return IsStructureGuideLinesEnabled(viewPrefs); 468 | } 469 | 470 | private bool IsStructureGuideLinesEnabled(VIEWPREFERENCES5 viewPrefs) 471 | { 472 | return viewPrefs.fShowBlockStructure == 1; 473 | } 474 | 475 | private VIEWPREFERENCES5 GetViewPreferences() 476 | { 477 | VIEWPREFERENCES5[] viewPrefs = new VIEWPREFERENCES5[] { new VIEWPREFERENCES5() }; 478 | Marshal.ThrowExceptionForHR(TextManager.GetUserPreferences6(viewPrefs, null, null)); 479 | return viewPrefs[0]; 480 | } 481 | 482 | private void SetViewPrefererences(VIEWPREFERENCES5 viewPrefs) 483 | { 484 | Marshal.ThrowExceptionForHR(TextManager.SetUserPreferences6(new VIEWPREFERENCES5[] { viewPrefs }, null, null)); 485 | } 486 | 487 | private void GetAllUserPreferences(Guid langServiceGuid, out VIEWPREFERENCES5 viewPrefs, out LANGPREFERENCES3 langPrefs) 488 | { 489 | LANGPREFERENCES3[] langPrefsArr = new LANGPREFERENCES3[] { new LANGPREFERENCES3() }; 490 | VIEWPREFERENCES5[] viewPrefsArr = new VIEWPREFERENCES5[] { new VIEWPREFERENCES5() }; 491 | langPrefsArr[0].guidLang = langServiceGuid; 492 | Marshal.ThrowExceptionForHR(TextManager.GetUserPreferences6(viewPrefsArr, langPrefsArr, null)); 493 | langPrefs = langPrefsArr[0]; 494 | viewPrefs = viewPrefsArr[0]; 495 | } 496 | 497 | private LANGPREFERENCES3 GetLanguagePreferences(Guid langServiceGuid) 498 | { 499 | LANGPREFERENCES3[] langPrefs = new LANGPREFERENCES3[] { new LANGPREFERENCES3() }; 500 | langPrefs[0].guidLang = langServiceGuid; 501 | Marshal.ThrowExceptionForHR(TextManager.GetUserPreferences6(null, langPrefs, null)); 502 | return langPrefs[0]; 503 | } 504 | 505 | private void SetLangPrefererences(LANGPREFERENCES3 langPrefs) 506 | { 507 | Marshal.ThrowExceptionForHR(TextManager.SetUserPreferences6(null, new LANGPREFERENCES3[] { langPrefs }, null)); 508 | } 509 | 510 | public void ExecToggleNavigationBar(IWpfTextView textView, Guid langServiceGuid) 511 | { 512 | // Get the language preferences 513 | LANGPREFERENCES3 langPrefs = GetLanguagePreferences(langServiceGuid); 514 | bool enabled = IsNavBarEnabled(langPrefs); 515 | // Update the state (toggle) 516 | langPrefs.fDropdownBar = (uint)(enabled ? 0 : 1); 517 | // Save the update to the langPrefs 518 | SetLangPrefererences(langPrefs); 519 | } 520 | 521 | private bool IsNavBarEnabled(Guid langServiceGuid) 522 | { 523 | return IsNavBarEnabled(GetLanguagePreferences(langServiceGuid)); 524 | } 525 | 526 | private static bool IsNavBarEnabled(LANGPREFERENCES3 langPrefs) 527 | { 528 | return langPrefs.fDropdownBar == 1; 529 | } 530 | 531 | 532 | 533 | } 534 | } 535 | -------------------------------------------------------------------------------- /HotSettings/HotSettingsCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using EnvDTE80; 3 | using Microsoft.VisualStudio.Settings; 4 | using Microsoft.VisualStudio.Shell; 5 | using Microsoft.VisualStudio.Shell.Settings; 6 | using Microsoft.VisualStudio.Text.Editor; 7 | using System; 8 | using System.ComponentModel.Design; 9 | using System.Windows; 10 | 11 | namespace HotSettings 12 | { 13 | /// 14 | /// Command handler 15 | /// 16 | internal sealed class HotSettingsCommandHandler 17 | { 18 | /// 19 | /// VS Package that provides this command, not null. 20 | /// 21 | private readonly Package package; 22 | 23 | private SettingsStore SettingsStore; 24 | private IEditorOptionsFactoryService OptionsService; 25 | //private IVsTextManager4 TextManager; 26 | //private IVsEditorAdaptersFactoryService EditorAdaptersFactoryService; 27 | 28 | public static OleMenuCommand ToggleShowMarksCmd; 29 | 30 | /// 31 | /// Gets the instance of the command. 32 | /// 33 | public static HotSettingsCommandHandler Instance { get; private set; } 34 | 35 | /// 36 | /// Gets the service provider from the owner package. 37 | /// 38 | private System.IServiceProvider ServiceProvider 39 | { 40 | get 41 | { 42 | return this.package; 43 | } 44 | } 45 | 46 | /// 47 | /// Initializes the singleton instance of the command. 48 | /// 49 | /// Owner package, not null. 50 | public static void Initialize(Package package) 51 | { 52 | Instance = new HotSettingsCommandHandler(package); 53 | } 54 | 55 | /// 56 | /// Initializes a new instance of the class. 57 | /// Adds our command handlers for menu (commands must exist in the command table file) 58 | /// 59 | /// Owner package, not null. 60 | private HotSettingsCommandHandler(Package package) 61 | { 62 | this.package = package ?? throw new ArgumentNullException("package"); 63 | 64 | ShellSettingsManager settingsManager = new ShellSettingsManager(package); 65 | SettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings); 66 | 67 | OptionsService = ServicesUtil.GetMefService(this.ServiceProvider); 68 | 69 | RegisterGlobalCommands(); 70 | } 71 | 72 | private void RegisterGlobalCommands() 73 | { 74 | if (ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService) 75 | { 76 | // Editor Margin Settings Commands 77 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleIndicatorMarginCmdId)); 78 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleLineNumbersCmdId)); 79 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleQuickActionsCmdId)); 80 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleSelectionMarginCmdId)); 81 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleTrackChangesCmdId)); 82 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleDiffMarginCmdId)); 83 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleOutliningCmdId)); 84 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleLiveUnitTestingCmdId)); 85 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleAnnotateCmdId)); 86 | // Editor Settings Commands 87 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleNavigationBarCmdId)); 88 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleCodeLensCmdId)); 89 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleIndentGuidesCmdId)); 90 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleHighlightCurrentLineCmdId)); 91 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleAutoDelimiterHighlightingCmdId)); 92 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleProcedureLineSeparatorCmdId)); 93 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleIntelliSensePopUpCmdId)); 94 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleLineEndingsCmdId)); 95 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleHighlightSymbolsCmdId)); 96 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleHighlightKeywordsCmdId)); 97 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleIntelliSenseSquigglesCmdId)); 98 | // Scrollbar Settings Commands 99 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowScrollbarMarkersCmdId)); 100 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowChangesCmdId)); 101 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowMarksCmdId)); 102 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowErrorsCmdId)); 103 | commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowCaretPositionCmdId)); 104 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleShowDiffsCmdId)); 105 | // Distraction Free mode 106 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleCleanEditorCmdId)); 107 | //commandService.AddCommand(CreateHotSettingsCommand(Constants.ToggleCleanMarginsCmdId)); 108 | } 109 | } 110 | 111 | private OleMenuCommand CreateHotSettingsCommand(int commandId) 112 | { 113 | Guid commandSet = Constants.HotSettingsCmdSetGuid; 114 | EventHandler execHandler = this.MenuItemCallback; 115 | EventHandler queryStatusHandler = this.OnBeforeQueryStatus; 116 | 117 | OleMenuCommand oleMenuCommand = CreateOleMenuCommand(commandSet, commandId, execHandler); 118 | oleMenuCommand.BeforeQueryStatus += queryStatusHandler; 119 | 120 | return oleMenuCommand; 121 | } 122 | 123 | public static OleMenuCommand CreateOleMenuCommand(Guid commandSet, int commandId, EventHandler handler) 124 | { 125 | CommandID menuCommandID = new CommandID(commandSet, commandId); 126 | return new OleMenuCommand(handler, menuCommandID); 127 | } 128 | 129 | /// 130 | /// This function is run whenever VS is considering displaying the command. 131 | /// For menu items, it runs it before opening the menu. For toolbar items, it seems to run is frequently. 132 | /// Here you can change the visibility of a menu item. Also set its Checked state, and other properties (like Enabled). 133 | /// 134 | public void OnBeforeQueryStatus(object sender, EventArgs e) 135 | { 136 | OleMenuCommand command = (OleMenuCommand)sender; 137 | switch ((uint)command.CommandID.ID) 138 | { 139 | //case Constants.ToggleIndicatorMarginCmdId: 140 | // this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Indicator Margin"); 141 | // break; 142 | //case Constants.ToggleLineNumbersCmdId: 143 | // this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "Line Numbers"); 144 | // break; 145 | //case Constants.ToggleQuickActionsCmdId: 146 | // HandleToggleLightbulbMarginQueryStatus(sender); 147 | // break; 148 | //case Constants.ToggleSelectionMarginCmdId: 149 | // this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Selection Margin"); 150 | // break; 151 | //case Constants.ToggleTrackChangesCmdId: 152 | // this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Track Changes"); 153 | // break; 154 | case Constants.ToggleDiffMarginCmdId: 155 | this.HideItem(sender); 156 | break; 157 | case Constants.ToggleOutliningCmdId: 158 | this.HandleOutliningQueryStatus(sender); 159 | break; 160 | case Constants.ToggleLiveUnitTestingCmdId: 161 | ToggleLiveUnitTesting.OnBeforeQueryStatus(sender, e); 162 | break; 163 | case Constants.ToggleAnnotateCmdId: 164 | //this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "Show Blame"); 165 | break; 166 | // Editor Settings 167 | //case Constants.ToggleNavigationBarCmdId: 168 | // this.HandleNavBarQueryStatus(sender); 169 | // break; 170 | case Constants.ToggleCodeLensCmdId: 171 | this.HandleToggleCodeLensQueryStatus(sender); 172 | break; 173 | //case Constants.ToggleStructureGuideLinesCmdId: 174 | // this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Indent Guides"); 175 | // // Hide if not VS2017+ 176 | // //this.HideItem(sender); 177 | //break; 178 | case Constants.ToggleHighlightCurrentLineCmdId: 179 | this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Highlight Current Line"); 180 | break; 181 | case Constants.ToggleAutoDelimiterHighlightingCmdId: 182 | this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor", "Auto Delimiter Highlighting"); 183 | break; 184 | case Constants.ToggleProcedureLineSeparatorCmdId: 185 | break; 186 | case Constants.ToggleIntelliSensePopUpCmdId: 187 | this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "Auto List Members"); 188 | this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "Auto List Params"); 189 | //this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "Hide Advanced Auto List Members"); 190 | break; 191 | case Constants.ToggleLineEndingsCmdId: 192 | break; 193 | case Constants.ToggleHighlightSymbolsCmdId: 194 | break; 195 | case Constants.ToggleHighlightKeywordsCmdId: 196 | break; 197 | //case Constants.ToggleIntelliSenseSquigglesCmdId: 198 | // Scrollbar Settings 199 | case Constants.ToggleShowScrollbarMarkersCmdId: 200 | // Turn off all Scrollbar markers with "ShowAnnotations" 201 | //this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", "ShowAnnotations"); 202 | MenuCommand menuCommand = ((MenuCommand)sender); 203 | //menuCommand.Visible = true; 204 | //menuCommand.Enabled = true; 205 | menuCommand.Checked = SettingsStore.GetBoolean("Text Editor\\CSharp", "ShowAnnotations"); 206 | break; 207 | case Constants.ToggleShowChangesCmdId: 208 | HandleScrollbarQueryStatus(sender, "ShowChanges"); 209 | break; 210 | case Constants.ToggleShowMarksCmdId: 211 | HandleScrollbarQueryStatus(sender, "ShowMarks"); 212 | break; 213 | case Constants.ToggleShowErrorsCmdId: 214 | HandleScrollbarQueryStatus(sender, "ShowErrors"); 215 | break; 216 | case Constants.ToggleShowCaretPositionCmdId: 217 | HandleScrollbarQueryStatus(sender, "ShowCaretPosition"); 218 | break; 219 | case Constants.ToggleShowDiffsCmdId: 220 | this.HideItem(sender); 221 | break; 222 | // Don't need query status for DistractionFree items. 223 | //case Constants.ToggleCleanEditorCmdId: 224 | // break; 225 | //case Constants.ToggleCleanMarginsCmdId: 226 | // break; 227 | } 228 | } 229 | 230 | private void HideItem(object sender) 231 | { 232 | MenuCommand command = (MenuCommand)sender; 233 | command.Enabled = false; 234 | command.Visible = false; 235 | } 236 | 237 | private void HandleScrollbarQueryStatus(object sender, string markerName) 238 | { 239 | // Only enable scrollbar options if ShowAnnotations is true. 240 | var showScrollbarMarkers = SettingsStore.GetBoolean("Text Editor\\CSharp", "ShowAnnotations"); 241 | MenuCommand menuCommand = ((MenuCommand)sender); 242 | menuCommand.Enabled = showScrollbarMarkers; 243 | 244 | // Update checked state based on state of specific marker 245 | if (!showScrollbarMarkers) 246 | { 247 | UpdateCheckedState(sender, false); 248 | } 249 | else 250 | { 251 | this.HandleQueryStatusCheckedUserProperty(sender, "Text Editor\\CSharp", markerName); 252 | } 253 | } 254 | 255 | private void HandleQueryStatusCheckedUserProperty(object sender, string collectionPath, string propertyName) 256 | { 257 | try 258 | { 259 | // Read property value 260 | var value = SettingsStore.GetBoolean(collectionPath, propertyName); 261 | UpdateCheckedState(sender, value); 262 | } 263 | catch (Exception) 264 | { 265 | // Do nothing 266 | } 267 | } 268 | 269 | private void HandleOutliningQueryStatus(object sender) 270 | { 271 | var enabled = ShellUtil.IsCommandAvailable("Edit.StopOutlining"); 272 | var disabled = ShellUtil.IsCommandAvailable("Edit.StartAutomaticOutlining"); 273 | UpdateCheckedState(sender, enabled); 274 | } 275 | 276 | private void HandleToggleLightbulbMarginQueryStatus(object sender) 277 | { 278 | var enabled = (bool)OptionsService.GlobalOptions.GetOptionValue("TextViewHost/SuggestionMargin"); 279 | UpdateCheckedState(sender, enabled); 280 | } 281 | 282 | private void HandleToggleLightbulbMarginAction(object sender, bool checkedState) 283 | { 284 | OptionsService.GlobalOptions.SetOptionValue("TextViewHost/SuggestionMargin", checkedState); 285 | } 286 | 287 | private void HandleToggleCodeLensQueryStatus(object sender) 288 | { 289 | var enabled = (bool)OptionsService.GlobalOptions.GetOptionValue("IsCodeLensEnabled"); 290 | UpdateCheckedState(sender, enabled); 291 | } 292 | 293 | private void HandleToggleCodeLensAction(object sender, bool checkedState) 294 | { 295 | this.OptionsService.GlobalOptions.SetOptionValue("IsCodeLensEnabled", checkedState); 296 | } 297 | 298 | private static void UpdateCheckedState(object sender, bool checkedState) 299 | { 300 | // Set Checked state 301 | MenuCommand menuCommand = ((MenuCommand)sender); 302 | if (menuCommand.Checked == checkedState) 303 | { 304 | // Command is already in correct state. No-op. 305 | return; 306 | } 307 | menuCommand.Checked = checkedState; 308 | } 309 | 310 | /// 311 | /// This function is the callback used to execute the command when the menu item is clicked. 312 | /// See the constructor to see how the menu item is associated with this function using 313 | /// OleMenuCommandService service and MenuCommand class. 314 | /// 315 | /// Event sender. 316 | /// Event args. 317 | private void MenuItemCallback(object sender, EventArgs e) 318 | { 319 | MenuCommand command = (MenuCommand)sender; 320 | bool newCheckedState = !command.Checked; 321 | 322 | // Dispatch the action 323 | switch (command.CommandID.ID) 324 | { 325 | case Constants.ToggleIndicatorMarginCmdId: 326 | UpdateSetting("TextEditor", "General", "MarginIndicatorBar", newCheckedState); 327 | break; 328 | case Constants.ToggleLineNumbersCmdId: 329 | UpdateSetting("TextEditor", "AllLanguages", "ShowLineNumbers", newCheckedState); 330 | break; 331 | //case Constants.ToggleQuickActionsCmdId: 332 | // HandleToggleLightbulbMarginAction(sender, newCheckedState); 333 | // break; 334 | case Constants.ToggleSelectionMarginCmdId: 335 | UpdateSetting("TextEditor", "General", "SelectionMargin", newCheckedState); 336 | break; 337 | case Constants.ToggleTrackChangesCmdId: 338 | UpdateSetting("TextEditor", "General", "TrackChanges", newCheckedState); 339 | break; 340 | case Constants.ToggleDiffMarginCmdId: 341 | // TODO: Implement this 342 | break; 343 | case Constants.ToggleOutliningCmdId: 344 | if (newCheckedState) 345 | ShellUtil.ExecuteCommand("Edit.StartAutomaticOutlining"); 346 | else 347 | ShellUtil.ExecuteCommand("Edit.StopOutlining"); 348 | break; 349 | case Constants.ToggleLiveUnitTestingCmdId: 350 | ToggleLiveUnitTesting.ToggleLUT(sender, e); 351 | break; 352 | case Constants.ToggleAnnotateCmdId: 353 | //UpdateSetting("TextEditor", "AllLanguages", "ShowBlame", newCheckedState); // TODO: Get this working 354 | break; 355 | 356 | // Editor Settings 357 | //case Constants.ToggleNavigationBarCmdId: 358 | // UpdateSetting("TextEditor", "AllLanguages", "ShowNavigationBar", newCheckedState); 359 | // command.Checked = newCheckedState; 360 | // break; 361 | case Constants.ToggleCodeLensCmdId: 362 | HandleToggleCodeLensAction(sender, newCheckedState); 363 | break; 364 | //case Constants.ToggleStructureGuideLinesCmdId: 365 | // UpdateSetting("TextEditor", "General", "IndentGuides", newCheckedState); 366 | // command.Checked = newCheckedState; 367 | // break; 368 | case Constants.ToggleHighlightCurrentLineCmdId: 369 | UpdateSetting("TextEditor", "General", "HighlightCurrentLine", newCheckedState); 370 | break; 371 | case Constants.ToggleAutoDelimiterHighlightingCmdId: 372 | UpdateSetting("TextEditor", "General", "AutoDelimiterHighlighting", newCheckedState); 373 | command.Checked = newCheckedState; 374 | break; 375 | case Constants.ToggleProcedureLineSeparatorCmdId: 376 | UpdateSetting("TextEditor", "CSharp-Specific", "DisplayLineSeparators", newCheckedState); 377 | command.Checked = newCheckedState; 378 | break; 379 | case Constants.ToggleIntelliSensePopUpCmdId: 380 | UpdateSetting("TextEditor", "AllLanguages", "AutoListMembers", newCheckedState); 381 | UpdateSetting("TextEditor", "AllLanguages", "AutoListParams", newCheckedState); 382 | break; 383 | case Constants.ToggleLineEndingsCmdId: 384 | UpdateSetting("TextEditor", "General", "LineEndings", newCheckedState); 385 | command.Checked = newCheckedState; 386 | break; 387 | case Constants.ToggleHighlightSymbolsCmdId: 388 | UpdateSetting("TextEditor", "CSharp-Specific", "HighlightReferences", newCheckedState); 389 | command.Checked = newCheckedState; 390 | break; 391 | case Constants.ToggleHighlightKeywordsCmdId: 392 | UpdateSetting("TextEditor", "CSharp-Specific", "EnableHighlightRelatedKeywords", newCheckedState); 393 | command.Checked = newCheckedState; 394 | break; 395 | //case Constants.ToggleIntelliSenseSquigglesCmdId: 396 | //UpdateSetting("TextEditor", "Basic", "TrackChanges", newCheckedState); 397 | //break; 398 | // Scrollbar Settings 399 | case Constants.ToggleShowScrollbarMarkersCmdId: 400 | UpdateSetting("TextEditor", "CSharp", "ShowAnnotations", newCheckedState); // Turns off all scrollbar markers 401 | break; 402 | case Constants.ToggleShowChangesCmdId: 403 | UpdateSetting("TextEditor", "CSharp", "ShowChanges", newCheckedState); 404 | break; 405 | case Constants.ToggleShowMarksCmdId: 406 | UpdateSetting("TextEditor", "CSharp", "ShowMarks", newCheckedState); 407 | break; 408 | case Constants.ToggleShowErrorsCmdId: 409 | UpdateSetting("TextEditor", "CSharp", "ShowErrors", newCheckedState); 410 | break; 411 | case Constants.ToggleShowCaretPositionCmdId: 412 | UpdateSetting("TextEditor", "CSharp", "ShowCaretPosition", newCheckedState); 413 | break; 414 | case Constants.ToggleShowDiffsCmdId: 415 | // Not implemented yet. Would hook into Git Diff Margin scrollbar setting. 416 | break; 417 | case Constants.ToggleCleanEditorCmdId: 418 | ExecuteToggleCleanEditor(); 419 | break; 420 | case Constants.ToggleCleanMarginsCmdId: 421 | MessageBox.Show("Toggle Margins"); 422 | // Not implemented yet. Would turn off all visible margins, or restore all previously visible margins 423 | break; 424 | } 425 | 426 | // Update state of checkbox 427 | //command.Checked = newCheckedState; 428 | } 429 | 430 | private void ExecuteToggleCleanEditor() 431 | { 432 | MessageBox.Show("Toggle Editor"); 433 | // Not implemented yet. Would turn off all editor adornments (not margins) 434 | } 435 | 436 | private void UpdateSetting(string category, string page, string settingName, bool value) 437 | { 438 | try 439 | { 440 | DTE2 _DTE2 = (DTE2)ServiceProvider.GetService(typeof(DTE)); 441 | // Example: _DTE2.Properties["TextEditor", "General"].Item("TrackChanges").Value = true; 442 | Properties properties = _DTE2.Properties[category, page]; 443 | properties.Item(settingName).Value = value; 444 | } 445 | catch (Exception) 446 | { 447 | // Do nothing 448 | } 449 | } 450 | 451 | } 452 | } 453 | -------------------------------------------------------------------------------- /HotSettings/HotSettings.vsct: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 34 | 35 | 36 | 37 | 38 | Editor Adornments 39 | Hot &Settings 40 | 41 | 42 | 43 | 44 | Editor Margin Context Menu 45 | EditorMarginContextMenu 46 | 47 | 48 | 49 | 50 | Scr&ollbar 51 | 52 | 53 | 54 | 55 | &View 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 91 | 92 | 99 | 108 | 117 | 126 | 135 | 144 | 152 | 160 | 170 | 178 | 179 | 188 | 196 | 205 | 214 | 221 | 228 | 235 | 242 | 249 | 256 | 261 | 262 | 270 | 278 | 286 | 294 | 302 | 310 | 311 | 316 | 324 | 325 | 334 | 335 | 336 | 337 | 338 | 339 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | --------------------------------------------------------------------------------