当前位置: 首页>>代码示例>>C#>>正文


C# GeoCoordinateWatcher.Start方法代码示例

本文整理汇总了C#中GeoCoordinateWatcher.Start方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher.Start方法的具体用法?C# GeoCoordinateWatcher.Start怎么用?C# GeoCoordinateWatcher.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeoCoordinateWatcher的用法示例。


在下文中一共展示了GeoCoordinateWatcher.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RouteDetailsPanoramaPage

        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();
            }
        }
开发者ID:madisp,项目名称:Omnibuss,代码行数:33,代码来源:RouteDetailsPanoramaPage.xaml.cs

示例2: MainPage

        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;
        }
开发者ID:mikkoviitala,项目名称:battlelogmobile,代码行数:26,代码来源:MainPage.xaml.cs

示例3: NewStore

        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();
        }
开发者ID:JLBR,项目名称:School-Projects,代码行数:26,代码来源:NewStore.xaml.cs

示例4: GeoLocationService

 public GeoLocationService()
 {
     _watcher = new GeoCoordinateWatcher();
     _watcher.StatusChanged += Watcher_StatusChanged;
     _watcher.PositionChanged += Watcher_PositionChanged;
     _watcher.Start();
 }
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:7,代码来源:GeoLocationService.cs

示例5: JustRun

        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";
            }
        }
开发者ID:frank44,项目名称:Just-Run,代码行数:35,代码来源:JustRun.xaml.cs

示例6: MapDetail

        // 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();
        }
开发者ID:VandyApps,项目名称:dining-windows,代码行数:31,代码来源:MapDetail.xaml.cs

示例7: MapPage

        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);
            }
        }
开发者ID:bdunlay,项目名称:geoscav,代码行数:28,代码来源:MapPage.xaml.cs

示例8: CustomMapControls

        /// <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);
            }
        }
开发者ID:pankajc-optimus,项目名称:windows-lib,代码行数:30,代码来源:CustomMapControls.cs

示例9: ConcertDetails

 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();
 }
开发者ID:rcrozon,项目名称:PartyProject,代码行数:34,代码来源:ConcertDetails.xaml.cs

示例10: Button_Click_1

 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();
 }
开发者ID:EGartin,项目名称:LocationExampleERG,代码行数:7,代码来源:MainPage.xaml.cs

示例11: OnNavigatedTo

 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();
 }
开发者ID:ogeo,项目名称:TestApp,代码行数:7,代码来源:Persone.xaml.cs

示例12: Initialize

        /// <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();
        }
开发者ID:soleon,项目名称:Travlexer,代码行数:36,代码来源:ApplicationContext.cs

示例13: MainPage

        // 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
        }
开发者ID:27kunal,项目名称:Pocket_Security,代码行数:30,代码来源:MainPage.xaml.cs

示例14: InitializeMap

        /// <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;
            }
        }
开发者ID:brianoconnell,项目名称:OnMyWay,代码行数:35,代码来源:MainPage.xaml.cs

示例15: TopicsModel

        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();
            }
        }
开发者ID:rafaelwinter,项目名称:Ocell,代码行数:33,代码来源:TopicsModel.cs


注:本文中的GeoCoordinateWatcher.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。