private void RangingBeaconsInRegion(object sender, RangeEventArgs e) { try { if (e.Beacons == null) { return; } MainApplication.DiscoveredBeacons.SetAllOutOfRange(); if (e.Beacons.Count > 0) { Console.WriteLine("Found " + e.Beacons.Count + " beacons."); foreach (var beacon in e.Beacons) { if (beacon != null) { String id = beacon.Major + "." + beacon.Minor; String name = "Beacon: " + id; MainApplication.DiscoveredBeacons.Found(new Beacon() { Major = Int32.Parse(beacon.Major.ToString()), Minor = Int32.Parse(beacon.Minor.ToString()), FriendlyName = name, Proximity = (ProximityType)beacon.Proximity, Accuracy = beacon.Accuracy }); } } // check to see whether the first beacon has changed if (firstBeacon == null) { firstBeacon = MainApplication.DiscoveredBeacons.First; } if (MainApplication.DiscoveredBeacons.First != null) { if (firstBeacon != MainApplication.DiscoveredBeacons.First) { // new beacon in first position firstBeacon = MainApplication.DiscoveredBeacons.First; Toast.MakeText(this, "Welcome to " + firstBeacon.FriendlyName, ToastLength.Short).Show(); // perform a checkin MainApplication.DiscoveredBeacons.SetCheckedIn(firstBeacon.Major, firstBeacon.Minor, true); Sound.Play(); } } } else { Console.WriteLine("No beacons found"); } // Update the UI? ListAdapter = new BeaconDataAdapter(this); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void RangingBeaconsInRegion(object sender, RangeEventArgs e) { try { if (e.Beacons == null) return; MainApplication.DiscoveredBeacons.SetAllOutOfRange (); if (e.Beacons.Count > 0) { Console.WriteLine ("Found " + e.Beacons.Count + " beacons."); foreach (var beacon in e.Beacons) { if (beacon != null) { String id = beacon.Major + "." + beacon.Minor; String name = "Beacon: "+id; MainApplication.DiscoveredBeacons.Found (new Beacon () {Major = Int32.Parse (beacon.Major.ToString ()), Minor = Int32.Parse (beacon.Minor.ToString ()), FriendlyName = name, Proximity = (ProximityType)beacon.Proximity, Accuracy = beacon.Accuracy }); } } // check to see whether the first beacon has changed if (firstBeacon == null) { firstBeacon = MainApplication.DiscoveredBeacons.First; } if (MainApplication.DiscoveredBeacons.First != null) { if (firstBeacon != MainApplication.DiscoveredBeacons.First) { // new beacon in first position firstBeacon = MainApplication.DiscoveredBeacons.First; Toast.MakeText(this, "Welcome to "+firstBeacon.FriendlyName, ToastLength.Short).Show(); // perform a checkin MainApplication.DiscoveredBeacons.SetCheckedIn(firstBeacon.Major, firstBeacon.Minor, true); Sound.Play (); } } } else { Console.WriteLine ("No beacons found"); } // Update the UI? ListAdapter = new BeaconDataAdapter (this); } catch (Exception ex) { Console.WriteLine (ex.ToString ()); } }