aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Video/FrameRate.cs
blob: 47ba5228913bf28465f71bdf04287cb907d15333 (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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Video.DirectCapture
{
    /// <summary>
    /// Used to hold a frame rate value for a CaptureDevice.
    /// </summary>
    public class FrameRate : INotifyPropertyChanged
    {
        /// <summary>
        /// Initializses a new instance of FrameRate.
        /// </summary>
        public FrameRate()
        {

        }

        /// <summary>
        /// Initializes a new FrameRate instance.
        /// </summary>
        /// <param name="rate">The frame rate.</param>
        public FrameRate(double rate)
            : this()
        {
            Rate = rate;
        }

        private double _rate;

        /// <summary>
        /// Gets or sets the current frame rate.
        /// </summary>
        public double Rate
        {
            get { return _rate; }
            set { _rate = value; RaisePropertyChanged("Rate"); }
        }

        /// <summary>
        /// Returns a strings representation of the current frame rate.
        /// </summary>
        /// <returns>Frame rate.</returns>
        public override string ToString()
        {
            return Rate.ToString("0.#") + " fps"; 
        }

        private void RaisePropertyChanged(String propName)
        {
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
ss="p">, bool fillGraph, List<System.Windows.Media.Brush> fill, bool antialized) { _stroke = stroke; _fill = fill; _fillGraph = fillGraph; _strokeWidth = strokeWidth; _antialiazed = antialized; lock (lastPoints) { lastPoints = polygonPoints; lastPointsFill = polygonPointsFill; updated = true; } } /// <summary> /// Does the actual rendering. /// BeginDraw and EndDraw are already called by the caller. /// </summary> public override void Render(RenderTarget target) { if (lastPoints.Count > 0 && updated) { lock (lastPoints) { target.AntialiasMode = _antialiazed ? AntialiasMode.PerPrimitive : AntialiasMode.Aliased; if (lastPoints.Count > 0 && lastPoints[0].Length > 0) { target.Clear(Color.Transparent); } for (int i = 0; i < lastPoints.Count; i++) { var stroke = _stroke[i].ToDxBrush(target); var fill = _fill[i].ToDxBrush(target); target.DrawPolygon(m_d2dFactory, stroke, _strokeWidth, lastPoints[i]); if (_fillGraph && fill != null && _fill[i] != null) { target.FillPolygon(m_d2dFactory, fill, lastPointsFill[i]); } } updated = false; GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, blocking: false); } } DisableRendering(); } } }