예제 #1
1
        private void initGeoLocationMock()
        {
            if (watcherMock == null)
            {
                GeoCoordinateEventMock[] events = new GeoCoordinateEventMock[] {
                    new  GeoCoordinateEventMock { Latitude=52.515, Longitude=13.3331, Time=new TimeSpan(0,0,20) },
                    new  GeoCoordinateEventMock { Latitude=52.3987, Longitude=13.0684, Time=new TimeSpan(0,0,20) },
                    new  GeoCoordinateEventMock { Latitude=52.4145, Longitude=12.5555, Time=new TimeSpan(0,0,20) }
                };

                watcherMock = new EventListGeoLocationMock(events);
                watcherMock.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcherPositionChanged);
            }

            watcherMock.Start();
        }
예제 #2
0
        public MainPage()
        {
            InitializeComponent();
            mainDatabase = new WorkoutDatabase();
            lastGPSlocation = null;
            joggingPolyLine = new MapPolyline();
            joggingPolyLine.Stroke = new SolidColorBrush(Colors.Blue);
            joggingPolyLine.StrokeThickness = 5;
            joggingPolyLine.Opacity = 0.7;
            joggingPolyLine.Locations = new LocationCollection();
            map1.Children.Add(joggingPolyLine);
            string deviceName = Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString();

            if (deviceName == "XDeviceEmulator")                                                                    // Checks for device name in order to determine whether to simulate a jogger or not
            {
                //Note: The following coordinates is just a Test coordinate for when running the GeoCoordinate simulator
               geowatcher = new GeoCoordinateSimulator(51.5941116666667, 4.77941666666667);

            }
            else
            {
                geowatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            }
            geowatcher.PositionChanged += watcher_PositionChanged;
            //The next line is responsible for loading the database from Isolated Storage. The loading and saving implementation works HOWEVER, It is NOT loaded properly and the previous workoutlist does not display previously saved workouts.
               // mainDatabase = dataSave.loadDatabaseFromIsolatedStorage("WorkoutDatabase");

               // checkIfFileExists();
        }
예제 #3
0
        private void DetachListeners(IGeoPositionWatcher <GeoCoordinate> geowatcher)
        {
            geowatcher.StatusChanged   -= watcher_StatusChanged;
            geowatcher.PositionChanged -= watcher_PositionChanged;
#if !SILVERLIGHT
            if (geowatcher is INotifyPropertyChanged && geowatcher is GeoCoordinateWatcher)
            {
                (geowatcher as INotifyPropertyChanged).PropertyChanged -= GpsLayer_PropertyChanged;
            }
#endif
        }
예제 #4
0
        private void AttachListeners(IGeoPositionWatcher <GeoCoordinate> geowatcher)
        {
            geowatcher.StatusChanged   += watcher_StatusChanged;
            geowatcher.PositionChanged += watcher_PositionChanged;
#if !SILVERLIGHT
            //This is to work around a bug in .NET's GeoCoordinateWatcher, where CoordinateChanged doesn't
            //fire when it should but instead rely on INotifyPropertyChanged
            if (geowatcher is INotifyPropertyChanged && geowatcher is GeoCoordinateWatcher)
            {
                (geowatcher as INotifyPropertyChanged).PropertyChanged += GpsLayer_PropertyChanged;
            }
#endif
        }
예제 #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GPSLocation()
 {
     // this.watcher = new GeoCoordinateWatcher();
     // Use GpsEmulatorClient's GeocoordinateWatcher in emulator.
     this.watcher = new GpsEmulatorClient.GeoCoordinateWatcher();
     this.watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
     this.watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
     this.Started = this.watcher.TryStart(false, TimeSpan.FromMilliseconds(2000));
     if (!this.Started)
     {
         Debug.WriteLine("GeoCoordinateWatcher timed out on start.");
     }
 }
예제 #6
0
 private LocationService()
 {
     lastLocation = null;
     if (Configuration.FAKE_LOCATION_ENABLED)
     {
         watcher = new FakeLocationMessenger(selectedMode);
         random = new Random();
     }
     else
     {
         watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
         (watcher as GeoCoordinateWatcher).MovementThreshold = UserData.Get<double>(DesiredMovementThreshold);
     }
 }
예제 #7
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            if (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator)
            {
                _Watcher = new GpsEmulatorClient.GeoCoordinateWatcher();
            }
            else
            {
                _Watcher = new System.Device.Location.GeoCoordinateWatcher();
            }

            _Watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
            _Watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
        }
예제 #8
0
 public LocationService()
 {
     if (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator)
     {
         _gpsWatcher = new GpsEmulatorClient.GeoCoordinateWatcher();
     }
     else
     {
         _gpsWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                       {
                           MovementThreshold = 10
                       };
     }
     
     _gpsWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
     _gpsWatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
 }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            gpsWatcher = GetGpsWatcher();
            gpsWatcher.PositionChanged += gpsWatcher_PositionChanged;

            DateTime dataInicioLeitura = DateTime.Now;
            bool aguardarLeitura = true;
            while (aguardarLeitura)
            {
                Thread.Sleep(1000);
                aguardarLeitura = DateTime.Now < (dataInicioLeitura.AddSeconds(10)); // aguardar 10 segundos
            }


            gpsWatcher.PositionChanged -= gpsWatcher_PositionChanged;
            SalvarPontosMapeados(); // implementar aqui método para salvar pontos no IsolatedStorageFile
            NotifyComplete();
        }
예제 #10
0
        public MovementSource()
        {
            Position = GeoCoordinate.Unknown;

            compass = Compass.GetDefault();
            if (compass != null)
            {
                compass.ReadingChanged += Compass_ReadingChanged;
            }

            if (!DesignerProperties.IsInDesignTool)   // Cider hates GeoCoordinateWatcher
            {
#if DEBUG
                watcher = new FakeGeoPositionWatcher(0.0, 0.0);
#else
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
#endif
                watcher.PositionChanged += Watcher_PositionChanged;
                watcher.StatusChanged   += Watcher_StatusChanged;
                watcher.Start();
            }
        }
        public TrackingViewModel(ILog log, IAccount account, ILocalize localize, IApplication application,
                                 IGeoPositionWatcher<GeoCoordinate> coordinateProvider, IHistory history,
                                 IRepository repository, ISettings settings)
        {
            _log = log;
            _localize = localize;
            _application = application;
            _coordinateProvider = coordinateProvider;
            _history = history;
            _repository = repository;
            _settings = settings;
            Account = account;

            _started = false;
            _startTime = System.Environment.TickCount;

            _coordinateProvider.PositionChanged += _coordinateProvider_PositionChanged;
            _coordinateProvider.Start();
            UICoordinates = new GeoCoordinateCollection();
            _timer.Interval = TimeSpan.FromSeconds(1);
            _timer.Tick += Timer_Tick;

            MapCenter = new GeoCoordinate(0, 0);
            Heading = 0;
            ZoomLevel = 15;
            Pitch = 55;
            PedestrianFeaturesEnabled = true;
            LandmarksEnabled = true;

            DistanceDisplay = "0 km";
            if (!_settings.IsMetric) DistanceDisplay = "0 mi";
            PaceDisplay = "00:00";
            CaloriesDisplay = "0";
            TimeDisplay = "00:00";

            StrokeColor = System.Windows.Media.Colors.Red;
            StrokeThickness = 5;
            Coordinates.Clear();

            StartVisibility = (!_started ? Visibility.Visible : Visibility.Collapsed);
            StopVisibility = (_started ? Visibility.Visible : Visibility.Collapsed);
            PauseVisibility = (!_paused ? Visibility.Visible : Visibility.Collapsed);
            ResumeVisibility = (_paused ? Visibility.Visible : Visibility.Collapsed);

        }
예제 #12
0
 private void DetachListeners(IGeoPositionWatcher<GeoCoordinate> geowatcher)
 {
     geowatcher.StatusChanged -= watcher_StatusChanged;
     geowatcher.PositionChanged -= watcher_PositionChanged;
     #if !SILVERLIGHT
     if (geowatcher is INotifyPropertyChanged && geowatcher is GeoCoordinateWatcher)
     {
             (geowatcher as INotifyPropertyChanged).PropertyChanged -= GpsLayer_PropertyChanged;
     }
     #endif
 }
예제 #13
0
 private void AttachListeners(IGeoPositionWatcher<GeoCoordinate> geowatcher)
 {
     geowatcher.StatusChanged += watcher_StatusChanged;
     geowatcher.PositionChanged += watcher_PositionChanged;
     #if !SILVERLIGHT
     //This is to work around a bug in .NET's GeoCoordinateWatcher, where CoordinateChanged doesn't
     //fire when it should but instead rely on INotifyPropertyChanged
     if (geowatcher is INotifyPropertyChanged && geowatcher is GeoCoordinateWatcher)
     {
         (geowatcher as INotifyPropertyChanged).PropertyChanged += GpsLayer_PropertyChanged;
     }
     #endif
 }