summaryrefslogtreecommitdiff
path: root/AnotoData/AnotoRadarScreen.cs
blob: d99c7436a3fff9e148629b68e247b07a4caaffdc (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
using System;
using System.Collections.Generic;

using System.Text;
using System.Drawing;
using System.Globalization;


namespace AnotoData
{
    public class AnotoRadarScreen : AnotoHotArea
    {
        CultureInfo ci = new CultureInfo("en-US");

        public AnotoRadarScreen()
        {
            this.Category = Categories.Screen;
            this.PageIndex = -1; //Multi pages

            LastX = -1;
            LastY = -1;
            LastPage = "";

        }

        public override bool IsInside(int x, int y, string page)
        {
            if ((page == "1728.0.0.8") || (page == "1728.0.0.9"))
                return true;
            return false;
        }

        private int LastX = -1;
        private int LastY = -1;
        private string LastPage = "";


        public void SendIvyMsg(string penSerial, int x, int y, string page, IvyBus.IvyControl TheIvyBus)
        {
            if ((LastX != x) || (LastY != y) || (LastPage != page))
            {
                //Normalize the data
                PointF ptN = GetNormilizedCoordinate(x, y, page);
                TheIvyBus.SendMsg("RadarScreenPenDown PenId=" + penSerial + " X=" + ptN.X.ToString(ci) + " Y=" + ptN.Y.ToString(ci));

                LastX = x;
                LastY = y;
                LastPage = page;
            }

        }

        public PointF GetNormilizedCoordinate(int x, int y, string page)
        {
            float yn = (float)y / (float)AnotoHotArea.MaxY;
            float xn = (float)x / (float)AnotoHotArea.MaxX / 2.0f;
            if (page == "1728.0.0.9") xn += 0.5f;

            return new PointF(xn, yn);
        }
    }
}