Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/Palettes/DecoratorPaletteBase.cs @ 12503

Last change on this file since 12503 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Media;
6
7namespace Microsoft.Research.DynamicDataDisplay.Common.Palettes
8{
9  /// <summary>
10  /// Represents a base class for decorating palette, which wraps another palette and intercepts calls to it.
11  /// </summary>
12  public abstract class DecoratorPaletteBase : PaletteBase
13  {
14    /// <summary>
15    /// Initializes a new instance of the <see cref="DecoratorPaletteBase"/> class.
16    /// </summary>
17    protected DecoratorPaletteBase() { }
18
19    /// <summary>
20    /// Initializes a new instance of the <see cref="DecoratorPaletteBase"/> class.
21    /// </summary>
22    /// <param name="palette">The palette.</param>
23    public DecoratorPaletteBase(IPalette palette)
24    {
25      Palette = palette;
26    }
27
28    private IPalette palette = null;
29    /// <summary>
30    /// Gets or sets the palette being decorated.
31    /// </summary>
32    /// <value>The palette.</value>
33    [NotNull]
34    public IPalette Palette
35    {
36      get { return palette; }
37      set
38      {
39        if (value == null)
40          throw new ArgumentNullException("value");
41
42        if (palette != null)
43          palette.Changed -= OnChildPaletteChanged;
44
45        palette = value;
46        palette.Changed += OnChildPaletteChanged;
47
48        RaiseChanged();
49      }
50    }
51
52    void OnChildPaletteChanged(object sender, EventArgs e)
53    {
54      RaiseChanged();
55    }
56
57    /// <summary>
58    /// Gets the color by interpolation coefficient.
59    /// </summary>
60    /// <param name="t">Interpolation coefficient, should belong to [0..1].</param>
61    /// <returns>Color.</returns>
62    public override Color GetColor(double t)
63    {
64      return palette.GetColor(t);
65    }
66  }
67}
Note: See TracBrowser for help on using the repository browser.