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
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Prep
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();
        }
    }
}