public Sector(string _pack, string[] _data) { strID = _pack + "/" + _data[0]; try { intMinAlt = int.Parse(_data[1], DataLink.DataCulture); } catch { intMinAlt = null; } try { intMaxAlt = int.Parse(_data[2], DataLink.DataCulture); } catch { intMaxAlt = null; } listRunways = new List <Runway>(); if (_data[3].Length > 0) { foreach (string strStr in _data[3].Split(',')) { listRunways.Add(Runway.Find(_pack + "/" + strStr)); } } }
public static Runway Find(string _id) { //Set bounds int intMidpoint; int intMin = 0; int intMax = listSorted.Count - 1; do { //Set midpoint intMidpoint = (intMin + intMax) / 2; //Find midpoint items Runway rwyCurrent = listSorted[intMidpoint]; //If current is search if (string.Compare(rwyCurrent.strID, _id) == 0) { return(rwyCurrent); } //If current is before search else if (string.Compare(rwyCurrent.strID, _id) < 0) { intMin = intMidpoint + 1; } //If current is after search else if (string.Compare(rwyCurrent.strID, _id) > 0) { intMax = intMidpoint - 1; } } while (intMin <= intMax); return(null); }
public static void LoadCurrents(string _file) { FileStream fs; if (!Directory.Exists(DataLink.strPrefsDirectory)) { Directory.CreateDirectory(DataLink.strPrefsDirectory); } if (!File.Exists(_file)) { fs = File.Create(_file); } else { fs = File.Open(_file, FileMode.Open, FileAccess.Read, FileShare.Read); } using (BufferedStream bs = new BufferedStream(fs)) using (StreamReader sr = new StreamReader(bs)) { string strRaw; while ((strRaw = sr.ReadLine()) != null) { if (strRaw.Length > 0 && strRaw.First() != ';') { Runway rwyFind = Find(strRaw); if (rwyFind != null) { if (rwyFind.apOwner.isActiveSet == true) { rwyFind.apOwner.AddActive(rwyFind); } else { rwyFind.apOwner.isActiveSet = true; rwyFind.apOwner.ClearActives(); rwyFind.apOwner.AddActive(rwyFind); } } } } } fs.Close(); }
private void BtnSave_Click(object sender, EventArgs e) { apCurrent.ClearActives(); for (int i = 0; i < tlpRunways.RowCount; i++) { CheckBox chkActive = (CheckBox)tlpRunways.GetControlFromPosition(1, i); if (chkActive.Checked) { apCurrent.AddActive((Runway)chkActive.Tag); } } Runway.SaveCurrent(Runway.strCurrentFile, apCurrent); MessageBox.Show("Active Runways Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static void LoadFiles() { if (!Directory.Exists(strDataDirectory)) { Directory.CreateDirectory(strDataDirectory); } if (!Directory.Exists(strPrefsDirectory)) { Directory.CreateDirectory(strPrefsDirectory); } List <Task> listStandaloneTasks = new List <Task>(); listStandaloneTasks.Add(Country.Load(Country.strDataFile)); listStandaloneTasks.Add(FIR.Load(FIR.strDataFile)); Task tskFavs = Client.LoadFavs(); string[] strarrDirectories = Directory.GetDirectories(strDataDirectory); for (int i = 0; i < strarrDirectories.Length; i++) { strarrDirectories[i] = strarrDirectories[i].Split('\\').Last(); } Controller.list = new List <Controller>(); List <Task> listControllerTasks = new List <Task>(); foreach (string strStr in strarrDirectories) { listControllerTasks.Add(Controller.Load(strStr)); } Task.WaitAll(listControllerTasks.ToArray()); Controller.SortAsync().Wait(); Task.WaitAll(listStandaloneTasks.ToArray()); Airport.Load(Airport.strDataFile, Airport.strFavFile).Wait(); Runway.list = new List <Runway>(); List <Task> listRunwayTasks = new List <Task>(); foreach (string strStr in strarrDirectories) { listRunwayTasks.Add(Runway.Load(strStr)); } Task.WaitAll(listRunwayTasks.ToArray()); Runway.listSorted = Runway.Sort(Runway.list); Runway.LoadCurrents(Runway.strCurrentFile); Sector.list = new List <Sector>(); List <Task> listSectorTasks = new List <Task>(); foreach (string strStr in strarrDirectories) { listSectorTasks.Add(Sector.Load(strStr)); } Task.WaitAll(listSectorTasks.ToArray()); Sector.SortAsync().Wait(); Airspace.list = new List <Airspace>(); List <Task> listAirspaceTasks = new List <Task>(); foreach (string strStr in strarrDirectories) { listAirspaceTasks.Add(Airspace.Load(strStr)); } Task.WaitAll(listAirspaceTasks.ToArray()); Airspace.listSorted = Airspace.Sort(Airspace.list); Task.WaitAll(tskFavs); }
public void AddActive(Runway _runway) { listActive.Add(_runway); }