You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.5 KiB
98 lines
2.5 KiB
// <file>
|
|
// <copyright see="prj:///doc/copyright.txt"/>
|
|
// <license see="prj:///doc/license.txt"/>
|
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
|
// <version>$Revision$</version>
|
|
// </file>
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
|
|
namespace ICSharpCode.TextEditor.Document
|
|
{
|
|
public enum TextMarkerType
|
|
{
|
|
SolidBlock,
|
|
Underlined,
|
|
WaveLine
|
|
}
|
|
|
|
/// <summary>
|
|
/// Marks a part of a document.
|
|
/// </summary>
|
|
public class TextMarker : ISegment
|
|
{
|
|
protected int length = -1;
|
|
|
|
protected int offset = -1;
|
|
|
|
public TextMarker(int offset, int length, TextMarkerType textMarkerType) : this(offset, length, textMarkerType, Color.Red)
|
|
{
|
|
}
|
|
|
|
public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color)
|
|
{
|
|
if (length < 1) length = 1;
|
|
this.offset = offset;
|
|
this.length = length;
|
|
TextMarkerType = textMarkerType;
|
|
Color = color;
|
|
}
|
|
|
|
public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor)
|
|
{
|
|
if (length < 1) length = 1;
|
|
this.offset = offset;
|
|
this.length = length;
|
|
TextMarkerType = textMarkerType;
|
|
Color = color;
|
|
ForeColor = foreColor;
|
|
OverrideForeColor = true;
|
|
}
|
|
|
|
public TextMarkerType TextMarkerType { get; }
|
|
|
|
public Color Color { get; }
|
|
|
|
public Color ForeColor { get; }
|
|
|
|
public bool OverrideForeColor { get; }
|
|
|
|
/// <summary>
|
|
/// Marks the text segment as read-only.
|
|
/// </summary>
|
|
public bool IsReadOnly { get; set; }
|
|
|
|
public string ToolTip { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Gets the last offset that is inside the marker region.
|
|
/// </summary>
|
|
public int EndOffset => offset + length - 1;
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format(
|
|
"[TextMarker: Offset = {0}, Length = {1}, Type = {2}]",
|
|
offset,
|
|
length,
|
|
TextMarkerType);
|
|
}
|
|
|
|
#region ICSharpCode.TextEditor.Document.ISegment interface implementation
|
|
|
|
public int Offset
|
|
{
|
|
get => offset;
|
|
set => offset = value;
|
|
}
|
|
|
|
public int Length
|
|
{
|
|
get => length;
|
|
set => length = value;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|