aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Painters/WpfEraseGraphPainter.cs
blob: 0e907d01f7a3aa1837769f7f2789caac7bbbf1b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RealTimeGraphX.Renderers;
using RealTimeGraphX.WPF.DataSeries;

namespace RealTimeGraphX.WPF.Painters
{
    /// <summary>
    /// Represents a WPF erase graph painter.
    /// </summary>
    /// <seealso cref="RealTimeGraphX.WPF.Painters.WpfScrollingGraphPainter" />
    public class WpfEraseGraphPainter : WpfScrollingGraphPainter
    {
        private Color _markerStrokeGdi;

        private System.Windows.Media.Color _markerStroke;
        /// <summary>
        /// Gets or sets the marker stroke.
        /// </summary>
        public System.Windows.Media.Color MarkerStroke
        {
            get { return _markerStroke; }
            set
            {
                _markerStroke = value;
                RaisePropertyChangedAuto();
                _markerStrokeGdi = _markerStroke.ToGdiColor();
            }
        }

        private double _markerThickness;
        /// <summary>
        /// Gets or sets the marker thickness.
        /// </summary>
        public double MarkerThickness
        {
            get { return _markerThickness; }
            set { _markerThickness = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="WpfEraseGraphPainter"/> class.
        /// </summary>
        public WpfEraseGraphPainter()
        {
            MarkerStroke = System.Windows.Media.Colors.White;
            MarkerThickness = 2;
        }

        /// <summary>
        /// Called when the connected input <see cref="T:RealTimeGraphX.IGraphRenderer" /> invoked the <see cref="M:RealTimeGraphX.GraphPainterBase.Draw(RealTimeGraphX.GraphDataSeries,System.Collections.Generic.IEnumerable{RealTimeGraphX.Drawing.GraphPoint})" /> method.
        /// </summary>
        /// <param name="seriesCollection">The series collection.</param>
        /// <param name="series">The series.</param>
        /// <param name="points">The points.</param>
        /// <param name="g">The graphics object.</param>
        protected override void OnDraw(IEnumerable<WpfDataSeries> seriesCollection, WpfDataSeries series, IEnumerable<GraphPoint> points, Graphics g)
        {
            base.OnDraw(seriesCollection, series, points, g);

            if (series == seriesCollection.Last())
            {
                Pen marker_pen = new Pen(_markerStrokeGdi, (float)_markerThickness);
                g.DrawLine(marker_pen, (float)Input.CurrentXPosition - 1, 0, (float)Input.CurrentXPosition - 1, (float)Output.SurfaceHeight);
                marker_pen.Dispose();
            }
        }
    }
}