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); } } } }
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(); } }
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 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 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); }
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 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 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 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 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 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 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 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(); } }
private void POFmanager_Load(object sender, EventArgs e) { string msg; string[] files = Directory.GetFiles(FolderMgt.DataFolder, "*.pof"); if (files.Length > 0) { foreach (string file in files) { msg = "Found " + file + ". Use this POF file?"; if (SCTcommon.SendMessage(msg, MessageBoxIcon.Question, MessageBoxButtons.YesNo) == DialogResult.Yes) { POFpathTextBox.Text = file; POFpathTextBox.Refresh(); break; } } } if (POFpathTextBox.TextLength > 0) { LoadFromTextBox(POFpathTextBox); } }
private void CalcBearingTextBox_TextChanged(object sender, EventArgs e) { string Msg = string.Empty; if (CalcBearingTextBox.TextLength != 0) { double test = Convert.ToDouble(CalcBearingTextBox.Text); if ((test > 360) | (test < 1)) { Msg = "Value must be 1 to 360."; } else { CalcBearingTextBox.Text = test.ToString(); CalcBrg = test; } if (Msg.Length != 0) { SCTcommon.SendMessage(Msg); CalcBearingTextBox.Text = string.Empty; } UpdateCalcButton(); } }
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 dtSSD = Form1.SSD; if (dtSSD.Rows.Count != 0) { // Load the gridview - can be sorted later. Future: add [Selected] string filter = "[SSDcode] LIKE '" + IdentifierTextBox.Text + "*" + "'"; DataView dvSSD = new DataView(dtSSD, filter, "SSDcode", DataViewRowState.CurrentRows); DataTable dtSSDList = dvSSD.ToTable(true, "SSDcode", "ID"); FixListDataGridView.DataSource = dtSSDList; FixListDataGridView.DefaultCellStyle.Font = new Font("Arial", 9); FixListDataGridView.Columns[0].HeaderText = "Code"; FixListDataGridView.Columns[1].Visible = false; if (FixListDataGridView.Rows.Count != 0) { FixListDataGridView.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.AllCells); } } else { string Msg = "You must activate your FAA data before you can search for SIDs & STARs."; SCTcommon.SendMessage(Msg); IdentifierTextBox.Text = string.Empty; } } else { FixListDataGridView.DataSource = null; } }
private bool CleanDataFolder() { // See if the user already has the same data - ask if user wants to rewrite it // If old data, confirm the user wants to overwrite it // if NO data, do the install without query // Start by identifying the datafolder if needed bool Continue = false; string Msg; string filter = "*28DaySubscription*"; bool result = false; int foundFilterDir = 0; // Verify the data folder holding the extraction data if (!Directory.Exists(FolderMgt.DataFolder)) { VerifyExtractPath(); } if (FolderMgt.DataFolder.Length == 0) { return(result); } // Search the datafolder for duplicate data subfolders and remove them string newCycleDate = CycleInfo.CycleStart.Date.ToString("yyyy'-'MM'-'dd"); string[] dirs = Directory.GetDirectories(@FolderMgt.DataFolder, filter, SearchOption.TopDirectoryOnly); foreach (string dir in dirs) { if (dir.IndexOf(newCycleDate) != -1) { Msg = "You already have a current dataset" + cr + "Cycle date: " + newCycleDate + cr + "Are you sure that you want to reinstall it?"; DialogResult dialogResult = SCTcommon.SendMessage(Msg, MessageBoxIcon.Question, MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Continue = true; } else { return(false); } } else { if (!Continue) { Msg = "You have oen or more FAA AIRAC folders in the data repository." + cr + "This program expects only one FAA folder '28DaySubscription_<date>'." + cr + "Click OK to remove ALL your existing FAA AIRAC folder(s), or BEFORE clicking OK" + cr + "move your old Subscription folders outside of your main data folder" + cr + "(" + FolderMgt.DataFolder + ")." + cr + cr + "Click Cancel to abort the FAA text file download and data update."; DialogResult dialogResult = SCTcommon.SendMessage(Msg, MessageBoxIcon.Question, MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { Continue = true; } else { return(false); } } } if (Continue) { if (Directory.Exists(dir)) { DirectoryInfo di = new DirectoryInfo(dir); //EmptyFolder(di); //DeleteSubFolders(di); di.Delete(true); } } } // Need to verify that there are no subscription folders in the data folder foreach (string dir in dirs) { if (dir.IndexOf(filter) != 0) { foundFilterDir++; } } result = foundFilterDir == 0; return(result); // Acceptable values are 0 (clean) or 1 (kept old data) }
public static void WriteESE() { // DataTable LS = Form1.LocalSector; var TextFiles = new List <string>(); string Message; string path; bool CombineIntoOneFile = SCTchecked.ChkOneESFile; if (SCTchecked.ChkES_SCTfile) { path = SCTcommon.CheckFile(PartialPath, "Header"); Console.WriteLine("Header..."); WriteHeader(path); if (CombineIntoOneFile) { TextFiles.Add(path); } path = SCTcommon.CheckFile(PartialPath, "Colors"); Console.WriteLine("ColorDefinitions"); SCToutput.WriteColors(path); if (CombineIntoOneFile) { TextFiles.Add(path); } path = SCTcommon.CheckFile(PartialPath, "Info"); Console.WriteLine("INFO section..."); SCToutput.WriteINFO(path); if (CombineIntoOneFile) { TextFiles.Add(path); } if (SCTchecked.ChkVOR) { path = SCTcommon.CheckFile(PartialPath, "VOR"); Console.WriteLine("VORs..."); SCToutput.WriteVOR(path); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkNDB) { path = SCTcommon.CheckFile(PartialPath, "NDB"); Console.WriteLine("NDBs..."); SCToutput.WriteNDB(path); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkFIX) { path = SCTcommon.CheckFile(PartialPath, "FIX"); Console.WriteLine("Fixes..."); SCToutput.WriteFixes(path); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkAPT) { path = SCTcommon.CheckFile(PartialPath, "APT"); Console.WriteLine("Airports..."); WriteAPT(path); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkRWY) { path = SCTcommon.CheckFile(PartialPath, "RWY"); Console.WriteLine("Airport Runways..."); WriteRWY(path); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkARB) { path = SCTcommon.CheckFile(PartialPath, "ARTCC_HIGH"); Console.WriteLine("ARTCC HIGH..."); SCToutput.WriteARB(path, true); if (CombineIntoOneFile) { TextFiles.Add(path); } path = SCTcommon.CheckFile(PartialPath, "ARTCC_LOW"); Console.WriteLine("ARTCC LOW..."); SCToutput.WriteARB(path, false); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkAWY) { Console.WriteLine("Low AirWays..."); path = SCTcommon.CheckFile(PartialPath, "AirwayLow"); SCToutput.WriteAWY(path, IsLow: true); if (CombineIntoOneFile) { TextFiles.Add(path); } path = SCTcommon.CheckFile(PartialPath, "AirwayHigh"); Console.WriteLine("High AirWays..."); SCToutput.WriteAWY(path, IsLow: false); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkSID) { Console.WriteLine("SIDS..."); SCToutput.WriteSIDSTAR(IsSID: true); if (CombineIntoOneFile) { TextFiles.Add(path); } } if (SCTchecked.ChkSTAR) { Console.WriteLine("STARS..."); SCToutput.WriteSIDSTAR(IsSID: false); if (CombineIntoOneFile) { TextFiles.Add(path); } } } Message = TextFiles.Count.ToString() + " text file(s) written to " + PartialPath + cr; path = SCTcommon.CheckFile(PartialPath, CycleInfo.AIRAC.ToString(), ".sct2"); using (var SCTfile = File.Create(path)) { foreach (var file in TextFiles) { using (var input = File.OpenRead(file)) { input.CopyTo(SCTfile); } } Message += "Sector file written to " + path + cr; } // --------------------------- ESE SIDSTAR STARTS HERE path = SCTcommon.CheckFile(PartialPath, "SIDSTAR", ".ese"); if (SCTchecked.ChkES_SSDfile && path != string.Empty) { Console.WriteLine("SIDS & STARS..."); WriteSIDSTAR(path); Message += "SIDSTARS file written to " + path + cr; } SCTcommon.SendMessage(Message); Console.WriteLine("End writing output files"); }
private void AddLine() { // Purpose - to Output a series of lines based upon user options // RETURNS - Nothing; writes a string to the Output Textbox string cr = Environment.NewLine; string Msg; // Create the list of points for the line (if not dashed, returns original points) string[] strOut = new string[4]; strOut[0] = strOut[1] = strOut[2] = strOut[3] = string.Empty; double[][] Lines = DashedLine(DashedLineRadioButton.Checked); if (SSDRadioButton.Checked) { foreach (double[] Line in Lines) { if (Line[0] == -1) { strOut[2] = string.Empty; strOut[3] = string.Empty; } else { strOut[2] = Conversions.Degrees2SCT(Line[0], true); strOut[3] = Conversions.Degrees2SCT(Line[1], false); } if ((strOut[0].Length != 0) && (strOut[2].Length != 0)) { switch (OutputType) { case "SSD": OutputTextBox.Text += SCTstrings.SSDout(strOut[0], strOut[1], strOut[2], strOut[3]) + cr; break; case "AWY": if (PrefixTextBox.TextLength != 0) { OutputTextBox.Text += SCTstrings.AWYout(PrefixTextBox.Text, strOut[0], strOut[1], strOut[2], strOut[3], StartFixTextBox.Text, EndFixTextBox.Text) + cr; } else { Msg = "The Airway identifier is required for this format." + cr + "(Place in the prefix text box.)"; SCTcommon.SendMessage(Msg); PrefixTextBox.Focus(); } break; case "ARTCC": if (PrefixTextBox.TextLength != 0) { OutputTextBox.Text += SCTstrings.BoundaryOut(PrefixTextBox.Text, strOut[0], strOut[1], strOut[2], strOut[3]); if (SuffixTextBox.TextLength != 0) { OutputTextBox.Text += SuffixTextBox.Text; } OutputTextBox.Text += cr; } else { Msg = "The ARTCC identifier is required for this format." + cr + "(Place in the prefix text box.)"; SCTcommon.SendMessage(Msg); PrefixTextBox.Focus(); } break; case "GEO": OutputTextBox.Text += SCTstrings.GeoOut(strOut[0], strOut[1], strOut[2], strOut[3], SuffixTextBox.Text) + cr; break; } } strOut[0] = strOut[2]; strOut[1] = strOut[3]; } } }
public static void WriteSCT() { // DataTable LS = Form1.LocalSector; var TextFiles = new List <string>(); string Message; Console.WriteLine("Header..."); string path = SCTcommon.CheckFile(PartialPath, "Header"); WriteHeader(path); TextFiles.Add(path); path = SCTcommon.CheckFile(PartialPath, "Colors"); Console.WriteLine("ColorDefinitions"); WriteColors(path); TextFiles.Add(path); path = SCTcommon.CheckFile(PartialPath, "Info"); Console.WriteLine("INFO section..."); WriteINFO(path); TextFiles.Add(path); if (SCTchecked.ChkVOR) { path = SCTcommon.CheckFile(PartialPath, "VOR"); Console.WriteLine("VORs..."); WriteVOR(path); TextFiles.Add(path); } if (SCTchecked.ChkNDB) { path = SCTcommon.CheckFile(PartialPath, "NDB"); Console.WriteLine("NDBs..."); WriteNDB(path); TextFiles.Add(path); } if (SCTchecked.ChkAPT) { path = SCTcommon.CheckFile(PartialPath, "APT"); Console.WriteLine("Airports..."); WriteAPT(path); TextFiles.Add(path); } if (SCTchecked.ChkRWY) { path = SCTcommon.CheckFile(PartialPath, "RWY"); Console.WriteLine("Airport Runways..."); WriteRWY(path); TextFiles.Add(path); } if (SCTchecked.ChkFIX) { path = SCTcommon.CheckFile(PartialPath, "FIX"); Console.WriteLine("Fixes..."); WriteFixes(path); TextFiles.Add(path); } if (SCTchecked.ChkARB) { Console.WriteLine("ARTCC HIGH..."); path = SCTcommon.CheckFile(PartialPath, "ARTCC_HIGH"); WriteARB(path, true); TextFiles.Add(path); Console.WriteLine("ARTCC LOW..."); path = SCTcommon.CheckFile(PartialPath, "ARTCC_LOW"); WriteARB(path, false); TextFiles.Add(path); } if (SCTchecked.ChkAWY) { path = SCTcommon.CheckFile(PartialPath, "AirwayLow"); Console.WriteLine("Low AirWays..."); WriteAWY(path, IsLow: true); TextFiles.Add(path); path = SCTcommon.CheckFile(PartialPath, "AirwayHigh"); Console.WriteLine("High AirWays..."); WriteAWY(path, IsLow: false); TextFiles.Add(path); } if (SCTchecked.ChkSID) { Console.WriteLine("SIDS..."); WriteSIDSTAR(IsSID: true); TextFiles.Add(path); } if (SCTchecked.ChkSTAR) { Console.WriteLine("STARS..."); WriteSIDSTAR(IsSID: false); TextFiles.Add(path); } if (SCTchecked.IncludeSUAfile) { path = SCTcommon.CheckFile(PartialPath, "SUA"); Console.WriteLine(path); if (path != string.Empty) { Console.WriteLine("SUAs..."); WriteSUA(); TextFiles.Add(path); } } if (SCTchecked.ChkOneVRCFile) { path = SCTcommon.CheckFile(PartialPath, CycleInfo.AIRAC.ToString(), ".sct2"); using (var SCTfile = File.Create(path)) { foreach (var file in TextFiles) { using (var input = File.OpenRead(file)) { input.CopyTo(SCTfile); } } } Message = "Sector file written to" + path; SCTcommon.SendMessage(Message, MessageBoxIcon.Information); } else { Message = TextFiles.Count + " text file(s) written to " + FolderMgt.OutputFolder; SCTcommon.SendMessage(Message, MessageBoxIcon.Information); } Console.WriteLine("End writing output files in SCToutput"); }
private void OKButton_Click(object sender, EventArgs e) { MyButtonCancel.Enabled = false; MyButtonCancel.Visible = false; int tempAIRAC = Convert.ToInt32(YearComboBox.Text.Substring(2, 2) + Convert.ToInt32(CycleComboBox.Text).ToString("D2")); CycleInfo.CycleDateFromAIRAC(tempAIRAC, true); if (!CleanDataFolder()) { InitializeConfirmationLabel(); Close(); // Must have a clean data folder to place data } // Set up values for the download; string newCycleDate = CycleInfo.CycleStart.Date.ToString("yyyy'-'MM'-'dd"); DirectoryInfo di; di = Directory.CreateDirectory(FolderMgt.DataFolder + "\\28DaySubscription_Effective_" + newCycleDate + "\\"); extractPath = di.FullName; string URL = "https://nfdc.faa.gov/webContent/28DaySub/28DaySubscription_Effective_" + newCycleDate + ".zip"; downloadsPath = "28DaySubscription_Effective_" + newCycleDate + ".zip"; downloadsPath = Path.GetTempPath() + downloadsPath; // If the zipfile is already downloaded, delete it (safer as it may be corrupted) if (File.Exists(downloadsPath)) { File.Delete(downloadsPath); } OKButton.Text = "Downloading FAA files"; OKButton.Enabled = false; // Start the download WebClient wc = new WebClient(); wc.DownloadProgressChanged += (s, f) => { progressBar1.Value = f.ProgressPercentage; }; wc.DownloadFileCompleted += (s, g) => { // Unless I messed up, there cannot be a data subdirectory by this name, so create it OKButton.Text = "Extracting files..."; OKButton.Refresh(); try { ZipFile.ExtractToDirectory(downloadsPath, extractPath); OKButton.Enabled = false; OKButton.Visible = false; ContinueButton.Enabled = true; ContinueButton.Visible = true; downloadComplete = true; if (File.Exists(downloadsPath)) { File.Delete(downloadsPath); } } catch { string msg = "Extraction failed. (Usually because there is already extracted data.) " + "Retry after manually removing all subscription files from the target folder. " + "You can extract manually to the target folder, then reselect the data folder to update the datafiles." + cr + " (" + di.FullName + ")"; SCTcommon.SendMessage(msg); DialogResult = DialogResult.Abort; } }; try { wc.DownloadFileAsync(new System.Uri(URL), downloadsPath); while (!downloadComplete) { Application.DoEvents(); } downloadComplete = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }