本文整理汇总了C#中ICSharpCode.AvalonEdit.Highlighting.HighlightingColor类的典型用法代码示例。如果您正苦于以下问题:C# HighlightingColor类的具体用法?C# HighlightingColor怎么用?C# HighlightingColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HighlightingColor类属于ICSharpCode.AvalonEdit.Highlighting命名空间,在下文中一共展示了HighlightingColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyColorToElement
/// <summary>
/// Applies a highlighting color to a visual line element.
/// </summary>
protected virtual void ApplyColorToElement(VisualLineElement element, HighlightingColor color)
{
if (color.Foreground != null)
{
Brush b = color.Foreground.GetBrush(CurrentContext);
if (b != null)
element.TextRunProperties.SetForegroundBrush(b);
}
if (color.Background != null)
{
Brush b = color.Background.GetBrush(CurrentContext);
if (b != null)
element.TextRunProperties.SetBackgroundBrush(b);
}
if (color.FontStyle != null || color.FontWeight != null)
{
Typeface tf = element.TextRunProperties.Typeface;
element.TextRunProperties.SetTypeface(new Typeface(
tf.FontFamily,
color.FontStyle ?? tf.Style,
color.FontWeight ?? tf.Weight,
tf.Stretch
));
}
}
示例2: RichText
internal RichText(string text, int[] offsets, HighlightingColor[] states)
{
this.text = text;
Debug.Assert(offsets[0] == 0);
Debug.Assert(offsets.Last() <= text.Length);
this.stateChangeOffsets = offsets;
this.stateChanges = states;
}
示例3: OnThemeUpdated
static void OnThemeUpdated() {
var theme = dntheme.Themes.Theme;
CodeBreakpointHighlightingColor = theme.GetColor(dntheme.ColorType.BreakpointStatement).TextInheritedColor;
CodeBreakpointDisabledHighlightingColor = theme.GetColor(dntheme.ColorType.DisabledBreakpointStatement).TextInheritedColor;
StackFrameCurrentHighlightingColor = theme.GetColor(dntheme.ColorType.CurrentStatement).TextInheritedColor;
StackFrameReturnHighlightingColor = theme.GetColor(dntheme.ColorType.ReturnStatement).TextInheritedColor;
StackFrameSelectedHighlightingColor = theme.GetColor(dntheme.ColorType.SelectedReturnStatement).TextInheritedColor;
}
示例4: OnThemeUpdated
void OnThemeUpdated(IThemeManager themeManager) {
var theme = themeManager.Theme;
CodeBreakpointHighlightingColor = theme.GetTextColor(ColorType.BreakpointStatement).ToHighlightingColor();
CodeBreakpointDisabledHighlightingColor = theme.GetTextColor(ColorType.DisabledBreakpointStatement).ToHighlightingColor();
StackFrameCurrentHighlightingColor = theme.GetTextColor(ColorType.CurrentStatement).ToHighlightingColor();
StackFrameReturnHighlightingColor = theme.GetTextColor(ColorType.ReturnStatement).ToHighlightingColor();
StackFrameSelectedHighlightingColor = theme.GetTextColor(ColorType.SelectedReturnStatement).ToHighlightingColor();
}
示例5: AddRule
public HighlightingDefinition AddRule(string expression, HighlightingColor color)
{
var rule = new HighlightingRule
{
Regex = expression.ToRegex(),
Color = color
};
return AddRule(rule);
}
示例6: WriteStyleAttributeForColor
/// <summary>
/// Writes the HTML attribute for the style to the text writer.
/// </summary>
public virtual void WriteStyleAttributeForColor(TextWriter writer, HighlightingColor color)
{
if (writer == null)
throw new ArgumentNullException("writer");
if (color == null)
throw new ArgumentNullException("color");
writer.Write(" style=\"");
WebUtility.HtmlEncode(color.ToCss(), writer);
writer.Write('"');
}
示例7: SearchResultMatch
public SearchResultMatch(FileName fileName, Location startLocation, Location endLocation, int offset, int length, HighlightedInlineBuilder builder, HighlightingColor defaultTextColor)
{
this.fileName = fileName;
this.startLocation = startLocation;
this.endLocation = endLocation;
this.offset = offset;
this.length = length;
this.builder = builder;
this.defaultTextColor = defaultTextColor;
}
示例8: GetColor
protected HighlightingColor GetColor()
{
var color = new HighlightingColor();
color.Foreground = GetForeground();
color.FontWeight = GetFontWeight();
color.FontStyle = GetFontStyle();
color.Name = Name;
return color;
}
示例9: SearchResultMatch
public SearchResultMatch(FileName fileName, TextLocation startLocation, TextLocation endLocation, int offset, int length, RichText displayText, HighlightingColor defaultTextColor)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
this.fileName = fileName;
this.startLocation = startLocation;
this.endLocation = endLocation;
this.offset = offset;
this.length = length;
this.displayText = displayText;
this.defaultTextColor = defaultTextColor;
}
示例10: ToHighlightingColor
/// <summary>
/// Converts <paramref name="self"/> to a <see cref="HighlightingColor"/> instance or null
/// if input is null
/// </summary>
/// <param name="self">This</param>
/// <returns></returns>
public static HighlightingColor ToHighlightingColor(this IThemeColor self)
{
if (self == null)
return null;
var hl = new HighlightingColor {
Name = self.Name,
FontWeight = self.FontWeight,
FontStyle = self.FontStyle,
Underline = null,
Foreground = MyHighlightingBrush.Create(self.Foreground),
Background = MyHighlightingBrush.Create(self.Background),
};
hl.Freeze();
return hl;
}
示例11: SetHighlighting
/// <summary>
/// Applies the properties from the HighlightingColor to the specified text segment.
/// </summary>
public void SetHighlighting(int offset, int length, HighlightingColor color)
{
if (color == null)
throw new ArgumentNullException("color");
int startIndex = GetIndexForOffset(offset);
int endIndex = GetIndexForOffset(offset + length);
for (int i = startIndex; i < endIndex; i++) {
HighlightingState state = stateChanges[i];
if (color.Foreground != null)
state.Foreground = color.Foreground.GetBrush(null);
if (color.FontStyle != null)
state.Style = color.FontStyle;
if (color.FontWeight != null)
state.Weight = color.FontWeight;
}
}
示例12: SetHighlighting
/// <summary>
/// Applies the properties from the HighlightingColor to the specified text segment.
/// </summary>
public void SetHighlighting(int offset, int length, HighlightingColor color)
{
if (color == null)
throw new ArgumentNullException("color");
if (color.Foreground == null && color.FontStyle == null && color.FontWeight == null) {
// Optimization: don't split the HighlightingState when we're not changing
// any property. For example, the "Punctuation" color in C# is
// empty by default.
return;
}
int startIndex = GetIndexForOffset(offset);
int endIndex = GetIndexForOffset(offset + length);
for (int i = startIndex; i < endIndex; i++) {
HighlightingState state = stateChanges[i];
if (color.Foreground != null)
state.Foreground = color.Foreground.GetBrush(null);
if (color.FontStyle != null)
state.Style = color.FontStyle;
if (color.FontWeight != null)
state.Weight = color.FontWeight;
}
}
示例13: ApplyColorToElement
private void ApplyColorToElement(VisualLineElement element, HighlightingColor color)
{
if (color.Foreground != null)
{
Brush brush = color.Foreground.GetBrush(base.CurrentContext);
if (brush != null)
{
element.TextRunProperties.SetForegroundBrush(brush);
}
}
if (color.Background != null)
{
Brush brush2 = color.Background.GetBrush(base.CurrentContext);
if (brush2 != null)
{
element.TextRunProperties.SetBackgroundBrush(brush2);
}
}
if (color.FontStyle.HasValue || color.FontWeight.HasValue)
{
Typeface typeface = element.TextRunProperties.Typeface;
element.TextRunProperties.SetTypeface(new Typeface(typeface.FontFamily, color.FontStyle ?? typeface.Style, color.FontWeight ?? typeface.Weight, typeface.Stretch));
}
}
示例14: ApplyHighlighting
/// <summary>
/// Applies the HighlightingColor to the specified range of text.
/// If the color specifies <c>null</c> for some properties, existing highlighting is preserved.
/// </summary>
public void ApplyHighlighting(int offset, int length, HighlightingColor color)
{
if (color == null || color.IsEmptyForMerge) {
// Optimization: don't split the HighlightingState when we're not changing
// any property. For example, the "Punctuation" color in C# is
// empty by default.
return;
}
int startIndex = GetIndexForOffset(offset);
int endIndex = GetIndexForOffset(offset + length);
for (int i = startIndex; i < endIndex; i++) {
stateChanges[i].MergeWith(color);
}
}
示例15: Append
/// <summary>
/// Appends another RichTextModel after this one.
/// </summary>
internal void Append(int offset, int[] newOffsets, HighlightingColor[] newColors)
{
Debug.Assert(newOffsets.Length == newColors.Length);
Debug.Assert(newOffsets[0] == 0);
// remove everything before offset:
while (stateChangeOffsets.Count > 0 && stateChangeOffsets.Last() <= offset) {
stateChangeOffsets.RemoveAt(stateChangeOffsets.Count - 1);
stateChanges.RemoveAt(stateChanges.Count - 1);
}
// Append the new segments
for (int i = 0; i < newOffsets.Length; i++) {
stateChangeOffsets.Add(offset + newOffsets[i]);
stateChanges.Add(newColors[i]);
}
}