/** * Initializes a new CBGeoDataStream object and uses the given CBHelper * object to retrieve data from the cloudbase.io APIS. * * @param name A unique identifier for the stream object. This will be handed over to all the delegate calls * @param CBHelper An initialized CBHelper object * @param NSString The name of the collection to search */ public CBGeoDataStream(string name, CBHelper helper, string collectionName) { this.streamName = name; this.helper = helper; this.CollectionName = collectionName; this.SearchRadius = 50; // we start with 50 meters this.previousSpeed = 0.0; this.foundObjects = new Dictionary<string, CBGeoLocatedObject>(); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling // the application's idle detection. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; if (settings.Contains("app_code")) { string appCode = Convert.ToString(settings["app_code"]); string appUniq = Convert.ToString(settings["app_uniq"]); string pwd = Convert.ToString(settings["app_pwd"]); App.helper = new CBHelper(appCode, appUniq); App.helper.SetPassword(pwd.ToLower()); } // enable geo-location for the data APIs. GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.PositionChanged += delegate(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { if (watcher != null) { if (App.helper != null) { // once we have a location we set the variable in the helper class and we stop looking App.helper.CurrentLocation = e.Position; watcher.Stop(); watcher.Dispose(); watcher = null; } } }; watcher.Start(); this.Notifications_Start(); }