summaryrefslogtreecommitdiff
path: root/Anoto/HotAreas/AnotoStrip.cs
blob: c193e0833d1a7d92b9169477c1dc4a2aebbfc43c (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;

namespace Anoto
{

    public class AnotoStrip:AnotoHotArea
    {
        public string CallSign;
        public string Name;
        public string AircraftType;
        public string CruseSpeed;
        public string Departure;
        public string Arrival;
        public string SSR;
        public string InputFL;
        public string PrintTime;
        public string Sector;
        public string Frequency;
        public string FL1;
        public string FL2;

        public string Beacon1;
        public string Beacon1Time;
        public string Beacon2;
        public string Beacon2Time;
        public string Beacon3;
        public string Beacon3Time;
        public string Beacon4;
        public string Beacon4Time;
        public string Beacon5;
        public string Beacon5Time;
        public string Beacon6;
        public string Beacon6Time;

        public string NextSector;

        private float rationCmPixel = (5515-65) / 20.2f;

        public SubCategories GetStripArea(int x, int y)
        {
            x -= 65;  //X Margin

            if (x < 4.9f * rationCmPixel)
                return SubCategories.Information;

            if (x < 7.2f * rationCmPixel)
                return SubCategories.C0;
            if (x < 9.0f * rationCmPixel)
                return SubCategories.C1;
            if (x < 11.0f * rationCmPixel)
                return SubCategories.C2;
            if (x < 12.4f * rationCmPixel)
                return SubCategories.Beacon1;        
            if (x < 13.8f * rationCmPixel)
                return SubCategories.Beacon2;
            if (x < 15.2f * rationCmPixel)
                return SubCategories.Beacon3;
            if (x < 16.6f * rationCmPixel)
                return SubCategories.Beacon4;
            if (x < 18.0f * rationCmPixel)
                return SubCategories.Beacon5;
            if (x < 19.3f * rationCmPixel)
                return SubCategories.Beacon6;

            return SubCategories.Unknown;
        }

        public string GetTextForCell(SubCategories subC)
        {
            string resutl = "";

            switch (subC)
            {
                case SubCategories.Information: resutl = this.SSR;
                    break;
                case SubCategories.C0: resutl = this.Sector;
                    break;
                case SubCategories.C1: resutl = this.FL1;
                    break;
                case SubCategories.C2: resutl = this.FL2;
                    break;
                case SubCategories.Beacon1: resutl = this.Beacon1;
                    break;
                case SubCategories.Beacon2: resutl = this.Beacon2;
                    break;
                case SubCategories.Beacon3: resutl = this.Beacon3;
                    break;
                case SubCategories.Beacon4: resutl = this.Beacon4;
                    break;
                case SubCategories.Beacon5: resutl = this.Beacon5;
                    break;
                case SubCategories.Beacon6: resutl = this.Beacon6;
                    break;
                case SubCategories.C4: resutl = this.NextSector;
                    break;
                default:
                    break;
            }
            return resutl;
        }

      

        public AnotoStrip(string[] l)
        {
            //    CALLSIGN; Nom; Type ACFT; Vit; Dép; Arr; SSR; Niv entrée; heure strip; Sect; fréq; FL; FL; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Secteur
            int i = 0;
            CallSign = l[i++];
            Name = l[i++];
            AircraftType = l[i++];
            CruseSpeed = l[i++];
            Departure = l[i++];
            Arrival = l[i++];
            SSR = l[i++];
            InputFL = l[i++];
            PrintTime = l[i++];
            Sector = l[i++];
            Frequency = l[i++];
            FL1 = l[i++];
            FL2 = l[i++];

            Beacon1 = l[i++];
            Beacon1Time = l[i++];
            Beacon2 = l[i++];
            Beacon2Time = l[i++];
            Beacon3 = l[i++];
            Beacon3Time = l[i++];
            Beacon4 = l[i++];
            Beacon4Time = l[i++];
            Beacon5 = l[i++];
            Beacon5Time = l[i++];
            Beacon6 = l[i++];
            Beacon6Time = l[i++];

            NextSector = l[i++];
        }

        public override string ToString()
        {
            return this.Category.ToString() + " ( " + CallSign + " )";// +Beacon1 + " " + Beacon2 + " " + Beacon3 + " " + Beacon4 + " " + Beacon5 + " " + Beacon6;
        }

        public bool IsSelected(Point pt)
        {
            return Rectangle.Contains(pt);
        }

        public static AnotoStrip GetStrip(int x, int y, string page, AnotoStrip[] strips)
        {
            AnotoStrip result = null;
            foreach (var s in strips)
            {
                if ( AnotoHotArea.PagesIP[s.PageIndex] == page)
                {
                    if (s.Rectangle.Contains(x, y))
                        return s;
                }
            }
            return result;
        }


        public static AnotoStrip[] LoadFileStrip(string fileName)
        {
            List<AnotoStrip> strips = new List<AnotoStrip>();

            //    CALLSIGN; Nom; Type ACFT; Vit; Dép; Arr; SSR; Niv entrée; heure strip; Sect; fréq; FL; FL; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Balise; estimée; Secteur
            StreamReader sr = new StreamReader(fileName);
            List<string> lines = new List<string>();
            string input;

            while ((input = sr.ReadLine()) != null)
            {
                lines.Add(input);
            }
            char[] sep = { ';' };

            int left = 65;
            int top = 89;
            int right = 5515;
            int bottom = 7850;

            int nbrStripPerPage = 10;
            int height = (bottom - top) / nbrStripPerPage;
            int width = right - left;

            int y = top;
            int x = left;

            for (int i = 0; i < lines.Count; i++)
            {
                string line = lines[i];

                string[] l = line.Split(sep);
                AnotoStrip s = new AnotoStrip(l);
                s.Category = Categories.Strip;

                s.Rectangle = new Rectangle(x, y, width, height);

                s.PageIndex = (int)(i / nbrStripPerPage);

                if ((i % nbrStripPerPage) == 0)
                    y = top;

                y += height;

                strips.Add(s);
            }
            return strips.ToArray();
        }

   
    }
}