public void ApplyColorScheme(SchemeName schemeName, ImmutableArray <RegistryItem> registryItems)
            {
                using var registryRoot = VSRegistry.RegistryRoot(_serviceProvider, __VsLocalRegistryType.RegType_Configuration, writable: true);

                foreach (var item in registryItems)
                {
                    using var itemKey = registryRoot.CreateSubKey(item.SectionName);
                    itemKey.SetValue(item.ValueName, item.ValueData);
                    // Flush RegistryKeys out of paranoia
                    itemKey.Flush();
                }

                registryRoot.Flush();

                SetAppliedColorScheme(schemeName);

                // Broadcast that system color settings have changed to force the ColorThemeService to reload colors.
                NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, NativeMethods.WM_SYSCOLORCHANGE, wparam: IntPtr.Zero, lparam: IntPtr.Zero);
            }
        public override void WriteToStream(IndentStream stream)
        {
            stream.Write("CREATE PARTITION SCHEME ");
            SchemeName.WriteToStream(stream);
            stream.WriteLine();

            stream.Write("AS PARTITION ");
            FuncName.WriteToStream(stream);
            stream.WriteLine();

            if (!string.IsNullOrEmpty(AllToken))
            {
                stream.Write(AllToken);
            }

            stream.Write(" TO");
            stream.Write("(");
            GroupNameList.WriteToStreamWithComma(stream);
            stream.Write(")");
        }
            private Stream GetColorSchemeXmlStream(SchemeName schemeName)
            {
                var assembly = Assembly.GetExecutingAssembly();

                return(assembly.GetManifestResourceStream($"Microsoft.VisualStudio.LanguageServices.ColorSchemes.{schemeName}.xml"));
            }
 private ColorScheme GetColorScheme(SchemeName schemeName)
 {
     using var colorSchemeStream = GetColorSchemeXmlStream(schemeName);
     return(ColorSchemeReader.ReadColorScheme(colorSchemeStream));
 }
            /// <summary>
            /// Determines if any Classification foreground colors have been customized in Fonts and Colors.
            /// </summary>
            public bool AreForegroundColorsCustomized(SchemeName schemeName, Guid themeId)
            {
                AssertIsForeground();

                // Ensure we are initialized
                if (_fontAndColorStorage is null)
                {
                    _fontAndColorStorage = _serviceProvider.GetService <
                        SVsFontAndColorStorage,
                        IVsFontAndColorStorage
                        >();
                    _fontAndColorUtilities = (IVsFontAndColorUtilities)_fontAndColorStorage !;
                }

                // Make no changes when in high contast mode or in unknown theme.
                if (
                    SystemParameters.HighContrast ||
                    !_colorSchemes.TryGetValue(schemeName, out var colorScheme) ||
                    !colorScheme.TryGetValue(themeId, out var colorSchemeTheme)
                    )
                {
                    return(false);
                }

                var coreThemeColors =
                    (themeId == KnownColorThemes.Dark)
                        ? DarkThemeForeground
                        : BlueLightThemeForeground;

                // Open Text Editor category for readonly access and do not load items if they are defaulted.
                if (
                    _fontAndColorStorage.OpenCategory(
                        TextEditorMEFItemsColorCategory,
                        (uint)__FCSTORAGEFLAGS.FCSF_READONLY
                        ) != VSConstants.S_OK
                    )
                {
                    // We were unable to access color information.
                    return(false);
                }

                try
                {
                    foreach (var classification in Classifications)
                    {
                        var colorItems = new ColorableItemInfo[1];

                        if (
                            _fontAndColorStorage.GetItem(classification, colorItems)
                            != VSConstants.S_OK
                            )
                        {
                            // Classifications that are still defaulted will not have entries.
                            continue;
                        }

                        var colorItem = colorItems[0];

                        if (
                            IsClassificationCustomized(
                                coreThemeColors,
                                colorSchemeTheme,
                                colorItem,
                                classification
                                )
                            )
                        {
                            return(true);
                        }
                    }
                }
                finally
                {
                    _fontAndColorStorage.CloseCategory();
                }

                return(false);
            }