Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Shapes/RectangleHighlight.cs @ 13847

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

#2283 added GUI and charts; fixed MCTS

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Media;
6using System.Windows;
7using System.ComponentModel;
8
9namespace Microsoft.Research.DynamicDataDisplay.Charts
10{
11  /// <summary>
12  /// Represents a rectangle with corners bound to viewport coordinates.
13  /// </summary>
14  public sealed class RectangleHighlight : ViewportShape
15  {
16    /// <summary>
17    /// Initializes a new instance of the <see cref="RectangleHighlight"/> class.
18    /// </summary>
19    public RectangleHighlight() { }
20
21    /// <summary>
22    /// Initializes a new instance of the <see cref="RectangleHighlight"/> class.
23    /// </summary>
24    /// <param name="bounds">The bounds.</param>
25    public RectangleHighlight(Rect bounds)
26    {
27      Bounds = bounds;
28    }
29
30    private DataRect rect = DataRect.Empty;
31    public DataRect Bounds
32    {
33      get { return rect; }
34      set
35      {
36        if (rect != value)
37        {
38          rect = value;
39          UpdateUIRepresentation();
40        }
41      }
42    }
43
44    protected override void UpdateUIRepresentationCore()
45    {
46      var transform = Plotter.Viewport.Transform;
47
48      Point p1 = rect.XMaxYMax.DataToScreen(transform);
49      Point p2 = rect.XMinYMin.DataToScreen(transform);
50      rectGeometry.Rect = new Rect(p1, p2);
51    }
52
53    private RectangleGeometry rectGeometry = new RectangleGeometry();
54    protected override Geometry DefiningGeometry
55    {
56      get { return rectGeometry; }
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.