Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6169 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
9 changed files with 213 additions and 56 deletions
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Windows.Media.TextFormatting; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.Rendering |
||||
{ |
||||
sealed class SimpleTextSource : TextSource |
||||
{ |
||||
readonly string text; |
||||
readonly TextRunProperties properties; |
||||
|
||||
public SimpleTextSource(string text, TextRunProperties properties) |
||||
{ |
||||
this.text = text; |
||||
this.properties = properties; |
||||
} |
||||
|
||||
public override TextRun GetTextRun(int textSourceCharacterIndex) |
||||
{ |
||||
if (textSourceCharacterIndex < text.Length) |
||||
return new TextCharacters(text, textSourceCharacterIndex, text.Length - textSourceCharacterIndex, properties); |
||||
else |
||||
return new TextEndOfParagraph(1); |
||||
} |
||||
|
||||
public override int GetTextEffectCharacterIndexFromTextSourceCharacterIndex(int textSourceCharacterIndex) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText(int textSourceCharacterIndexLimit) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.TextFormatting; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.Rendering |
||||
{ |
||||
sealed class TextViewCachedElements : IDisposable |
||||
{ |
||||
Dictionary<string, TextLine> simpleLightGrayTexts; |
||||
|
||||
public TextLine GetSimpleLightGrayText(string text, ITextRunConstructionContext context) |
||||
{ |
||||
if (simpleLightGrayTexts == null) |
||||
simpleLightGrayTexts = new Dictionary<string, TextLine>(); |
||||
TextLine textLine; |
||||
if (!simpleLightGrayTexts.TryGetValue(text, out textLine)) { |
||||
var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties); |
||||
p.SetForegroundBrush(Brushes.LightGray); |
||||
textLine = FormattedTextElement.PrepareText(context.TextView.TextFormatter, text, p); |
||||
simpleLightGrayTexts[text] = textLine; |
||||
} |
||||
return textLine; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
if (simpleLightGrayTexts != null) { |
||||
foreach (TextLine line in simpleLightGrayTexts.Values) |
||||
line.Dispose(); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue