zoukankan      html  css  js  c++  java
  • .NET 4.0 Location : 查看传感器状态变化

    .NET 4.0 中关于访问传感器状态进行了封装。在.NET4.0 beta2中我们可以用GeoLocationProvider。但是现在我们可以方便的使用GeoCoordinateWatcher类进行获知。较以往的GeoLocationProvider现在的GeoCoordinateWatcher结构如下:

    image

    具体代码如下:using System;

    using System.Device.Location;
    namespace LocationStatusChange
    {
        
    class Program
        {
            
    static void Main(string[] args)
            {
                Console.WriteLine(
    "Outputting location updates, press any key to exit...");
                LocationWatcher watcher 
    = new LocationWatcher();
                Console.ReadKey();
            } 

        }
        
    class LocationWatcher
        {
            
    private GeoCoordinateWatcher provider; 

            
    public LocationWatcher()
            {
                
    this.provider = new GeoCoordinateWatcher();
                
    this.provider.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(provider_StatusChanged);
                
    this.provider.Start();
            } 

            
    void provider_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
            {
                Console.WriteLine(
    "LocationStatus: " + e.Status.ToString());
            }
        }
     

  • 相关阅读:
    PyQt5--Buttons
    PyQt5--Position
    PyQt5--ShowWindowCenter
    PyQt5--MessageBox
    PyQt5--CloseWindow
    PyQt5--ShowTips
    PyQt5---ChangeIcon
    PyQt5---firstwindow
    PyQt5--StatusBar
    PyQt5 的几个核心模块作用
  • 原文地址:https://www.cnblogs.com/Skypurple/p/2086762.html
Copyright © 2011-2022 走看看