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


C# GeoCoordinateWatcher.TryStart方法代码示例

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


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

示例1: CustomMapControl_Loaded

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

示例2: PhoneApplicationPage_Loaded

 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));
 }
开发者ID:rciampa,项目名称:TopCarrotMobile-WP,代码行数:7,代码来源:Login.xaml.cs

示例3: Location

        public void Location()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

            // Do not suppress prompt, and wait 1000 milliseconds to start.
            watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

            GeoCoordinate coord = watcher.Position.Location;

            if (coord.IsUnknown != true)
            {
                System.Diagnostics.Debug.WriteLine("Lat: {0}, Long: {1}",
                    coord.Latitude,
                    coord.Longitude);
               // return ("Lat: " + coord.Latitude + ", Long: " + coord.Longitude);
                latitude = coord.Latitude;
                longitude = coord.Longitude;

            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Unknown");
                latitude = -1;
                longitude = -1;
            }
        }
开发者ID:niviaqua,项目名称:WindowsPhoneApp-JoinFeatures,代码行数:26,代码来源:GeoLocation.cs

示例4: MainPage

 // Constructor
 public MainPage()
 {
     InitializeComponent();
     // Init watcher with default accuracy
     watcher = new GeoCoordinateWatcher();
     // Start listen for coordinates
     watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
 }
开发者ID:OSLL,项目名称:geo2tag-web,代码行数:9,代码来源:MainPage.xaml.cs

示例5: LocationProvider

 public LocationProvider()
 {
     // Setup position watcher
     this.watcher = new System.Device.Location.GeoCoordinateWatcher(System.Device.Location.GeoPositionAccuracy.Default);
     watcher.MovementThreshold = MovementTreshold;
     watcher.TryStart(false, TimeSpan.FromSeconds(WatcherStartDelay));
     watcher.PositionChanged += OnLocationChanged;
 }
开发者ID:AleksandarDev,项目名称:ImageWall,代码行数:8,代码来源:LocationProvider.cs

示例6: map_page

        private Pushpin myPushpin; //точка для отображеия координат

        #endregion Fields

        #region Constructors

        //конструктор
        public map_page()
        {
            InitializeComponent();
            myGeoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            myGeoWatcher.MovementThreshold = 100.0f;
            myGeoWatcher.StatusChanged += myGeoWatcher_StatusChanged;
            myGeoWatcher.PositionChanged += myGeoWatcher_PositionChanged;
            //myAccel = new Accelerometer();
            //myAccel.CurrentValueChanged += myAccel_CurrentValueChanged;
            //myAccel.Start();
            myPushpin = new Pushpin();
               myGeoWatcher.TryStart(false, TimeSpan.FromSeconds(60));
        }
开发者ID:RuseL-Bykov,项目名称:WP7App-Course-project-,代码行数:20,代码来源:map_page.xaml.cs

示例7: InitializeGeoCoordinateWatcher

        bool InitializeGeoCoordinateWatcher()
        {
            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);

            if (watcher.Permission == GeoPositionPermission.Denied)
            {
                LocationData = new Location { HasPermission = false };
                return false;
            }

            watcher.MovementThreshold = 0;
            return watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
        }
开发者ID:seriema,项目名称:WP7Caps,代码行数:13,代码来源:ComponentsInfo.cs

示例8: GetCurrentLocation

        /// <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;
        }
开发者ID:noamkfir,项目名称:WazeWP7,代码行数:17,代码来源:BackgroundNavigator.cs

示例9: TrackMe

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

示例10: Init

        private void Init()
        {
            initialized = true;

            if (!SettingsManager.Instance.GetApplicationSetting(SettingsManager.App_UseWin7LocationAPI, SettingsManager.Default_UseWin7LocationAPI))
                return;

            watcher = new GeoCoordinateWatcher();
            watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
            watcher.MovementThreshold = double.Parse(ConfigurationManager.AppSettings["Windows7LocationThreshold"]);
            watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);

            EnsureIfAvailable();
        }
开发者ID:Saldash,项目名称:ProxySwitcher,代码行数:15,代码来源:LocationManager.cs

示例11: PlatformSpecificStart

        protected override void PlatformSpecificStart(MvxLocationOptions options)
        {
            if (_geolocator != null)
                throw new MvxException("You cannot start the MvxLocation service more than once");

            _geolocator = new GeoCoordinateWatcher
            {
                MovementThreshold = options.MovementThresholdInM
            };

            _geolocator.TryStart(false, TimeSpan.FromMilliseconds((uint)options.TimeBetweenUpdates.TotalMilliseconds));

            _geolocator.StatusChanged += OnStatusChanged;
            _geolocator.PositionChanged += OnPositionChanged;
        }
开发者ID:cyrilcathala,项目名称:MvvmCross-Plugins,代码行数:15,代码来源:MvxWpfLocationWatcher.cs

示例12: LocationCondition

 static LocationCondition()
 {
     while (true)
     {
         geo = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
         geo.PositionChanged += geo_PositionChanged;
         if (!geo.TryStart(true, new TimeSpan(0, 0, 5)))
         {
             MessageBox.Show("Locality requires location access to function properly.", "Locality", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             Environment.Exit(0);
         }
         else
         {
             break;
         }
     }
 }
开发者ID:digideskio,项目名称:Locality,代码行数:17,代码来源:LocationCondition.cs

示例13: Get

        /// <summary>
        /// Get the current location from the Windows location API.
        /// </summary>
        /// <returns>
        /// The <see cref="LatLong"/> instance.
        /// </returns>
        /// <remarks>
        /// This currently includes Thread.Sleep hack to ensure the device is ready.
        /// </remarks>
        public static LatLong Get()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

            watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));

            // TODO: hack hack hack
            Thread.Sleep(1000);

            GeoCoordinate coord = watcher.Position.Location;

            return new LatLong()
            {
                Latitude = coord.Latitude,
                Longitude = coord.Longitude
            };
        }
开发者ID:juliankay,项目名称:FakeGPS,代码行数:26,代码来源:GeolocationHelper.cs

示例14: GetLocationCourseAndSpeed

        public String GetLocationCourseAndSpeed()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
           watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));

            if (watcher.Position.Location.IsUnknown != true)
            {
                GeoCoordinate coord = watcher.Position.Location;
                System.Diagnostics.Debug.WriteLine("Course: {0}, Speed: {1}",
                    coord.Course,
                    coord.Speed);
                return ("Course: "+coord.Course+", Speed: "+coord.Speed);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Unknown");
                return ("Return Unknown");
            }
        }
开发者ID:niviaqua,项目名称:WindowsPhoneApp-JoinFeatures,代码行数:19,代码来源:GeoLocation.cs

示例15: GetCurrentGpsPosition

 private void GetCurrentGpsPosition()
 {
     //request for Location services
     if (SettingsHelper.IsLocationServicesEnabled())
     {
         GeoCoordinateWatcher geoWatcher = new GeoCoordinateWatcher();
         geoWatcher.MovementThreshold = 50;
         geoWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(geoWatcher_PositionChanged);
         if (!geoWatcher.TryStart(false, TimeSpan.FromSeconds(30)))
         {
             Debug.WriteLine("Unsuccessful gps start");
         }
     }
     else
     {
         PrivacyHelper.ShowLocationServicesPrivacyPrompt();
         if (SettingsHelper.IsLocationServicesEnabled())
         {
             GetCurrentGpsPosition();
         }
     }
 }
开发者ID:tbmihailov,项目名称:geomindme,代码行数:22,代码来源:MapView.xaml.cs


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