Пример #1
0
        private void AutoImportGpsDataFileParameters(Race race)
        {
            int number = 0;

            foreach (string gpsDataFile in _gpsDataFileParameters)
            {
                try
                {
                    AmphibianSoftware.VisualSail.Data.Boat b = new AmphibianSoftware.VisualSail.Data.Boat();
                    b.BoatType = BoatType.FindAll()[0];
                    System.IO.FileInfo file = new System.IO.FileInfo(gpsDataFile);
                    if (file.Name.Contains("."))
                    {
                        b.Name = file.Name.Substring(0, file.Name.LastIndexOf("."));
                    }
                    else
                    {
                        b.Name = file.Name;
                    }
                    b.Color = ColorHelper.AutoColorPick(number).ToArgb();
                    number++;
                    b.Number = number.ToString();
                    b.Save();
                    if (System.IO.File.Exists(gpsDataFile))
                    {
                        AmphibianSoftware.VisualSail.Data.Import.FileImporter fi = AmphibianSoftware.VisualSail.Data.Import.FileImporter.DetectFileType(gpsDataFile);
                        //BusyDialogManager.Show("Importing Data");
                        SensorFile sf = fi.ImportFile(gpsDataFile, b);
                        sf.Save();
                        //BusyDialogManager.HideAll();
                    }
                    race.Boats.Add(b);
                }
                catch (Exception e)
                {
                    MessageBox.Show("A problem occured while loading " + gpsDataFile + "." + Environment.NewLine + e.Message);
                }
            }
            _gpsDataFileParameters.Clear();
            _gpsDataFileParameters = null;
        }