1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections.Generic;
6
using System.Collections.ObjectModel;
8
using System.Windows.Media;
10
using ICSharpCode.Core;
12
namespace ICSharpCode.AvalonEdit.AddIn
15
/// Holds a customized highlighting color.
17
public class CustomizedHighlightingColor
20
/// The language to which this customization applies. null==all languages.
22
public string Language;
25
/// The name of the highlighting color being modified.
29
public bool Bold, Italic;
30
public Color? Foreground, Background;
32
public static List<CustomizedHighlightingColor> LoadColors()
34
var list = PropertyService.Get("CustomizedHighlightingRules", new List<CustomizedHighlightingColor>());
35
// Always make a copy of the list so that the original list cannot be modified without using SaveColors().
36
return new List<CustomizedHighlightingColor>(list);
40
/// Saves the set of colors.
42
public static void SaveColors(IEnumerable<CustomizedHighlightingColor> colors)
44
lock (staticLockObj) {
46
PropertyService.Set("CustomizedHighlightingRules", colors.ToList());
48
EventHandler e = ActiveColorsChanged;
50
e(null, EventArgs.Empty);
53
static ReadOnlyCollection<CustomizedHighlightingColor> activeColors;
54
static readonly object staticLockObj = new object();
56
public static ReadOnlyCollection<CustomizedHighlightingColor> ActiveColors {
58
lock (staticLockObj) {
59
if (activeColors == null)
60
activeColors = LoadColors().AsReadOnly();
67
/// Occurs when the set of customized highlighting colors was changed.
69
public static EventHandler ActiveColorsChanged;