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;
    }
}