コード例 #1
0
        public static String FromGRouteToIsolatedStorageFormat(GRoute route)
        {
            String result = "";

            result += "<xml>";

            result += Environment.NewLine + "\t" + "<route> ";
            result += Environment.NewLine + "\t\t" + "<StartTime>" + route.StartTime.ToString("yyyy:MM:dd:HH:mm:ss") + "</StartTime>";
            result += Environment.NewLine + "\t\t" + "<EndTime>" + route.EndTime.ToString("yyyy:MM:dd:HH:mm:ss") + "</EndTime> ";
            result += Environment.NewLine + "\t\t" + "<FullTime>" + route.FullTime.TotalSeconds + "</FullTime> ";
            result += Environment.NewLine + "\t\t" + "<UploadCheck>" + route.UploadCheck.ToString() + "</UploadCheck> ";
            result += Environment.NewLine + "\t\t" + "<TotalDistance>" + route.TotalDistance.ToString() + "</TotalDistance> ";

            result += Environment.NewLine + "\t\t" + "<coordinates>";
            foreach (GPoint point in route.Coordinates)
            {
                result += Environment.NewLine + "\t\t\t" + "<point>";
                result += Environment.NewLine + "\t\t\t\t" + "<Lon>" + point.Longitude.ToString().Replace(",", ".") + "</Lon>";
                result += Environment.NewLine + "\t\t\t\t" + "<Lat>" + point.Latitude.ToString().Replace(",", ".") + "</Lat>";
                result += Environment.NewLine + "\t\t\t\t" + "<Speed>" + point.Speed.ToString().Replace(",", ".") + "</Speed>";
                result += Environment.NewLine + "\t\t\t\t" + "<Alt>" + point.Altitude.ToString().Replace(",", ".") + "</Alt>";
                result += Environment.NewLine + "\t\t\t\t" + "<Com>" + point.Comment.ToString() + "</Com>";
                result += Environment.NewLine + "\t\t\t\t" + "<TT>" + point.TimeTaken.ToString("yyyy:MM:dd:HH:mm:ss") + "</TT>";
                result += Environment.NewLine + "\t\t\t\t" + "<Num>" + point.PointNumber.ToString() + "</Num>";
                //TO-DO Make picture paths here
                result += Environment.NewLine + "\t\t\t" + "</point>";
            }
            result += Environment.NewLine + "\t\t" + "</coordinates>";

            result += Environment.NewLine + "\t" + "</route>";

            result += Environment.NewLine + "</xml>";

            return(result);
        }
コード例 #2
0
ファイル: gSystemViewModel.cs プロジェクト: B8li/gRoute
 private void DeleteCurrentRoute()
 {
     this.Stop();// Just to be sure that GPS Sensor  is stopped
     this._currentRoute         = new GRoute();
     this.LocationServiceStatus = gSystemSettings.GLocationServiceStatus.NotStarted;
     RefreshRouteProperties();
     RaisePropertyChanged("PointItems"); //Used to refresh data grid
 }
コード例 #3
0
ファイル: gSystemViewModel.cs プロジェクト: B8li/gRoute
        public gSystemViewModel()
        {
            this._elasptedTimeTimer          = new DispatcherTimer();
            this._elasptedTimeTimer.Interval = TimeSpan.FromSeconds(1);
            this._elasptedTimeTimer.Tick    += new EventHandler(_elasptedTimeTimer_Tick);

            this._locationService              = new GLocationService();
            this._currentRoute                 = new GRoute();
            this._locationService.OnNewGPoint += new GLocationService.NewGPoint(_locationService_OnNewGPoint);
            this._cuurentStatus                = this._locationService.LocationServiceStatus;
            this._routesOnPhone                = new ObservableCollection <GRoute>();
        }
コード例 #4
0
        public static bool FromIsolatedStorageFormatToGRoutes(String text, out List <GRoute> routes)
        {
            routes = new List <GRoute>();
            bool succes = false;

            String[] split   = { Environment.NewLine };
            String   pattern = @">(.*?)<";
            GRoute   route   = new GRoute();
            GPoint   point   = new GPoint();

            String lineValue = "";

            try
            {
                String[] lines = text.Split(split, StringSplitOptions.RemoveEmptyEntries);
                foreach (String line in lines)
                {
                    if (line.Contains("<route>"))
                    {
                        route = new GRoute();
                    }
                    else if (line.Contains("<StartTime>"))
                    {
                        lineValue       = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        route.StartTime = GPointConverter.FromStringToDateTime(lineValue);
                    }
                    else if (line.Contains("<EndTime>"))
                    {
                        lineValue     = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        route.EndTime = GPointConverter.FromStringToDateTime(lineValue);
                    }
                    else if (line.Contains("FullTime"))
                    {
                        lineValue      = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        route.FullTime = TimeSpan.FromSeconds(Int32.Parse(lineValue));
                    }
                    else if (line.Contains("UploadCheck"))
                    {
                        lineValue         = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        route.UploadCheck = Boolean.Parse(lineValue);
                    }
                    else if (line.Contains("TotalDistance"))
                    {
                        lineValue           = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        route.TotalDistance = GPointConverter.ConvertToDouble(lineValue);
                    }
                    else if (line.Contains("<point>"))
                    {
                        point = new GPoint();
                    }
                    else if (line.Contains("Lon"))
                    {
                        lineValue       = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Longitude = GPointConverter.ConvertToDouble(lineValue);
                    }
                    else if (line.Contains("Lat"))
                    {
                        lineValue      = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Latitude = GPointConverter.ConvertToDouble(lineValue);
                    }
                    else if (line.Contains("Speed"))
                    {
                        lineValue   = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Speed = GPointConverter.ConvertToDouble(lineValue);
                    }
                    else if (line.Contains("Alt"))
                    {
                        lineValue      = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Altitude = GPointConverter.ConvertToDouble(lineValue);
                    }
                    else if (line.Contains("Com"))
                    {
                        lineValue     = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Comment = lineValue;
                    }
                    else if (line.Contains("TT"))
                    {
                        lineValue       = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.TimeTaken = new DateTimeOffset(GPointConverter.FromStringToDateTime(lineValue));
                    }
                    else if (line.Contains("Num"))
                    {
                        lineValue      = Regex.Matches(line, pattern)[0].Groups[1].ToString();
                        point.Altitude = Int32.Parse(lineValue);
                    }
                    else if (line.Contains("/point"))
                    {
                        route.AddNewGPoint(point, false);
                    }
                    else if (line.Contains("/route"))
                    {
                        routes.Add(route);
                    }
                }
            }
            catch (Exception e)
            {
                succes = false;
                MessageBox.Show(e.Message);
            }

            return(succes);
        }