Skip to content

Instantly share code, notes, and snippets.

@NoahRic
Created October 28, 2009 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NoahRic/220306 to your computer and use it in GitHub Desktop.
Save NoahRic/220306 to your computer and use it in GitHub Desktop.
Code for setting the active selection to use a gradient brush, like beta 1 (VS 2010 Beta 2).
void SetGradientBrush(IEditorFormatMap formatMap)
{
Color highlight = SystemColors.HighlightColor;
Color darkColor = Color.FromArgb(96, highlight.R, highlight.G, highlight.B);
Color lightColor = Color.FromArgb(48, highlight.R, highlight.G, highlight.B);
// Change the selected text properties to use a gradient brush and an outline pen
var properties = formatMap.GetProperties("Selected Text");
properties[EditorFormatDefinition.BackgroundBrushId] = new LinearGradientBrush(
new GradientStopCollection() { new GradientStop(darkColor, 0.0), new GradientStop(lightColor, 0.5), new GradientStop(darkColor, 1.0) }, 90.0);
properties["BackgroundPen"] = new Pen(SystemColors.HighlightBrush, 1) { LineJoin = PenLineJoin.Round };
formatMap.SetProperties("Selected Text", properties);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment