Ejemplo n.º 1
0
        private async Task <Guid> GetCurrentThemeAsync(CancellationToken cancellationToken)
        {
            const string COLLECTION_NAME = @"ApplicationPrivateSettings\Microsoft\VisualStudio";
            const string PROPERTY_NAME   = "ColorTheme";

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            IVsSettingsManager manager = (IVsSettingsManager)await VS.Services.GetSettingsManagerAsync();

            SettingsStore store = new ShellSettingsManager(manager).GetReadOnlySettingsStore(SettingsScope.UserSettings);

            if (store.CollectionExists(COLLECTION_NAME))
            {
                if (store.PropertyExists(COLLECTION_NAME, PROPERTY_NAME))
                {
                    // The value is made up of three parts, separated
                    // by a star. The third part is the GUID of the theme.
                    string[] parts = store.GetString(COLLECTION_NAME, PROPERTY_NAME).Split('*');
                    if (parts.Length == 3)
                    {
                        if (Guid.TryParse(parts[2], out Guid value))
                        {
                            return(value);
                        }
                    }
                }
            }

            return(Guid.Empty);
        }