using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Media; namespace Microsoft.Research.DynamicDataDisplay.Common.Palettes { /// /// Represents a base class for decorating palette, which wraps another palette and intercepts calls to it. /// public abstract class DecoratorPaletteBase : PaletteBase { /// /// Initializes a new instance of the class. /// protected DecoratorPaletteBase() { } /// /// Initializes a new instance of the class. /// /// The palette. public DecoratorPaletteBase(IPalette palette) { Palette = palette; } private IPalette palette = null; /// /// Gets or sets the palette being decorated. /// /// The palette. public IPalette Palette { get { return palette; } set { if (value == null) throw new ArgumentNullException("value"); if (palette != null) palette.Changed -= OnChildPaletteChanged; palette = value; palette.Changed += OnChildPaletteChanged; RaiseChanged(); } } void OnChildPaletteChanged(object sender, EventArgs e) { RaiseChanged(); } /// /// Gets the color by interpolation coefficient. /// /// Interpolation coefficient, should belong to [0..1]. /// Color. public override Color GetColor(double t) { return palette.GetColor(t); } } }