public override void LoadOptions() { base.LoadOptions(); if (allSyntaxDefinitions == null) { var builtins = from name in typeof(HighlightingManager).Assembly.GetManifestResourceNames().AsParallel() where name.StartsWith(typeof(HighlightingManager).Namespace + ".Resources.", StringComparison.OrdinalIgnoreCase) && name.EndsWith(".xshd", StringComparison.OrdinalIgnoreCase) select LoadBuiltinXshd(name); var extended = ICSharpCode.Core.AddInTree.BuildItems <AddInTreeSyntaxMode>(SyntaxModeDoozer.Path, null, false) .AsParallel() .Select(m => m.LoadXshd()); allSyntaxDefinitions = extended.AsEnumerable().Concat(builtins) .DistinctBy(def => def.Name) .OrderBy(def => def.Name) .ToList(); } customizationList = new List <CustomizedHighlightingColor>(CustomizedHighlightingColor.LoadColors()); CreateDefaultEntries(null, out defaultText, defaultEntries); languageComboBox.Items.Clear(); languageComboBox.Items.Add(new XshdSyntaxDefinition { Name = "All languages" }); foreach (XshdSyntaxDefinition def in allSyntaxDefinitions.Where(d => !d.Name.Equals("XmlDoc", StringComparison.OrdinalIgnoreCase))) { languageComboBox.Items.Add(def); } if (allSyntaxDefinitions.Count > 0) { languageComboBox.SelectedIndex = 0; } }
public override void LoadOptions() { base.LoadOptions(); if (allSyntaxDefinitions == null) { allSyntaxDefinitions = ( from name in typeof(HighlightingManager).Assembly.GetManifestResourceNames().AsParallel() where name.StartsWith(typeof(HighlightingManager).Namespace + ".Resources.", StringComparison.OrdinalIgnoreCase) && name.EndsWith(".xshd", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("XmlDoc.xshd", StringComparison.OrdinalIgnoreCase) select LoadBuiltinXshd(name) ).Concat( ICSharpCode.Core.AddInTree.BuildItems <AddInTreeSyntaxMode>(SyntaxModeDoozer.Path, null, false).AsParallel() .Select(m => m.LoadXshd()) ) //.Where(def => def.Elements.OfType<XshdColor>().Any(c => c.ExampleText != null)) .OrderBy(def => def.Name) .ToList(); } customizationList = CustomizedHighlightingColor.LoadColors(); languageComboBox.Items.Clear(); languageComboBox.Items.Add(new XshdSyntaxDefinition { Name = "All languages" }); foreach (XshdSyntaxDefinition def in allSyntaxDefinitions) { languageComboBox.Items.Add(def); } if (allSyntaxDefinitions.Count > 0) { languageComboBox.SelectedIndex = 0; } }
public CustomizedHighlightingItem(List <CustomizedHighlightingColor> customizationList, IHighlightingItem original, string language, bool canSetForeground = true, bool canSetBackground = true, bool canSetFont = true) { if (customizationList == null) { throw new ArgumentNullException("customizationList"); } if (original == null) { throw new ArgumentNullException("original"); } this.customizationList = customizationList; this.original = original; this.language = language; this.CanSetForeground = canSetForeground; this.CanSetBackground = canSetBackground; this.CanSetFont = canSetFont; foreach (CustomizedHighlightingColor c in customizationList) { if (c.Language == language && c.Name == this.Name) { this.customization = c; break; } } }
void SetCustomization(bool?bold = null, bool?italic = null, bool?underline = null, Color?foreground = null, bool?useDefaultForeground = null, Color?background = null, bool?useDefaultBackground = null) { CustomizedHighlightingColor newColor = new CustomizedHighlightingColor(); newColor.Language = language; newColor.Name = this.Name; newColor.Bold = bold ?? this.Bold; newColor.Italic = italic ?? this.Italic; newColor.Underline = underline ?? this.Underline; if (useDefaultBackground ?? this.UseDefaultBackground) { newColor.Background = null; } else { newColor.Background = background ?? this.Background; } if (useDefaultForeground ?? this.UseDefaultForeground) { newColor.Foreground = null; } else { newColor.Foreground = foreground ?? this.Foreground; } // remove existing customization if (language == null) { customizationList.RemoveAll(c => c.Name == this.Name); } else if (customization != null) { customizationList.Remove(customization); } if (newColor.Bold == original.Bold && newColor.Italic == original.Italic && newColor.Underline == original.Underline && (newColor.Background == null) == original.UseDefaultBackground && (newColor.Background == null || newColor.Background == original.Background) && (newColor.Foreground == null) == original.UseDefaultForeground && (newColor.Foreground == null || newColor.Foreground == original.Foreground)) { // all settings at default values, customization entry not necessary this.customization = null; } else { this.customization = newColor; // insert at beginning to ensure language-specific entries take preference over generic entries customizationList.Insert(0, newColor); } AllPropertiesChanged(); }
public ColorableItems( string name, CustomizedHighlightingColor color, FontsAndColorsItems fontsAndColorsItems) { this.Name = name; this.color = color; this.fontsAndColorsItems = fontsAndColorsItems; }
CustomizedHighlightingColor AddDefaultTextAndBackgroundColorToRules() { var highlightingColor = new CustomizedHighlightingColor(); highlightingColor.Name = CustomizableHighlightingColorizer.DefaultTextAndBackground; fakeHighlightingRules.Colors.Add(highlightingColor); return(highlightingColor); }
CustomizedHighlightingColor AddPlainTextHighlightingColorToCustomColors() { var color = new CustomizedHighlightingColor() { Name = CustomizableHighlightingColorizer.DefaultTextAndBackground }; Colors.Add(color); return(color); }
ColorableItems CreatePlainTextColorableItems() { CustomizedHighlightingColor color = FindPlainTextHighlightingColor(); if (color == null) { color = AddPlainTextHighlightingColorToCustomColors(); } return(new ColorableItems(PlainTextItem, color, this)); }
void CreateColorableItems() { highlightingColor = new CustomizedHighlightingColor(); fakeHighlightingRules = new FakeCustomizedHighlightingRules(); fakeHighlightingRules.Colors.Add(highlightingColor); fontsAndColorsItems = new FontsAndColorsItems(fakeHighlightingRules); items = new ColorableItems("Name", highlightingColor, fontsAndColorsItems); }
private void HighlightBrackets() { CSharpBracketSearcher BracketSearcher = new CSharpBracketSearcher(); var bracketSearchResult = BracketSearcher.SearchBracket(this.txtEditor.Document, this.txtEditor.TextArea.Caret.Offset); if (bracketSearchResult != null) { BracketHighlightRenderer br = new BracketHighlightRenderer(txtEditor.TextArea.TextView); br.SetHighlight(bracketSearchResult); BracketHighlightRenderer.ApplyCustomizationsToRendering(br, CustomizedHighlightingColor.FetchCustomizations(this.txtEditor.SyntaxHighlighting.Name)); } }
public void SaveColors(IEnumerable <CustomizedHighlightingColor> colors) { if (workbench.InvokeRequired) { Action <IEnumerable <CustomizedHighlightingColor> > action = SaveColors; workbench.SafeThreadAsyncCall(action, colors); } else { CustomizedHighlightingColor.SaveColors(colors); } }
public void Item_DefaultTextBackgroundColorIsBlue_PlainTextItemBackgroundIsBlue() { CreateFontsAndColorItems(); CustomizedHighlightingColor defaultColor = AddDefaultTextAndBackgroundColorToRules(); defaultColor.Background = Colors.Blue; ColorableItems colorableItems = items.Item("Plain Text"); uint backgroundOleColor = colorableItems.Background; Color backgroundColor = ColorHelper.ConvertToColor(backgroundOleColor); Assert.AreEqual(Colors.Blue, backgroundColor); }
public void Item_GetPlainTextItemWhenCustomHighlightingColorDoesNotExist_PlainTextItemAddedToCustomizationColorsWhenBoldIsSetToTrue() { CreateFontsAndColorItems(); global::EnvDTE.ColorableItems colorableItems = items.Item("Plain Text"); colorableItems.Bold = true; CustomizedHighlightingColor color = fakeHighlightingRules .ColorsSaved .Find(c => c.Name == CustomizingHighlighter.DefaultTextAndBackground); Assert.IsNotNull(color); }
void SetCustomization(bool? bold = null, bool? italic = null, bool? underline = null, Color? foreground = null, bool? useDefaultForeground = null, Color? background = null, bool? useDefaultBackground = null) { CustomizedHighlightingColor newColor = new CustomizedHighlightingColor(); newColor.Language = language; newColor.Name = this.Name; newColor.Bold = bold ?? this.Bold; newColor.Italic = italic ?? this.Italic; newColor.Underline = underline ?? this.Underline; if (useDefaultBackground ?? this.UseDefaultBackground) newColor.Background = null; else newColor.Background = background ?? this.Background; if (useDefaultForeground ?? this.UseDefaultForeground) newColor.Foreground = null; else newColor.Foreground = foreground ?? this.Foreground; // remove existing customization if (language == null) customizationList.RemoveAll(c => c.Name == this.Name); else if (customization != null) customizationList.Remove(customization); if (newColor.Bold == original.Bold && newColor.Italic == original.Italic && newColor.Underline == original.Underline && (newColor.Background == null) == original.UseDefaultBackground && (newColor.Background == null || newColor.Background == original.Background) && (newColor.Foreground == null) == original.UseDefaultForeground && (newColor.Foreground == null || newColor.Foreground == original.Foreground)) { // all settings at default values, customization entry not necessary this.customization = null; } else { this.customization = newColor; // insert at beginning to ensure language-specific entries take preference over generic entries customizationList.Insert(0, newColor); } AllPropertiesChanged(); }
public CustomizedHighlightingItem(List<CustomizedHighlightingColor> customizationList, IHighlightingItem original, string language, bool canSetForeground = true, bool canSetBackground = true, bool canSetFont = true) { if (customizationList == null) throw new ArgumentNullException("customizationList"); if (original == null) throw new ArgumentNullException("original"); this.customizationList = customizationList; this.original = original; this.language = language; this.CanSetForeground = canSetForeground; this.CanSetBackground = canSetBackground; this.CanSetFont = canSetFont; foreach (CustomizedHighlightingColor c in customizationList) { if (c.Language == language && c.Name == this.Name) { this.customization = c; break; } } }
public IReadOnlyList <CustomizedHighlightingColor> LoadColors() { return(CustomizedHighlightingColor.LoadColors()); }
public override bool SaveOptions() { CustomizedHighlightingColor.SaveColors(customizationList); return(base.SaveOptions()); }