Exemple #1
0
        /// <summary>
        /// Queries the device state.
        /// </summary>
        /// <returns>Device state information</returns>
        public GpsDeviceState GetDeviceState()
        {
            GpsDeviceState device = null;

            // allocate a buffer on the native side.  Since the
            IntPtr pGpsDevice = Utils.LocalAlloc(GpsDeviceState.GpsDeviceStructureSize);

            // GPS_DEVICE structure has arrays of characters, it's easier to just
            // write directly into memory rather than create a managed structure with
            // the same layout.
            Marshal.WriteInt32(pGpsDevice, 1);                                        // write out GPS version of 1
            Marshal.WriteInt32(pGpsDevice, 4, GpsDeviceState.GpsDeviceStructureSize); // write out dwSize of structure

            int result = GPSGetDeviceState(pGpsDevice);

            if (result == 0)
            {
                // instantiate the GpsDeviceState class passing in the native pointer
                device = new GpsDeviceState(pGpsDevice);
            }

            // free our native memory
            Utils.LocalFree(pGpsDevice);

            return(device);
        }
Exemple #2
0
        /// <summary>
        /// Queries the device state.
        /// </summary>
        /// <returns>Device state information</returns>
        public GpsDeviceState GetDeviceState()
        {
            GpsDeviceState device = null;

             // allocate a buffer on the native side.  Since the
             IntPtr pGpsDevice = Utils.LocalAlloc(GpsDeviceState.GpsDeviceStructureSize);

             // GPS_DEVICE structure has arrays of characters, it's easier to just
             // write directly into memory rather than create a managed structure with
             // the same layout.
             Marshal.WriteInt32(pGpsDevice, 1);	// write out GPS version of 1
             Marshal.WriteInt32(pGpsDevice, 4, GpsDeviceState.GpsDeviceStructureSize);	// write out dwSize of structure

             int result = GPSGetDeviceState(pGpsDevice);

             if(result == 0)
             {
            // instantiate the GpsDeviceState class passing in the native pointer
            device = new GpsDeviceState(pGpsDevice);
             }

             // free our native memory
             Utils.LocalFree(pGpsDevice);

             return device;
        }
 public DeviceStateChangedEventArgs(GpsDeviceState deviceState)
 {
     this.deviceState = deviceState;
 }
Exemple #4
0
        void gps_DeviceStateChanged(object sender, GpsDeviceState args)
        {
            device = args;

             if(IsVisible)
             {
            Invoke(updateDataHandler);
             }
        }
 public DeviceStateChangedEventArgs(GpsDeviceState deviceState)
 {
     this.deviceState = deviceState;
 }
Exemple #6
0
 void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args)
 {
     device = args.DeviceState;
      Invoke(updateDataHandler);
 }