public static int NavAID() { string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAID.txt"); DataView dv = new DataView(wpNavAID); int result = 0; if (FullFilename.IndexOf("Error") == -1) { wpNavAID.Clear(); using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) { if (Line.Substring(0, 1) != ";") { DataRowView drv = dv.AddNew(); drv["Name"] = Line.Substring(0, 14).Trim(); drv["FacilityID"] = Line.Substring(24, 5).Trim(); drv["Type"] = Line.Substring(29, 4).Trim(); drv["Latitude"] = Convert.ToDouble(Line.Substring(33, 10).Trim()); drv["Longitude"] = Convert.ToDouble(Line.Substring(43, 11).Trim()); drv["Frequency"] = Line.Substring(54, 6).Trim(); drv.EndEdit(); } } } result = dv.Count; Console.WriteLine(result + " rows added to" + dv.Table.TableName); } dv.Dispose(); return(result); }
private void SaveOutput2FileButton_Click(object sender, EventArgs e) { string Msg; if (OutputTextBox.TextLength != 0) { SaveFileDialog saveFileDialog1 = new SaveFileDialog { Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*", FilterIndex = 2, RestoreDirectory = true }; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if (saveFileDialog1.FileName.Length != 0) { string path = saveFileDialog1.FileName; File.WriteAllText(path, OutputTextBox.Text); Msg = "Output written to " + path; SCTcommon.SendMessage(Msg); } } else { Msg = "No file selected; file not saved."; SCTcommon.SendMessage(Msg); } } else { Msg = "No text in output textbox to save!"; SCTcommon.SendMessage(Msg); } }
private void InsertCoordsButton_Click(object sender, EventArgs e) { if ((CenterLat == -1) || (CenterLon == -1)) { SCTcommon.SendMessage("First select the center point of the arc."); return; } if ((CalcDistanceTextBox.TextLength == 0) || (Convert.ToDouble(CalcDistanceTextBox.Text) < 1)) { SCTcommon.SendMessage("Radius of arc must be at least 1 NM"); return; } else { double[] Coords; double CenterLat = Conversions.DMS2Degrees(CenterLatitudeTextBox.Text); double CenterLon = Conversions.DMS2Degrees(CenterLongitudeTextBox.Text); double Dist = Convert.ToDouble(CalcDistanceTextBox.Text); double BrgStart = Convert.ToDouble(StartRadialNUD.Value); double BrgEnd = Convert.ToDouble(EndRadialNUD.Value); double MagVar = Convert.ToDouble(MagVarTextBox.Text); double Lat; double Lon; if (CircleCheckBox.Checked) { Coords = LatLongCalc.Destination(CenterLat, CenterLon, Dist, 90, 'N'); Lat = Coords[0]; Lon = Coords[1]; StartLatitudeTextBox.Text = Conversions.Degrees2SCT(Lat, true); StartLongitudeTextBox.Text = Conversions.Degrees2SCT(Lon, false); StartLat = Lat; StartLon = Lon; EndLatitudeTextBox.Text = Conversions.Degrees2SCT(Lat, true); EndLongitudeTextBox.Text = Conversions.Degrees2SCT(Lon, false); EndLat = Lat; EndLon = Lon; } else { if (MagBrgCheckBox.Checked == true) { BrgStart -= MagVar; BrgEnd -= MagVar; } Coords = LatLongCalc.Destination(CenterLat, CenterLon, Dist, BrgStart, 'N'); Lat = Coords[0]; Lon = Coords[1]; StartLatitudeTextBox.Text = Conversions.Degrees2SCT(Lat, true); StartLongitudeTextBox.Text = Conversions.Degrees2SCT(Lon, false); StartLat = Lat; StartLon = Lon; Coords = LatLongCalc.Destination(CenterLat, CenterLon, Dist, BrgEnd, 'N'); Lat = Coords[0]; Lon = Coords[1]; EndLatitudeTextBox.Text = Conversions.Degrees2SCT(Lat, true); EndLongitudeTextBox.Text = Conversions.Degrees2SCT(Lon, false); EndLat = Lat; EndLon = Lon; } UpdateStats(); } }
public static void NavAID() { string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAID.txt"); DataView dvNGNavAid = new DataView(NGNavAID); DataRowView dataRow; if (FullFilename.IndexOf("Error") == -1) { NGNavAID.Clear(); using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) { if (Line.Substring(0, 1) != ";") { dataRow = dvNGNavAid.AddNew(); dataRow["Name"] = Line.Substring(0, 14).Trim(); dataRow["FacilityID"] = Line.Substring(24, 5).Trim(); dataRow["Type"] = Line.Substring(29, 4).Trim(); dataRow["Latitude"] = Convert.ToDouble(Line.Substring(33, 10).Trim()); dataRow["Longitude"] = Convert.ToDouble(Line.Substring(43, 11).Trim()); dataRow["Frequency"] = Line.Substring(54, 6).Trim(); dataRow.EndEdit(); } } } Debug.Print(NGNavAID.Rows.Count + " rows added to NGNavAid table."); } dvNGNavAid.Dispose(); }
public static int NavRTE() { // Add NaviGraph routes (wpNavRTE) // Returns number of rows read to datatable (0 if failed, no file) string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavRTE.txt"); DataView dv = new DataView(wpNavRTE); int result = 0; if (FullFilename.IndexOf("Error") == -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) // Until EOF { if (Line.Substring(0, 1) != ";") // Check for comment { AddRTE(dv); } } result = dv.Count; Console.WriteLine(result + " rows added to" + dv.Table.TableName); } } dv.Dispose(); return(result); }
public static int Airports() { // Add the Airports index (has only ICAO and Lat/Lon) // Use the wpNavAPT file for runways and Airport names // RETURNS number of rows added (0 for no file or failed) int result = 0; const int ICOA = 0; const int Lat = 1; const int Lon = 2; string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "airports.dat"); DataView dv = new DataView(airports); if (FullFilename.IndexOf("Error") == -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) // Until EOF { if (Line.Substring(0, 1) != ";") // Check for comment { DataRowView drv = dv.AddNew(); drv[ICOA] = Line.Substring(0, 4); drv[Lat] = Convert.ToDouble(Line.Substring(4, 10).Trim()); drv[Lon] = Convert.ToDouble(Line.Substring(14, 11).Trim()); drv.EndEdit(); } } result = dv.Count; Console.WriteLine(result + " rows added to" + dv.Table.TableName); } } dv.Dispose(); return(result); }
private void CalcMagVarTextBox_TextChanged(object sender, EventArgs e) { if (CalcMagVarTextBox.TextLength != 0) { int test = Convert.ToInt32(CalcMagVarTextBox.Text); if ((test < -40) | (test > 30)) { Msg = "Are you sure?" + "Historical extremes: US +30, EU -40" + cr + "and cannot exceed -140 to 140."; } else { CalcMagVarTextBox.Text = test.ToString(); CalcMag = test; } if (Msg.Length != 0) { SCTcommon.SendMessage(Msg); CalcMagVarTextBox.Text = string.Empty; CalcMag = 0; } } UpdateCalcButton(); }
private void ColorNameTextBox_MouseDoubleClick(object sender, MouseEventArgs e) { string colorName = ColorNameTextBox.Text; string colorValue = Extensions.Right(ColorValueTextBox.Text, ColorValueTextBox.TextLength - 1); const string label = "#define"; if (colorName.Length == 0) { SCTcommon.SendMessage("Need a name to copy to #define.", MessageBoxIcon.Error); } else { if (colorName.Substring(0, 1) == "#") { SCTcommon.SendMessage("Name cannot begin with '#' - enter a new name", MessageBoxIcon.Error); } else { if (!Extensions.IsNumeric(colorValue)) { SCTcommon.SendMessage("colorValue must be numeric.", MessageBoxIcon.Error); } else { Clipboard.SetText(label + " " + colorName + " " + colorValue); } } } }
public static void NavRTE() { // Add NaviGraph routes that are NOT in FAA table // That is - Ultra, Oceanic, and World routes string curID; string prevID = string.Empty; bool IDexists = false; bool Adding; string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavRTE.txt"); DataView dvRTE = new DataView(NGRTE); if (FullFilename.IndexOf("Error") != -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) // Until EOF { if (Line.Substring(0, 1) != ";") // Check for comment { curID = Line.Substring(0, Line.IndexOf(" ")).Trim(); Adding = curID == prevID; if (!Adding) { dvRTE.RowFilter = "[AWYID] = '" + curID + "'"; IDexists = (dvRTE.Count != 0); } if (Adding || !IDexists) { AddRTE(dvRTE); } prevID = curID; } } } } }
public static void NavFIX() { string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavFIX.txt"); DataView dvNGFIX = new DataView(NGFixes); DataRowView datarow; if (FullFilename.IndexOf("Error") == -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) { if (Line.Substring(0, 1) != ";") { datarow = dvNGFIX.AddNew(); datarow["FacilityID"] = Line.Substring(0, 5).Trim(); datarow[1] = Convert.ToDouble(Line.Substring(29, 10).Trim()); datarow[2] = Convert.ToDouble(Line.Substring(39, 11).Trim()); datarow.EndEdit(); } } Debug.WriteLine(NGFixes.Rows.Count + " rows added to NGFixes"); } } dvNGFIX.Dispose(); }
public static int NavFIX() { string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavFIX.txt"); DataView dv = new DataView(FIXes); int result = 0; if (FullFilename.IndexOf("Error") == -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) { if (Line.Substring(0, 1) != ";") { DataRowView drv = dv.AddNew(); drv = dv.AddNew(); drv["FacilityID"] = Line.Substring(0, 5).Trim(); drv[1] = Convert.ToDouble(Line.Substring(29, 10).Trim()); drv[2] = Convert.ToDouble(Line.Substring(39, 11).Trim()); drv.EndEdit(); } } result = dv.Count; Console.WriteLine(result + " rows added to " + dv.Table.TableName); } } dv.Dispose(); return(result); }
private void PrefixTextBox_TextChanged(object sender, EventArgs e) { if (PrefixTextBox.TextLength > 26) { string Msg = "Prefix may not be longer than 26 characters."; SCTcommon.SendMessage(Msg); PrefixTextBox.Text = string.Empty; } }
private void Copy2ClipboardButton_Click(object sender, EventArgs e) { if (OutputTextBox.TextLength > 0) { OutputTextBox.SelectAll(); Clipboard.SetText(OutputTextBox.SelectedText); } else { SCTcommon.SendMessage("Nothing in output box to copy!"); } }
private string DrawFix_Symbol() { string result = string.Empty; string curFix = HoldFixTextBox.Text; object[] NavData; if (DrawFixSymbol) { NavData = SCTcommon.GetNavData(curFix); result += Hershey.DrawSymbol(NavData); } return(result); }
private void AddLinesButton_Click(object sender, EventArgs e) { if (IdentifierTextBox.Text != FixListDataGridView.CurrentRow.Cells[0].Value.ToString()) { SCTcommon.SendMessage("Double click the desired diagram first."); } else { UpdatingLabel.Visible = true; Refresh(); if (FixListDataGridView.CurrentRow != null) { // Clear the prior data, if any DataTable SSD = Form1.SSD; DataView dvSSD = new DataView(SSD) { RowFilter = "[ID] = '" + SSDID + "'", Sort = "Sequence", }; // Pass the single row of SSD data to the writing programs if (dvSSD.Count != 0) { BuildSSD(dvSSD); } if (BigResult.Length == 0) { BigResult = "; ================================================================" + cr + "; AIRAC CYCLE: " + CycleInfo.AIRAC + cr + "; Cycle: " + CycleInfo.CycleStart + " to " + CycleInfo.CycleEnd + cr + "; ================================================================" + cr; } if (InfoSection.IncludeSidStarReferences) { WriteSSDrefs(); } // Is this a SID or STAR section? The 1st character will tell string Section = "STAR"; if (SSDID.Substring(0, 1) == "D") { Section = "SID"; } BigResult += cr + "[" + Section + "]" + cr; WriteSSDLines(); // Since Labels depend on lines, call them there } OutputTextBox.Text = BigResult; } UpdatingLabel.Visible = false; Refresh(); }
private void CalcDistanceTextBox_TextChanged(object sender, EventArgs e) { double tempRadius = Convert.ToDouble(CalcDistanceTextBox.Text); if ((tempRadius < 0.0) || (tempRadius > 999.9)) { SCTcommon.SendMessage("Radius must be in range 0 to 999.9 NM"); CalcDistanceTextBox.Text = "0"; } else { ArcRadius = tempRadius; } }
private int WritePOF(bool AsESE = false) { DataTable POF = Form1.POFdata; string line = string.Empty; int maxCol = 11; string extension = ".pof"; if (AsESE) { maxCol += 8; extension = ".ese"; } int result = 0; // Open and write the lines string filename = FolderMgt.OutputFolder + "\\" + InfoSection.SponsorARTCC + "_POF_" + CycleInfo.AIRAC + extension; using (StreamWriter sw = new StreamWriter(filename)) { sw.WriteLine(CycleHeader()); if (AsESE) { sw.WriteLine("[POSITIONS]"); } // Loop the rows foreach (DataRow POFentry in POF.AsEnumerable()) { // Loop the columns for (int i = 0; i < maxCol; i++) { if (POFentry[i].ToString().Length != 0) { line += POFentry[i].ToString(); } line += ":"; } // Remove the last colons while (line.Substring(line.Length - 1, 1) == ":") { line = line.Substring(0, line.Length - 1); } sw.WriteLine(line); result++; line = string.Empty; } } string msg = result + " lines written to " + filename; SCTcommon.SendMessage(msg, MessageBoxIcon.Information); return(result); }
public static int AIRAC() { // Find the cycleinfo.txt file. -1 if doesnt exist (bad folder) or return AIRAC int result = -1; string Line; string sResult; string sTemp; string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "cycle_info.txt"); if (FullFilename.IndexOf("ERROR") != -1) { return(result); } DataView dv = new DataView(cycleinfo); DataRowView drv = dv.AddNew(); using (StreamReader reader = new StreamReader(FullFilename)) { Line = reader.ReadLine(); if (result == -1) { if (Line.IndexOf("AIRAC") != -1) { sResult = Line.Substring(Line.IndexOf(":") + 1); result = Convert.ToInt32(sResult.Trim()); drv["AIRAC"] = Convert.ToInt32(result); } if (Line.IndexOf("Version") != -1) { sResult = Line.Substring(Line.IndexOf(":") + 1); result = Convert.ToInt32(sResult.Trim()); drv["Version"] = Convert.ToInt32(result); } if (Line.IndexOf("Valid") != -1) { sResult = Line.Substring(Line.IndexOf(":") + 1).Trim(); sTemp = Line.Substring(0, Line.IndexOf("-") - 1).Trim(); drv["BeginDate"] = DateTime.ParseExact(sTemp, "dd/MMM/yyyy", CultureInfo.InvariantCulture); sResult = Line.Substring(Line.IndexOf("-")).Trim(); drv["EndDate"] = DateTime.ParseExact(sResult, "dd/MMM/yyyy", CultureInfo.InvariantCulture); } if (Line.IndexOf("Files parsed") != -1) { sResult = Line.Substring(Line.IndexOf(":") + 1).Trim(); drv["ParsedDate"] = DateTime.ParseExact(sResult, "dd/mm/yyyy", CultureInfo.InvariantCulture); } } } drv.EndEdit(); dv.Dispose(); return(result); }
private void LoadFromTextBox(TextBox tb) { if (File.Exists(tb.Text)) { if (ReadPOF.ReadPOFfile(tb.Text) > 0) { LoadPOFdatagridview(); } } else { string msg = "File not found - consider using file dialog button"; SCTcommon.SendMessage(msg); } }
private void ScaleTextBox_Validated(object sender, EventArgs e) { string Msg; try { double Scale1 = Convert.ToDouble(ScaleTextBox.Text); } catch { Msg = "Scale must be a number between 0 and 10 nautical miles"; SCTcommon.SendMessage(Msg); ScaleTextBox.Text = string.Empty; } }
private void BearingTextBox_Validated(object sender, EventArgs e) { string Msg; try { double Brg1 = Convert.ToDouble(BearingTextBox.Text); } catch { Msg = "Bearing must be a number between 1 and 360 degrees"; SCTcommon.SendMessage(Msg); BearingTextBox.Text = string.Empty; } }
private void Copy2ClipboardButton_Click(object sender, EventArgs e) { string Msg; if (OutputTextBox.TextLength != 0) { Clipboard.Clear(); Clipboard.SetText(OutputTextBox.Text.ToString()); Msg = "Contents of output textbox copied to clipboard"; } else { Msg = "No text in output textbox to copy!"; } SCTcommon.SendMessage(Msg, MessageBoxIcon.Information); }
private string VerifyExtractPath() { // returns the path to extract the data (the data folder) string Msg = "Select new / Verify current data folder to contain FAA data subfolder"; string extractPath = SCTcommon.GetFolderPath(FolderMgt.DataFolder, Msg); if (extractPath.Length == 0) { Msg = "No folder selected to save FAA text files. Update aborted."; SCTcommon.SendMessage(Msg, MessageBoxIcon.Warning); } else { FolderMgt.DataFolder = extractPath; } return(extractPath); }
public static void AddCoordsToPOF() { DataView dvPOF = new DataView(Form1.POFdata); DataView dvAPT = new DataView(Form1.APT); int ErrorCount = 0; // POF prefix should have the abbreviation of the Airport // If RName has 'Center', use saved centering coordinates // Otherwise, lookup the airport to use as center coords foreach (DataRowView drvPOF in dvPOF) { switch (drvPOF["CallSuffix"].ToString()) { case "CTR": drvPOF["Latitude"] = InfoSection.CenterLatitude_SCT; drvPOF["Longitude"] = InfoSection.CenterLongitude_SCT; break; case "APP": case "TWR": case "GND": case "DEL": dvAPT.RowFilter = "[FacilityID] = '" + drvPOF["CallPrefix"].ToString() + "'"; if (dvAPT.Count > 0) { drvPOF["Latitude"] = Conversions.DecDeg2SCT(Convert.ToDouble(dvAPT[0]["Latitude"]), true); drvPOF["Longitude"] = Conversions.DecDeg2SCT(Convert.ToDouble(dvAPT[0]["Longitude"]), false); } else { drvPOF["Latitude"] = "Not Found"; drvPOF["Longitude"] = "Not Found"; ErrorCount++; } break; default: break; } } if (ErrorCount > 0) { string msg = ErrorCount.ToString() + " positions do not have coordinates (Euroscope only)."; SCTcommon.SendMessage(msg, MessageBoxIcon.Error); } }
private void IdentifierTextBox_TextChanged(object sender, EventArgs e) { { // Search the tables for fixes and return the coordinates, // then place the coordinates into the list box. // if (IdentifierTextBox.TextLength != 0) { // First, be sure there is data in the database! DataTable dtVOR = Form1.VOR; DataTable dtNDB = Form1.NDB; DataTable dtFIX = Form1.FIX; DataTable dtAPT = Form1.APT; if (dtFIX.Rows.Count != 0) { // Load the gridview - can be sorted later. Future: add [Selected] string filter = "[FacilityID] LIKE '" + IdentifierTextBox.Text + "*" + "'"; DataView dvVOR = new DataView(dtVOR, filter, "FacilityID", DataViewRowState.CurrentRows); DataView dvNDB = new DataView(dtNDB, filter, "FacilityID", DataViewRowState.CurrentRows); DataView dvFIX = new DataView(dtFIX, filter, "FacilityID", DataViewRowState.CurrentRows); DataView dvAPT = new DataView(dtAPT, filter, "FacilityID", DataViewRowState.CurrentRows); DataTable dtFixList = dvVOR.ToTable(true, "FacilityID", "Latitude", "Longitude"); dtFixList.Merge(dvNDB.ToTable(true, "FacilityID", "Latitude", "Longitude")); dtFixList.Merge(dvFIX.ToTable(true, "FacilityID", "Latitude", "Longitude")); dtFixList.Merge(dvAPT.ToTable(true, "FacilityID", "Latitude", "Longitude")); FixListDataGridView.DataSource = dtFixList; FixListDataGridView.DefaultCellStyle.Font = new Font("Arial", 9); FixListDataGridView.Columns[0].HeaderText = "ID"; if (FixListDataGridView.Rows.Count != 0) { FixListDataGridView.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.AllCells); } } else { string Msg = "You must select your FAA data folder before you can search for Fixes."; SCTcommon.SendMessage(Msg); IdentifierTextBox.Text = string.Empty; } } else { FixListDataGridView.DataSource = null; } } }
public static int ReadPOFfile(string filepath = "") { int result; string line; string FullFilename; Form1.POFdata.Clear(); if (filepath.Length == 0) { FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "ARTCC.pof"); string msg = "In order to generate the [POSITIONS] section of the ESE file, " + cr + "you must place a copy of your POF file in the SCT Builder resource folder." + cr + "Name the file ARTCC.pof. You can do this now." + cr + cr + "Click OK to continue or Cancel to skip creating the [POSITIONS] section"; while (FullFilename == "ERROR") { DialogResult dialogResult = SCTcommon.SendMessage(msg, MessageBoxIcon.Warning, MessageBoxButtons.OKCancel);; if (dialogResult == DialogResult.Cancel) { break; } FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "ARTCC.pof"); } } else { FullFilename = filepath; } using (StreamReader sr = new StreamReader(FullFilename)) { while ((line = sr.ReadLine()) != null) { if ((line.Length != 0) && (line.Substring(0, 1) != ";")) { LoadPOFrow(line); } } } result = Form1.POFdata.Rows.Count; if (result > 0) { AddCoordsToPOF(); } Console.WriteLine("ReadPOF.ReadPOFfile added " + result + " rows to POFdata table."); return(result); }
private void DrawButton_Click(object sender, EventArgs e) { string result = string.Empty; object[] NavData; string curFix; double Lat1 = Conversions.DMS2Degrees(LatTextBox.Text, "."); double Lon1 = Conversions.DMS2Degrees(LonTextBox.Text, "."); int Brg = Convert.ToInt32(BearingTextBox.Text) - 90; // Rotation in addition to MagVar float Scale = Convert.ToSingle(ScaleTextBox.Text); // Scaling beyond internal 1/3600 if (IncludeSymbolCheckBox.Checked && (FixListDataGridView.CurrentRow != null)) { curFix = FixListDataGridView.CurrentRow.Cells[0].Value.ToString(); NavData = SCTcommon.GetNavData(curFix); result += Hershey.DrawSymbol(NavData); } result += Hershey.WriteHF(LabelTextBox.Text, Lat1, Lon1, Brg, Scale); OutputTextBox.Text = result; }
private void ArcHeightTextBox_Validated(object sender, EventArgs e) { if (ArcHeightTextBox.TextLength != 0) { double tempHeight = Convert.ToDouble(ArcHeightTextBox.Text); if (tempHeight > ChordRadius) { SCTcommon.SendMessage("Height cannot exceed chord radius (R)." + cr + "(One-half distance between start and end coordinate"); ArcHeightTextBox.Text = ArcRadius.ToString("F3"); } if (tempHeight <= 0) { SCTcommon.SendMessage("Height must be positive value"); ArcHeightTextBox.Text = ArcRadius.ToString("F3"); } ChordHeight = Convert.ToDouble(ArcHeightTextBox.Text); CenterFromChord(); } }
public static int NavAPT() { // Add the NavAPT file to the DataTable // Because this file is column-delimited, cannot use ParseLine // RETURNS number of rows read (0 if no file or failed) int result = 0; const int FacID = 0; const int Name = 1; const int RWY = 2; const int Length = 3; const int Brg = 4; const int FinalBrg = 8; const int Lat = 5; const int Lon = 6; const int Freq = 7; const int Elev = 9; string FullFilename = SCTcommon.GetFullPathname(FolderMgt.DataFolder, "wpNavAPT.txt"); DataView dv = new DataView(wpNavAPT); if (FullFilename.IndexOf("Error") == -1) { using (StreamReader sr = new StreamReader(FullFilename)) { while ((Line = sr.ReadLine()) != null) // Until EOF { if (Line.Substring(0, 1) != ";") // Check for comment { DataRowView drv = dv.AddNew(); drv[Name] = Line.Substring(0, 24); drv[FacID] = Line.Substring(24, 4); drv[RWY] = Line.Substring(28, 3).Trim(); drv[Length] = Convert.ToInt32(Line.Substring(31, 5)); drv[Brg] = Convert.ToInt32(Line.Substring(36, 3)); drv[Lat] = Convert.ToDouble(Line.Substring(39, 10).Trim()); drv[Lon] = Convert.ToDouble(Line.Substring(49, 11).Trim()); drv[Freq] = Convert.ToDouble(Line.Substring(60, 6).Trim()); drv[FinalBrg] = Convert.ToInt32(Line.Substring(66, 3)); drv[Elev] = Convert.ToInt32(Line.Substring(69, 5)); drv.EndEdit(); } } result = dv.Count; Console.WriteLine(result + " rows added to" + dv.Table.TableName); } } dv.Dispose(); return(result); }
private static string DrawFixInfo(List <string> FixNames, int Angle = 0, float Scale = 1f) { // Calling function for fixes in diagrams // Because labels and/or symbols might be drawn // Will need to add the DrawFixNames for ALT and SPEED here string result = string.Empty; float Latitude; float Longitude; float[] AdjustedCoords = null; foreach (string Fix in FixNames) { // FixInfo returns: 0-Fix (calling ID), 1-Freq, 2-Lat, 3-Lon, 4-Name or Use, 5-Type object[] FixData = SCTcommon.GetNavData(Fix); if ((FixData[5].ToString() != "NA") && (FixData[0].ToString().Length != 0)) { Latitude = Convert.ToSingle(FixData[3]); Longitude = Convert.ToSingle(FixData[4]); if ((Latitude != 0) && (Longitude != 0)) { if (InfoSection.DrawFixSymbolsOnDiagrams) { result += Hershey.DrawSymbol(FixData); AdjustedCoords = Hershey.Adjust(Latitude, Longitude, 15, -30); } if (InfoSection.DrawFixLabelsOnDiagrams) { if (!InfoSection.DrawFixSymbolsOnDiagrams) { AdjustedCoords = Hershey.Adjust(Latitude, Longitude, 5, 0); } result += Hershey.WriteHF(Fix, AdjustedCoords[0], AdjustedCoords[1], Angle, Scale); } } } } return(result); }