From 42dc1d36235292786322d28340a81c6cb3fd46c0 Mon Sep 17 00:00:00 2001 From: hurter Date: Wed, 31 Aug 2011 16:25:05 +0000 Subject: --- Anoto/HotAreas/AnotoStrip.cs | 219 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 Anoto/HotAreas/AnotoStrip.cs (limited to 'Anoto/HotAreas/AnotoStrip.cs') diff --git a/Anoto/HotAreas/AnotoStrip.cs b/Anoto/HotAreas/AnotoStrip.cs new file mode 100644 index 0000000..c193e08 --- /dev/null +++ b/Anoto/HotAreas/AnotoStrip.cs @@ -0,0 +1,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 strips = new List(); + + // 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 lines = new List(); + 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(); + } + + + } +} -- cgit v1.1