void ofd_FileOkSaveKML(object sender, CancelEventArgs e) { AirNavigationRaceLiveMain.SetStatusText(""); double channelRadius; double altitude; // retrieve points from selected tree element if (ListOfRouteNames.Count == 0) { return; } bool ret = double.TryParse(txtChannelWidth.Text, out channelRadius); if (!ret) { channelRadius = DEFAULT_CHANNEL_WIDTH / 2.0; } else { channelRadius = channelRadius / 2.0; } ret = double.TryParse(txtHeight.Text, out altitude); if (!ret) { altitude = 300; } bool hasRoundedCorners = chkUseRoundedCorners.Checked; SaveFileDialog sfd = sender as SaveFileDialog; string fname = sfd.FileName; ANRData anrData = new ANRData(); anrData.generateParcour(ListOfRoutes, ListOfRouteNames, ListOfNBL, ListOfNBLNames, HAS_MARKERS, CREATE_PROH_AREA, USE_STANDARD_ORDER, channelRadius, altitude, hasRoundedCorners); Document document = anrData.Document; Kml kml = new Kml(); kml.Feature = document; KmlFile file = KmlFile.Create(kml, false); using (var stream = System.IO.File.Open(fname, FileMode.Create, FileAccess.Write, FileShare.Read)) { file.Save(stream); } AirNavigationRaceLiveMain.SetStatusText(string.Format("Route Generator - saved file {0}", sfd.FileName)); }
private void btnExportParcourCoord_Click(object sender, EventArgs e) { string fnameIn = txtInputFile.Text; string fnameOut = txtOutputFile.Text; XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(fnameIn); ANRData anr = new ANRData(); List <string> lst = anr.exportParcourCoordinates(xmlDoc); File.WriteAllLines(fnameOut, anr.exportParcourCoordinates(xmlDoc).ToArray()); } catch (ApplicationException ex1) { MessageBox.Show(ex1.Message, "Parcour import from *.kml", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error while Parsing kml File"); } btnExportParcourCoord.Enabled = false; btnClear.Enabled = false; }