Пример #1
0
        private static PolarSession CreatePersonSessionFromFile(string fileName)
        {
            var          reader  = new XmlTextReader(fileName);
            PolarSession session = null;

            try
            {
                var doc       = new XPathDocument(reader);
                var nav       = doc.CreateNavigator();
                var nsManager = new XmlNamespaceManager(nav.NameTable);
                nsManager.AddNamespace("gpx10", "http://www.topografix.com/GPX/1/0");
                nsManager.AddNamespace("gpx11", "http://www.topografix.com/GPX/1/1");
                XPathNavigator timeNode;
                timeNode = nav.SelectSingleNode("/gpx10:gpx/gpx10:time", nsManager);
                if (timeNode != null)
                {
                    session = new PolarSession(timeNode.ValueAsDateTime, fileName);
                }
                timeNode = nav.SelectSingleNode("/gpx11:gpx/gpx11:time", nsManager);
                if (timeNode != null)
                {
                    session = new PolarSession(timeNode.ValueAsDateTime, fileName);
                }
            }
            catch (Exception)
            {
            }
            reader.Close();
            return(session);
        }
Пример #2
0
        public DialogResult ShowPreImportDialogs()
        {
            if (BeginWork != null)
            {
                BeginWork(this, new EventArgs());
            }

            List <PolarPerson> persons = new List <PolarPerson>();

            foreach (var path in paths)
            {
                var baseDir = new DirectoryInfo(path);
                if (baseDir.Exists)
                {
                    // get all persons
                    var personDirectories = new List <DirectoryInfo>(baseDir.GetDirectories());
                    // exclude logo, samples, themes and usb directories
                    personDirectories.RemoveAll(
                        di => (new List <string> {
                        "logo", "samples", "themes", "usb"
                    }).Contains(di.Name.ToLower()));
                    persons.AddRange(GetPersons(personDirectories));
                }
            }
            if (EndWork != null)
            {
                EndWork(this, new EventArgs());
            }

            using (var dlg = new PersonSessionSelector(persons))
            {
                DialogResult result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    sessionToImport = dlg.SelectedSession;
                }
                return(result);
            }
        }