Page 1 of 1
Make Windows 8 detect Ranorex as location service user
Posted: Tue Feb 03, 2015 12:18 am
by Brent Arata
I would like Ranorex to utilize .NET's location services in Windows 8 for geofencing automation but do not know how to configure Ranorex to do so. Is there a way to do this via Ranorex or in Windows 8?
Re: Make Windows 8 detect Ranorex as location service user
Posted: Tue Feb 03, 2015 1:47 am
by Brent Arata
I was able to retrieve the coordinates by enabling location services in windows 8 by using the GeoCoordinateWatcher under the System.Device.Location namespace. However, I am still confused as to why the StatusChanged event handler was not being executed through Ranorex's implementation of the .NET framework.
Code: Select all
private GeoCoordinateWatcher watcher;
void ITestModule.Run() {
ShowStatusUpdates();
}
private void ShowStatusUpdates() {
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.TryStart(false, TimeSpan.FromSeconds(60));
if (watcher.Permission.Equals(GeoPositionPermission.Granted)) {
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(StatusChanged);
while (!watcher.Status.Equals(GeoPositionStatus.Ready) && !watcher.Status.Equals(GeoPositionStatus.NoData)) {
Delay.Milliseconds(20);
}
GeoCoordinate newGeoCoordinate = watcher.Position.Location;
System.Diagnostics.Debug.WriteLine("Lat: {0}, Long: {1}",
newGeoCoordinate.Latitude,
newGeoCoordinate.Longitude);
watcher.Stop();
watcher.Dispose();
}
else if (watcher.Permission.Equals(GeoPositionPermission.Denied) || watcher.Permission.Equals(GeoPositionPermission.Unknown)) {
System.Diagnostics.Debug.WriteLine("Location services are disabled. To enable them, Goto Settings - Location - Enable Location Services.");
watcher.Stop();
watcher.Dispose();
}
}
private void StatusChanged(object sender, GeoPositionStatusChangedEventArgs e) {
switch (e.Status) {
case GeoPositionStatus.Initializing:
System.Diagnostics.Debug.WriteLine("Working on location fix");
break;
case GeoPositionStatus.Ready:
System.Diagnostics.Debug.WriteLine("Have location");
GeoCoordinate newGeoCoordinate = watcher.Position.Location;
System.Diagnostics.Debug.WriteLine("Lat: {0}, Long: {1}",
newGeoCoordinate.Latitude,
newGeoCoordinate.Longitude);
watcher.Stop();
watcher.Dispose();
break;
case GeoPositionStatus.NoData:
System.Diagnostics.Debug.WriteLine("No data");
watcher.Stop();
watcher.Dispose();
break;
case GeoPositionStatus.Disabled:
System.Diagnostics.Debug.WriteLine("Disabled");
watcher.Stop();
watcher.Dispose();
break;
}
}
Re: Make Windows 8 detect Ranorex as location service user
Posted: Tue Feb 10, 2015 1:18 pm
by Support Team
Brent Arata wrote:owever, I am still confused as to why the StatusChanged event handler was not being executed through Ranorex's implementation of the .NET framework.
Ranorex uses the default .NET Framework, it does not provide a special implementation of it.
I don't think that Ranorex has anything in particular to do with the fact that you don't see the event being fired. IMHO it is rather a timing issue. When I tried to execute your code, I only got the event every second time, even if I was not using Ranorex. When I then loaded the Ranorex plugins, I first did not get the event, but suddenly got it every time.
Great that you got the PositionChange event working.
Regards,
Alex
Ranorex Team