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));
        }
        void ofd_FileOkSelectKML(object sender, CancelEventArgs e)
        {
            AirNavigationRaceLiveMain.SetStatusText("");

            RoutePoints      = new List <Vector>();
            ListOfRoutes     = new List <List <Vector> >();
            ListOfRouteNames = new List <string>();
            ListOfNBL        = new List <List <Vector> >();
            ListOfNBLNames   = new List <string>();

            treeViewAvailableRoutes.Nodes.Clear();
            OpenFileDialog ofd   = sender as OpenFileDialog;
            string         fName = ofd.FileName;

            FileNameKML = ofd.FileName;

            if (fName == string.Empty)
            {
                return;
            }

            KmlFile file;

            try
            {
                using (FileStream stream = File.Open(fName, FileMode.Open))
                {
                    file = KmlFile.Load(stream);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            if ((file != null) && (file.Root != null))
            {
                Kml      kml = file.Root as Kml;
                TreeView trv = treeViewAvailableRoutes;
                ExtractPlaceMarkLineStrings(kml.Feature, trv);
                btnAddRoute.Visible            = true;
                chkAddAllRoutes.Visible        = true;
                lblSelectedRoutes.Visible      = true;
                btnClearSelectedRoutes.Visible = true;
                treeViewSelectedRoutes.Visible = true;
            }
            AirNavigationRaceLiveMain.SetStatusText(string.Format("Route Generator - loaded file {0}", ofd.FileName));
        }
Esempio n. 3
0
        void ofd_FileOkSaveKML(object sender, CancelEventArgs e)
        {
            AirNavigationRaceLiveMain.SetStatusText("");

            XDocument xDocInverted;

            if (GetInvertedRoutes(FileNameKML, out xDocInverted))
            {
                SaveFileDialog sfd   = sender as SaveFileDialog;
                string         fname = sfd.FileName;
                xDocInverted.Save(sfd.FileName);

                AirNavigationRaceLiveMain.SetStatusText(string.Format("Route Inverter - saved file {0}", sfd.FileName));
            }
        }
Esempio n. 4
0
        void ofd_FileOkSelectKML(object sender, CancelEventArgs e)
        {
            AirNavigationRaceLiveMain.SetStatusText("");

            OpenFileDialog ofd   = sender as OpenFileDialog;
            string         fName = ofd.FileName;

            FileNameKML = ofd.FileName;

            if (fName == string.Empty)
            {
                return;
            }

            KmlFile file;

            try
            {
                using (FileStream stream = File.Open(fName, FileMode.Open))
                {
                    file = KmlFile.Load(stream);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            if ((file != null) && (file.Root != null))
            {
                AirNavigationRaceLiveMain.SetStatusText(string.Format("Route Inverter - loaded file {0}", ofd.FileName));
            }

            string         FileFilter = "KML Files|*.kml|All Files|*.*";
            SaveFileDialog sfd        = new SaveFileDialog();

            sfd.Title            = "Invert ANR routes and save as KML";
            sfd.FileName         = FileNameKML.Replace(".kml", "_inverted.kml");
            sfd.CheckFileExists  = false;
            sfd.RestoreDirectory = true;
            sfd.Filter           = FileFilter;
            //ofd.FilterIndex = 5;
            sfd.FileOk += new CancelEventHandler(ofd_FileOkSaveKML);
            sfd.ShowDialog();
        }
Esempio n. 5
0
 public static void SetStatus(String message)
 {
     AirNavigationRaceLiveMain.SetStatusText(message);
 }