aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/RealTimeGraphEx/Models/RealTimeGraphColumnsCollection.cs
blob: f2fb28170c63ed45ff620da540ab2297ff7e85b8 (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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealTimeGraphEx.Models
{
    public class RealTimeGraphColumnsCollection
    {
        public List<RealTimeGraphExColumn> Columns { get; set; }
        public List<double> ActualValues { get; set; }

        public int TotalColumns
        {
            get { return Columns.Count; }
        }

        public RealTimeGraphColumnsCollection()
        {
            Columns = new List<RealTimeGraphExColumn>();
            ActualValues = new List<double>();
        }

        public void Add(RealTimeGraphExColumn rec, int actualValue)
        {
            Columns.Add(rec);
            ActualValues.Add(actualValue);
        }

        public void Add(int x, int y, int width, int bottom, int actualValue)
        {
            Add(new RealTimeGraphExColumn(x, y, width, bottom), actualValue);
        }

        public void RemoveFromStart(int count)
        {
            lock (Columns)
            {
                Columns.RemoveRange(0, count);

                double offSet = Columns[0].X;

                for (int i = 0; i < Columns.Count; i++)
                {
                    Columns[i].X = (int)(Columns[i].X - offSet);
                    Columns[i].Right = (int)(Columns[i].Right - offSet);
                }
            }
        }

        public void Replace(int x, int y, int right, int bottom, int actualValue, int index)
        {
            var p = new RealTimeGraphExColumn(x, y, right, bottom);
            Columns.RemoveAt(index);
            Columns.Insert(index, p);
            ActualValues.RemoveAt(index);
            ActualValues.Insert(index, actualValue);
        }

        public void ClearColumns()
        {
            Columns.Clear();
            ActualValues.Clear();
        }
    }
}