public ColorableItemFontsAndColorsPropertyNodeFactory(DTE2 dte, FontsAndColorsItems collection, ColorableItems property) { _dte = dte; _collection = collection; _property = property; }
public static Brush Get_Background_Color() { try { DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE; EnvDTE.Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor"); Property prop = propertiesList.Item("FontsAndColorsItems"); FontsAndColorsItems fci = (FontsAndColorsItems)prop.Object; for (int i = 1; i < fci.Count; ++i) { ColorableItems ci = fci.Item(i); if (ci.Name.Equals("PLAIN TEXT", StringComparison.OrdinalIgnoreCase)) { return(new SolidColorBrush(ConvertColor(System.Drawing.ColorTranslator.FromOle((int)ci.Background)))); } } } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR("AsmDudeToolsStatic:Get_Background_Color " + e.Message); } AsmDudeToolsStatic.Output_WARNING("AsmDudeToolsStatic:Get_Background_Color: could not retrieve text color"); return(new SolidColorBrush(Colors.Gray)); }
public void Item_GetUnknownItem_ReturnsNull() { CreateFontsAndColorItems(); AddDefaultTextAndBackgroundColorToRules(); ColorableItems colorableItems = items.Item("Unknown item"); Assert.IsNull(colorableItems); }
public void Item_GetPlainTextItemWhenCustomHighlightingColorDoesNotExist_ReturnsPlainTextItemWithDefaultBackgroundColor() { CreateFontsAndColorItems(); ColorableItems colorableItems = items.Item("Plain Text"); uint backgroundOleColor = colorableItems.Background; Color backgroundColor = ColorHelper.ConvertToColor(backgroundOleColor); Assert.AreEqual(ColorableItems.DefaultBackgroundColor, backgroundColor); }
public void Item_GetPlainTextItemInUpperCase_ReturnsColorableItems() { CreateFontsAndColorItems(); AddDefaultTextAndBackgroundColorToRules(); ColorableItems colorableItems = items.Item("PLAIN TEXT"); string name = colorableItems.Name; Assert.AreEqual("Plain Text", name); }
void CreateColorableItems() { highlightingColor = new CustomizedHighlightingColor(); fakeHighlightingRules = new FakeCustomizedHighlightingRules(); fakeHighlightingRules.Colors.Add(highlightingColor); fontsAndColorsItems = new FontsAndColorsItems(fakeHighlightingRules); items = new ColorableItems("Name", highlightingColor, fontsAndColorsItems); }
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(); ColorableItems colorableItems = items.Item("Plain Text"); colorableItems.Bold = true; CustomizedHighlightingColor color = fakeHighlightingRules .ColorsSaved .Find(c => c.Name == CustomizableHighlightingColorizer.DefaultTextAndBackground); Assert.IsNotNull(color); }
public MDView() { InitializeComponent(); dte = Package.GetGlobalService(typeof(DTE)) as DTE2; events = dte.Events; docEvents = events.DocumentEvents; dte.Events.WindowEvents.WindowActivated += OnWindowActivated; docEvents.DocumentSaved += OnDocumentSaved; browser.LoadCompleted += OnBrowserLoadCompleted; var properties = dte.get_Properties("FontsAndColors", "TextEditor"); var fontsAndColorsItems = (EnvDTE.FontsAndColorsItems)properties.Item("FontsAndColorsItems").Object; colorableItems = fontsAndColorsItems.Item("Plain Text") as ColorableItems; UpdateMarkdown(""); Unloaded += (s, o) => (formatter as IDisposable).Dispose(); }
private HighlighterAttributes GetVsHighlighterAttributesNoCache([NotNull] string highlighterAttributeId) { ColorableItems colorableItems = VsColorUtilities.TryGetColorableItemsByName(highlighterAttributeId, _dte); if (colorableItems == null) { return(HighlighterAttributes.UNDEFINED); } Color foregroundColor = ColorTranslator.FromOle((int)colorableItems.Foreground); var attributes = new HighlighterAttributes(foregroundColor); if (colorableItems.Bold) { attributes = attributes.Merge(new HighlighterAttributes(FontStyle.Bold)); } return(attributes); }
public EditorFontAndColors() { FontFamily = "Consolas"; FontSize = 10.0f; FontBold = false; ForeColor = Color.Black; BackColor = Color.White; HighlightFontBold = false; HighlightForeColor = Color.White; HighlightBackColor = Color.Blue; try { DTE dte = (DTE)Package.GetGlobalService(typeof(DTE)); Properties props = dte.Properties["FontsAndColors", "TextEditor"]; FontsAndColorsItems fac = (FontsAndColorsItems)props.Item("FontsAndColorsItems").Object; ColorableItems colors = fac.Item("Plain Text"); FontFamily = props.Item("FontFamily").Value.ToString(); FontSize = (short)props.Item("FontSize").Value; FontBold = colors.Bold; ForeColor = ColorTranslator.FromOle((int)colors.Foreground); BackColor = ColorTranslator.FromOle((int)colors.Background); colors = fac.Item("Selected Text"); HighlightFontBold = colors.Bold; HighlightForeColor = ColorTranslator.FromOle((int)colors.Foreground); HighlightBackColor = ColorTranslator.FromOle((int)colors.Background); } catch (Exception ex) { Trace.WriteLine("Error loading text editor font and colors"); Trace.WriteLine(ex.ToString()); } }
public static async Task <Brush> GetBackgroundColorAsync() { if (!ThreadHelper.CheckAccess()) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); } DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE; Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor"); Property prop = propertiesList.Item("FontsAndColorsItems"); FontsAndColorsItems fci = (FontsAndColorsItems)prop.Object; for (int i = 1; i < fci.Count; ++i) { ColorableItems ci = fci.Item(i); if (ci.Name.Equals("PLAIN TEXT", StringComparison.OrdinalIgnoreCase)) { return(new SolidColorBrush(ConvertColor(System.Drawing.ColorTranslator.FromOle((int)ci.Background)))); } } Output_WARNING("AsmDudeToolsStatic:Get_Background_Color: could not retrieve text color"); return(new SolidColorBrush(Colors.Gray)); }
internal ShellColorableItem(ColorableItems items) { _items = items; }