//</Snippet3> //<Snippet4> public void TextViewCreated(IWpfTextView textView) { IEditorFormatMap formatMap = FormatMapService.GetEditorFormatMap(textView); ResourceDictionary regularCaretProperties = formatMap.GetProperties("Caret"); ResourceDictionary overwriteCaretProperties = formatMap.GetProperties("Overwrite Caret"); ResourceDictionary indicatorMargin = formatMap.GetProperties("Indicator Margin"); ResourceDictionary visibleWhitespace = formatMap.GetProperties("Visible Whitespace"); ResourceDictionary selectedText = formatMap.GetProperties("Selected Text"); ResourceDictionary inactiveSelectedText = formatMap.GetProperties("Inactive Selected Text"); formatMap.BeginBatchUpdate(); regularCaretProperties[EditorFormatDefinition.ForegroundBrushId] = Brushes.Magenta; formatMap.SetProperties("Caret", regularCaretProperties); overwriteCaretProperties[EditorFormatDefinition.ForegroundBrushId] = Brushes.Turquoise; formatMap.SetProperties("Overwrite Caret", overwriteCaretProperties); indicatorMargin[EditorFormatDefinition.BackgroundColorId] = Colors.LightGreen; formatMap.SetProperties("Indicator Margin", indicatorMargin); visibleWhitespace[EditorFormatDefinition.ForegroundColorId] = Colors.Red; formatMap.SetProperties("Visible Whitespace", visibleWhitespace); selectedText[EditorFormatDefinition.BackgroundBrushId] = Brushes.LightPink; formatMap.SetProperties("Selected Text", selectedText); inactiveSelectedText[EditorFormatDefinition.BackgroundBrushId] = Brushes.DeepPink; formatMap.SetProperties("Inactive Selected Text", inactiveSelectedText); formatMap.EndBatchUpdate(); }
private static void UpdateEditorColors(IEditorFormatMap formatMap) { try { formatMap.BeginBatchUpdate(); foreach (var pair in ThemeColors.EditorColors) { var type = pair.Key; var color = pair.Value; var property = formatMap.GetProperties(type); if (property == null) { Error.LogError($"Cannot find editor format related to {type}", Module); continue; } property.Remove("ForegroundColor"); property.Remove("BackgroundColor"); property.Add("ForegroundColor", color.Foreground); property.Add("BackgroundColor", color.Background); formatMap.SetProperties(type, property); } } finally { formatMap.EndBatchUpdate(); } }
public void TextViewCreated(IWpfTextView textView) { ThreadHelper.ThrowIfNotOnUIThread(); IEditorFormatMap formatMap = FormatMapService.GetEditorFormatMap(textView); ResourceDictionary mplContent = formatMap.GetProperties("MplContent"); ResourceDictionary mplCodeBrackets = formatMap.GetProperties("MplCodeBrackets"); if (MplPackage.Options.SolarizedTheme) { if (MplPackage.Options.DarkThemesList.Contains(MplPackage.GetThemeName())) { //dark theme textView.Background = Constants.backgroundDarkBrush; } else { //light theme textView.Background = Constants.backgroundLightBrush; } formatMap.BeginBatchUpdate(); mplContent[EditorFormatDefinition.ForegroundColorId] = MplPackage.MplContentColor; mplContent[EditorFormatDefinition.ForegroundBrushId] = new SolidColorBrush(MplPackage.MplContentColor); formatMap.SetProperties("MplContent", mplContent); mplCodeBrackets[EditorFormatDefinition.ForegroundColorId] = MplPackage.MplEmphasizedColor; mplCodeBrackets[EditorFormatDefinition.ForegroundBrushId] = new SolidColorBrush(MplPackage.MplEmphasizedColor); formatMap.SetProperties("MplCodeBrackets", mplCodeBrackets); formatMap.EndBatchUpdate(); } }
private void CoverageColours_ColoursChanged(object sender, EventArgs e) { if (prepared) { editorFormatMap.BeginBatchUpdate(); foreach (var coverageEditorFormatDefinition in coverageEditorFormatDefinitions) { var newBackgroundColor = GetBackgroundColor(coverageEditorFormatDefinition.CoverageType); coverageEditorFormatDefinition.SetBackgroundColor(newBackgroundColor); editorFormatMap.AddProperties(coverageEditorFormatDefinition.Identifier, coverageEditorFormatDefinition.CreateResourceDictionary()); } editorFormatMap.EndBatchUpdate(); } }
void InitializeAll() { bool callBeginEndUpdate = !editorFormatMap.IsInBatchUpdate; if (callBeginEndUpdate) { editorFormatMap.BeginBatchUpdate(); } var theme = themeService.Theme; var textProps = textAppearanceCategory.CreateResourceDictionary(theme); var winbg = textProps[EditorFormatMapConstants.TextViewBackgroundId] as Brush ?? SystemColors.WindowBrush; var winbgRes = editorFormatMap.GetProperties(EditorFormatMapConstants.TextViewBackgroundId); if (winbgRes[EditorFormatDefinition.BackgroundBrushId] != winbg) { winbgRes[EditorFormatDefinition.BackgroundBrushId] = winbg; editorFormatMap.SetProperties(EditorFormatMapConstants.TextViewBackgroundId, winbgRes); } foreach (var t in GetEditorFormatDefinitions()) { var key = t.Item1.Name; var props = t.Item2.CreateThemeResourceDictionary(theme); editorFormatMap.SetProperties(key, props); } var ptDict = CreatePlainTextDictionary(textProps); editorFormatMap.SetProperties(EditorFormatMapConstants.PlainText, ptDict); if (callBeginEndUpdate) { editorFormatMap.EndBatchUpdate(); } }
public void EndBatchUpdate() => categoryMap.EndBatchUpdate();