Browse Source

Add Freeze() method to HighlightingColor.

pull/32/merge
Daniel Grunwald 13 years ago
parent
commit
bc52a0b8fe
  1. 77
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs

77
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs

@ -17,30 +17,82 @@ namespace ICSharpCode.AvalonEdit.Highlighting
[Serializable] [Serializable]
public class HighlightingColor : ISerializable public class HighlightingColor : ISerializable
{ {
string name;
FontWeight? fontWeight;
FontStyle? fontStyle;
HighlightingBrush foreground;
HighlightingBrush background;
bool frozen;
/// <summary> /// <summary>
/// Gets/Sets the name of the color. /// Gets/Sets the name of the color.
/// </summary> /// </summary>
public string Name { get; set; } public string Name {
get {
return name;
}
set {
if (frozen)
throw new InvalidOperationException();
name = value;
}
}
/// <summary> /// <summary>
/// Gets/sets the font weight. Null if the highlighting color does not change the font weight. /// Gets/sets the font weight. Null if the highlighting color does not change the font weight.
/// </summary> /// </summary>
public FontWeight? FontWeight { get; set; } public FontWeight? FontWeight {
get {
return fontWeight;
}
set {
if (frozen)
throw new InvalidOperationException();
fontWeight = value;
}
}
/// <summary> /// <summary>
/// Gets/sets the font style. Null if the highlighting color does not change the font style. /// Gets/sets the font style. Null if the highlighting color does not change the font style.
/// </summary> /// </summary>
public FontStyle? FontStyle { get; set; } public FontStyle? FontStyle {
get {
return fontStyle;
}
set {
if (frozen)
throw new InvalidOperationException();
fontStyle = value;
}
}
/// <summary> /// <summary>
/// Gets/sets the foreground color applied by the highlighting. /// Gets/sets the foreground color applied by the highlighting.
/// </summary> /// </summary>
public HighlightingBrush Foreground { get; set; } public HighlightingBrush Foreground {
get {
return foreground;
}
set {
if (frozen)
throw new InvalidOperationException();
foreground = value;
}
}
/// <summary> /// <summary>
/// Gets/sets the background color applied by the highlighting. /// Gets/sets the background color applied by the highlighting.
/// </summary> /// </summary>
public HighlightingBrush Background { get; set; } public HighlightingBrush Background {
get {
return background;
}
set {
if (frozen)
throw new InvalidOperationException();
background = value;
}
}
/// <summary> /// <summary>
/// Creates a new HighlightingColor instance. /// Creates a new HighlightingColor instance.
@ -119,5 +171,20 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{ {
return "[" + GetType().Name + " " + (string.IsNullOrEmpty(this.Name) ? ToCss() : this.Name) + "]"; return "[" + GetType().Name + " " + (string.IsNullOrEmpty(this.Name) ? ToCss() : this.Name) + "]";
} }
/// <summary>
/// Prevent further changes to this highlighting color.
/// </summary>
public void Freeze()
{
frozen = true;
}
/// <summary>
/// Gets whether this HighlightingColor instance is frozen.
/// </summary>
public bool IsFrozen {
get { return frozen; }
}
} }
} }

Loading…
Cancel
Save